#include <metal_stdlib>

using namespace metal;
void any_e755c1(device int* const tint_symbol_1) {
  bool res = true;
  *(tint_symbol_1) = select(0, 1, all((res == false)));
}

struct tint_symbol {
  float4 value [[position]];
};

float4 vertex_main_inner(device int* const tint_symbol_2) {
  any_e755c1(tint_symbol_2);
  return float4(0.0f);
}

vertex tint_symbol vertex_main(device int* tint_symbol_3 [[buffer(0)]]) {
  float4 const inner_result = vertex_main_inner(tint_symbol_3);
  tint_symbol wrapper_result = {};
  wrapper_result.value = inner_result;
  return wrapper_result;
}

fragment void fragment_main(device int* tint_symbol_4 [[buffer(0)]]) {
  any_e755c1(tint_symbol_4);
  return;
}

kernel void compute_main(device int* tint_symbol_5 [[buffer(0)]]) {
  any_e755c1(tint_symbol_5);
  return;
}

