282 lines
7.3 KiB
Plaintext
282 lines
7.3 KiB
Plaintext
|
#include <metal_stdlib>
|
||
|
|
||
|
using namespace metal;
|
||
|
struct BST {
|
||
|
int data;
|
||
|
int leftIndex;
|
||
|
int rightIndex;
|
||
|
};
|
||
|
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 node, thread int* const data) {
|
||
|
int const x_158 = *(data);
|
||
|
(*(node)).data = x_158;
|
||
|
(*(node)).leftIndex = -1;
|
||
|
(*(node)).rightIndex = -1;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
void insert_i1_i1_(thread int* const treeIndex, thread int* const data_1, thread tint_array_wrapper* const tint_symbol_4) {
|
||
|
int baseIndex = 0;
|
||
|
BST param = {};
|
||
|
int param_1 = 0;
|
||
|
BST param_2 = {};
|
||
|
int param_3 = 0;
|
||
|
baseIndex = 0;
|
||
|
while (true) {
|
||
|
int const x_167 = baseIndex;
|
||
|
int const x_168 = *(treeIndex);
|
||
|
if ((x_167 <= x_168)) {
|
||
|
} else {
|
||
|
break;
|
||
|
}
|
||
|
int const x_171 = *(data_1);
|
||
|
int const x_172 = baseIndex;
|
||
|
int const x_174 = (*(tint_symbol_4)).arr[x_172].data;
|
||
|
if ((x_171 <= x_174)) {
|
||
|
int const x_179 = baseIndex;
|
||
|
int const x_181 = (*(tint_symbol_4)).arr[x_179].leftIndex;
|
||
|
if ((x_181 == -1)) {
|
||
|
int const x_186 = baseIndex;
|
||
|
int const x_187 = *(treeIndex);
|
||
|
(*(tint_symbol_4)).arr[x_186].leftIndex = x_187;
|
||
|
int const x_189 = *(treeIndex);
|
||
|
BST const x_191 = (*(tint_symbol_4)).arr[x_189];
|
||
|
param = x_191;
|
||
|
int const x_192 = *(data_1);
|
||
|
param_1 = x_192;
|
||
|
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param), &(param_1));
|
||
|
BST const x_194 = param;
|
||
|
(*(tint_symbol_4)).arr[x_189] = x_194;
|
||
|
return;
|
||
|
} else {
|
||
|
int const x_196 = baseIndex;
|
||
|
int const x_198 = (*(tint_symbol_4)).arr[x_196].leftIndex;
|
||
|
baseIndex = x_198;
|
||
|
continue;
|
||
|
}
|
||
|
return;
|
||
|
} else {
|
||
|
int const x_199 = baseIndex;
|
||
|
int const x_201 = (*(tint_symbol_4)).arr[x_199].rightIndex;
|
||
|
if ((x_201 == -1)) {
|
||
|
int const x_206 = baseIndex;
|
||
|
int const x_207 = *(treeIndex);
|
||
|
(*(tint_symbol_4)).arr[x_206].rightIndex = x_207;
|
||
|
int const x_209 = *(treeIndex);
|
||
|
BST const x_211 = (*(tint_symbol_4)).arr[x_209];
|
||
|
param_2 = x_211;
|
||
|
int const x_212 = *(data_1);
|
||
|
param_3 = x_212;
|
||
|
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_2), &(param_3));
|
||
|
BST const x_214 = param_2;
|
||
|
(*(tint_symbol_4)).arr[x_209] = x_214;
|
||
|
return;
|
||
|
} else {
|
||
|
int const x_216 = baseIndex;
|
||
|
int const x_218 = (*(tint_symbol_4)).arr[x_216].rightIndex;
|
||
|
baseIndex = x_218;
|
||
|
continue;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int search_i1_(thread int* const target, thread tint_array_wrapper* const tint_symbol_5) {
|
||
|
int index = 0;
|
||
|
BST currentNode = {};
|
||
|
int x_220 = 0;
|
||
|
index = 0;
|
||
|
while (true) {
|
||
|
int const x_225 = index;
|
||
|
if ((x_225 != -1)) {
|
||
|
} else {
|
||
|
break;
|
||
|
}
|
||
|
int const x_228 = index;
|
||
|
BST const x_230 = (*(tint_symbol_5)).arr[x_228];
|
||
|
currentNode = x_230;
|
||
|
int const x_232 = currentNode.data;
|
||
|
int const x_233 = *(target);
|
||
|
if ((x_232 == x_233)) {
|
||
|
int const x_237 = *(target);
|
||
|
return x_237;
|
||
|
}
|
||
|
int const x_238 = *(target);
|
||
|
int const x_240 = currentNode.data;
|
||
|
if ((x_238 > x_240)) {
|
||
|
int const x_246 = currentNode.rightIndex;
|
||
|
x_220 = x_246;
|
||
|
} else {
|
||
|
int const x_248 = currentNode.leftIndex;
|
||
|
x_220 = x_248;
|
||
|
}
|
||
|
int const x_249 = x_220;
|
||
|
index = x_249;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
void main_1(thread tint_array_wrapper* const tint_symbol_6, thread float4* const tint_symbol_7) {
|
||
|
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_84 = (*(tint_symbol_6)).arr[0];
|
||
|
param_4 = x_84;
|
||
|
param_5 = 9;
|
||
|
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_4), &(param_5));
|
||
|
BST const x_86 = param_4;
|
||
|
(*(tint_symbol_6)).arr[0] = x_86;
|
||
|
int const x_88 = treeIndex_1;
|
||
|
treeIndex_1 = (x_88 + 1);
|
||
|
int const x_90 = treeIndex_1;
|
||
|
param_6 = x_90;
|
||
|
param_7 = 5;
|
||
|
insert_i1_i1_(&(param_6), &(param_7), tint_symbol_6);
|
||
|
int const x_92 = treeIndex_1;
|
||
|
treeIndex_1 = (x_92 + 1);
|
||
|
int const x_94 = treeIndex_1;
|
||
|
param_8 = x_94;
|
||
|
param_9 = 12;
|
||
|
insert_i1_i1_(&(param_8), &(param_9), tint_symbol_6);
|
||
|
int const x_96 = treeIndex_1;
|
||
|
treeIndex_1 = (x_96 + 1);
|
||
|
int const x_98 = treeIndex_1;
|
||
|
param_10 = x_98;
|
||
|
param_11 = 15;
|
||
|
insert_i1_i1_(&(param_10), &(param_11), tint_symbol_6);
|
||
|
int const x_100 = treeIndex_1;
|
||
|
treeIndex_1 = (x_100 + 1);
|
||
|
int const x_102 = treeIndex_1;
|
||
|
param_12 = x_102;
|
||
|
param_13 = 7;
|
||
|
insert_i1_i1_(&(param_12), &(param_13), tint_symbol_6);
|
||
|
int const x_104 = treeIndex_1;
|
||
|
treeIndex_1 = (x_104 + 1);
|
||
|
int const x_106 = treeIndex_1;
|
||
|
param_14 = x_106;
|
||
|
param_15 = 8;
|
||
|
insert_i1_i1_(&(param_14), &(param_15), tint_symbol_6);
|
||
|
int const x_108 = treeIndex_1;
|
||
|
treeIndex_1 = (x_108 + 1);
|
||
|
int const x_110 = treeIndex_1;
|
||
|
param_16 = x_110;
|
||
|
param_17 = 2;
|
||
|
insert_i1_i1_(&(param_16), &(param_17), tint_symbol_6);
|
||
|
int const x_112 = treeIndex_1;
|
||
|
treeIndex_1 = (x_112 + 1);
|
||
|
int const x_114 = treeIndex_1;
|
||
|
param_18 = x_114;
|
||
|
param_19 = 6;
|
||
|
insert_i1_i1_(&(param_18), &(param_19), tint_symbol_6);
|
||
|
int const x_116 = treeIndex_1;
|
||
|
treeIndex_1 = (x_116 + 1);
|
||
|
int const x_118 = treeIndex_1;
|
||
|
param_20 = x_118;
|
||
|
param_21 = 17;
|
||
|
insert_i1_i1_(&(param_20), &(param_21), tint_symbol_6);
|
||
|
int const x_120 = treeIndex_1;
|
||
|
treeIndex_1 = (x_120 + 1);
|
||
|
int const x_122 = treeIndex_1;
|
||
|
param_22 = x_122;
|
||
|
param_23 = 13;
|
||
|
insert_i1_i1_(&(param_22), &(param_23), tint_symbol_6);
|
||
|
count = 0;
|
||
|
i = 0;
|
||
|
while (true) {
|
||
|
int const x_128 = i;
|
||
|
if ((x_128 < 20)) {
|
||
|
} else {
|
||
|
break;
|
||
|
}
|
||
|
int const x_131 = i;
|
||
|
param_24 = x_131;
|
||
|
int const x_132 = search_i1_(&(param_24), tint_symbol_6);
|
||
|
result = x_132;
|
||
|
int const x_133 = i;
|
||
|
switch(x_133) {
|
||
|
case 2:
|
||
|
case 5:
|
||
|
case 6:
|
||
|
case 7:
|
||
|
case 8:
|
||
|
case 9:
|
||
|
case 12:
|
||
|
case 13:
|
||
|
case 15:
|
||
|
case 17: {
|
||
|
int const x_143 = result;
|
||
|
int const x_144 = i;
|
||
|
if ((x_143 == x_144)) {
|
||
|
int const x_148 = count;
|
||
|
count = (x_148 + 1);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
default: {
|
||
|
int const x_137 = result;
|
||
|
if ((x_137 == -1)) {
|
||
|
int const x_141 = count;
|
||
|
count = (x_141 + 1);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
{
|
||
|
int const x_150 = i;
|
||
|
i = (x_150 + 1);
|
||
|
}
|
||
|
}
|
||
|
int const x_152 = count;
|
||
|
if ((x_152 == 20)) {
|
||
|
*(tint_symbol_7) = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||
|
} else {
|
||
|
*(tint_symbol_7) = float4(0.0f, 0.0f, 1.0f, 1.0f);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
fragment tint_symbol_1 tint_symbol() {
|
||
|
thread tint_array_wrapper tint_symbol_8 = {};
|
||
|
thread float4 tint_symbol_9 = 0.0f;
|
||
|
main_1(&(tint_symbol_8), &(tint_symbol_9));
|
||
|
main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_9};
|
||
|
tint_symbol_1 const tint_symbol_3 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1};
|
||
|
return tint_symbol_3;
|
||
|
}
|
||
|
|