#include <metal_stdlib>

using namespace metal;

struct modf_result_vec2_f32 {
  float2 fract;
  float2 whole;
};
void modf_2d50da() {
  modf_result_vec2_f32 res = modf_result_vec2_f32{.fract=float2(-0.5f), .whole=float2(-1.0f)};
}

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

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

struct VertexOutput {
  float4 pos;
};

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

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

