#include <metal_stdlib>

using namespace metal;

struct modf_result_vec4_f32 {
  float4 fract;
  float4 whole;
};
void modf_f3d1f9() {
  modf_result_vec4_f32 res = modf_result_vec4_f32{.fract=float4(-0.5f), .whole=float4(-1.0f)};
}

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

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

struct VertexOutput {
  float4 pos;
};

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

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

