#include <metal_stdlib>

using namespace metal;

struct modf_result_vec3_f32 {
  float3 fract;
  float3 whole;
};
modf_result_vec3_f32 tint_modf(float3 param_0) {
  modf_result_vec3_f32 result;
  result.fract = modf(param_0, result.whole);
  return result;
}

void modf_5ea256() {
  float3 arg_0 = float3(-1.5f);
  modf_result_vec3_f32 res = tint_modf(arg_0);
}

fragment void fragment_main() {
  modf_5ea256();
  return;
}

kernel void compute_main() {
  modf_5ea256();
  return;
}

struct VertexOutput {
  float4 pos;
};

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

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

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

