#include <metal_stdlib>

using namespace metal;
void textureLoad_519ab5(texture1d<float, access::read> tint_symbol_1, device float4* const tint_symbol_2) {
  int arg_1 = 1;
  float4 res = tint_symbol_1.read(uint(arg_1));
  *(tint_symbol_2) = res;
}

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

float4 vertex_main_inner(texture1d<float, access::read> tint_symbol_3, device float4* const tint_symbol_4) {
  textureLoad_519ab5(tint_symbol_3, tint_symbol_4);
  return float4(0.0f);
}

vertex tint_symbol vertex_main(texture1d<float, access::read> tint_symbol_5 [[texture(0)]], device float4* tint_symbol_6 [[buffer(0)]]) {
  float4 const inner_result = vertex_main_inner(tint_symbol_5, tint_symbol_6);
  tint_symbol wrapper_result = {};
  wrapper_result.value = inner_result;
  return wrapper_result;
}

fragment void fragment_main(texture1d<float, access::read> tint_symbol_7 [[texture(0)]], device float4* tint_symbol_8 [[buffer(0)]]) {
  textureLoad_519ab5(tint_symbol_7, tint_symbol_8);
  return;
}

kernel void compute_main(texture1d<float, access::read> tint_symbol_9 [[texture(0)]], device float4* tint_symbol_10 [[buffer(0)]]) {
  textureLoad_519ab5(tint_symbol_9, tint_symbol_10);
  return;
}

