Add tests derived from VK-GL-CTS

This adds SPIR-V assembly and WGSL tests derived from VK-GL-CTS commit
571256871c2e2f03995373e1e4a02958d8cd8cf5. The following procedure was
followed:

- Those .amber files in VK-GL-CTS wholly owned by Google were
  identified

- All GLSL and SPIR-V shaders were extracted from the Amber files and
  converted into SPIR-V binaries

- The compact-ids pass of spirv-opt was applied to each binary

- Duplicate binaries were removed

- spirv-opt -O was used to obtain an optimized version of each remaining
  binary, with duplicates discarded

- Binaries that failed validation using spirv-val with target
  environment SPIR-V 1.3 were discarded

- Those binaries that tint could not successfully convert into WGSL were
  put aside for further investigation

- SPIR-V assembly versions of the remaining binaries are included in
  this CL

- test-runner with -generate-expected and -generate-skip was used to
  generate expected .spvasm, .msl, .hlsl and .wgsl outputs for these
  SPIR-V assembly tests

- Each successfully-generated .expected.wgsl is included in this CL
  again, as a WGLSL test

- test-runner with -generate-expected and -generate-skip was used again,
  to generate expected outputs for these WGSL tests

Change-Id: Ibe9baf2729cf97e0b633db9a426f53362a5de540
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58842
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Alastair Donaldson
2021-07-23 13:10:12 +00:00
committed by Tint LUCI CQ
parent bd3edb564f
commit f7e73d4ee3
5160 changed files with 621458 additions and 0 deletions

View File

@@ -0,0 +1,483 @@
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %_GLF_color
OpExecutionMode %main OriginUpperLeft
OpSource ESSL 320
OpName %main "main"
OpName %BST "BST"
OpMemberName %BST 0 "data"
OpMemberName %BST 1 "leftIndex"
OpMemberName %BST 2 "rightIndex"
OpName %makeTreeNode_struct_BST_i1_i1_i11_i1_ "makeTreeNode(struct-BST-i1-i1-i11;i1;"
OpName %tree "tree"
OpName %data "data"
OpName %insert_i1_i1_ "insert(i1;i1;"
OpName %treeIndex "treeIndex"
OpName %data_0 "data"
OpName %search_i1_ "search(i1;"
OpName %target "target"
OpName %baseIndex "baseIndex"
OpName %tree_0 "tree"
OpName %buf0 "buf0"
OpMemberName %buf0 0 "injectionSwitch"
OpName %_ ""
OpName %param "param"
OpName %param_0 "param"
OpName %param_1 "param"
OpName %param_2 "param"
OpName %index "index"
OpName %currentNode "currentNode"
OpName %treeIndex_0 "treeIndex"
OpName %param_3 "param"
OpName %param_4 "param"
OpName %param_5 "param"
OpName %param_6 "param"
OpName %param_7 "param"
OpName %param_8 "param"
OpName %param_9 "param"
OpName %param_10 "param"
OpName %param_11 "param"
OpName %param_12 "param"
OpName %param_13 "param"
OpName %param_14 "param"
OpName %param_15 "param"
OpName %param_16 "param"
OpName %param_17 "param"
OpName %param_18 "param"
OpName %param_19 "param"
OpName %param_20 "param"
OpName %param_21 "param"
OpName %param_22 "param"
OpName %count "count"
OpName %i "i"
OpName %result "result"
OpName %param_23 "param"
OpName %_GLF_color "_GLF_color"
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %buf0 Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %_GLF_color Location 0
%void = OpTypeVoid
%49 = OpTypeFunction %void
%int = OpTypeInt 32 1
%BST = OpTypeStruct %int %int %int
%_ptr_Function_BST = OpTypePointer Function %BST
%_ptr_Function_int = OpTypePointer Function %int
%53 = OpTypeFunction %void %_ptr_Function_BST %_ptr_Function_int
%54 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int
%55 = OpTypeFunction %int %_ptr_Function_int
%int_0 = OpConstant %int 0
%int_1 = OpConstant %int 1
%int_n1 = OpConstant %int -1
%int_2 = OpConstant %int 2
%bool = OpTypeBool
%uint = OpTypeInt 32 0
%uint_10 = OpConstant %uint 10
%_arr_BST_uint_10 = OpTypeArray %BST %uint_10
%_ptr_Private__arr_BST_uint_10 = OpTypePointer Private %_arr_BST_uint_10
%tree_0 = OpVariable %_ptr_Private__arr_BST_uint_10 Private
%_ptr_Private_int = OpTypePointer Private %int
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%buf0 = OpTypeStruct %v2float
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%_ = OpVariable %_ptr_Uniform_buf0 Uniform
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_float = OpTypePointer Uniform %float
%uint_1 = OpConstant %uint 1
%_ptr_Private_BST = OpTypePointer Private %BST
%int_9 = OpConstant %int 9
%int_5 = OpConstant %int 5
%int_12 = OpConstant %int 12
%int_15 = OpConstant %int 15
%int_7 = OpConstant %int 7
%int_8 = OpConstant %int 8
%int_6 = OpConstant %int 6
%int_17 = OpConstant %int 17
%int_13 = OpConstant %int 13
%int_20 = OpConstant %int 20
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_GLF_color = OpVariable %_ptr_Output_v4float Output
%float_1 = OpConstant %float 1
%float_0 = OpConstant %float 0
%87 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
%88 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
%main = OpFunction %void None %49
%89 = OpLabel
%treeIndex_0 = OpVariable %_ptr_Function_int Function
%param_3 = OpVariable %_ptr_Function_BST Function
%param_4 = OpVariable %_ptr_Function_int Function
%param_5 = OpVariable %_ptr_Function_int Function
%param_6 = OpVariable %_ptr_Function_int Function
%param_7 = OpVariable %_ptr_Function_int Function
%param_8 = OpVariable %_ptr_Function_int Function
%param_9 = OpVariable %_ptr_Function_int Function
%param_10 = OpVariable %_ptr_Function_int Function
%param_11 = OpVariable %_ptr_Function_int Function
%param_12 = OpVariable %_ptr_Function_int Function
%param_13 = OpVariable %_ptr_Function_int Function
%param_14 = OpVariable %_ptr_Function_int Function
%param_15 = OpVariable %_ptr_Function_int Function
%param_16 = OpVariable %_ptr_Function_int Function
%param_17 = OpVariable %_ptr_Function_int Function
%param_18 = OpVariable %_ptr_Function_int Function
%param_19 = OpVariable %_ptr_Function_int Function
%param_20 = OpVariable %_ptr_Function_int Function
%param_21 = OpVariable %_ptr_Function_int Function
%param_22 = OpVariable %_ptr_Function_int Function
%count = OpVariable %_ptr_Function_int Function
%i = OpVariable %_ptr_Function_int Function
%result = OpVariable %_ptr_Function_int Function
%param_23 = OpVariable %_ptr_Function_int Function
OpStore %treeIndex_0 %int_0
%90 = OpAccessChain %_ptr_Private_BST %tree_0 %int_0
%91 = OpLoad %BST %90
OpStore %param_3 %91
OpStore %param_4 %int_9
%92 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param_3 %param_4
%93 = OpLoad %BST %param_3
%94 = OpAccessChain %_ptr_Private_BST %tree_0 %int_0
OpStore %94 %93
%95 = OpLoad %int %treeIndex_0
%96 = OpIAdd %int %95 %int_1
OpStore %treeIndex_0 %96
%97 = OpLoad %int %treeIndex_0
OpStore %param_5 %97
OpStore %param_6 %int_5
%98 = OpFunctionCall %void %insert_i1_i1_ %param_5 %param_6
%99 = OpLoad %int %treeIndex_0
%100 = OpIAdd %int %99 %int_1
OpStore %treeIndex_0 %100
%101 = OpLoad %int %treeIndex_0
OpStore %param_7 %101
OpStore %param_8 %int_12
%102 = OpFunctionCall %void %insert_i1_i1_ %param_7 %param_8
%103 = OpLoad %int %treeIndex_0
%104 = OpIAdd %int %103 %int_1
OpStore %treeIndex_0 %104
%105 = OpLoad %int %treeIndex_0
OpStore %param_9 %105
OpStore %param_10 %int_15
%106 = OpFunctionCall %void %insert_i1_i1_ %param_9 %param_10
%107 = OpLoad %int %treeIndex_0
%108 = OpIAdd %int %107 %int_1
OpStore %treeIndex_0 %108
%109 = OpLoad %int %treeIndex_0
OpStore %param_11 %109
OpStore %param_12 %int_7
%110 = OpFunctionCall %void %insert_i1_i1_ %param_11 %param_12
%111 = OpLoad %int %treeIndex_0
%112 = OpIAdd %int %111 %int_1
OpStore %treeIndex_0 %112
%113 = OpLoad %int %treeIndex_0
OpStore %param_13 %113
OpStore %param_14 %int_8
%114 = OpFunctionCall %void %insert_i1_i1_ %param_13 %param_14
%115 = OpLoad %int %treeIndex_0
%116 = OpIAdd %int %115 %int_1
OpStore %treeIndex_0 %116
%117 = OpLoad %int %treeIndex_0
OpStore %param_15 %117
OpStore %param_16 %int_2
%118 = OpFunctionCall %void %insert_i1_i1_ %param_15 %param_16
%119 = OpLoad %int %treeIndex_0
%120 = OpIAdd %int %119 %int_1
OpStore %treeIndex_0 %120
%121 = OpLoad %int %treeIndex_0
OpStore %param_17 %121
OpStore %param_18 %int_6
%122 = OpFunctionCall %void %insert_i1_i1_ %param_17 %param_18
%123 = OpLoad %int %treeIndex_0
%124 = OpIAdd %int %123 %int_1
OpStore %treeIndex_0 %124
%125 = OpLoad %int %treeIndex_0
OpStore %param_19 %125
OpStore %param_20 %int_17
%126 = OpFunctionCall %void %insert_i1_i1_ %param_19 %param_20
%127 = OpLoad %int %treeIndex_0
%128 = OpIAdd %int %127 %int_1
OpStore %treeIndex_0 %128
%129 = OpLoad %int %treeIndex_0
OpStore %param_21 %129
OpStore %param_22 %int_13
%130 = OpFunctionCall %void %insert_i1_i1_ %param_21 %param_22
OpStore %count %int_0
OpStore %i %int_0
OpBranch %131
%131 = OpLabel
OpLoopMerge %132 %133 None
OpBranch %134
%134 = OpLabel
%135 = OpLoad %int %i
%136 = OpSLessThan %bool %135 %int_20
OpBranchConditional %136 %137 %132
%137 = OpLabel
%138 = OpLoad %int %i
OpStore %param_23 %138
%139 = OpFunctionCall %int %search_i1_ %param_23
OpStore %result %139
%140 = OpLoad %int %i
OpSelectionMerge %141 None
OpSwitch %140 %142 9 %143 5 %143 12 %143 15 %143 7 %143 8 %143 2 %143 6 %143 17 %143 13 %143
%142 = OpLabel
%144 = OpLoad %int %result
%145 = OpIEqual %bool %144 %int_n1
OpSelectionMerge %146 None
OpBranchConditional %145 %147 %146
%147 = OpLabel
%148 = OpLoad %int %count
%149 = OpIAdd %int %148 %int_1
OpStore %count %149
OpBranch %146
%146 = OpLabel
OpBranch %141
%143 = OpLabel
%150 = OpLoad %int %result
%151 = OpLoad %int %i
%152 = OpIEqual %bool %150 %151
OpSelectionMerge %153 None
OpBranchConditional %152 %154 %153
%154 = OpLabel
%155 = OpLoad %int %count
%156 = OpIAdd %int %155 %int_1
OpStore %count %156
OpBranch %153
%153 = OpLabel
OpBranch %141
%141 = OpLabel
OpBranch %133
%133 = OpLabel
%157 = OpLoad %int %i
%158 = OpIAdd %int %157 %int_1
OpStore %i %158
OpBranch %131
%132 = OpLabel
%159 = OpLoad %int %count
%160 = OpIEqual %bool %159 %int_20
OpSelectionMerge %161 None
OpBranchConditional %160 %162 %163
%162 = OpLabel
OpStore %_GLF_color %87
OpBranch %161
%163 = OpLabel
OpStore %_GLF_color %88
OpBranch %161
%161 = OpLabel
OpReturn
OpFunctionEnd
%makeTreeNode_struct_BST_i1_i1_i11_i1_ = OpFunction %void None %53
%tree = OpFunctionParameter %_ptr_Function_BST
%data = OpFunctionParameter %_ptr_Function_int
%164 = OpLabel
%165 = OpLoad %int %data
%166 = OpAccessChain %_ptr_Function_int %tree %int_0
OpStore %166 %165
%167 = OpAccessChain %_ptr_Function_int %tree %int_1
OpStore %167 %int_n1
%168 = OpAccessChain %_ptr_Function_int %tree %int_2
OpStore %168 %int_n1
OpReturn
OpFunctionEnd
%insert_i1_i1_ = OpFunction %void None %54
%treeIndex = OpFunctionParameter %_ptr_Function_int
%data_0 = OpFunctionParameter %_ptr_Function_int
%169 = OpLabel
%baseIndex = OpVariable %_ptr_Function_int Function
%param = OpVariable %_ptr_Function_BST Function
%param_0 = OpVariable %_ptr_Function_int Function
%170 = OpVariable %_ptr_Function_int Function
%param_1 = OpVariable %_ptr_Function_BST Function
%param_2 = OpVariable %_ptr_Function_int Function
OpStore %baseIndex %int_0
OpBranch %171
%171 = OpLabel
OpLoopMerge %172 %173 None
OpBranch %174
%174 = OpLabel
%175 = OpLoad %int %baseIndex
%176 = OpLoad %int %treeIndex
%177 = OpSLessThanEqual %bool %175 %176
OpBranchConditional %177 %178 %172
%178 = OpLabel
%179 = OpLoad %int %data_0
%180 = OpLoad %int %baseIndex
%181 = OpAccessChain %_ptr_Private_int %tree_0 %180 %int_0
%182 = OpLoad %int %181
%183 = OpSLessThanEqual %bool %179 %182
OpSelectionMerge %184 None
OpBranchConditional %183 %185 %186
%185 = OpLabel
%187 = OpLoad %int %baseIndex
%188 = OpAccessChain %_ptr_Private_int %tree_0 %187 %int_1
%189 = OpLoad %int %188
%190 = OpIEqual %bool %189 %int_n1
OpSelectionMerge %191 None
OpBranchConditional %190 %192 %193
%192 = OpLabel
%194 = OpLoad %int %baseIndex
%195 = OpLoad %int %treeIndex
%196 = OpAccessChain %_ptr_Private_int %tree_0 %194 %int_1
OpStore %196 %195
%197 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_0
%198 = OpLoad %float %197
%199 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_1
%200 = OpLoad %float %199
%201 = OpFOrdLessThan %bool %198 %200
OpSelectionMerge %202 None
OpBranchConditional %201 %203 %202
%203 = OpLabel
%204 = OpLoad %int %treeIndex
%205 = OpAccessChain %_ptr_Private_BST %tree_0 %204
%206 = OpLoad %BST %205
OpStore %param %206
%207 = OpLoad %int %data_0
OpStore %param_0 %207
%208 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param %param_0
%209 = OpLoad %BST %param
%210 = OpAccessChain %_ptr_Private_BST %tree_0 %204
OpStore %210 %209
OpBranch %202
%202 = OpLabel
%211 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_0
%212 = OpLoad %float %211
%213 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_1
%214 = OpLoad %float %213
%215 = OpFOrdLessThan %bool %212 %214
OpSelectionMerge %216 None
OpBranchConditional %215 %217 %216
%217 = OpLabel
OpReturn
%216 = OpLabel
OpBranch %191
%193 = OpLabel
%218 = OpLoad %int %baseIndex
%219 = OpAccessChain %_ptr_Private_int %tree_0 %218 %int_1
%220 = OpLoad %int %219
OpStore %baseIndex %220
OpBranch %173
%191 = OpLabel
OpBranch %184
%186 = OpLabel
%221 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_0
%222 = OpLoad %float %221
%223 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_1
%224 = OpLoad %float %223
%225 = OpFOrdLessThan %bool %222 %224
OpSelectionMerge %226 None
OpBranchConditional %225 %227 %228
%227 = OpLabel
%229 = OpLoad %int %baseIndex
%230 = OpAccessChain %_ptr_Private_int %tree_0 %229 %int_2
%231 = OpLoad %int %230
OpStore %170 %231
OpBranch %226
%228 = OpLabel
%232 = OpLoad %int %baseIndex
%233 = OpAccessChain %_ptr_Private_int %tree_0 %232 %int_2
%234 = OpLoad %int %233
OpStore %170 %234
OpBranch %226
%226 = OpLabel
%235 = OpLoad %int %170
%236 = OpIEqual %bool %235 %int_n1
OpSelectionMerge %237 None
OpBranchConditional %236 %238 %239
%238 = OpLabel
%240 = OpLoad %int %baseIndex
%241 = OpLoad %int %treeIndex
%242 = OpAccessChain %_ptr_Private_int %tree_0 %240 %int_2
OpStore %242 %241
%243 = OpLoad %int %treeIndex
%244 = OpAccessChain %_ptr_Private_BST %tree_0 %243
%245 = OpLoad %BST %244
OpStore %param_1 %245
%246 = OpLoad %int %data_0
OpStore %param_2 %246
%247 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param_1 %param_2
%248 = OpLoad %BST %param_1
%249 = OpAccessChain %_ptr_Private_BST %tree_0 %243
OpStore %249 %248
OpReturn
%239 = OpLabel
%250 = OpLoad %int %baseIndex
%251 = OpAccessChain %_ptr_Private_int %tree_0 %250 %int_2
%252 = OpLoad %int %251
OpStore %baseIndex %252
OpBranch %173
%237 = OpLabel
OpUnreachable
%184 = OpLabel
%253 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_0
%254 = OpLoad %float %253
%255 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %uint_1
%256 = OpLoad %float %255
%257 = OpFOrdGreaterThan %bool %254 %256
OpSelectionMerge %258 None
OpBranchConditional %257 %259 %258
%259 = OpLabel
OpReturn
%258 = OpLabel
OpBranch %173
%173 = OpLabel
OpBranch %171
%172 = OpLabel
OpReturn
OpFunctionEnd
%search_i1_ = OpFunction %int None %55
%target = OpFunctionParameter %_ptr_Function_int
%260 = OpLabel
%index = OpVariable %_ptr_Function_int Function
%currentNode = OpVariable %_ptr_Function_BST Function
%261 = OpVariable %_ptr_Function_int Function
OpStore %index %int_0
OpBranch %262
%262 = OpLabel
OpLoopMerge %263 %264 None
OpBranch %265
%265 = OpLabel
%266 = OpLoad %int %index
%267 = OpINotEqual %bool %266 %int_n1
OpBranchConditional %267 %268 %263
%268 = OpLabel
%269 = OpLoad %int %index
%270 = OpAccessChain %_ptr_Private_BST %tree_0 %269
%271 = OpLoad %BST %270
OpStore %currentNode %271
%272 = OpAccessChain %_ptr_Function_int %currentNode %int_0
%273 = OpLoad %int %272
%274 = OpLoad %int %target
%275 = OpIEqual %bool %273 %274
OpSelectionMerge %276 None
OpBranchConditional %275 %277 %276
%277 = OpLabel
%278 = OpLoad %int %target
OpReturnValue %278
%276 = OpLabel
%279 = OpLoad %int %target
%280 = OpAccessChain %_ptr_Function_int %currentNode %int_0
%281 = OpLoad %int %280
%282 = OpSGreaterThan %bool %279 %281
OpSelectionMerge %283 None
OpBranchConditional %282 %284 %285
%284 = OpLabel
%286 = OpAccessChain %_ptr_Function_int %currentNode %int_2
%287 = OpLoad %int %286
OpStore %261 %287
OpBranch %283
%285 = OpLabel
%288 = OpAccessChain %_ptr_Function_int %currentNode %int_1
%289 = OpLoad %int %288
OpStore %261 %289
OpBranch %283
%283 = OpLabel
%290 = OpLoad %int %261
OpStore %index %290
OpBranch %264
%264 = OpLabel
OpBranch %262
%263 = OpLabel
OpReturnValue %int_n1
OpFunctionEnd

