| #include <metal_stdlib> |
| using namespace metal; |
| |
| struct tint_module_vars_struct { |
| thread int* a; |
| thread float* b; |
| }; |
| |
| int tint_mod_i32(int lhs, int rhs) { |
| uint const v = uint((lhs == (-2147483647 - 1))); |
| bool const v_1 = bool((v & uint((rhs == -1)))); |
| uint const v_2 = uint((rhs == 0)); |
| int const v_3 = select(rhs, 1, bool((v_2 | uint(v_1)))); |
| return as_type<int>((as_type<uint>(lhs) - as_type<uint>(as_type<int>((as_type<uint>((lhs / v_3)) * as_type<uint>(v_3)))))); |
| } |
| |
| int tint_div_i32(int lhs, int rhs) { |
| uint const v_4 = uint((lhs == (-2147483647 - 1))); |
| bool const v_5 = bool((v_4 & uint((rhs == -1)))); |
| uint const v_6 = uint((rhs == 0)); |
| return (lhs / select(rhs, 1, bool((v_6 | uint(v_5))))); |
| } |
| |
| void foo(int maybe_zero, tint_module_vars_struct tint_module_vars) { |
| (*tint_module_vars.a) = tint_div_i32((*tint_module_vars.a), maybe_zero); |
| (*tint_module_vars.a) = tint_mod_i32((*tint_module_vars.a), maybe_zero); |
| (*tint_module_vars.b) = ((*tint_module_vars.b) / 0.0f); |
| (*tint_module_vars.b) = fmod((*tint_module_vars.b), 0.0f); |
| float const v_7 = float(maybe_zero); |
| (*tint_module_vars.b) = ((*tint_module_vars.b) / v_7); |
| float const v_8 = float(maybe_zero); |
| (*tint_module_vars.b) = fmod((*tint_module_vars.b), v_8); |
| } |