#include <metal_stdlib>

using namespace metal;

struct frexp_result_vec2_f16 {
  half2 fract;
  int2 exp;
};
void frexp_5f47bf() {
  frexp_result_vec2_f16 res = frexp_result_vec2_f16{.fract=half2(0.5h), .exp=int2(1)};
}

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

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

struct VertexOutput {
  float4 pos;
};

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

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

