#include <metal_stdlib>

using namespace metal;

float4 tint_radians(float4 param_0) {
  return param_0 * 0.01745329251994329547;
}

float4 radians_09b7fc() {
  float4 arg_0 = float4(1.0f);
  float4 res = tint_radians(arg_0);
  return res;
}

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

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

struct VertexOutput {
  float4 pos;
  float4 prevent_dce;
};

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

VertexOutput vertex_main_inner() {
  VertexOutput out = {};
  out.pos = float4(0.0f);
  out.prevent_dce = radians_09b7fc();
  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;
}