View File

@@ -0,0 +1,255 @@
struct BST {
int data;
int leftIndex;
int rightIndex;
};
static BST tree_1[10] = (BST[10])0;
cbuffer cbuffer_x_16 : register(b0, space0) {
uint4 x_16[1];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
void makeTreeNode_struct_BST_i1_i1_i11_i1_(inout BST tree, inout int data) {
const int x_165 = data;
tree.data = x_165;
tree.leftIndex = -1;
tree.rightIndex = -1;
return;
}
void insert_i1_i1_(inout int treeIndex, inout int data_1) {
int baseIndex = 0;
BST param = (BST)0;
int param_1 = 0;
int x_170 = 0;
BST param_2 = (BST)0;
int param_3 = 0;
baseIndex = 0;
while (true) {
const int x_175 = baseIndex;
const int x_176 = treeIndex;
if ((x_175 <= x_176)) {
} else {
break;
}
const int x_179 = data_1;
const int x_182 = tree_1[baseIndex].data;
if ((x_179 <= x_182)) {
const int x_189 = tree_1[baseIndex].leftIndex;
if ((x_189 == -1)) {
const int x_194 = baseIndex;
const int x_195 = treeIndex;
tree_1[x_194].leftIndex = x_195;
const float x_198 = asfloat(x_16[0].x);
const float x_200 = asfloat(x_16[0].y);
if ((x_198 < x_200)) {
const int x_204 = treeIndex;
const BST x_206 = tree_1[x_204];
param = x_206;
const int x_207 = data_1;
param_1 = x_207;
makeTreeNode_struct_BST_i1_i1_i11_i1_(param, param_1);
tree_1[x_204] = param;
}
const float x_212 = asfloat(x_16[0].x);
const float x_214 = asfloat(x_16[0].y);
if ((x_212 < x_214)) {
return;
}
} else {
const int x_220 = tree_1[baseIndex].leftIndex;
baseIndex = x_220;
continue;
}
} else {
const float x_222 = asfloat(x_16[0].x);
const float x_224 = asfloat(x_16[0].y);
if ((x_222 < x_224)) {
const int x_231 = tree_1[baseIndex].rightIndex;
x_170 = x_231;
} else {
const int x_234 = tree_1[baseIndex].rightIndex;
x_170 = x_234;
}
if ((x_170 == -1)) {
const int x_240 = baseIndex;
const int x_241 = treeIndex;
tree_1[x_240].rightIndex = x_241;
const int x_243 = treeIndex;
const BST x_245 = tree_1[x_243];
param_2 = x_245;
const int x_246 = data_1;
param_3 = x_246;
makeTreeNode_struct_BST_i1_i1_i11_i1_(param_2, param_3);
tree_1[x_243] = param_2;
return;
} else {
const int x_252 = tree_1[baseIndex].rightIndex;
baseIndex = x_252;
continue;
}
return;
}
const float x_254 = asfloat(x_16[0].x);
const float x_256 = asfloat(x_16[0].y);
if ((x_254 > x_256)) {
return;
}
}
return;
}
int search_i1_(inout int target) {
int index = 0;
BST currentNode = (BST)0;
int x_261 = 0;
index = 0;
while (true) {
if ((index != -1)) {
} else {
break;
}
const BST x_271 = tree_1[index];
currentNode = x_271;
const int x_273 = currentNode.data;
const int x_274 = target;
if ((x_273 == x_274)) {
const int x_278 = target;
return x_278;
}
const int x_279 = target;
const int x_281 = currentNode.data;
if ((x_279 > x_281)) {
const int x_287 = currentNode.rightIndex;
x_261 = x_287;
} else {
const int x_289 = currentNode.leftIndex;
x_261 = x_289;
}
index = x_261;
}
return -1;
}
void main_1() {
int treeIndex_1 = 0;
BST param_4 = (BST)0;
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;
const BST x_91 = tree_1[0];
param_4 = x_91;
param_5 = 9;
makeTreeNode_struct_BST_i1_i1_i11_i1_(param_4, param_5);
tree_1[0] = param_4;
treeIndex_1 = (treeIndex_1 + 1);
param_6 = treeIndex_1;
param_7 = 5;
insert_i1_i1_(param_6, param_7);
treeIndex_1 = (treeIndex_1 + 1);
param_8 = treeIndex_1;
param_9 = 12;
insert_i1_i1_(param_8, param_9);
treeIndex_1 = (treeIndex_1 + 1);
param_10 = treeIndex_1;
param_11 = 15;
insert_i1_i1_(param_10, param_11);
treeIndex_1 = (treeIndex_1 + 1);
param_12 = treeIndex_1;
param_13 = 7;
insert_i1_i1_(param_12, param_13);
treeIndex_1 = (treeIndex_1 + 1);
param_14 = treeIndex_1;
param_15 = 8;
insert_i1_i1_(param_14, param_15);
treeIndex_1 = (treeIndex_1 + 1);
param_16 = treeIndex_1;
param_17 = 2;
insert_i1_i1_(param_16, param_17);
treeIndex_1 = (treeIndex_1 + 1);
param_18 = treeIndex_1;
param_19 = 6;
insert_i1_i1_(param_18, param_19);
treeIndex_1 = (treeIndex_1 + 1);
param_20 = treeIndex_1;
param_21 = 17;
insert_i1_i1_(param_20, param_21);
treeIndex_1 = (treeIndex_1 + 1);
param_22 = treeIndex_1;
param_23 = 13;
insert_i1_i1_(param_22, param_23);
count = 0;
i = 0;
{
for(; (i < 20); i = (i + 1)) {
param_24 = i;
const int x_139 = search_i1_(param_24);
result = x_139;
switch(i) {
case 2:
case 5:
case 6:
case 7:
case 8:
case 9:
case 12:
case 13:
case 15:
case 17: {
if ((result == i)) {
count = (count + 1);
}
break;
}
default: {
if ((result == -1)) {
count = (count + 1);
}
break;
}
}
}
}
if ((count == 20)) {
x_GLF_color = float4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
x_GLF_color = float4(0.0f, 0.0f, 1.0f, 1.0f);
}
return;
}
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol {
float4 x_GLF_color_1 : SV_Target0;
};
tint_symbol main() {
main_1();
const main_out tint_symbol_1 = {x_GLF_color};
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3;
}

View File

@@ -0,0 +1,306 @@
#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_4) {
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_4)).arr[x_180].data;
if ((x_179 <= x_182)) {
int const x_187 = baseIndex;
int const x_189 = (*(tint_symbol_4)).arr[x_187].leftIndex;
if ((x_189 == -1)) {
int const x_194 = baseIndex;
int const x_195 = *(treeIndex);
(*(tint_symbol_4)).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_4)).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_4)).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_4)).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_4)).arr[x_229].rightIndex;
x_170 = x_231;
} else {
int const x_232 = baseIndex;
int const x_234 = (*(tint_symbol_4)).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_4)).arr[x_240].rightIndex = x_241;
int const x_243 = *(treeIndex);
BST const x_245 = (*(tint_symbol_4)).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_4)).arr[x_243] = x_248;
return;
} else {
int const x_250 = baseIndex;
int const x_252 = (*(tint_symbol_4)).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_5) {
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_5)).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_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_91 = (*(tint_symbol_6)).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_6)).arr[0] = x_93;
int const x_95 = treeIndex_1;
treeIndex_1 = (x_95 + 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_6);
int const x_99 = treeIndex_1;
treeIndex_1 = (x_99 + 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_6);
int const x_103 = treeIndex_1;
treeIndex_1 = (x_103 + 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_6);
int const x_107 = treeIndex_1;
treeIndex_1 = (x_107 + 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_6);
int const x_111 = treeIndex_1;
treeIndex_1 = (x_111 + 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_6);
int const x_115 = treeIndex_1;
treeIndex_1 = (x_115 + 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_6);
int const x_119 = treeIndex_1;
treeIndex_1 = (x_119 + 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_6);
int const x_123 = treeIndex_1;
treeIndex_1 = (x_123 + 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_6);
int const x_127 = treeIndex_1;
treeIndex_1 = (x_127 + 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_6);
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_6);
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 = (x_155 + 1);
}
break;
}
default: {
int const x_144 = result;
if ((x_144 == -1)) {
int const x_148 = count;
count = (x_148 + 1);
}
break;
}
}
{
int const x_157 = i;
i = (x_157 + 1);
}
}
int const x_159 = count;
if ((x_159 == 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(constant buf0& x_16 [[buffer(0)]]) {
thread tint_array_wrapper tint_symbol_8 = {};
thread float4 tint_symbol_9 = 0.0f;
main_1(x_16, &(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;
}

View File

@@ -0,0 +1,539 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 355
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %tint_symbol_1
OpExecutionMode %main OriginUpperLeft
OpName %BST "BST"
OpMemberName %BST 0 "data"
OpMemberName %BST 1 "leftIndex"
OpMemberName %BST 2 "rightIndex"
OpName %tree_1 "tree_1"
OpName %buf0 "buf0"
OpMemberName %buf0 0 "injectionSwitch"
OpName %x_16 "x_16"
OpName %x_GLF_color "x_GLF_color"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %makeTreeNode_struct_BST_i1_i1_i11_i1_ "makeTreeNode_struct_BST_i1_i1_i11_i1_"
OpName %tree "tree"
OpName %data "data"
OpName %insert_i1_i1_ "insert_i1_i1_"
OpName %treeIndex "treeIndex"
OpName %data_1 "data_1"
OpName %baseIndex "baseIndex"
OpName %param "param"
OpName %param_1 "param_1"
OpName %x_170 "x_170"
OpName %param_2 "param_2"
OpName %param_3 "param_3"
OpName %search_i1_ "search_i1_"
OpName %target "target"
OpName %index "index"
OpName %currentNode "currentNode"
OpName %x_261 "x_261"
OpName %main_1 "main_1"
OpName %treeIndex_1 "treeIndex_1"
OpName %param_4 "param_4"
OpName %param_5 "param_5"
OpName %param_6 "param_6"
OpName %param_7 "param_7"
OpName %param_8 "param_8"
OpName %param_9 "param_9"
OpName %param_10 "param_10"
OpName %param_11 "param_11"
OpName %param_12 "param_12"
OpName %param_13 "param_13"
OpName %param_14 "param_14"
OpName %param_15 "param_15"
OpName %param_16 "param_16"
OpName %param_17 "param_17"
OpName %param_18 "param_18"
OpName %param_19 "param_19"
OpName %param_20 "param_20"
OpName %param_21 "param_21"
OpName %param_22 "param_22"
OpName %param_23 "param_23"
OpName %count "count"
OpName %i "i"
OpName %result "result"
OpName %param_24 "param_24"
OpName %main_out "main_out"
OpMemberName %main_out 0 "x_GLF_color_1"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol "tint_symbol"
OpName %main "main"
OpMemberDecorate %BST 0 Offset 0
OpMemberDecorate %BST 1 Offset 4
OpMemberDecorate %BST 2 Offset 8
OpDecorate %_arr_BST_uint_10 ArrayStride 12
OpDecorate %buf0 Block
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %x_16 NonWritable
OpDecorate %x_16 DescriptorSet 0
OpDecorate %x_16 Binding 0
OpDecorate %tint_symbol_1 Location 0
OpMemberDecorate %main_out 0 Offset 0
%int = OpTypeInt 32 1
%BST = OpTypeStruct %int %int %int
%uint = OpTypeInt 32 0
%uint_10 = OpConstant %uint 10
%_arr_BST_uint_10 = OpTypeArray %BST %uint_10
%_ptr_Private__arr_BST_uint_10 = OpTypePointer Private %_arr_BST_uint_10
%8 = OpConstantNull %_arr_BST_uint_10
%tree_1 = OpVariable %_ptr_Private__arr_BST_uint_10 Private %8
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%buf0 = OpTypeStruct %v2float
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%x_16 = OpVariable %_ptr_Uniform_buf0 Uniform
%v4float = OpTypeVector %float 4
%_ptr_Private_v4float = OpTypePointer Private %v4float
%17 = OpConstantNull %v4float
%x_GLF_color = OpVariable %_ptr_Private_v4float Private %17
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %17
%void = OpTypeVoid
%_ptr_Function_BST = OpTypePointer Function %BST
%_ptr_Function_int = OpTypePointer Function %int
%20 = OpTypeFunction %void %_ptr_Function_BST %_ptr_Function_int
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%int_n1 = OpConstant %int -1
%uint_2 = OpConstant %uint 2
%40 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int
%46 = OpConstantNull %int
%48 = OpConstantNull %BST
%int_0 = OpConstant %int 0
%bool = OpTypeBool
%_ptr_Private_int = OpTypePointer Private %int
%_ptr_Uniform_float = OpTypePointer Uniform %float
%_ptr_Private_BST = OpTypePointer Private %BST
%161 = OpTypeFunction %int %_ptr_Function_int
%202 = OpTypeFunction %void
%int_9 = OpConstant %int 9
%int_1 = OpConstant %int 1
%int_5 = OpConstant %int 5
%int_12 = OpConstant %int 12
%int_15 = OpConstant %int 15
%int_7 = OpConstant %int 7
%int_8 = OpConstant %int 8
%int_2 = OpConstant %int 2
%int_6 = OpConstant %int 6
%int_17 = OpConstant %int 17
%int_13 = OpConstant %int 13
%int_20 = OpConstant %int 20
%float_1 = OpConstant %float 1
%float_0 = OpConstant %float 0
%341 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
%342 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
%main_out = OpTypeStruct %v4float
%343 = OpTypeFunction %void %main_out
%makeTreeNode_struct_BST_i1_i1_i11_i1_ = OpFunction %void None %20
%tree = OpFunctionParameter %_ptr_Function_BST
%data = OpFunctionParameter %_ptr_Function_int
%27 = OpLabel
%29 = OpLoad %int %data
%32 = OpAccessChain %_ptr_Function_int %tree %uint_0
OpStore %32 %29
%35 = OpAccessChain %_ptr_Function_int %tree %uint_1
OpStore %35 %int_n1
%39 = OpAccessChain %_ptr_Function_int %tree %uint_2
OpStore %39 %int_n1
OpReturn
OpFunctionEnd
%insert_i1_i1_ = OpFunction %void None %40
%treeIndex = OpFunctionParameter %_ptr_Function_int
%data_1 = OpFunctionParameter %_ptr_Function_int
%44 = OpLabel
%baseIndex = OpVariable %_ptr_Function_int Function %46
%param = OpVariable %_ptr_Function_BST Function %48
%param_1 = OpVariable %_ptr_Function_int Function %46
%x_170 = OpVariable %_ptr_Function_int Function %46
%param_2 = OpVariable %_ptr_Function_BST Function %48
%param_3 = OpVariable %_ptr_Function_int Function %46
OpStore %baseIndex %int_0
OpBranch %54
%54 = OpLabel
OpLoopMerge %55 %56 None
OpBranch %57
%57 = OpLabel
%58 = OpLoad %int %baseIndex
%60 = OpLoad %int %treeIndex
%61 = OpSLessThanEqual %bool %58 %60
OpSelectionMerge %63 None
OpBranchConditional %61 %64 %65
%64 = OpLabel
OpBranch %63
%65 = OpLabel
OpBranch %55
%63 = OpLabel
%67 = OpLoad %int %data_1
%68 = OpLoad %int %baseIndex
%70 = OpAccessChain %_ptr_Private_int %tree_1 %68 %uint_0
%71 = OpLoad %int %70
%72 = OpSLessThanEqual %bool %67 %71
OpSelectionMerge %73 None
OpBranchConditional %72 %74 %75
%74 = OpLabel
%76 = OpLoad %int %baseIndex
%77 = OpAccessChain %_ptr_Private_int %tree_1 %76 %uint_1
%78 = OpLoad %int %77
%79 = OpIEqual %bool %78 %int_n1
OpSelectionMerge %80 None
OpBranchConditional %79 %81 %82
%81 = OpLabel
%83 = OpLoad %int %baseIndex
%85 = OpLoad %int %treeIndex
%86 = OpAccessChain %_ptr_Private_int %tree_1 %83 %uint_1
OpStore %86 %85
%88 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%89 = OpLoad %float %88
%90 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%91 = OpLoad %float %90
%92 = OpFOrdLessThan %bool %89 %91
OpSelectionMerge %93 None
OpBranchConditional %92 %94 %93
%94 = OpLabel
%96 = OpLoad %int %treeIndex
%98 = OpAccessChain %_ptr_Private_BST %tree_1 %96
%99 = OpLoad %BST %98
OpStore %param %99
%101 = OpLoad %int %data_1
OpStore %param_1 %101
%102 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param %param_1
%105 = OpLoad %BST %param
%106 = OpAccessChain %_ptr_Private_BST %tree_1 %96
OpStore %106 %105
OpBranch %93
%93 = OpLabel
%107 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%108 = OpLoad %float %107
%109 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%110 = OpLoad %float %109
%111 = OpFOrdLessThan %bool %108 %110
OpSelectionMerge %112 None
OpBranchConditional %111 %113 %112
%113 = OpLabel
OpReturn
%112 = OpLabel
OpBranch %80
%82 = OpLabel
%114 = OpLoad %int %baseIndex
%115 = OpAccessChain %_ptr_Private_int %tree_1 %114 %uint_1
%116 = OpLoad %int %115
OpStore %baseIndex %116
OpBranch %56
%80 = OpLabel
OpBranch %73
%75 = OpLabel
%117 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%118 = OpLoad %float %117
%119 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%120 = OpLoad %float %119
%121 = OpFOrdLessThan %bool %118 %120
OpSelectionMerge %122 None
OpBranchConditional %121 %123 %124
%123 = OpLabel
%125 = OpLoad %int %baseIndex
%126 = OpAccessChain %_ptr_Private_int %tree_1 %125 %uint_2
%127 = OpLoad %int %126
OpStore %x_170 %127
OpBranch %122
%124 = OpLabel
%128 = OpLoad %int %baseIndex
%129 = OpAccessChain %_ptr_Private_int %tree_1 %128 %uint_2
%130 = OpLoad %int %129
OpStore %x_170 %130
OpBranch %122
%122 = OpLabel
%131 = OpLoad %int %x_170
%132 = OpIEqual %bool %131 %int_n1
OpSelectionMerge %133 None
OpBranchConditional %132 %134 %135
%134 = OpLabel
%136 = OpLoad %int %baseIndex
%138 = OpLoad %int %treeIndex
%139 = OpAccessChain %_ptr_Private_int %tree_1 %136 %uint_2
OpStore %139 %138
%141 = OpLoad %int %treeIndex
%142 = OpAccessChain %_ptr_Private_BST %tree_1 %141
%143 = OpLoad %BST %142
OpStore %param_2 %143
%145 = OpLoad %int %data_1
OpStore %param_3 %145
%146 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param_2 %param_3
%149 = OpLoad %BST %param_2
%150 = OpAccessChain %_ptr_Private_BST %tree_1 %141
OpStore %150 %149
OpReturn
%135 = OpLabel
%151 = OpLoad %int %baseIndex
%152 = OpAccessChain %_ptr_Private_int %tree_1 %151 %uint_2
%153 = OpLoad %int %152
OpStore %baseIndex %153
OpBranch %56
%133 = OpLabel
OpReturn
%73 = OpLabel
%154 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%155 = OpLoad %float %154
%156 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%157 = OpLoad %float %156
%158 = OpFOrdGreaterThan %bool %155 %157
OpSelectionMerge %159 None
OpBranchConditional %158 %160 %159
%160 = OpLabel
OpReturn
%159 = OpLabel
OpBranch %56
%56 = OpLabel
OpBranch %54
%55 = OpLabel
OpReturn
OpFunctionEnd
%search_i1_ = OpFunction %int None %161
%target = OpFunctionParameter %_ptr_Function_int
%164 = OpLabel
%index = OpVariable %_ptr_Function_int Function %46
%currentNode = OpVariable %_ptr_Function_BST Function %48
%x_261 = OpVariable %_ptr_Function_int Function %46
OpStore %index %int_0
OpBranch %168
%168 = OpLabel
OpLoopMerge %169 %170 None
OpBranch %171
%171 = OpLabel
%172 = OpLoad %int %index
%173 = OpINotEqual %bool %172 %int_n1
OpSelectionMerge %174 None
OpBranchConditional %173 %175 %176
%175 = OpLabel
OpBranch %174
%176 = OpLabel
OpBranch %169
%174 = OpLabel
%177 = OpLoad %int %index
%178 = OpAccessChain %_ptr_Private_BST %tree_1 %177
%179 = OpLoad %BST %178
OpStore %currentNode %179
%180 = OpAccessChain %_ptr_Function_int %currentNode %uint_0
%181 = OpLoad %int %180
%183 = OpLoad %int %target
%184 = OpIEqual %bool %181 %183
OpSelectionMerge %185 None
OpBranchConditional %184 %186 %185
%186 = OpLabel
%188 = OpLoad %int %target
OpReturnValue %188
%185 = OpLabel
%190 = OpLoad %int %target
%191 = OpAccessChain %_ptr_Function_int %currentNode %uint_0
%192 = OpLoad %int %191
%193 = OpSGreaterThan %bool %190 %192
OpSelectionMerge %194 None
OpBranchConditional %193 %195 %196
%195 = OpLabel
%197 = OpAccessChain %_ptr_Function_int %currentNode %uint_2
%198 = OpLoad %int %197
OpStore %x_261 %198
OpBranch %194
%196 = OpLabel
%199 = OpAccessChain %_ptr_Function_int %currentNode %uint_1
%200 = OpLoad %int %199
OpStore %x_261 %200
OpBranch %194
%194 = OpLabel
%201 = OpLoad %int %x_261
OpStore %index %201
OpBranch %170
%170 = OpLabel
OpBranch %168
%169 = OpLabel
OpReturnValue %int_n1
OpFunctionEnd
%main_1 = OpFunction %void None %202
%204 = OpLabel
%treeIndex_1 = OpVariable %_ptr_Function_int Function %46
%param_4 = OpVariable %_ptr_Function_BST Function %48
%param_5 = OpVariable %_ptr_Function_int Function %46
%param_6 = OpVariable %_ptr_Function_int Function %46
%param_7 = OpVariable %_ptr_Function_int Function %46
%param_8 = OpVariable %_ptr_Function_int Function %46
%param_9 = OpVariable %_ptr_Function_int Function %46
%param_10 = OpVariable %_ptr_Function_int Function %46
%param_11 = OpVariable %_ptr_Function_int Function %46
%param_12 = OpVariable %_ptr_Function_int Function %46
%param_13 = OpVariable %_ptr_Function_int Function %46
%param_14 = OpVariable %_ptr_Function_int Function %46
%param_15 = OpVariable %_ptr_Function_int Function %46
%param_16 = OpVariable %_ptr_Function_int Function %46
%param_17 = OpVariable %_ptr_Function_int Function %46
%param_18 = OpVariable %_ptr_Function_int Function %46
%param_19 = OpVariable %_ptr_Function_int Function %46
%param_20 = OpVariable %_ptr_Function_int Function %46
%param_21 = OpVariable %_ptr_Function_int Function %46
%param_22 = OpVariable %_ptr_Function_int Function %46
%param_23 = OpVariable %_ptr_Function_int Function %46
%count = OpVariable %_ptr_Function_int Function %46
%i = OpVariable %_ptr_Function_int Function %46
%result = OpVariable %_ptr_Function_int Function %46
%param_24 = OpVariable %_ptr_Function_int Function %46
OpStore %treeIndex_1 %int_0
%230 = OpAccessChain %_ptr_Private_BST %tree_1 %int_0
%231 = OpLoad %BST %230
OpStore %param_4 %231
OpStore %param_5 %int_9
%233 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param_4 %param_5
%236 = OpLoad %BST %param_4
%237 = OpAccessChain %_ptr_Private_BST %tree_1 %int_0
OpStore %237 %236
%238 = OpLoad %int %treeIndex_1
%240 = OpIAdd %int %238 %int_1
OpStore %treeIndex_1 %240
%241 = OpLoad %int %treeIndex_1
OpStore %param_6 %241
OpStore %param_7 %int_5
%243 = OpFunctionCall %void %insert_i1_i1_ %param_6 %param_7
%246 = OpLoad %int %treeIndex_1
%247 = OpIAdd %int %246 %int_1
OpStore %treeIndex_1 %247
%248 = OpLoad %int %treeIndex_1
OpStore %param_8 %248
OpStore %param_9 %int_12
%250 = OpFunctionCall %void %insert_i1_i1_ %param_8 %param_9
%253 = OpLoad %int %treeIndex_1
%254 = OpIAdd %int %253 %int_1
OpStore %treeIndex_1 %254
%255 = OpLoad %int %treeIndex_1
OpStore %param_10 %255
OpStore %param_11 %int_15
%257 = OpFunctionCall %void %insert_i1_i1_ %param_10 %param_11
%260 = OpLoad %int %treeIndex_1
%261 = OpIAdd %int %260 %int_1
OpStore %treeIndex_1 %261
%262 = OpLoad %int %treeIndex_1
OpStore %param_12 %262
OpStore %param_13 %int_7
%264 = OpFunctionCall %void %insert_i1_i1_ %param_12 %param_13
%267 = OpLoad %int %treeIndex_1
%268 = OpIAdd %int %267 %int_1
OpStore %treeIndex_1 %268
%269 = OpLoad %int %treeIndex_1
OpStore %param_14 %269
OpStore %param_15 %int_8
%271 = OpFunctionCall %void %insert_i1_i1_ %param_14 %param_15
%274 = OpLoad %int %treeIndex_1
%275 = OpIAdd %int %274 %int_1
OpStore %treeIndex_1 %275
%276 = OpLoad %int %treeIndex_1
OpStore %param_16 %276
OpStore %param_17 %int_2
%278 = OpFunctionCall %void %insert_i1_i1_ %param_16 %param_17
%281 = OpLoad %int %treeIndex_1
%282 = OpIAdd %int %281 %int_1
OpStore %treeIndex_1 %282
%283 = OpLoad %int %treeIndex_1
OpStore %param_18 %283
OpStore %param_19 %int_6
%285 = OpFunctionCall %void %insert_i1_i1_ %param_18 %param_19
%288 = OpLoad %int %treeIndex_1
%289 = OpIAdd %int %288 %int_1
OpStore %treeIndex_1 %289
%290 = OpLoad %int %treeIndex_1
OpStore %param_20 %290
OpStore %param_21 %int_17
%292 = OpFunctionCall %void %insert_i1_i1_ %param_20 %param_21
%295 = OpLoad %int %treeIndex_1
%296 = OpIAdd %int %295 %int_1
OpStore %treeIndex_1 %296
%297 = OpLoad %int %treeIndex_1
OpStore %param_22 %297
OpStore %param_23 %int_13
%299 = OpFunctionCall %void %insert_i1_i1_ %param_22 %param_23
OpStore %count %int_0
OpStore %i %int_0
OpBranch %302
%302 = OpLabel
OpLoopMerge %303 %304 None
OpBranch %305
%305 = OpLabel
%306 = OpLoad %int %i
%308 = OpSLessThan %bool %306 %int_20
OpSelectionMerge %309 None
OpBranchConditional %308 %310 %311
%310 = OpLabel
OpBranch %309
%311 = OpLabel
OpBranch %303
%309 = OpLabel
%312 = OpLoad %int %i
OpStore %param_24 %312
%313 = OpFunctionCall %int %search_i1_ %param_24
OpStore %result %313
%315 = OpLoad %int %i
OpSelectionMerge %316 None
OpSwitch %315 %317 2 %318 5 %318 6 %318 7 %318 8 %318 9 %318 12 %318 13 %318 15 %318 17 %318
%318 = OpLabel
%319 = OpLoad %int %result
%320 = OpLoad %int %i
%321 = OpIEqual %bool %319 %320
OpSelectionMerge %322 None
OpBranchConditional %321 %323 %322
%323 = OpLabel
%324 = OpLoad %int %count
%325 = OpIAdd %int %324 %int_1
OpStore %count %325
OpBranch %322
%322 = OpLabel
OpBranch %316
%317 = OpLabel
%326 = OpLoad %int %result
%327 = OpIEqual %bool %326 %int_n1
OpSelectionMerge %328 None
OpBranchConditional %327 %329 %328
%329 = OpLabel
%330 = OpLoad %int %count
%331 = OpIAdd %int %330 %int_1
OpStore %count %331
OpBranch %328
%328 = OpLabel
OpBranch %316
%316 = OpLabel
OpBranch %304
%304 = OpLabel
%332 = OpLoad %int %i
%333 = OpIAdd %int %332 %int_1
OpStore %i %333
OpBranch %302
%303 = OpLabel
%334 = OpLoad %int %count
%335 = OpIEqual %bool %334 %int_20
OpSelectionMerge %336 None
OpBranchConditional %335 %337 %338
%337 = OpLabel
OpStore %x_GLF_color %341
OpBranch %336
%338 = OpLabel
OpStore %x_GLF_color %342
OpBranch %336
%336 = OpLabel
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %343
%tint_symbol = OpFunctionParameter %main_out
%347 = OpLabel
%348 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %348
OpReturn
OpFunctionEnd
%main = OpFunction %void None %202
%350 = OpLabel
%351 = OpFunctionCall %void %main_1
%353 = OpLoad %v4float %x_GLF_color
%354 = OpCompositeConstruct %main_out %353
%352 = OpFunctionCall %void %tint_symbol_2 %354
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,293 @@
struct BST {
data : i32;
leftIndex : i32;
rightIndex : i32;
};
[[block]]
struct buf0 {
injectionSwitch : vec2<f32>;
};
var<private> tree_1 : array<BST, 10>;
[[group(0), binding(0)]] var<uniform> x_16 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn makeTreeNode_struct_BST_i1_i1_i11_i1_(tree : ptr<function, BST>, data : ptr<function, i32>) {
let x_165 : i32 = *(data);
(*(tree)).data = x_165;
(*(tree)).leftIndex = -1;
(*(tree)).rightIndex = -1;
return;
}
fn insert_i1_i1_(treeIndex : ptr<function, i32>, data_1 : ptr<function, i32>) {
var baseIndex : i32;
var param : BST;
var param_1 : i32;
var x_170 : i32;
var param_2 : BST;
var param_3 : i32;
baseIndex = 0;
loop {
let x_175 : i32 = baseIndex;
let x_176 : i32 = *(treeIndex);
if ((x_175 <= x_176)) {
} else {
break;
}
let x_179 : i32 = *(data_1);
let x_180 : i32 = baseIndex;
let x_182 : i32 = tree_1[x_180].data;
if ((x_179 <= x_182)) {
let x_187 : i32 = baseIndex;
let x_189 : i32 = tree_1[x_187].leftIndex;
if ((x_189 == -1)) {
let x_194 : i32 = baseIndex;
let x_195 : i32 = *(treeIndex);
tree_1[x_194].leftIndex = x_195;
let x_198 : f32 = x_16.injectionSwitch.x;
let x_200 : f32 = x_16.injectionSwitch.y;
if ((x_198 < x_200)) {
let x_204 : i32 = *(treeIndex);
let x_206 : BST = tree_1[x_204];
param = x_206;
let x_207 : i32 = *(data_1);
param_1 = x_207;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param), &(param_1));
let x_209 : BST = param;
tree_1[x_204] = x_209;
}
let x_212 : f32 = x_16.injectionSwitch.x;
let x_214 : f32 = x_16.injectionSwitch.y;
if ((x_212 < x_214)) {
return;
}
} else {
let x_218 : i32 = baseIndex;
let x_220 : i32 = tree_1[x_218].leftIndex;
baseIndex = x_220;
continue;
}
} else {
let x_222 : f32 = x_16.injectionSwitch.x;
let x_224 : f32 = x_16.injectionSwitch.y;
if ((x_222 < x_224)) {
let x_229 : i32 = baseIndex;
let x_231 : i32 = tree_1[x_229].rightIndex;
x_170 = x_231;
} else {
let x_232 : i32 = baseIndex;
let x_234 : i32 = tree_1[x_232].rightIndex;
x_170 = x_234;
}
let x_235 : i32 = x_170;
if ((x_235 == -1)) {
let x_240 : i32 = baseIndex;
let x_241 : i32 = *(treeIndex);
tree_1[x_240].rightIndex = x_241;
let x_243 : i32 = *(treeIndex);
let x_245 : BST = tree_1[x_243];
param_2 = x_245;
let x_246 : i32 = *(data_1);
param_3 = x_246;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_2), &(param_3));
let x_248 : BST = param_2;
tree_1[x_243] = x_248;
return;
} else {
let x_250 : i32 = baseIndex;
let x_252 : i32 = tree_1[x_250].rightIndex;
baseIndex = x_252;
continue;
}
return;
}
let x_254 : f32 = x_16.injectionSwitch.x;
let x_256 : f32 = x_16.injectionSwitch.y;
if ((x_254 > x_256)) {
return;
}
}
return;
}
fn search_i1_(target : ptr<function, i32>) -> i32 {
var index : i32;
var currentNode : BST;
var x_261 : i32;
index = 0;
loop {
let x_266 : i32 = index;
if ((x_266 != -1)) {
} else {
break;
}
let x_269 : i32 = index;
let x_271 : BST = tree_1[x_269];
currentNode = x_271;
let x_273 : i32 = currentNode.data;
let x_274 : i32 = *(target);
if ((x_273 == x_274)) {
let x_278 : i32 = *(target);
return x_278;
}
let x_279 : i32 = *(target);
let x_281 : i32 = currentNode.data;
if ((x_279 > x_281)) {
let x_287 : i32 = currentNode.rightIndex;
x_261 = x_287;
} else {
let x_289 : i32 = currentNode.leftIndex;
x_261 = x_289;
}
let x_290 : i32 = x_261;
index = x_290;
}
return -1;
}
fn main_1() {
var treeIndex_1 : i32;
var param_4 : BST;
var param_5 : i32;
var param_6 : i32;
var param_7 : i32;
var param_8 : i32;
var param_9 : i32;
var param_10 : i32;
var param_11 : i32;
var param_12 : i32;
var param_13 : i32;
var param_14 : i32;
var param_15 : i32;
var param_16 : i32;
var param_17 : i32;
var param_18 : i32;
var param_19 : i32;
var param_20 : i32;
var param_21 : i32;
var param_22 : i32;
var param_23 : i32;
var count : i32;
var i : i32;
var result : i32;
var param_24 : i32;
treeIndex_1 = 0;
let x_91 : BST = tree_1[0];
param_4 = x_91;
param_5 = 9;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_4), &(param_5));
let x_93 : BST = param_4;
tree_1[0] = x_93;
let x_95 : i32 = treeIndex_1;
treeIndex_1 = (x_95 + 1);
let x_97 : i32 = treeIndex_1;
param_6 = x_97;
param_7 = 5;
insert_i1_i1_(&(param_6), &(param_7));
let x_99 : i32 = treeIndex_1;
treeIndex_1 = (x_99 + 1);
let x_101 : i32 = treeIndex_1;
param_8 = x_101;
param_9 = 12;
insert_i1_i1_(&(param_8), &(param_9));
let x_103 : i32 = treeIndex_1;
treeIndex_1 = (x_103 + 1);
let x_105 : i32 = treeIndex_1;
param_10 = x_105;
param_11 = 15;
insert_i1_i1_(&(param_10), &(param_11));
let x_107 : i32 = treeIndex_1;
treeIndex_1 = (x_107 + 1);
let x_109 : i32 = treeIndex_1;
param_12 = x_109;
param_13 = 7;
insert_i1_i1_(&(param_12), &(param_13));
let x_111 : i32 = treeIndex_1;
treeIndex_1 = (x_111 + 1);
let x_113 : i32 = treeIndex_1;
param_14 = x_113;
param_15 = 8;
insert_i1_i1_(&(param_14), &(param_15));
let x_115 : i32 = treeIndex_1;
treeIndex_1 = (x_115 + 1);
let x_117 : i32 = treeIndex_1;
param_16 = x_117;
param_17 = 2;
insert_i1_i1_(&(param_16), &(param_17));
let x_119 : i32 = treeIndex_1;
treeIndex_1 = (x_119 + 1);
let x_121 : i32 = treeIndex_1;
param_18 = x_121;
param_19 = 6;
insert_i1_i1_(&(param_18), &(param_19));
let x_123 : i32 = treeIndex_1;
treeIndex_1 = (x_123 + 1);
let x_125 : i32 = treeIndex_1;
param_20 = x_125;
param_21 = 17;
insert_i1_i1_(&(param_20), &(param_21));
let x_127 : i32 = treeIndex_1;
treeIndex_1 = (x_127 + 1);
let x_129 : i32 = treeIndex_1;
param_22 = x_129;
param_23 = 13;
insert_i1_i1_(&(param_22), &(param_23));
count = 0;
i = 0;
loop {
let x_135 : i32 = i;
if ((x_135 < 20)) {
} else {
break;
}
let x_138 : i32 = i;
param_24 = x_138;
let x_139 : i32 = search_i1_(&(param_24));
result = x_139;
let x_140 : i32 = i;
switch(x_140) {
case 2, 5, 6, 7, 8, 9, 12, 13, 15, 17: {
let x_150 : i32 = result;
let x_151 : i32 = i;
if ((x_150 == x_151)) {
let x_155 : i32 = count;
count = (x_155 + 1);
}
}
default: {
let x_144 : i32 = result;
if ((x_144 == -1)) {
let x_148 : i32 = count;
count = (x_148 + 1);
}
}
}
continuing {
let x_157 : i32 = i;
i = (x_157 + 1);
}
}
let x_159 : i32 = count;
if ((x_159 == 20)) {
x_GLF_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} else {
x_GLF_color = vec4<f32>(0.0, 0.0, 1.0, 1.0);
}
return;
}
struct main_out {
[[location(0)]]
x_GLF_color_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main() -> main_out {
main_1();
return main_out(x_GLF_color);
}

View File

@@ -0,0 +1,293 @@
struct BST {
data : i32;
leftIndex : i32;
rightIndex : i32;
};
[[block]]
struct buf0 {
injectionSwitch : vec2<f32>;
};
var<private> tree_1 : array<BST, 10>;
[[group(0), binding(0)]] var<uniform> x_16 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn makeTreeNode_struct_BST_i1_i1_i11_i1_(tree : ptr<function, BST>, data : ptr<function, i32>) {
let x_165 : i32 = *(data);
(*(tree)).data = x_165;
(*(tree)).leftIndex = -1;
(*(tree)).rightIndex = -1;
return;
}
fn insert_i1_i1_(treeIndex : ptr<function, i32>, data_1 : ptr<function, i32>) {
var baseIndex : i32;
var param : BST;
var param_1 : i32;
var x_170 : i32;
var param_2 : BST;
var param_3 : i32;
baseIndex = 0;
loop {
let x_175 : i32 = baseIndex;
let x_176 : i32 = *(treeIndex);
if ((x_175 <= x_176)) {
} else {
break;
}
let x_179 : i32 = *(data_1);
let x_180 : i32 = baseIndex;
let x_182 : i32 = tree_1[x_180].data;
if ((x_179 <= x_182)) {
let x_187 : i32 = baseIndex;
let x_189 : i32 = tree_1[x_187].leftIndex;
if ((x_189 == -1)) {
let x_194 : i32 = baseIndex;
let x_195 : i32 = *(treeIndex);
tree_1[x_194].leftIndex = x_195;
let x_198 : f32 = x_16.injectionSwitch.x;
let x_200 : f32 = x_16.injectionSwitch.y;
if ((x_198 < x_200)) {
let x_204 : i32 = *(treeIndex);
let x_206 : BST = tree_1[x_204];
param = x_206;
let x_207 : i32 = *(data_1);
param_1 = x_207;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param), &(param_1));
let x_209 : BST = param;
tree_1[x_204] = x_209;
}
let x_212 : f32 = x_16.injectionSwitch.x;
let x_214 : f32 = x_16.injectionSwitch.y;
if ((x_212 < x_214)) {
return;
}
} else {
let x_218 : i32 = baseIndex;
let x_220 : i32 = tree_1[x_218].leftIndex;
baseIndex = x_220;
continue;
}
} else {
let x_222 : f32 = x_16.injectionSwitch.x;
let x_224 : f32 = x_16.injectionSwitch.y;
if ((x_222 < x_224)) {
let x_229 : i32 = baseIndex;
let x_231 : i32 = tree_1[x_229].rightIndex;
x_170 = x_231;
} else {
let x_232 : i32 = baseIndex;
let x_234 : i32 = tree_1[x_232].rightIndex;
x_170 = x_234;
}
let x_235 : i32 = x_170;
if ((x_235 == -1)) {
let x_240 : i32 = baseIndex;
let x_241 : i32 = *(treeIndex);
tree_1[x_240].rightIndex = x_241;
let x_243 : i32 = *(treeIndex);
let x_245 : BST = tree_1[x_243];
param_2 = x_245;
let x_246 : i32 = *(data_1);
param_3 = x_246;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_2), &(param_3));
let x_248 : BST = param_2;
tree_1[x_243] = x_248;
return;
} else {
let x_250 : i32 = baseIndex;
let x_252 : i32 = tree_1[x_250].rightIndex;
baseIndex = x_252;
continue;
}
return;
}
let x_254 : f32 = x_16.injectionSwitch.x;
let x_256 : f32 = x_16.injectionSwitch.y;
if ((x_254 > x_256)) {
return;
}
}
return;
}
fn search_i1_(target : ptr<function, i32>) -> i32 {
var index : i32;
var currentNode : BST;
var x_261 : i32;
index = 0;
loop {
let x_266 : i32 = index;
if ((x_266 != -1)) {
} else {
break;
}
let x_269 : i32 = index;
let x_271 : BST = tree_1[x_269];
currentNode = x_271;
let x_273 : i32 = currentNode.data;
let x_274 : i32 = *(target);
if ((x_273 == x_274)) {
let x_278 : i32 = *(target);
return x_278;
}
let x_279 : i32 = *(target);
let x_281 : i32 = currentNode.data;
if ((x_279 > x_281)) {
let x_287 : i32 = currentNode.rightIndex;
x_261 = x_287;
} else {
let x_289 : i32 = currentNode.leftIndex;
x_261 = x_289;
}
let x_290 : i32 = x_261;
index = x_290;
}
return -1;
}
fn main_1() {
var treeIndex_1 : i32;
var param_4 : BST;
var param_5 : i32;
var param_6 : i32;
var param_7 : i32;
var param_8 : i32;
var param_9 : i32;
var param_10 : i32;
var param_11 : i32;
var param_12 : i32;
var param_13 : i32;
var param_14 : i32;
var param_15 : i32;
var param_16 : i32;
var param_17 : i32;
var param_18 : i32;
var param_19 : i32;
var param_20 : i32;
var param_21 : i32;
var param_22 : i32;
var param_23 : i32;
var count : i32;
var i : i32;
var result : i32;
var param_24 : i32;
treeIndex_1 = 0;
let x_91 : BST = tree_1[0];
param_4 = x_91;
param_5 = 9;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_4), &(param_5));
let x_93 : BST = param_4;
tree_1[0] = x_93;
let x_95 : i32 = treeIndex_1;
treeIndex_1 = (x_95 + 1);
let x_97 : i32 = treeIndex_1;
param_6 = x_97;
param_7 = 5;
insert_i1_i1_(&(param_6), &(param_7));
let x_99 : i32 = treeIndex_1;
treeIndex_1 = (x_99 + 1);
let x_101 : i32 = treeIndex_1;
param_8 = x_101;
param_9 = 12;
insert_i1_i1_(&(param_8), &(param_9));
let x_103 : i32 = treeIndex_1;
treeIndex_1 = (x_103 + 1);
let x_105 : i32 = treeIndex_1;
param_10 = x_105;
param_11 = 15;
insert_i1_i1_(&(param_10), &(param_11));
let x_107 : i32 = treeIndex_1;
treeIndex_1 = (x_107 + 1);
let x_109 : i32 = treeIndex_1;
param_12 = x_109;
param_13 = 7;
insert_i1_i1_(&(param_12), &(param_13));
let x_111 : i32 = treeIndex_1;
treeIndex_1 = (x_111 + 1);
let x_113 : i32 = treeIndex_1;
param_14 = x_113;
param_15 = 8;
insert_i1_i1_(&(param_14), &(param_15));
let x_115 : i32 = treeIndex_1;
treeIndex_1 = (x_115 + 1);
let x_117 : i32 = treeIndex_1;
param_16 = x_117;
param_17 = 2;
insert_i1_i1_(&(param_16), &(param_17));
let x_119 : i32 = treeIndex_1;
treeIndex_1 = (x_119 + 1);
let x_121 : i32 = treeIndex_1;
param_18 = x_121;
param_19 = 6;
insert_i1_i1_(&(param_18), &(param_19));
let x_123 : i32 = treeIndex_1;
treeIndex_1 = (x_123 + 1);
let x_125 : i32 = treeIndex_1;
param_20 = x_125;
param_21 = 17;
insert_i1_i1_(&(param_20), &(param_21));
let x_127 : i32 = treeIndex_1;
treeIndex_1 = (x_127 + 1);
let x_129 : i32 = treeIndex_1;
param_22 = x_129;
param_23 = 13;
insert_i1_i1_(&(param_22), &(param_23));
count = 0;
i = 0;
loop {
let x_135 : i32 = i;
if ((x_135 < 20)) {
} else {
break;
}
let x_138 : i32 = i;
param_24 = x_138;
let x_139 : i32 = search_i1_(&(param_24));
result = x_139;
let x_140 : i32 = i;
switch(x_140) {
case 2, 5, 6, 7, 8, 9, 12, 13, 15, 17: {
let x_150 : i32 = result;
let x_151 : i32 = i;
if ((x_150 == x_151)) {
let x_155 : i32 = count;
count = (x_155 + 1);
}
}
default: {
let x_144 : i32 = result;
if ((x_144 == -1)) {
let x_148 : i32 = count;
count = (x_148 + 1);
}
}
}
continuing {
let x_157 : i32 = i;
i = (x_157 + 1);
}
}
let x_159 : i32 = count;
if ((x_159 == 20)) {
x_GLF_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} else {
x_GLF_color = vec4<f32>(0.0, 0.0, 1.0, 1.0);
}
return;
}
struct main_out {
[[location(0)]]
x_GLF_color_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main() -> main_out {
main_1();
return main_out(x_GLF_color);
}

View File

@@ -0,0 +1,255 @@
struct BST {
int data;
int leftIndex;
int rightIndex;
};
static BST tree_1[10] = (BST[10])0;
cbuffer cbuffer_x_16 : register(b0, space0) {
uint4 x_16[1];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
void makeTreeNode_struct_BST_i1_i1_i11_i1_(inout BST tree, inout int data) {
const int x_165 = data;
tree.data = x_165;
tree.leftIndex = -1;
tree.rightIndex = -1;
return;
}
void insert_i1_i1_(inout int treeIndex, inout int data_1) {
int baseIndex = 0;
BST param = (BST)0;
int param_1 = 0;
int x_170 = 0;
BST param_2 = (BST)0;
int param_3 = 0;
baseIndex = 0;
while (true) {
const int x_175 = baseIndex;
const int x_176 = treeIndex;
if ((x_175 <= x_176)) {
} else {
break;
}
const int x_179 = data_1;
const int x_182 = tree_1[baseIndex].data;
if ((x_179 <= x_182)) {
const int x_189 = tree_1[baseIndex].leftIndex;
if ((x_189 == -1)) {
const int x_194 = baseIndex;
const int x_195 = treeIndex;
tree_1[x_194].leftIndex = x_195;
const float x_198 = asfloat(x_16[0].x);
const float x_200 = asfloat(x_16[0].y);
if ((x_198 < x_200)) {
const int x_204 = treeIndex;
const BST x_206 = tree_1[x_204];
param = x_206;
const int x_207 = data_1;
param_1 = x_207;
makeTreeNode_struct_BST_i1_i1_i11_i1_(param, param_1);
tree_1[x_204] = param;
}
const float x_212 = asfloat(x_16[0].x);
const float x_214 = asfloat(x_16[0].y);
if ((x_212 < x_214)) {
return;
}
} else {
const int x_220 = tree_1[baseIndex].leftIndex;
baseIndex = x_220;
continue;
}
} else {
const float x_222 = asfloat(x_16[0].x);
const float x_224 = asfloat(x_16[0].y);
if ((x_222 < x_224)) {
const int x_231 = tree_1[baseIndex].rightIndex;
x_170 = x_231;
} else {
const int x_234 = tree_1[baseIndex].rightIndex;
x_170 = x_234;
}
if ((x_170 == -1)) {
const int x_240 = baseIndex;
const int x_241 = treeIndex;
tree_1[x_240].rightIndex = x_241;
const int x_243 = treeIndex;
const BST x_245 = tree_1[x_243];
param_2 = x_245;
const int x_246 = data_1;
param_3 = x_246;
makeTreeNode_struct_BST_i1_i1_i11_i1_(param_2, param_3);
tree_1[x_243] = param_2;
return;
} else {
const int x_252 = tree_1[baseIndex].rightIndex;
baseIndex = x_252;
continue;
}
return;
}
const float x_254 = asfloat(x_16[0].x);
const float x_256 = asfloat(x_16[0].y);
if ((x_254 > x_256)) {
return;
}
}
return;
}
int search_i1_(inout int target) {
int index = 0;
BST currentNode = (BST)0;
int x_261 = 0;
index = 0;
while (true) {
if ((index != -1)) {
} else {
break;
}
const BST x_271 = tree_1[index];
currentNode = x_271;
const int x_273 = currentNode.data;
const int x_274 = target;
if ((x_273 == x_274)) {
const int x_278 = target;
return x_278;
}
const int x_279 = target;
const int x_281 = currentNode.data;
if ((x_279 > x_281)) {
const int x_287 = currentNode.rightIndex;
x_261 = x_287;
} else {
const int x_289 = currentNode.leftIndex;
x_261 = x_289;
}
index = x_261;
}
return -1;
}
void main_1() {
int treeIndex_1 = 0;
BST param_4 = (BST)0;
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;
const BST x_91 = tree_1[0];
param_4 = x_91;
param_5 = 9;
makeTreeNode_struct_BST_i1_i1_i11_i1_(param_4, param_5);
tree_1[0] = param_4;
treeIndex_1 = (treeIndex_1 + 1);
param_6 = treeIndex_1;
param_7 = 5;
insert_i1_i1_(param_6, param_7);
treeIndex_1 = (treeIndex_1 + 1);
param_8 = treeIndex_1;
param_9 = 12;
insert_i1_i1_(param_8, param_9);
treeIndex_1 = (treeIndex_1 + 1);
param_10 = treeIndex_1;
param_11 = 15;
insert_i1_i1_(param_10, param_11);
treeIndex_1 = (treeIndex_1 + 1);
param_12 = treeIndex_1;
param_13 = 7;
insert_i1_i1_(param_12, param_13);
treeIndex_1 = (treeIndex_1 + 1);
param_14 = treeIndex_1;
param_15 = 8;
insert_i1_i1_(param_14, param_15);
treeIndex_1 = (treeIndex_1 + 1);
param_16 = treeIndex_1;
param_17 = 2;
insert_i1_i1_(param_16, param_17);
treeIndex_1 = (treeIndex_1 + 1);
param_18 = treeIndex_1;
param_19 = 6;
insert_i1_i1_(param_18, param_19);
treeIndex_1 = (treeIndex_1 + 1);
param_20 = treeIndex_1;
param_21 = 17;
insert_i1_i1_(param_20, param_21);
treeIndex_1 = (treeIndex_1 + 1);
param_22 = treeIndex_1;
param_23 = 13;
insert_i1_i1_(param_22, param_23);
count = 0;
i = 0;
{
for(; (i < 20); i = (i + 1)) {
param_24 = i;
const int x_139 = search_i1_(param_24);
result = x_139;
switch(i) {
case 2:
case 5:
case 6:
case 7:
case 8:
case 9:
case 12:
case 13:
case 15:
case 17: {
if ((result == i)) {
count = (count + 1);
}
break;
}
default: {
if ((result == -1)) {
count = (count + 1);
}
break;
}
}
}
}
if ((count == 20)) {
x_GLF_color = float4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
x_GLF_color = float4(0.0f, 0.0f, 1.0f, 1.0f);
}
return;
}
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol {
float4 x_GLF_color_1 : SV_Target0;
};
tint_symbol main() {
main_1();
const main_out tint_symbol_1 = {x_GLF_color};
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3;
}

View File

@@ -0,0 +1,306 @@
#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_4) {
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_4)).arr[x_180].data;
if ((x_179 <= x_182)) {
int const x_187 = baseIndex;
int const x_189 = (*(tint_symbol_4)).arr[x_187].leftIndex;
if ((x_189 == -1)) {
int const x_194 = baseIndex;
int const x_195 = *(treeIndex);
(*(tint_symbol_4)).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_4)).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_4)).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_4)).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_4)).arr[x_229].rightIndex;
x_170 = x_231;
} else {
int const x_232 = baseIndex;
int const x_234 = (*(tint_symbol_4)).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_4)).arr[x_240].rightIndex = x_241;
int const x_243 = *(treeIndex);
BST const x_245 = (*(tint_symbol_4)).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_4)).arr[x_243] = x_248;
return;
} else {
int const x_250 = baseIndex;
int const x_252 = (*(tint_symbol_4)).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_5) {
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_5)).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_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_91 = (*(tint_symbol_6)).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_6)).arr[0] = x_93;
int const x_95 = treeIndex_1;
treeIndex_1 = (x_95 + 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_6);
int const x_99 = treeIndex_1;
treeIndex_1 = (x_99 + 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_6);
int const x_103 = treeIndex_1;
treeIndex_1 = (x_103 + 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_6);
int const x_107 = treeIndex_1;
treeIndex_1 = (x_107 + 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_6);
int const x_111 = treeIndex_1;
treeIndex_1 = (x_111 + 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_6);
int const x_115 = treeIndex_1;
treeIndex_1 = (x_115 + 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_6);
int const x_119 = treeIndex_1;
treeIndex_1 = (x_119 + 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_6);
int const x_123 = treeIndex_1;
treeIndex_1 = (x_123 + 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_6);
int const x_127 = treeIndex_1;
treeIndex_1 = (x_127 + 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_6);
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_6);
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 = (x_155 + 1);
}
break;
}
default: {
int const x_144 = result;
if ((x_144 == -1)) {
int const x_148 = count;
count = (x_148 + 1);
}
break;
}
}
{
int const x_157 = i;
i = (x_157 + 1);
}
}
int const x_159 = count;
if ((x_159 == 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(constant buf0& x_16 [[buffer(0)]]) {
thread tint_array_wrapper tint_symbol_8 = {};
thread float4 tint_symbol_9 = 0.0f;
main_1(x_16, &(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;
}

View File

@@ -0,0 +1,539 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 355
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %tint_symbol_1
OpExecutionMode %main OriginUpperLeft
OpName %BST "BST"
OpMemberName %BST 0 "data"
OpMemberName %BST 1 "leftIndex"
OpMemberName %BST 2 "rightIndex"
OpName %tree_1 "tree_1"
OpName %buf0 "buf0"
OpMemberName %buf0 0 "injectionSwitch"
OpName %x_16 "x_16"
OpName %x_GLF_color "x_GLF_color"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %makeTreeNode_struct_BST_i1_i1_i11_i1_ "makeTreeNode_struct_BST_i1_i1_i11_i1_"
OpName %tree "tree"
OpName %data "data"
OpName %insert_i1_i1_ "insert_i1_i1_"
OpName %treeIndex "treeIndex"
OpName %data_1 "data_1"
OpName %baseIndex "baseIndex"
OpName %param "param"
OpName %param_1 "param_1"
OpName %x_170 "x_170"
OpName %param_2 "param_2"
OpName %param_3 "param_3"
OpName %search_i1_ "search_i1_"
OpName %target "target"
OpName %index "index"
OpName %currentNode "currentNode"
OpName %x_261 "x_261"
OpName %main_1 "main_1"
OpName %treeIndex_1 "treeIndex_1"
OpName %param_4 "param_4"
OpName %param_5 "param_5"
OpName %param_6 "param_6"
OpName %param_7 "param_7"
OpName %param_8 "param_8"
OpName %param_9 "param_9"
OpName %param_10 "param_10"
OpName %param_11 "param_11"
OpName %param_12 "param_12"
OpName %param_13 "param_13"
OpName %param_14 "param_14"
OpName %param_15 "param_15"
OpName %param_16 "param_16"
OpName %param_17 "param_17"
OpName %param_18 "param_18"
OpName %param_19 "param_19"
OpName %param_20 "param_20"
OpName %param_21 "param_21"
OpName %param_22 "param_22"
OpName %param_23 "param_23"
OpName %count "count"
OpName %i "i"
OpName %result "result"
OpName %param_24 "param_24"
OpName %main_out "main_out"
OpMemberName %main_out 0 "x_GLF_color_1"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol "tint_symbol"
OpName %main "main"
OpMemberDecorate %BST 0 Offset 0
OpMemberDecorate %BST 1 Offset 4
OpMemberDecorate %BST 2 Offset 8
OpDecorate %_arr_BST_uint_10 ArrayStride 12
OpDecorate %buf0 Block
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %x_16 NonWritable
OpDecorate %x_16 DescriptorSet 0
OpDecorate %x_16 Binding 0
OpDecorate %tint_symbol_1 Location 0
OpMemberDecorate %main_out 0 Offset 0
%int = OpTypeInt 32 1
%BST = OpTypeStruct %int %int %int
%uint = OpTypeInt 32 0
%uint_10 = OpConstant %uint 10
%_arr_BST_uint_10 = OpTypeArray %BST %uint_10
%_ptr_Private__arr_BST_uint_10 = OpTypePointer Private %_arr_BST_uint_10
%8 = OpConstantNull %_arr_BST_uint_10
%tree_1 = OpVariable %_ptr_Private__arr_BST_uint_10 Private %8
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%buf0 = OpTypeStruct %v2float
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%x_16 = OpVariable %_ptr_Uniform_buf0 Uniform
%v4float = OpTypeVector %float 4
%_ptr_Private_v4float = OpTypePointer Private %v4float
%17 = OpConstantNull %v4float
%x_GLF_color = OpVariable %_ptr_Private_v4float Private %17
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %17
%void = OpTypeVoid
%_ptr_Function_BST = OpTypePointer Function %BST
%_ptr_Function_int = OpTypePointer Function %int
%20 = OpTypeFunction %void %_ptr_Function_BST %_ptr_Function_int
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%int_n1 = OpConstant %int -1
%uint_2 = OpConstant %uint 2
%40 = OpTypeFunction %void %_ptr_Function_int %_ptr_Function_int
%46 = OpConstantNull %int
%48 = OpConstantNull %BST
%int_0 = OpConstant %int 0
%bool = OpTypeBool
%_ptr_Private_int = OpTypePointer Private %int
%_ptr_Uniform_float = OpTypePointer Uniform %float
%_ptr_Private_BST = OpTypePointer Private %BST
%161 = OpTypeFunction %int %_ptr_Function_int
%202 = OpTypeFunction %void
%int_9 = OpConstant %int 9
%int_1 = OpConstant %int 1
%int_5 = OpConstant %int 5
%int_12 = OpConstant %int 12
%int_15 = OpConstant %int 15
%int_7 = OpConstant %int 7
%int_8 = OpConstant %int 8
%int_2 = OpConstant %int 2
%int_6 = OpConstant %int 6
%int_17 = OpConstant %int 17
%int_13 = OpConstant %int 13
%int_20 = OpConstant %int 20
%float_1 = OpConstant %float 1
%float_0 = OpConstant %float 0
%341 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
%342 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
%main_out = OpTypeStruct %v4float
%343 = OpTypeFunction %void %main_out
%makeTreeNode_struct_BST_i1_i1_i11_i1_ = OpFunction %void None %20
%tree = OpFunctionParameter %_ptr_Function_BST
%data = OpFunctionParameter %_ptr_Function_int
%27 = OpLabel
%29 = OpLoad %int %data
%32 = OpAccessChain %_ptr_Function_int %tree %uint_0
OpStore %32 %29
%35 = OpAccessChain %_ptr_Function_int %tree %uint_1
OpStore %35 %int_n1
%39 = OpAccessChain %_ptr_Function_int %tree %uint_2
OpStore %39 %int_n1
OpReturn
OpFunctionEnd
%insert_i1_i1_ = OpFunction %void None %40
%treeIndex = OpFunctionParameter %_ptr_Function_int
%data_1 = OpFunctionParameter %_ptr_Function_int
%44 = OpLabel
%baseIndex = OpVariable %_ptr_Function_int Function %46
%param = OpVariable %_ptr_Function_BST Function %48
%param_1 = OpVariable %_ptr_Function_int Function %46
%x_170 = OpVariable %_ptr_Function_int Function %46
%param_2 = OpVariable %_ptr_Function_BST Function %48
%param_3 = OpVariable %_ptr_Function_int Function %46
OpStore %baseIndex %int_0
OpBranch %54
%54 = OpLabel
OpLoopMerge %55 %56 None
OpBranch %57
%57 = OpLabel
%58 = OpLoad %int %baseIndex
%60 = OpLoad %int %treeIndex
%61 = OpSLessThanEqual %bool %58 %60
OpSelectionMerge %63 None
OpBranchConditional %61 %64 %65
%64 = OpLabel
OpBranch %63
%65 = OpLabel
OpBranch %55
%63 = OpLabel
%67 = OpLoad %int %data_1
%68 = OpLoad %int %baseIndex
%70 = OpAccessChain %_ptr_Private_int %tree_1 %68 %uint_0
%71 = OpLoad %int %70
%72 = OpSLessThanEqual %bool %67 %71
OpSelectionMerge %73 None
OpBranchConditional %72 %74 %75
%74 = OpLabel
%76 = OpLoad %int %baseIndex
%77 = OpAccessChain %_ptr_Private_int %tree_1 %76 %uint_1
%78 = OpLoad %int %77
%79 = OpIEqual %bool %78 %int_n1
OpSelectionMerge %80 None
OpBranchConditional %79 %81 %82
%81 = OpLabel
%83 = OpLoad %int %baseIndex
%85 = OpLoad %int %treeIndex
%86 = OpAccessChain %_ptr_Private_int %tree_1 %83 %uint_1
OpStore %86 %85
%88 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%89 = OpLoad %float %88
%90 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%91 = OpLoad %float %90
%92 = OpFOrdLessThan %bool %89 %91
OpSelectionMerge %93 None
OpBranchConditional %92 %94 %93
%94 = OpLabel
%96 = OpLoad %int %treeIndex
%98 = OpAccessChain %_ptr_Private_BST %tree_1 %96
%99 = OpLoad %BST %98
OpStore %param %99
%101 = OpLoad %int %data_1
OpStore %param_1 %101
%102 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param %param_1
%105 = OpLoad %BST %param
%106 = OpAccessChain %_ptr_Private_BST %tree_1 %96
OpStore %106 %105
OpBranch %93
%93 = OpLabel
%107 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%108 = OpLoad %float %107
%109 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%110 = OpLoad %float %109
%111 = OpFOrdLessThan %bool %108 %110
OpSelectionMerge %112 None
OpBranchConditional %111 %113 %112
%113 = OpLabel
OpReturn
%112 = OpLabel
OpBranch %80
%82 = OpLabel
%114 = OpLoad %int %baseIndex
%115 = OpAccessChain %_ptr_Private_int %tree_1 %114 %uint_1
%116 = OpLoad %int %115
OpStore %baseIndex %116
OpBranch %56
%80 = OpLabel
OpBranch %73
%75 = OpLabel
%117 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%118 = OpLoad %float %117
%119 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%120 = OpLoad %float %119
%121 = OpFOrdLessThan %bool %118 %120
OpSelectionMerge %122 None
OpBranchConditional %121 %123 %124
%123 = OpLabel
%125 = OpLoad %int %baseIndex
%126 = OpAccessChain %_ptr_Private_int %tree_1 %125 %uint_2
%127 = OpLoad %int %126
OpStore %x_170 %127
OpBranch %122
%124 = OpLabel
%128 = OpLoad %int %baseIndex
%129 = OpAccessChain %_ptr_Private_int %tree_1 %128 %uint_2
%130 = OpLoad %int %129
OpStore %x_170 %130
OpBranch %122
%122 = OpLabel
%131 = OpLoad %int %x_170
%132 = OpIEqual %bool %131 %int_n1
OpSelectionMerge %133 None
OpBranchConditional %132 %134 %135
%134 = OpLabel
%136 = OpLoad %int %baseIndex
%138 = OpLoad %int %treeIndex
%139 = OpAccessChain %_ptr_Private_int %tree_1 %136 %uint_2
OpStore %139 %138
%141 = OpLoad %int %treeIndex
%142 = OpAccessChain %_ptr_Private_BST %tree_1 %141
%143 = OpLoad %BST %142
OpStore %param_2 %143
%145 = OpLoad %int %data_1
OpStore %param_3 %145
%146 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param_2 %param_3
%149 = OpLoad %BST %param_2
%150 = OpAccessChain %_ptr_Private_BST %tree_1 %141
OpStore %150 %149
OpReturn
%135 = OpLabel
%151 = OpLoad %int %baseIndex
%152 = OpAccessChain %_ptr_Private_int %tree_1 %151 %uint_2
%153 = OpLoad %int %152
OpStore %baseIndex %153
OpBranch %56
%133 = OpLabel
OpReturn
%73 = OpLabel
%154 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_0
%155 = OpLoad %float %154
%156 = OpAccessChain %_ptr_Uniform_float %x_16 %uint_0 %uint_1
%157 = OpLoad %float %156
%158 = OpFOrdGreaterThan %bool %155 %157
OpSelectionMerge %159 None
OpBranchConditional %158 %160 %159
%160 = OpLabel
OpReturn
%159 = OpLabel
OpBranch %56
%56 = OpLabel
OpBranch %54
%55 = OpLabel
OpReturn
OpFunctionEnd
%search_i1_ = OpFunction %int None %161
%target = OpFunctionParameter %_ptr_Function_int
%164 = OpLabel
%index = OpVariable %_ptr_Function_int Function %46
%currentNode = OpVariable %_ptr_Function_BST Function %48
%x_261 = OpVariable %_ptr_Function_int Function %46
OpStore %index %int_0
OpBranch %168
%168 = OpLabel
OpLoopMerge %169 %170 None
OpBranch %171
%171 = OpLabel
%172 = OpLoad %int %index
%173 = OpINotEqual %bool %172 %int_n1
OpSelectionMerge %174 None
OpBranchConditional %173 %175 %176
%175 = OpLabel
OpBranch %174
%176 = OpLabel
OpBranch %169
%174 = OpLabel
%177 = OpLoad %int %index
%178 = OpAccessChain %_ptr_Private_BST %tree_1 %177
%179 = OpLoad %BST %178
OpStore %currentNode %179
%180 = OpAccessChain %_ptr_Function_int %currentNode %uint_0
%181 = OpLoad %int %180
%183 = OpLoad %int %target
%184 = OpIEqual %bool %181 %183
OpSelectionMerge %185 None
OpBranchConditional %184 %186 %185
%186 = OpLabel
%188 = OpLoad %int %target
OpReturnValue %188
%185 = OpLabel
%190 = OpLoad %int %target
%191 = OpAccessChain %_ptr_Function_int %currentNode %uint_0
%192 = OpLoad %int %191
%193 = OpSGreaterThan %bool %190 %192
OpSelectionMerge %194 None
OpBranchConditional %193 %195 %196
%195 = OpLabel
%197 = OpAccessChain %_ptr_Function_int %currentNode %uint_2
%198 = OpLoad %int %197
OpStore %x_261 %198
OpBranch %194
%196 = OpLabel
%199 = OpAccessChain %_ptr_Function_int %currentNode %uint_1
%200 = OpLoad %int %199
OpStore %x_261 %200
OpBranch %194
%194 = OpLabel
%201 = OpLoad %int %x_261
OpStore %index %201
OpBranch %170
%170 = OpLabel
OpBranch %168
%169 = OpLabel
OpReturnValue %int_n1
OpFunctionEnd
%main_1 = OpFunction %void None %202
%204 = OpLabel
%treeIndex_1 = OpVariable %_ptr_Function_int Function %46
%param_4 = OpVariable %_ptr_Function_BST Function %48
%param_5 = OpVariable %_ptr_Function_int Function %46
%param_6 = OpVariable %_ptr_Function_int Function %46
%param_7 = OpVariable %_ptr_Function_int Function %46
%param_8 = OpVariable %_ptr_Function_int Function %46
%param_9 = OpVariable %_ptr_Function_int Function %46
%param_10 = OpVariable %_ptr_Function_int Function %46
%param_11 = OpVariable %_ptr_Function_int Function %46
%param_12 = OpVariable %_ptr_Function_int Function %46
%param_13 = OpVariable %_ptr_Function_int Function %46
%param_14 = OpVariable %_ptr_Function_int Function %46
%param_15 = OpVariable %_ptr_Function_int Function %46
%param_16 = OpVariable %_ptr_Function_int Function %46
%param_17 = OpVariable %_ptr_Function_int Function %46
%param_18 = OpVariable %_ptr_Function_int Function %46
%param_19 = OpVariable %_ptr_Function_int Function %46
%param_20 = OpVariable %_ptr_Function_int Function %46
%param_21 = OpVariable %_ptr_Function_int Function %46
%param_22 = OpVariable %_ptr_Function_int Function %46
%param_23 = OpVariable %_ptr_Function_int Function %46
%count = OpVariable %_ptr_Function_int Function %46
%i = OpVariable %_ptr_Function_int Function %46
%result = OpVariable %_ptr_Function_int Function %46
%param_24 = OpVariable %_ptr_Function_int Function %46
OpStore %treeIndex_1 %int_0
%230 = OpAccessChain %_ptr_Private_BST %tree_1 %int_0
%231 = OpLoad %BST %230
OpStore %param_4 %231
OpStore %param_5 %int_9
%233 = OpFunctionCall %void %makeTreeNode_struct_BST_i1_i1_i11_i1_ %param_4 %param_5
%236 = OpLoad %BST %param_4
%237 = OpAccessChain %_ptr_Private_BST %tree_1 %int_0
OpStore %237 %236
%238 = OpLoad %int %treeIndex_1
%240 = OpIAdd %int %238 %int_1
OpStore %treeIndex_1 %240
%241 = OpLoad %int %treeIndex_1
OpStore %param_6 %241
OpStore %param_7 %int_5
%243 = OpFunctionCall %void %insert_i1_i1_ %param_6 %param_7
%246 = OpLoad %int %treeIndex_1
%247 = OpIAdd %int %246 %int_1
OpStore %treeIndex_1 %247
%248 = OpLoad %int %treeIndex_1
OpStore %param_8 %248
OpStore %param_9 %int_12
%250 = OpFunctionCall %void %insert_i1_i1_ %param_8 %param_9
%253 = OpLoad %int %treeIndex_1
%254 = OpIAdd %int %253 %int_1
OpStore %treeIndex_1 %254
%255 = OpLoad %int %treeIndex_1
OpStore %param_10 %255
OpStore %param_11 %int_15
%257 = OpFunctionCall %void %insert_i1_i1_ %param_10 %param_11
%260 = OpLoad %int %treeIndex_1
%261 = OpIAdd %int %260 %int_1
OpStore %treeIndex_1 %261
%262 = OpLoad %int %treeIndex_1
OpStore %param_12 %262
OpStore %param_13 %int_7
%264 = OpFunctionCall %void %insert_i1_i1_ %param_12 %param_13
%267 = OpLoad %int %treeIndex_1
%268 = OpIAdd %int %267 %int_1
OpStore %treeIndex_1 %268
%269 = OpLoad %int %treeIndex_1
OpStore %param_14 %269
OpStore %param_15 %int_8
%271 = OpFunctionCall %void %insert_i1_i1_ %param_14 %param_15
%274 = OpLoad %int %treeIndex_1
%275 = OpIAdd %int %274 %int_1
OpStore %treeIndex_1 %275
%276 = OpLoad %int %treeIndex_1
OpStore %param_16 %276
OpStore %param_17 %int_2
%278 = OpFunctionCall %void %insert_i1_i1_ %param_16 %param_17
%281 = OpLoad %int %treeIndex_1
%282 = OpIAdd %int %281 %int_1
OpStore %treeIndex_1 %282
%283 = OpLoad %int %treeIndex_1
OpStore %param_18 %283
OpStore %param_19 %int_6
%285 = OpFunctionCall %void %insert_i1_i1_ %param_18 %param_19
%288 = OpLoad %int %treeIndex_1
%289 = OpIAdd %int %288 %int_1
OpStore %treeIndex_1 %289
%290 = OpLoad %int %treeIndex_1
OpStore %param_20 %290
OpStore %param_21 %int_17
%292 = OpFunctionCall %void %insert_i1_i1_ %param_20 %param_21
%295 = OpLoad %int %treeIndex_1
%296 = OpIAdd %int %295 %int_1
OpStore %treeIndex_1 %296
%297 = OpLoad %int %treeIndex_1
OpStore %param_22 %297
OpStore %param_23 %int_13
%299 = OpFunctionCall %void %insert_i1_i1_ %param_22 %param_23
OpStore %count %int_0
OpStore %i %int_0
OpBranch %302
%302 = OpLabel
OpLoopMerge %303 %304 None
OpBranch %305
%305 = OpLabel
%306 = OpLoad %int %i
%308 = OpSLessThan %bool %306 %int_20
OpSelectionMerge %309 None
OpBranchConditional %308 %310 %311
%310 = OpLabel
OpBranch %309
%311 = OpLabel
OpBranch %303
%309 = OpLabel
%312 = OpLoad %int %i
OpStore %param_24 %312
%313 = OpFunctionCall %int %search_i1_ %param_24
OpStore %result %313
%315 = OpLoad %int %i
OpSelectionMerge %316 None
OpSwitch %315 %317 2 %318 5 %318 6 %318 7 %318 8 %318 9 %318 12 %318 13 %318 15 %318 17 %318
%318 = OpLabel
%319 = OpLoad %int %result
%320 = OpLoad %int %i
%321 = OpIEqual %bool %319 %320
OpSelectionMerge %322 None
OpBranchConditional %321 %323 %322
%323 = OpLabel
%324 = OpLoad %int %count
%325 = OpIAdd %int %324 %int_1
OpStore %count %325
OpBranch %322
%322 = OpLabel
OpBranch %316
%317 = OpLabel
%326 = OpLoad %int %result
%327 = OpIEqual %bool %326 %int_n1
OpSelectionMerge %328 None
OpBranchConditional %327 %329 %328
%329 = OpLabel
%330 = OpLoad %int %count
%331 = OpIAdd %int %330 %int_1
OpStore %count %331
OpBranch %328
%328 = OpLabel
OpBranch %316
%316 = OpLabel
OpBranch %304
%304 = OpLabel
%332 = OpLoad %int %i
%333 = OpIAdd %int %332 %int_1
OpStore %i %333
OpBranch %302
%303 = OpLabel
%334 = OpLoad %int %count
%335 = OpIEqual %bool %334 %int_20
OpSelectionMerge %336 None
OpBranchConditional %335 %337 %338
%337 = OpLabel
OpStore %x_GLF_color %341
OpBranch %336
%338 = OpLabel
OpStore %x_GLF_color %342
OpBranch %336
%336 = OpLabel
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %343
%tint_symbol = OpFunctionParameter %main_out
%347 = OpLabel
%348 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %348
OpReturn
OpFunctionEnd
%main = OpFunction %void None %202
%350 = OpLabel
%351 = OpFunctionCall %void %main_1
%353 = OpLoad %v4float %x_GLF_color
%354 = OpCompositeConstruct %main_out %353
%352 = OpFunctionCall %void %tint_symbol_2 %354
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,293 @@
struct BST {
data : i32;
leftIndex : i32;
rightIndex : i32;
};
[[block]]
struct buf0 {
injectionSwitch : vec2<f32>;
};
var<private> tree_1 : array<BST, 10>;
[[group(0), binding(0)]] var<uniform> x_16 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn makeTreeNode_struct_BST_i1_i1_i11_i1_(tree : ptr<function, BST>, data : ptr<function, i32>) {
let x_165 : i32 = *(data);
(*(tree)).data = x_165;
(*(tree)).leftIndex = -1;
(*(tree)).rightIndex = -1;
return;
}
fn insert_i1_i1_(treeIndex : ptr<function, i32>, data_1 : ptr<function, i32>) {
var baseIndex : i32;
var param : BST;
var param_1 : i32;
var x_170 : i32;
var param_2 : BST;
var param_3 : i32;
baseIndex = 0;
loop {
let x_175 : i32 = baseIndex;
let x_176 : i32 = *(treeIndex);
if ((x_175 <= x_176)) {
} else {
break;
}
let x_179 : i32 = *(data_1);
let x_180 : i32 = baseIndex;
let x_182 : i32 = tree_1[x_180].data;
if ((x_179 <= x_182)) {
let x_187 : i32 = baseIndex;
let x_189 : i32 = tree_1[x_187].leftIndex;
if ((x_189 == -1)) {
let x_194 : i32 = baseIndex;
let x_195 : i32 = *(treeIndex);
tree_1[x_194].leftIndex = x_195;
let x_198 : f32 = x_16.injectionSwitch.x;
let x_200 : f32 = x_16.injectionSwitch.y;
if ((x_198 < x_200)) {
let x_204 : i32 = *(treeIndex);
let x_206 : BST = tree_1[x_204];
param = x_206;
let x_207 : i32 = *(data_1);
param_1 = x_207;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param), &(param_1));
let x_209 : BST = param;
tree_1[x_204] = x_209;
}
let x_212 : f32 = x_16.injectionSwitch.x;
let x_214 : f32 = x_16.injectionSwitch.y;
if ((x_212 < x_214)) {
return;
}
} else {
let x_218 : i32 = baseIndex;
let x_220 : i32 = tree_1[x_218].leftIndex;
baseIndex = x_220;
continue;
}
} else {
let x_222 : f32 = x_16.injectionSwitch.x;
let x_224 : f32 = x_16.injectionSwitch.y;
if ((x_222 < x_224)) {
let x_229 : i32 = baseIndex;
let x_231 : i32 = tree_1[x_229].rightIndex;
x_170 = x_231;
} else {
let x_232 : i32 = baseIndex;
let x_234 : i32 = tree_1[x_232].rightIndex;
x_170 = x_234;
}
let x_235 : i32 = x_170;
if ((x_235 == -1)) {
let x_240 : i32 = baseIndex;
let x_241 : i32 = *(treeIndex);
tree_1[x_240].rightIndex = x_241;
let x_243 : i32 = *(treeIndex);
let x_245 : BST = tree_1[x_243];
param_2 = x_245;
let x_246 : i32 = *(data_1);
param_3 = x_246;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_2), &(param_3));
let x_248 : BST = param_2;
tree_1[x_243] = x_248;
return;
} else {
let x_250 : i32 = baseIndex;
let x_252 : i32 = tree_1[x_250].rightIndex;
baseIndex = x_252;
continue;
}
return;
}
let x_254 : f32 = x_16.injectionSwitch.x;
let x_256 : f32 = x_16.injectionSwitch.y;
if ((x_254 > x_256)) {
return;
}
}
return;
}
fn search_i1_(target : ptr<function, i32>) -> i32 {
var index : i32;
var currentNode : BST;
var x_261 : i32;
index = 0;
loop {
let x_266 : i32 = index;
if ((x_266 != -1)) {
} else {
break;
}
let x_269 : i32 = index;
let x_271 : BST = tree_1[x_269];
currentNode = x_271;
let x_273 : i32 = currentNode.data;
let x_274 : i32 = *(target);
if ((x_273 == x_274)) {
let x_278 : i32 = *(target);
return x_278;
}
let x_279 : i32 = *(target);
let x_281 : i32 = currentNode.data;
if ((x_279 > x_281)) {
let x_287 : i32 = currentNode.rightIndex;
x_261 = x_287;
} else {
let x_289 : i32 = currentNode.leftIndex;
x_261 = x_289;
}
let x_290 : i32 = x_261;
index = x_290;
}
return -1;
}
fn main_1() {
var treeIndex_1 : i32;
var param_4 : BST;
var param_5 : i32;
var param_6 : i32;
var param_7 : i32;
var param_8 : i32;
var param_9 : i32;
var param_10 : i32;
var param_11 : i32;
var param_12 : i32;
var param_13 : i32;
var param_14 : i32;
var param_15 : i32;
var param_16 : i32;
var param_17 : i32;
var param_18 : i32;
var param_19 : i32;
var param_20 : i32;
var param_21 : i32;
var param_22 : i32;
var param_23 : i32;
var count : i32;
var i : i32;
var result : i32;
var param_24 : i32;
treeIndex_1 = 0;
let x_91 : BST = tree_1[0];
param_4 = x_91;
param_5 = 9;
makeTreeNode_struct_BST_i1_i1_i11_i1_(&(param_4), &(param_5));
let x_93 : BST = param_4;
tree_1[0] = x_93;
let x_95 : i32 = treeIndex_1;
treeIndex_1 = (x_95 + 1);
let x_97 : i32 = treeIndex_1;
param_6 = x_97;
param_7 = 5;
insert_i1_i1_(&(param_6), &(param_7));
let x_99 : i32 = treeIndex_1;
treeIndex_1 = (x_99 + 1);
let x_101 : i32 = treeIndex_1;
param_8 = x_101;
param_9 = 12;
insert_i1_i1_(&(param_8), &(param_9));
let x_103 : i32 = treeIndex_1;
treeIndex_1 = (x_103 + 1);
let x_105 : i32 = treeIndex_1;
param_10 = x_105;
param_11 = 15;
insert_i1_i1_(&(param_10), &(param_11));
let x_107 : i32 = treeIndex_1;
treeIndex_1 = (x_107 + 1);
let x_109 : i32 = treeIndex_1;
param_12 = x_109;
param_13 = 7;
insert_i1_i1_(&(param_12), &(param_13));
let x_111 : i32 = treeIndex_1;
treeIndex_1 = (x_111 + 1);
let x_113 : i32 = treeIndex_1;
param_14 = x_113;
param_15 = 8;
insert_i1_i1_(&(param_14), &(param_15));
let x_115 : i32 = treeIndex_1;
treeIndex_1 = (x_115 + 1);
let x_117 : i32 = treeIndex_1;
param_16 = x_117;
param_17 = 2;
insert_i1_i1_(&(param_16), &(param_17));
let x_119 : i32 = treeIndex_1;
treeIndex_1 = (x_119 + 1);
let x_121 : i32 = treeIndex_1;
param_18 = x_121;
param_19 = 6;
insert_i1_i1_(&(param_18), &(param_19));
let x_123 : i32 = treeIndex_1;
treeIndex_1 = (x_123 + 1);
let x_125 : i32 = treeIndex_1;
param_20 = x_125;
param_21 = 17;
insert_i1_i1_(&(param_20), &(param_21));
let x_127 : i32 = treeIndex_1;
treeIndex_1 = (x_127 + 1);
let x_129 : i32 = treeIndex_1;
param_22 = x_129;
param_23 = 13;
insert_i1_i1_(&(param_22), &(param_23));
count = 0;
i = 0;
loop {
let x_135 : i32 = i;
if ((x_135 < 20)) {
} else {
break;
}
let x_138 : i32 = i;
param_24 = x_138;
let x_139 : i32 = search_i1_(&(param_24));
result = x_139;
let x_140 : i32 = i;
switch(x_140) {
case 2, 5, 6, 7, 8, 9, 12, 13, 15, 17: {
let x_150 : i32 = result;
let x_151 : i32 = i;
if ((x_150 == x_151)) {
let x_155 : i32 = count;
count = (x_155 + 1);
}
}
default: {
let x_144 : i32 = result;
if ((x_144 == -1)) {
let x_148 : i32 = count;
count = (x_148 + 1);
}
}
}
continuing {
let x_157 : i32 = i;
i = (x_157 + 1);
}
}
let x_159 : i32 = count;
if ((x_159 == 20)) {
x_GLF_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} else {
x_GLF_color = vec4<f32>(0.0, 0.0, 1.0, 1.0);
}
return;
}
struct main_out {
[[location(0)]]
x_GLF_color_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main() -> main_out {
main_1();
return main_out(x_GLF_color);
}