#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  device int* non_uniform_global;
  device float* output;
  thread bool* continue_execution;
};

void foo(tint_module_vars_struct tint_module_vars) {
  if (((*tint_module_vars.non_uniform_global) < 0)) {
    (*tint_module_vars.continue_execution) = false;
  }
}

void bar(tint_module_vars_struct tint_module_vars) {
  float const v = dfdx(1.0f);
  if ((*tint_module_vars.continue_execution)) {
    (*tint_module_vars.output) = v;
  }
}

fragment void tint_symbol(device int* non_uniform_global [[buffer(0)]], device float* output [[buffer(1)]]) {
  thread bool continue_execution = true;
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.non_uniform_global=non_uniform_global, .output=output, .continue_execution=(&continue_execution)};
  foo(tint_module_vars);
  bar(tint_module_vars);
  if (!((*tint_module_vars.continue_execution))) {
    discard_fragment();
  }
}
