| #include <metal_stdlib> |
| |
| using namespace metal; |
| struct tint_array_wrapper { |
| int arr[10]; |
| }; |
| struct QuicksortObject { |
| tint_array_wrapper numbers; |
| }; |
| struct buf0 { |
| /* 0x0000 */ packed_float2 resolution; |
| }; |
| struct main_out { |
| float4 x_GLF_color_1; |
| }; |
| struct tint_symbol_1 { |
| float4 x_GLF_color_1 [[color(0)]]; |
| }; |
| |
| void swap_i1_i1_(thread int* const i, thread int* const j, thread QuicksortObject* const tint_symbol_4) { |
| int temp = 0; |
| int const x_92 = *(i); |
| int const x_94 = (*(tint_symbol_4)).numbers.arr[x_92]; |
| temp = x_94; |
| int const x_95 = *(i); |
| int const x_96 = *(j); |
| int const x_98 = (*(tint_symbol_4)).numbers.arr[x_96]; |
| (*(tint_symbol_4)).numbers.arr[x_95] = x_98; |
| int const x_100 = *(j); |
| int const x_101 = temp; |
| (*(tint_symbol_4)).numbers.arr[x_100] = x_101; |
| return; |
| } |
| |
| int performPartition_i1_i1_(thread int* const l, thread int* const h, thread QuicksortObject* const tint_symbol_5) { |
| int pivot = 0; |
| int i_1 = 0; |
| int j_1 = 0; |
| int param = 0; |
| int param_1 = 0; |
| int param_2 = 0; |
| int param_3 = 0; |
| int const x_104 = *(h); |
| int const x_106 = (*(tint_symbol_5)).numbers.arr[x_104]; |
| pivot = x_106; |
| int const x_107 = *(l); |
| i_1 = (x_107 - 1); |
| int const x_109 = *(l); |
| j_1 = x_109; |
| while (true) { |
| int const x_114 = j_1; |
| int const x_115 = *(h); |
| if ((x_114 <= (x_115 - 1))) { |
| } else { |
| break; |
| } |
| int const x_119 = j_1; |
| int const x_121 = (*(tint_symbol_5)).numbers.arr[x_119]; |
| int const x_122 = pivot; |
| if ((x_121 <= x_122)) { |
| int const x_126 = i_1; |
| i_1 = (x_126 + 1); |
| int const x_128 = i_1; |
| param = x_128; |
| int const x_129 = j_1; |
| param_1 = x_129; |
| swap_i1_i1_(&(param), &(param_1), tint_symbol_5); |
| } |
| { |
| int const x_131 = j_1; |
| j_1 = (x_131 + 1); |
| } |
| } |
| int const x_133 = i_1; |
| param_2 = (x_133 + 1); |
| int const x_135 = *(h); |
| param_3 = x_135; |
| swap_i1_i1_(&(param_2), &(param_3), tint_symbol_5); |
| int const x_137 = i_1; |
| return (x_137 + 1); |
| } |
| |
| void quicksort_(thread QuicksortObject* const tint_symbol_6) { |
| int l_1 = 0; |
| int h_1 = 0; |
| int top = 0; |
| tint_array_wrapper stack = {}; |
| int p = 0; |
| int param_4 = 0; |
| int param_5 = 0; |
| l_1 = 0; |
| h_1 = 9; |
| top = -1; |
| int const x_140 = top; |
| int const x_141 = (x_140 + 1); |
| top = x_141; |
| int const x_142 = l_1; |
| stack.arr[x_141] = x_142; |
| int const x_144 = top; |
| int const x_145 = (x_144 + 1); |
| top = x_145; |
| int const x_146 = h_1; |
| stack.arr[x_145] = x_146; |
| while (true) { |
| int const x_152 = top; |
| if ((x_152 >= 0)) { |
| } else { |
| break; |
| } |
| int const x_155 = top; |
| top = (x_155 - 1); |
| int const x_158 = stack.arr[x_155]; |
| h_1 = x_158; |
| int const x_159 = top; |
| top = (x_159 - 1); |
| int const x_162 = stack.arr[x_159]; |
| l_1 = x_162; |
| int const x_163 = l_1; |
| param_4 = x_163; |
| int const x_164 = h_1; |
| param_5 = x_164; |
| int const x_165 = performPartition_i1_i1_(&(param_4), &(param_5), tint_symbol_6); |
| p = x_165; |
| int const x_166 = p; |
| int const x_168 = l_1; |
| if (((x_166 - 1) > x_168)) { |
| int const x_172 = top; |
| int const x_173 = (x_172 + 1); |
| top = x_173; |
| int const x_174 = l_1; |
| stack.arr[x_173] = x_174; |
| int const x_176 = top; |
| int const x_177 = (x_176 + 1); |
| top = x_177; |
| int const x_178 = p; |
| stack.arr[x_177] = (x_178 - 1); |
| } |
| int const x_181 = p; |
| int const x_183 = h_1; |
| if (((x_181 + 1) < x_183)) { |
| int const x_187 = top; |
| int const x_188 = (x_187 + 1); |
| top = x_188; |
| int const x_189 = p; |
| stack.arr[x_188] = (x_189 + 1); |
| int const x_192 = top; |
| int const x_193 = (x_192 + 1); |
| top = x_193; |
| int const x_194 = h_1; |
| stack.arr[x_193] = x_194; |
| } |
| } |
| return; |
| } |
| |
| void main_1(thread QuicksortObject* const tint_symbol_7, thread float4* const tint_symbol_8) { |
| int i_2 = 0; |
| i_2 = 0; |
| while (true) { |
| int const x_64 = i_2; |
| if ((x_64 < 10)) { |
| } else { |
| break; |
| } |
| int const x_67 = i_2; |
| int const x_68 = i_2; |
| (*(tint_symbol_7)).numbers.arr[x_67] = (10 - x_68); |
| int const x_71 = i_2; |
| int const x_72 = i_2; |
| int const x_74 = (*(tint_symbol_7)).numbers.arr[x_72]; |
| int const x_75 = i_2; |
| int const x_77 = (*(tint_symbol_7)).numbers.arr[x_75]; |
| (*(tint_symbol_7)).numbers.arr[x_71] = (x_74 * x_77); |
| { |
| int const x_80 = i_2; |
| i_2 = (x_80 + 1); |
| } |
| } |
| quicksort_(tint_symbol_7); |
| int const x_84 = (*(tint_symbol_7)).numbers.arr[0]; |
| int const x_86 = (*(tint_symbol_7)).numbers.arr[4]; |
| if ((x_84 < x_86)) { |
| *(tint_symbol_8) = float4(1.0f, 0.0f, 0.0f, 1.0f); |
| } else { |
| *(tint_symbol_8) = float4(0.0f, 1.0f, 0.0f, 1.0f); |
| } |
| return; |
| } |
| |
| fragment tint_symbol_1 tint_symbol() { |
| thread QuicksortObject tint_symbol_9 = {}; |
| thread float4 tint_symbol_10 = 0.0f; |
| main_1(&(tint_symbol_9), &(tint_symbol_10)); |
| main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_10}; |
| tint_symbol_1 const tint_symbol_3 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1}; |
| return tint_symbol_3; |
| } |
| |