#include <metal_stdlib>

using namespace metal;
float abs_b96037() {
  float arg_0 = 1.0f;
  float res = fabs(arg_0);
  return res;
}

fragment void fragment_main(device float* tint_symbol_1 [[buffer(0)]]) {
  *(tint_symbol_1) = abs_b96037();
  return;
}

kernel void compute_main(device float* tint_symbol_2 [[buffer(0)]]) {
  *(tint_symbol_2) = abs_b96037();
  return;
}

struct VertexOutput {
  float4 pos;
  float prevent_dce;
};

struct tint_symbol {
  float prevent_dce [[user(locn0)]] [[flat]];
  float4 pos [[position]];
};

VertexOutput vertex_main_inner() {
  VertexOutput out = {};
  out.pos = float4(0.0f);
  out.prevent_dce = abs_b96037();
  return out;
}

vertex tint_symbol vertex_main() {
  VertexOutput const inner_result = vertex_main_inner();
  tint_symbol wrapper_result = {};
  wrapper_result.pos = inner_result.pos;
  wrapper_result.prevent_dce = inner_result.prevent_dce;
  return wrapper_result;
}

