; LLVM IR from robinrodricks/InspiritImage :: Inspirit.Assurf/clib/kdtree (kdtree)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct._VlKDTree = type { ptr, i32, i32, ptr, i32 }
%struct._VlKDTreeNode = type { i32, i32, i32, i32, double, double, double }
%struct._VlKDForest = type { i32, ptr, i32, ptr, i32, ptr, ptr, i32, i32, [5 x %struct._VlKDTreeSplitDimension], i32, i32, ptr, i32, i32, ptr, i32, i32, i32, i32 }
%struct._VlKDTreeSplitDimension = type { i32, double, double }
%struct._VlKDTreeDataIndexEntry = type { i32, double }
%struct._VlKDForestNeighbor = type { double, i32 }
%struct._VlKDForestSearchState = type { ptr, i32, double }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_kdforest_query_recursively(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, double noundef %6, ptr noundef %7) #1 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca double, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  %26 = alloca double, align 8
  %27 = alloca double, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca i32, align 4
  %32 = alloca i32, align 4
  %33 = alloca i32, align 4
  %34 = alloca ptr, align 8
  %35 = alloca ptr, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store i32 %2, ptr %12, align 4, !tbaa !9
  store ptr %3, ptr %13, align 8, !tbaa !5
  store i32 %4, ptr %14, align 4, !tbaa !9
  store ptr %5, ptr %15, align 8, !tbaa !5
  store double %6, ptr %16, align 8, !tbaa !11
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._VlKDTree, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds %struct._VlKDTreeNode, ptr %38, i64 %40
  store ptr %41, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %42 = load ptr, ptr %18, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._VlKDTreeNode, ptr %42, i32 0, i32 3
  %44 = load i32, ptr %43, align 4, !tbaa !15
  store i32 %44, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %45 = load ptr, ptr %18, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._VlKDTreeNode, ptr %45, i32 0, i32 5
  %47 = load double, ptr %46, align 8, !tbaa !17
  store double %47, ptr %25, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %48 = load ptr, ptr %18, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._VlKDTreeNode, ptr %48, i32 0, i32 4
  %50 = load double, ptr %49, align 8, !tbaa !18
  store double %50, ptr %26, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #4
  %51 = load ptr, ptr %18, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._VlKDTreeNode, ptr %51, i32 0, i32 6
  %53 = load double, ptr %52, align 8, !tbaa !19
  store double %53, ptr %27, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._VlKDForest, ptr %54, i32 0, i32 18
  %56 = load i32, ptr %55, align 8, !tbaa !20
  %57 = add i32 %56, 1
  store i32 %57, ptr %55, align 8, !tbaa !20
  %58 = load ptr, ptr %17, align 8, !tbaa !5
  %59 = load i32, ptr %19, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %58, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !11
  store double %62, ptr %24, align 8, !tbaa !11
  %63 = load ptr, ptr %18, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._VlKDTreeNode, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !22
  %66 = icmp slt i32 %65, 0
  br i1 %66, label %67, label %196

67:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #4
  %68 = load ptr, ptr %18, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._VlKDTreeNode, ptr %68, i32 0, i32 1
  %70 = load i32, ptr %69, align 4, !tbaa !22
  %71 = sub nsw i32 0, %70
  %72 = sub nsw i32 %71, 1
  store i32 %72, ptr %29, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #4
  %73 = load ptr, ptr %18, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._VlKDTreeNode, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !23
  %76 = sub nsw i32 0, %75
  %77 = sub nsw i32 %76, 1
  store i32 %77, ptr %30, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #4
  %78 = load i32, ptr %29, align 4, !tbaa !9
  store i32 %78, ptr %31, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %191, %67
  %80 = load i32, ptr %31, align 4, !tbaa !9
  %81 = load i32, ptr %30, align 4, !tbaa !9
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %83, label %98

83:                                               ; preds = %79
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._VlKDForest, ptr %84, i32 0, i32 16
  %86 = load i32, ptr %85, align 8, !tbaa !24
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %96, label %88

