blob: 76e4639b845a98df2842c31a1b4b3cd2c6d7540a [file] [log] [blame]
#include <metal_stdlib>
using namespace metal;
struct BST {
int data;
int leftIndex;
int rightIndex;
};
struct buf0 {
/* 0x0000 */ packed_float2 injectionSwitch;
};
struct tint_array_wrapper {
BST arr[10];
};
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol_1 {
float4 x_GLF_color_1 [[color(0)]];
};
void makeTreeNode_struct_BST_i1_i1_i11_i1_(thread BST* const tree, thread int* const data) {
int const x_165 = *(data);
(*(tree)).data = x_165;
(*(tree)).leftIndex = -1;
(*(tree)).rightIndex = -1;
return;
}
void insert_i1_i1_(constant buf0& x_16, thread int* const treeIndex, thread int* const data_1, thread tint_array_wrapper* const tint_symbol_3) {
int baseIndex = 0;
BST param = {};
int param_1 = 0;
int x_170 = 0;
BST param_2 = {};
int param_3 = 0;
baseIndex = 0;
while (true) {
int const x_175 = baseIndex;
int const x_176 = *(treeIndex);
if ((x_175 <= x_176)) {
} else {
break;
}
int const x_179 = *(data_1);
int const x_180 = baseIndex;
int const x_182 = (*(tint_symbol_3)).arr[x_180].data;
if ((x_179 <= x_182)) {
int const x_187 = baseIndex;
int const x_189 = (*(tint_symbol_3)).arr[x_187].leftIndex;
if ((x_189 == -1)) {
int const x_194 = baseIndex;
int const x_195 = *(treeIndex);
(*(tint_symbol_3)).arr[x_194].leftIndex = x_195;
float const x_198 = x_16.injectionSwitch.x;
float const x_200 = x_16.injectionSwitch.y;
if ((x_198 < x_200)) {
int const x_204 = *(treeIndex);
BST const x_206 = (*(tint_symbol_3)).arr[x_204];
param = x_206;
int const x_207 = *(data_1);
param_1 = x_207;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param), &(param_1));
BST const x_209 = param;
(*(tint_symbol_3)).arr[x_204] = x_209;
}
float const x_212 = x_16.injectionSwitch.x;
float const x_214 = x_16.injectionSwitch.y;
if ((x_212 < x_214)) {
return;
}
} else {
int const x_218 = baseIndex;
int const x_220 = (*(tint_symbol_3)).arr[x_218].leftIndex;
baseIndex = x_220;
continue;
}
} else {
float const x_222 = x_16.injectionSwitch.x;
float const x_224 = x_16.injectionSwitch.y;
if ((x_222 < x_224)) {
int const x_229 = baseIndex;
int const x_231 = (*(tint_symbol_3)).arr[x_229].rightIndex;
x_170 = x_231;
} else {
int const x_232 = baseIndex;
int const x_234 = (*(tint_symbol_3)).arr[x_232].rightIndex;
x_170 = x_234;
}
int const x_235 = x_170;
if ((x_235 == -1)) {
int const x_240 = baseIndex;
int const x_241 = *(treeIndex);
(*(tint_symbol_3)).arr[x_240].rightIndex = x_241;
int const x_243 = *(treeIndex);
BST const x_245 = (*(tint_symbol_3)).arr[x_243];
param_2 = x_245;
int const x_246 = *(data_1);
param_3 = x_246;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_2), &(param_3));
BST const x_248 = param_2;
(*(tint_symbol_3)).arr[x_243] = x_248;
return;
} else {
int const x_250 = baseIndex;
int const x_252 = (*(tint_symbol_3)).arr[x_250].rightIndex;
baseIndex = x_252;
continue;
}
return;
}
float const x_254 = x_16.injectionSwitch.x;
float const x_256 = x_16.injectionSwitch.y;
if ((x_254 > x_256)) {
return;
}
}
return;
}
int search_i1_(thread int* const target, thread tint_array_wrapper* const tint_symbol_4) {
int index = 0;
BST currentNode = {};
int x_261 = 0;
index = 0;
while (true) {
int const x_266 = index;
if ((x_266 != -1)) {
} else {
break;
}
int const x_269 = index;
BST const x_271 = (*(tint_symbol_4)).arr[x_269];
currentNode = x_271;
int const x_273 = currentNode.data;
int const x_274 = *(target);
if ((x_273 == x_274)) {
int const x_278 = *(target);
return x_278;
}
int const x_279 = *(target);
int const x_281 = currentNode.data;
if ((x_279 > x_281)) {
int const x_287 = currentNode.rightIndex;
x_261 = x_287;
} else {
int const x_289 = currentNode.leftIndex;
x_261 = x_289;
}
int const x_290 = x_261;
index = x_290;
}
return -1;
}
void main_1(constant buf0& x_16, thread tint_array_wrapper* const tint_symbol_5, thread float4* const tint_symbol_6) {
int treeIndex_1 = 0;
BST param_4 = {};
int param_5 = 0;
int param_6 = 0;
int param_7 = 0;
int param_8 = 0;
int param_9 = 0;
int param_10 = 0;
int param_11 = 0;
int param_12 = 0;
int param_13 = 0;
int param_14 = 0;
int param_15 = 0;
int param_16 = 0;
int param_17 = 0;
int param_18 = 0;
int param_19 = 0;
int param_20 = 0;
int param_21 = 0;
int param_22 = 0;
int param_23 = 0;
int count = 0;
int i = 0;
int result = 0;
int param_24 = 0;
treeIndex_1 = 0;
BST const x_91 = (*(tint_symbol_5)).arr[0];
param_4 = x_91;
param_5 = 9;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_4), &(param_5));
BST const x_93 = param_4;
(*(tint_symbol_5)).arr[0] = x_93;
int const x_95 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_95) + as_type<uint>(1)));
int const x_97 = treeIndex_1;
param_6 = x_97;
param_7 = 5;
insert_i1_i1_(x_16, &(param_6), &(param_7), tint_symbol_5);
int const x_99 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_99) + as_type<uint>(1)));
int const x_101 = treeIndex_1;
param_8 = x_101;
param_9 = 12;
insert_i1_i1_(x_16, &(param_8), &(param_9), tint_symbol_5);
int const x_103 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_103) + as_type<uint>(1)));
int const x_105 = treeIndex_1;
param_10 = x_105;
param_11 = 15;
insert_i1_i1_(x_16, &(param_10), &(param_11), tint_symbol_5);
int const x_107 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_107) + as_type<uint>(1)));
int const x_109 = treeIndex_1;
param_12 = x_109;
param_13 = 7;
insert_i1_i1_(x_16, &(param_12), &(param_13), tint_symbol_5);
int const x_111 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_111) + as_type<uint>(1)));
int const x_113 = treeIndex_1;
param_14 = x_113;
param_15 = 8;
insert_i1_i1_(x_16, &(param_14), &(param_15), tint_symbol_5);
int const x_115 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_115) + as_type<uint>(1)));
int const x_117 = treeIndex_1;
param_16 = x_117;
param_17 = 2;
insert_i1_i1_(x_16, &(param_16), &(param_17), tint_symbol_5);
int const x_119 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_119) + as_type<uint>(1)));
int const x_121 = treeIndex_1;
param_18 = x_121;
param_19 = 6;
insert_i1_i1_(x_16, &(param_18), &(param_19), tint_symbol_5);
int const x_123 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_123) + as_type<uint>(1)));
int const x_125 = treeIndex_1;
param_20 = x_125;
param_21 = 17;
insert_i1_i1_(x_16, &(param_20), &(param_21), tint_symbol_5);
int const x_127 = treeIndex_1;
treeIndex_1 = as_type<int>((as_type<uint>(x_127) + as_type<uint>(1)));
int const x_129 = treeIndex_1;
param_22 = x_129;
param_23 = 13;
insert_i1_i1_(x_16, &(param_22), &(param_23), tint_symbol_5);
count = 0;
i = 0;
while (true) {
int const x_135 = i;
if ((x_135 < 20)) {
} else {
break;
}
int const x_138 = i;
param_24 = x_138;
int const x_139 = search_i1_(&(param_24), tint_symbol_5);
result = x_139;
int const x_140 = i;
switch(x_140) {
case 2:
case 5:
case 6:
case 7:
case 8:
case 9:
case 12:
case 13:
case 15:
case 17: {
int const x_150 = result;
int const x_151 = i;
if ((x_150 == x_151)) {
int const x_155 = count;
count = as_type<int>((as_type<uint>(x_155) + as_type<uint>(1)));
}
break;
}
default: {
int const x_144 = result;
if ((x_144 == -1)) {
int const x_148 = count;
count = as_type<int>((as_type<uint>(x_148) + as_type<uint>(1)));
}
break;
}
}
{
int const x_157 = i;
i = as_type<int>((as_type<uint>(x_157) + as_type<uint>(1)));
}
}
int const x_159 = count;
if ((x_159 == 20)) {
*(tint_symbol_6) = float4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
*(tint_symbol_6) = float4(0.0f, 0.0f, 1.0f, 1.0f);
}
return;
}
main_out tint_symbol_inner(constant buf0& x_16, thread tint_array_wrapper* const tint_symbol_7, thread float4* const tint_symbol_8) {
main_1(x_16, tint_symbol_7, tint_symbol_8);
main_out const tint_symbol_2 = {.x_GLF_color_1=*(tint_symbol_8)};
return tint_symbol_2;
}
fragment tint_symbol_1 tint_symbol(constant buf0& x_16 [[buffer(0)]]) {
thread tint_array_wrapper tint_symbol_9 = {};
thread float4 tint_symbol_10 = 0.0f;
main_out const inner_result = tint_symbol_inner(x_16, &(tint_symbol_9), &(tint_symbol_10));
tint_symbol_1 wrapper_result = {};
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
return wrapper_result;
}