#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);
}