88:                                               ; preds = %83
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._VlKDForest, ptr %89, i32 0, i32 17
  %91 = load i32, ptr %90, align 4, !tbaa !25
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._VlKDForest, ptr %92, i32 0, i32 16
  %94 = load i32, ptr %93, align 8, !tbaa !24
  %95 = icmp ult i32 %91, %94
  br label %96

96:                                               ; preds = %88, %83
  %97 = phi i1 [ true, %83 ], [ %95, %88 ]
  br label %98

98:                                               ; preds = %96, %79
  %99 = phi i1 [ false, %79 ], [ %97, %96 ]
  br i1 %99, label %100, label %194

100:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #4
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._VlKDTree, ptr %101, i32 0, i32 3
  %103 = load ptr, ptr %102, align 8, !tbaa !26
  %104 = load i32, ptr %31, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct._VlKDTreeDataIndexEntry, ptr %103, i64 %105
  %107 = getelementptr inbounds %struct._VlKDTreeDataIndexEntry, ptr %106, i32 0, i32 0
  %108 = load i32, ptr %107, align 8, !tbaa !27
  store i32 %108, ptr %32, align 4, !tbaa !9
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._VlKDForest, ptr %109, i32 0, i32 15
  %111 = load ptr, ptr %110, align 8, !tbaa !29
  %112 = load i32, ptr %32, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds i32, ptr %111, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct._VlKDForest, ptr %116, i32 0, i32 14
  %118 = load i32, ptr %117, align 4, !tbaa !30
  %119 = icmp eq i32 %115, %118
  br i1 %119, label %120, label %121

120:                                              ; preds = %100
  store i32 4, ptr %33, align 4
  br label %188

121:                                              ; preds = %100
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct._VlKDForest, ptr %122, i32 0, i32 14
  %124 = load i32, ptr %123, align 4, !tbaa !30
  %125 = load ptr, ptr %10, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct._VlKDForest, ptr %125, i32 0, i32 15
  %127 = load ptr, ptr %126, align 8, !tbaa !29
  %128 = load i32, ptr %32, align 4, !tbaa !9
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i32, ptr %127, i64 %129
  store i32 %124, ptr %130, align 4, !tbaa !9
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct._VlKDForest, ptr %131, i32 0, i32 0
  %133 = load i32, ptr %132, align 8, !tbaa !31
  %134 = load ptr, ptr %17, align 8, !tbaa !5
  %135 = load ptr, ptr %10, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct._VlKDForest, ptr %135, i32 0, i32 3
  %137 = load ptr, ptr %136, align 8, !tbaa !32
  %138 = load i32, ptr %32, align 4, !tbaa !9
  %139 = load ptr, ptr %10, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._VlKDForest, ptr %139, i32 0, i32 0
  %141 = load i32, ptr %140, align 8, !tbaa !31
  %142 = mul i32 %138, %141
  %143 = zext i32 %142 to i64
  %144 = getelementptr inbounds double, ptr %137, i64 %143
  %145 = call double @vec_compare_function(i32 noundef %133, ptr noundef %134, ptr noundef %144)
  store double %145, ptr %16, align 8, !tbaa !11
  %146 = load ptr, ptr %10, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct._VlKDForest, ptr %146, i32 0, i32 17
  %148 = load i32, ptr %147, align 4, !tbaa !25
  %149 = add i32 %148, 1
  store i32 %149, ptr %147, align 4, !tbaa !25
  %150 = load ptr, ptr %15, align 8, !tbaa !5
  %151 = load i32, ptr %150, align 4, !tbaa !9
  %152 = load i32, ptr %14, align 4, !tbaa !9
  %153 = icmp ult i32 %151, %152
  br i1 %153, label %154, label %168

154:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 8, ptr %34) #4
  %155 = load ptr, ptr %13, align 8, !tbaa !5
  %156 = load ptr, ptr %15, align 8, !tbaa !5
  %157 = load i32, ptr %156, align 4, !tbaa !9
  %158 = zext i32 %157 to i64
  %159 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %155, i64 %158
  store ptr %159, ptr %34, align 8, !tbaa !5
  %160 = load i32, ptr %32, align 4, !tbaa !9
  %161 = load ptr, ptr %34, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %161, i32 0, i32 1
  store i32 %160, ptr %162, align 8, !tbaa !33
  %163 = load double, ptr %16, align 8, !tbaa !11
  %164 = load ptr, ptr %34, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %164, i32 0, i32 0
  store double %163, ptr %165, align 8, !tbaa !35
  %166 = load ptr, ptr %13, align 8, !tbaa !5
  %167 = load ptr, ptr %15, align 8, !tbaa !5
  call void @vl_kdforest_neighbor_heap_push(ptr noundef %166, ptr noundef %167)
  call void @llvm.lifetime.end.p0(i64 8, ptr %34) #4
  br label %187

168:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 8, ptr %35) #4
  %169 = load ptr, ptr %13, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %169, i64 0
  store ptr %170, ptr %35, align 8, !tbaa !5
  %171 = load ptr, ptr %35, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %171, i32 0, i32 0
  %173 = load double, ptr %172, align 8, !tbaa !35
  %174 = load double, ptr %16, align 8, !tbaa !11
  %175 = fcmp ogt double %173, %174
  br i1 %175, label %176, label %186

176:                                              ; preds = %168
  %177 = load i32, ptr %32, align 4, !tbaa !9
  %178 = load ptr, ptr %35, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %178, i32 0, i32 1
  store i32 %177, ptr %179, align 8, !tbaa !33
  %180 = load double, ptr %16, align 8, !tbaa !11
  %181 = load ptr, ptr %35, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %181, i32 0, i32 0
  store double %180, ptr %182, align 8, !tbaa !35
  %183 = load ptr, ptr %13, align 8, !tbaa !5
  %184 = load ptr, ptr %15, align 8, !tbaa !5
  %185 = load i32, ptr %184, align 4, !tbaa !9
  call void @vl_kdforest_neighbor_heap_update(ptr noundef %183, i32 noundef %185, i32 noundef 0)
  br label %186

186:                                              ; preds = %176, %168
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #4
  br label %187

187:                                              ; preds = %186, %154
  store i32 0, ptr %33, align 4
  br label %188

188:                                              ; preds = %187, %120
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #4
  %189 = load i32, ptr %33, align 4
  switch i32 %189, label %294 [
    i32 0, label %190
    i32 4, label %191
  ]

190:                                              ; preds = %188
  br label %191

191:                                              ; preds = %190, %188
  %192 = load i32, ptr %31, align 4, !tbaa !9
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr %31, align 4, !tbaa !9
  br label %79, !llvm.loop !36

194:                                              ; preds = %98
  %195 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %195, ptr %9, align 4
  store i32 1, ptr %33, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #4
  br label %292

196:                                              ; preds = %8
  %197 = load double, ptr %24, align 8, !tbaa !11
  %198 = load double, ptr %26, align 8, !tbaa !11
  %199 = fsub double %197, %198
  store double %199, ptr %22, align 8, !tbaa !11
  %200 = load double, ptr %16, align 8, !tbaa !11
  %201 = load double, ptr %22, align 8, !tbaa !11
  %202 = load double, ptr %22, align 8, !tbaa !11
  %203 = call double @llvm.fmuladd.f64(double %201, double %202, double %200)
  store double %203, ptr %23, align 8, !tbaa !11
  %204 = load double, ptr %24, align 8, !tbaa !11
  %205 = load double, ptr %26, align 8, !tbaa !11
  %206 = fcmp ole double %204, %205
  br i1 %206, label %207, label %227

207:                                              ; preds = %196
  %208 = load ptr, ptr %18, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct._VlKDTreeNode, ptr %208, i32 0, i32 1
  %210 = load i32, ptr %209, align 4, !tbaa !22
  store i32 %210, ptr %20, align 4, !tbaa !9
  %211 = load ptr, ptr %18, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct._VlKDTreeNode, ptr %211, i32 0, i32 2
  %213 = load i32, ptr %212, align 8, !tbaa !23
  store i32 %213, ptr %21, align 4, !tbaa !9
  %214 = load double, ptr %24, align 8, !tbaa !11
  %215 = load double, ptr %25, align 8, !tbaa !11
  %216 = fcmp ole double %214, %215
  br i1 %216, label %217, label %226

