#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  device float4* prevent_dce;
  texture2d_array<float, access::sample> arg_0;
  sampler arg_1;
};

float4 textureSample_6717ca(tint_module_vars_struct tint_module_vars) {
  float2 arg_2 = float2(1.0f);
  int arg_3 = 1;
  float4 res = tint_module_vars.arg_0.sample(tint_module_vars.arg_1, arg_2, max(arg_3, 0));
  return res;
}

fragment void fragment_main(device float4* prevent_dce [[buffer(0)]], texture2d_array<float, access::sample> arg_0 [[texture(0)]], sampler arg_1 [[sampler(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce, .arg_0=arg_0, .arg_1=arg_1};
  (*tint_module_vars.prevent_dce) = textureSample_6717ca(tint_module_vars);
}