217:                                              ; preds = %207
  %218 = load double, ptr %24, align 8, !tbaa !11
  %219 = load double, ptr %25, align 8, !tbaa !11
  %220 = fsub double %218, %219
  store double %220, ptr %22, align 8, !tbaa !11
  %221 = load double, ptr %22, align 8, !tbaa !11
  %222 = load double, ptr %22, align 8, !tbaa !11
  %223 = load double, ptr %23, align 8, !tbaa !11
  %224 = fneg double %221
  %225 = call double @llvm.fmuladd.f64(double %224, double %222, double %223)
  store double %225, ptr %23, align 8, !tbaa !11
  br label %226

226:                                              ; preds = %217, %207
  br label %247

227:                                              ; preds = %196
  %228 = load ptr, ptr %18, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct._VlKDTreeNode, ptr %228, i32 0, i32 2
  %230 = load i32, ptr %229, align 8, !tbaa !23
  store i32 %230, ptr %20, align 4, !tbaa !9
  %231 = load ptr, ptr %18, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct._VlKDTreeNode, ptr %231, i32 0, i32 1
  %233 = load i32, ptr %232, align 4, !tbaa !22
  store i32 %233, ptr %21, align 4, !tbaa !9
  %234 = load double, ptr %24, align 8, !tbaa !11
  %235 = load double, ptr %27, align 8, !tbaa !11
  %236 = fcmp ogt double %234, %235
  br i1 %236, label %237, label %246

237:                                              ; preds = %227
  %238 = load double, ptr %24, align 8, !tbaa !11
  %239 = load double, ptr %27, align 8, !tbaa !11
  %240 = fsub double %238, %239
  store double %240, ptr %22, align 8, !tbaa !11
  %241 = load double, ptr %22, align 8, !tbaa !11
  %242 = load double, ptr %22, align 8, !tbaa !11
  %243 = load double, ptr %23, align 8, !tbaa !11
  %244 = fneg double %241
  %245 = call double @llvm.fmuladd.f64(double %244, double %242, double %243)
  store double %245, ptr %23, align 8, !tbaa !11
  br label %246

246:                                              ; preds = %237, %227
  br label %247

247:                                              ; preds = %246, %226
  %248 = load ptr, ptr %15, align 8, !tbaa !5
  %249 = load i32, ptr %248, align 4, !tbaa !9
  %250 = load i32, ptr %14, align 4, !tbaa !9
  %251 = icmp ult i32 %249, %250
  br i1 %251, label %259, label %252

252:                                              ; preds = %247
  %253 = load ptr, ptr %13, align 8, !tbaa !5
  %254 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %253, i64 0
  %255 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %254, i32 0, i32 0
  %256 = load double, ptr %255, align 8, !tbaa !35
  %257 = load double, ptr %23, align 8, !tbaa !11
  %258 = fcmp ogt double %256, %257
  br i1 %258, label %259, label %282

259:                                              ; preds = %252, %247
  %260 = load ptr, ptr %10, align 8, !tbaa !5
  %261 = getelementptr inbounds %struct._VlKDForest, ptr %260, i32 0, i32 12
  %262 = load ptr, ptr %261, align 8, !tbaa !38
  %263 = load ptr, ptr %10, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct._VlKDForest, ptr %263, i32 0, i32 13
  %265 = load i32, ptr %264, align 8, !tbaa !39
  %266 = zext i32 %265 to i64
  %267 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %262, i64 %266
  store ptr %267, ptr %28, align 8, !tbaa !5
  %268 = load ptr, ptr %11, align 8, !tbaa !5
  %269 = load ptr, ptr %28, align 8, !tbaa !5
  %270 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %269, i32 0, i32 0
  store ptr %268, ptr %270, align 8, !tbaa !40
  %271 = load i32, ptr %21, align 4, !tbaa !9
  %272 = load ptr, ptr %28, align 8, !tbaa !5
  %273 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %272, i32 0, i32 1
  store i32 %271, ptr %273, align 8, !tbaa !42
  %274 = load double, ptr %23, align 8, !tbaa !11
  %275 = load ptr, ptr %28, align 8, !tbaa !5
  %276 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %275, i32 0, i32 2
  store double %274, ptr %276, align 8, !tbaa !43
  %277 = load ptr, ptr %10, align 8, !tbaa !5
  %278 = getelementptr inbounds %struct._VlKDForest, ptr %277, i32 0, i32 12
  %279 = load ptr, ptr %278, align 8, !tbaa !38
  %280 = load ptr, ptr %10, align 8, !tbaa !5
  %281 = getelementptr inbounds %struct._VlKDForest, ptr %280, i32 0, i32 13
  call void @vl_kdforest_search_heap_push(ptr noundef %279, ptr noundef %281)
  br label %282

282:                                              ; preds = %259, %252
  %283 = load ptr, ptr %10, align 8, !tbaa !5
  %284 = load ptr, ptr %11, align 8, !tbaa !5
  %285 = load i32, ptr %20, align 4, !tbaa !9
  %286 = load ptr, ptr %13, align 8, !tbaa !5
  %287 = load i32, ptr %14, align 4, !tbaa !9
  %288 = load ptr, ptr %15, align 8, !tbaa !5
  %289 = load double, ptr %16, align 8, !tbaa !11
  %290 = load ptr, ptr %17, align 8, !tbaa !5
  %291 = call i32 @vl_kdforest_query_recursively(ptr noundef %283, ptr noundef %284, i32 noundef %285, ptr noundef %286, i32 noundef %287, ptr noundef %288, double noundef %289, ptr noundef %290)
  store i32 %291, ptr %9, align 4
  store i32 1, ptr %33, align 4
  br label %292

292:                                              ; preds = %282, %194
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  %293 = load i32, ptr %9, align 4
  ret i32 %293

294:                                              ; preds = %188
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare double @vec_compare_function(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare void @vl_kdforest_neighbor_heap_push(ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare void @vl_kdforest_neighbor_heap_update(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: inlinehint nounwind uwtable
declare void @vl_kdforest_search_heap_push(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_VlKDTree", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24}
!15 = !{!16, !10, i64 12}
!16 = !{!"_VlKDTreeNode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !12, i64 16, !12, i64 24, !12, i64 32}
!17 = !{!16, !12, i64 24}
!18 = !{!16, !12, i64 16}
!19 = !{!16, !12, i64 32}
!20 = !{!21, !10, i64 224}
!21 = !{!"_VlKDForest", !10, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !7, i64 64, !10, i64 184, !10, i64 188, !6, i64 192, !10, i64 200, !10, i64 204, !6, i64 208, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228}
!22 = !{!16, !10, i64 4}
!23 = !{!16, !10, i64 8}
!24 = !{!21, !10, i64 216}
!25 = !{!21, !10, i64 220}
!26 = !{!14, !6, i64 16}
!27 = !{!28, !10, i64 0}
!28 = !{!"_VlKDTreeDataIndexEntry", !10, i64 0, !12, i64 8}
!29 = !{!21, !6, i64 208}
!30 = !{!21, !10, i64 204}
!31 = !{!21, !10, i64 0}
!32 = !{!21, !6, i64 24}
!33 = !{!34, !10, i64 8}
!34 = !{!"_VlKDForestNeighbor", !12, i64 0, !10, i64 8}
!35 = !{!34, !12, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!21, !6, i64 192}
!39 = !{!21, !10, i64 200}
!40 = !{!41, !6, i64 0}
!41 = !{!"_VlKDForestSearchState", !6, i64 0, !10, i64 8, !12, i64 16}
!42 = !{!41, !10, i64 8}
!43 = !{!41, !12, i64 16}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct._VlKDTreeNode = type { i32, i32, i32, i32, double, double, double }
%struct._VlKDTreeDataIndexEntry = type { i32, double }
%struct._VlKDForestNeighbor = type { double, i32 }
%struct._VlKDForestSearchState = type { ptr, i32, double }

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_kdforest_query_recursively(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, double noundef %6, ptr noundef %7) local_unnamed_addr #0 {
  %9 = getelementptr inbounds i8, ptr %0, i64 224
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = zext i32 %2 to i64
  %12 = getelementptr inbounds %struct._VlKDTreeNode, ptr %10, i64 %11
  %13 = getelementptr inbounds i8, ptr %12, i64 12
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %12, i64 16
  %16 = load <2 x double>, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %12, i64 32
  %18 = load double, ptr %17, align 8, !tbaa !15
  %19 = load i32, ptr %9, align 8, !tbaa !16
  %20 = add i32 %19, 1
  store i32 %20, ptr %9, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %12, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !18
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %tailrecurse._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %24 = getelementptr inbounds i8, ptr %0, i64 192
  %25 = getelementptr inbounds i8, ptr %0, i64 200
  br label %77

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %8
  %.tr115.lcssa = phi i32 [ %2, %8 ], [ %.0102, %tailrecurse ]
  %.lcssa121 = phi ptr [ %12, %8 ], [ %120, %tailrecurse ]
  %.lcssa = phi i32 [ %22, %8 ], [ %129, %tailrecurse ]
  %26 = getelementptr inbounds i8, ptr %.lcssa121, i64 8
  %27 = load i32, ptr %26, align 8, !tbaa !19
  %28 = xor i32 %27, -1
  %29 = getelementptr inbounds i8, ptr %0, i64 220
  %30 = icmp sgt i32 %.lcssa, %27
  br i1 %30, label %.lr.ph125, label %.critedge

.lr.ph125:                                        ; preds = %tailrecurse._crit_edge
  %31 = xor i32 %.lcssa, -1
  %32 = getelementptr inbounds i8, ptr %0, i64 216
  %33 = getelementptr inbounds i8, ptr %1, i64 16
  %34 = getelementptr inbounds i8, ptr %0, i64 208
  %35 = getelementptr inbounds i8, ptr %0, i64 204
  %36 = getelementptr inbounds i8, ptr %0, i64 24
  %37 = getelementptr inbounds i8, ptr %3, i64 8
  %38 = zext nneg i32 %31 to i64
  br label %39

39:                                               ; preds = %.lr.ph125, %74
  %indvars.iv = phi i64 [ %38, %.lr.ph125 ], [ %indvars.iv.next, %74 ]
  %40 = load i32, ptr %32, align 8, !tbaa !20
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %.critedge2, label %42

42:                                               ; preds = %39
  %43 = load i32, ptr %29, align 4, !tbaa !21
  %44 = icmp ult i32 %43, %40
  br i1 %44, label %.critedge2, label %.critedge

.critedge2:                                       ; preds = %39, %42
  %45 = load ptr, ptr %33, align 8, !tbaa !22
  %46 = getelementptr inbounds %struct._VlKDTreeDataIndexEntry, ptr %45, i64 %indvars.iv
  %47 = load i32, ptr %46, align 8, !tbaa !23
  %48 = load ptr, ptr %34, align 8, !tbaa !25
  %49 = sext i32 %47 to i64
  %50 = getelementptr inbounds i32, ptr %48, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !26
  %52 = load i32, ptr %35, align 4, !tbaa !27
  %53 = icmp eq i32 %51, %52
  br i1 %53, label %74, label %54

54:                                               ; preds = %.critedge2
  store i32 %52, ptr %50, align 4, !tbaa !26
  %55 = load i32, ptr %0, align 8, !tbaa !28
  %56 = load ptr, ptr %36, align 8, !tbaa !29
  %57 = mul i32 %55, %47
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  %60 = tail call double @vec_compare_function(i32 noundef %55, ptr noundef %7, ptr noundef %59)
  %61 = load i32, ptr %29, align 4, !tbaa !21
  %62 = add i32 %61, 1
  store i32 %62, ptr %29, align 4, !tbaa !21
  %63 = load i32, ptr %5, align 4, !tbaa !26
  %64 = icmp ult i32 %63, %4
  br i1 %64, label %65, label %69

65:                                               ; preds = %54
  %66 = zext i32 %63 to i64
  %67 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %3, i64 %66
  %68 = getelementptr inbounds i8, ptr %67, i64 8
  store i32 %47, ptr %68, align 8, !tbaa !30
  store double %60, ptr %67, align 8, !tbaa !32
  tail call void @vl_kdforest_neighbor_heap_push(ptr noundef %3, ptr noundef nonnull %5)
  br label %74

69:                                               ; preds = %54
  %70 = load double, ptr %3, align 8, !tbaa !32
  %71 = fcmp ogt double %70, %60
  br i1 %71, label %72, label %74

72:                                               ; preds = %69
  store i32 %47, ptr %37, align 8, !tbaa !30
  store double %60, ptr %3, align 8, !tbaa !32
  %73 = load i32, ptr %5, align 4, !tbaa !26
  tail call void @vl_kdforest_neighbor_heap_update(ptr noundef nonnull %3, i32 noundef %73, i32 noundef 0)
  br label %74

74:                                               ; preds = %65, %72, %69, %.critedge2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %75 = trunc nuw i64 %indvars.iv.next to i32
  %76 = icmp slt i32 %75, %28
  br i1 %76, label %39, label %.critedge, !llvm.loop !33

77:                                               ; preds = %.lr.ph, %tailrecurse
  %78 = phi i32 [ %20, %.lr.ph ], [ %127, %tailrecurse ]
  %79 = phi ptr [ %10, %.lr.ph ], [ %118, %tailrecurse ]
  %80 = phi i32 [ %22, %.lr.ph ], [ %129, %tailrecurse ]
  %.pn.in = phi i32 [ %14, %.lr.ph ], [ %122, %tailrecurse ]
  %81 = phi double [ %18, %.lr.ph ], [ %126, %tailrecurse ]
  %82 = phi ptr [ %12, %.lr.ph ], [ %120, %tailrecurse ]
  %83 = phi <2 x double> [ %16, %.lr.ph ], [ %124, %tailrecurse ]
  %.pn = zext i32 %.pn.in to i64
  %.in = getelementptr inbounds double, ptr %7, i64 %.pn
  %84 = load double, ptr %.in, align 8, !tbaa !14
  %85 = extractelement <2 x double> %83, i64 0
  %86 = fsub double %84, %85
  %87 = tail call double @llvm.fmuladd.f64(double %86, double %86, double %6)
  %88 = fcmp ugt double %84, %85
  %89 = getelementptr inbounds i8, ptr %82, i64 8
  %90 = load i32, ptr %89, align 8, !tbaa !19
  br i1 %88, label %98, label %91

91:                                               ; preds = %77
  %92 = extractelement <2 x double> %83, i64 1
  %93 = fcmp ugt double %84, %92
  br i1 %93, label %104, label %94

94:                                               ; preds = %91
  %95 = fsub double %84, %92
  %96 = fneg double %95
  %97 = tail call double @llvm.fmuladd.f64(double %96, double %95, double %87)
  br label %104

98:                                               ; preds = %77
  %99 = fcmp ogt double %84, %81
  br i1 %99, label %100, label %104

100:                                              ; preds = %98
  %101 = fsub double %84, %81
  %102 = fneg double %101
  %103 = tail call double @llvm.fmuladd.f64(double %102, double %101, double %87)
  br label %104

104:                                              ; preds = %98, %100, %91, %94
  %.0105 = phi double [ %97, %94 ], [ %87, %91 ], [ %103, %100 ], [ %87, %98 ]
  %.0104 = phi i32 [ %90, %94 ], [ %90, %91 ], [ %80, %100 ], [ %80, %98 ]
  %.0102 = phi i32 [ %80, %94 ], [ %80, %91 ], [ %90, %100 ], [ %90, %98 ]
  %105 = load i32, ptr %5, align 4, !tbaa !26
  %106 = icmp ult i32 %105, %4
  br i1 %106, label %110, label %107

107:                                              ; preds = %104
  %108 = load double, ptr %3, align 8, !tbaa !32
  %109 = fcmp ogt double %108, %.0105
  br i1 %109, label %110, label %tailrecurse

110:                                              ; preds = %107, %104
  %111 = load ptr, ptr %24, align 8, !tbaa !35
  %112 = load i32, ptr %25, align 8, !tbaa !36
  %113 = zext i32 %112 to i64
  %114 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %111, i64 %113
  store ptr %1, ptr %114, align 8, !tbaa !37
  %115 = getelementptr inbounds i8, ptr %114, i64 8
  store i32 %.0104, ptr %115, align 8, !tbaa !39
  %116 = getelementptr inbounds i8, ptr %114, i64 16
  store double %.0105, ptr %116, align 8, !tbaa !40
  tail call void @vl_kdforest_search_heap_push(ptr noundef %111, ptr noundef nonnull %25)
  %.pre = load ptr, ptr %1, align 8, !tbaa !5
  %.pre130 = load i32, ptr %9, align 8, !tbaa !16
  br label %tailrecurse

tailrecurse:                                      ; preds = %110, %107
  %117 = phi i32 [ %.pre130, %110 ], [ %78, %107 ]
  %118 = phi ptr [ %.pre, %110 ], [ %79, %107 ]
  %119 = zext i32 %.0102 to i64
  %120 = getelementptr inbounds %struct._VlKDTreeNode, ptr %118, i64 %119
  %121 = getelementptr inbounds i8, ptr %120, i64 12
  %122 = load i32, ptr %121, align 4, !tbaa !11
  %123 = getelementptr inbounds i8, ptr %120, i64 16
  %124 = load <2 x double>, ptr %123, align 8, !tbaa !14
  %125 = getelementptr inbounds i8, ptr %120, i64 32
  %126 = load double, ptr %125, align 8, !tbaa !15
  %127 = add i32 %117, 1
  store i32 %127, ptr %9, align 8, !tbaa !16
  %128 = getelementptr inbounds i8, ptr %120, i64 4
  %129 = load i32, ptr %128, align 4, !tbaa !18
  %130 = icmp slt i32 %129, 0
  br i1 %130, label %tailrecurse._crit_edge, label %77

.critedge:                                        ; preds = %74, %42, %tailrecurse._crit_edge
  ret i32 %.tr115.lcssa
}

; Function Attrs: inlinehint nounwind uwtable
declare double @vec_compare_function(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare void @vl_kdforest_neighbor_heap_push(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare void @vl_kdforest_neighbor_heap_update(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: inlinehint nounwind uwtable
declare void @vl_kdforest_search_heap_push(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_VlKDTree", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_VlKDTreeNode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !13, i64 24, !13, i64 32}
!13 = !{!"double", !8, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 32}
!16 = !{!17, !10, i64 224}
!17 = !{!"_VlKDForest", !10, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !8, i64 64, !10, i64 184, !10, i64 188, !7, i64 192, !10, i64 200, !10, i64 204, !7, i64 208, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228}
!18 = !{!12, !10, i64 4}
!19 = !{!12, !10, i64 8}
!20 = !{!17, !10, i64 216}
!21 = !{!17, !10, i64 220}
!22 = !{!6, !7, i64 16}
!23 = !{!24, !10, i64 0}
!24 = !{!"_VlKDTreeDataIndexEntry", !10, i64 0, !13, i64 8}
!25 = !{!17, !7, i64 208}
!26 = !{!10, !10, i64 0}
!27 = !{!17, !10, i64 204}
!28 = !{!17, !10, i64 0}
!29 = !{!17, !7, i64 24}
!30 = !{!31, !10, i64 8}
!31 = !{!"_VlKDForestNeighbor", !13, i64 0, !10, i64 8}
!32 = !{!31, !13, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = !{!17, !7, i64 192}
!36 = !{!17, !10, i64 200}
!37 = !{!38, !7, i64 0}
!38 = !{!"_VlKDForestSearchState", !7, i64 0, !10, i64 8, !13, i64 16}
!39 = !{!38, !10, i64 8}
!40 = !{!38, !13, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass