; 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._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._VlKDTree = type { ptr, i32, i32, ptr, i32 }
%struct._VlKDForestSearchState = type { ptr, i32, double }
%struct._VlKDForestNeighbor = type { double, i32 }

@.str.1 = external hidden unnamed_addr constant [98 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.vl_kdforest_query = external hidden unnamed_addr constant [85 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @vl_kdforest_query_recursively(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef) #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_kdforest_query(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #4 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._VlKDForest, ptr %20, i32 0, i32 16
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = icmp eq i32 %22, 0
  %24 = zext i1 %23 to i32
  store i32 %24, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !9
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %4
  br label %29

28:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 542, ptr noundef @__PRETTY_FUNCTION__.vl_kdforest_query) #8
  unreachable

29:                                               ; preds = %27
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = icmp ugt i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  br label %34

33:                                               ; preds = %29
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 543, ptr noundef @__PRETTY_FUNCTION__.vl_kdforest_query) #8
  unreachable

34:                                               ; preds = %32
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  br label %39

38:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 544, ptr noundef @__PRETTY_FUNCTION__.vl_kdforest_query) #8
  unreachable

39:                                               ; preds = %37
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._VlKDForest, ptr %40, i32 0, i32 14
  %42 = load i32, ptr %41, align 4, !tbaa !13
  %43 = add i32 %42, 1
  store i32 %43, ptr %41, align 4, !tbaa !13
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._VlKDForest, ptr %44, i32 0, i32 18
  store i32 0, ptr %45, align 8, !tbaa !14
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._VlKDForest, ptr %46, i32 0, i32 12
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = icmp ne ptr %48, null
  br i1 %49, label %130, label %50

50:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !9
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %69, %50
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._VlKDForest, ptr %53, i32 0, i32 7
  %55 = load i32, ptr %54, align 8, !tbaa !16
  %56 = icmp ult i32 %52, %55
  br i1 %56, label %57, label %72

57:                                               ; preds = %51
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._VlKDForest, ptr %58, i32 0, i32 6
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds ptr, ptr %60, i64 %62
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._VlKDTree, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 8, !tbaa !18
  %67 = load i32, ptr %14, align 4, !tbaa !9
  %68 = add i32 %67, %66
  store i32 %68, ptr %14, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %57
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %10, align 4, !tbaa !9
  br label %51, !llvm.loop !20

72:                                               ; preds = %51
  %73 = load i32, ptr %14, align 4, !tbaa !9
  %74 = zext i32 %73 to i64
  %75 = mul i64 24, %74
  %76 = call noalias ptr @malloc(i64 noundef %75) #9
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._VlKDForest, ptr %77, i32 0, i32 12
  store ptr %76, ptr %78, align 8, !tbaa !15
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._VlKDForest, ptr %79, i32 0, i32 4
  %81 = load i32, ptr %80, align 8, !tbaa !22
  %82 = zext i32 %81 to i64
  %83 = call noalias ptr @calloc(i64 noundef 4, i64 noundef %82) #10
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._VlKDForest, ptr %84, i32 0, i32 15
  store ptr %83, ptr %85, align 8, !tbaa !23
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %86

86:                                               ; preds = %126, %72
  %87 = load i32, ptr %10, align 4, !tbaa !9
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._VlKDForest, ptr %88, i32 0, i32 7
  %90 = load i32, ptr %89, align 8, !tbaa !16
  %91 = icmp ult i32 %87, %90
  br i1 %91, label %92, label %129

92:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._VlKDForest, ptr %93, i32 0, i32 0
  %95 = load i32, ptr %94, align 8, !tbaa !24
  %96 = zext i32 %95 to i64
  %97 = mul i64 16, %96
  %98 = call noalias ptr @malloc(i64 noundef %97) #9
  store ptr %98, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %99 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %99, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %100 = load ptr, ptr %16, align 8, !tbaa !5
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._VlKDForest, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 8, !tbaa !24
  %104 = mul i32 2, %103
  %105 = zext i32 %104 to i64
  %106 = getelementptr inbounds double, ptr %100, i64 %105
  store ptr %106, ptr %17, align 8, !tbaa !5
  br label %107

107:                                              ; preds = %111, %92
  %108 = load ptr, ptr %16, align 8, !tbaa !5
  %109 = load ptr, ptr %17, align 8, !tbaa !5
  %110 = icmp ult ptr %108, %109
  br i1 %110, label %111, label %116

111:                                              ; preds = %107
  %112 = load ptr, ptr %16, align 8, !tbaa !5
  %113 = getelementptr inbounds double, ptr %112, i32 1
  store ptr %113, ptr %16, align 8, !tbaa !5
  store double 0x43EFFFFFFFF01000, ptr %112, align 8, !tbaa !25
  %114 = load ptr, ptr %16, align 8, !tbaa !5
  %115 = getelementptr inbounds double, ptr %114, i32 1
  store ptr %115, ptr %16, align 8, !tbaa !5
  store double 0x41DFE00000000000, ptr %114, align 8, !tbaa !25
  br label %107, !llvm.loop !27

116:                                              ; preds = %107
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._VlKDForest, ptr %117, i32 0, i32 6
  %119 = load ptr, ptr %118, align 8, !tbaa !17
  %120 = load i32, ptr %10, align 4, !tbaa !9
  %121 = zext i32 %120 to i64
  %122 = getelementptr inbounds ptr, ptr %119, i64 %121
  %123 = load ptr, ptr %122, align 8, !tbaa !5
  %124 = load ptr, ptr %15, align 8, !tbaa !5
  call void @vl_kdtree_calc_bounds_recursively(ptr noundef %123, i32 noundef 0, ptr noundef %124)
  %125 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %125) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %126

126:                                              ; preds = %116
  %127 = load i32, ptr %10, align 4, !tbaa !9
  %128 = add i32 %127, 1
  store i32 %128, ptr %10, align 4, !tbaa !9
  br label %86, !llvm.loop !28

129:                                              ; preds = %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %130

130:                                              ; preds = %129, %39
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct._VlKDForest, ptr %131, i32 0, i32 17
  store i32 0, ptr %132, align 4, !tbaa !29
  %133 = load ptr, ptr %5, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct._VlKDForest, ptr %133, i32 0, i32 19
  store i32 0, ptr %134, align 4, !tbaa !30
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct._VlKDForest, ptr %135, i32 0, i32 13
  store i32 0, ptr %136, align 8, !tbaa !31
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %137

137:                                              ; preds = %170, %130
  %138 = load i32, ptr %10, align 4, !tbaa !9
  %139 = load ptr, ptr %5, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._VlKDForest, ptr %139, i32 0, i32 7
  %141 = load i32, ptr %140, align 8, !tbaa !16
  %142 = icmp ult i32 %138, %141
  br i1 %142, label %143, label %173

143:                                              ; preds = %137
  %144 = load ptr, ptr %5, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct._VlKDForest, ptr %144, i32 0, i32 12
  %146 = load ptr, ptr %145, align 8, !tbaa !15
  %147 = load ptr, ptr %5, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct._VlKDForest, ptr %147, i32 0, i32 13
  %149 = load i32, ptr %148, align 8, !tbaa !31
  %150 = zext i32 %149 to i64
  %151 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %146, i64 %150
  store ptr %151, ptr %12, align 8, !tbaa !5
  %152 = load ptr, ptr %5, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct._VlKDForest, ptr %152, i32 0, i32 6
  %154 = load ptr, ptr %153, align 8, !tbaa !17
  %155 = load i32, ptr %10, align 4, !tbaa !9
  %156 = zext i32 %155 to i64
  %157 = getelementptr inbounds ptr, ptr %154, i64 %156
  %158 = load ptr, ptr %157, align 8, !tbaa !5
  %159 = load ptr, ptr %12, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %159, i32 0, i32 0
  store ptr %158, ptr %160, align 8, !tbaa !32
  %161 = load ptr, ptr %12, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %161, i32 0, i32 1
  store i32 0, ptr %162, align 8, !tbaa !34
  %163 = load ptr, ptr %12, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %163, i32 0, i32 2
  store double 0.000000e+00, ptr %164, align 8, !tbaa !35
  %165 = load ptr, ptr %5, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct._VlKDForest, ptr %165, i32 0, i32 12
  %167 = load ptr, ptr %166, align 8, !tbaa !15
  %168 = load ptr, ptr %5, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct._VlKDForest, ptr %168, i32 0, i32 13
  call void @vl_kdforest_search_heap_push(ptr noundef %167, ptr noundef %169)
  br label %170

170:                                              ; preds = %143
  %171 = load i32, ptr %10, align 4, !tbaa !9
  %172 = add i32 %171, 1
  store i32 %172, ptr %10, align 4, !tbaa !9
  br label %137, !llvm.loop !36

173:                                              ; preds = %137
  br label %174

174:                                              ; preds = %239, %173
  %175 = load i32, ptr %11, align 4, !tbaa !9
  %176 = icmp ne i32 %175, 0
  br i1 %176, label %185, label %177

177:                                              ; preds = %174
  %178 = load ptr, ptr %5, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct._VlKDForest, ptr %178, i32 0, i32 17
  %180 = load i32, ptr %179, align 4, !tbaa !29
  %181 = load ptr, ptr %5, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct._VlKDForest, ptr %181, i32 0, i32 16
  %183 = load i32, ptr %182, align 8, !tbaa !11
  %184 = icmp ult i32 %180, %183
  br label %185

185:                                              ; preds = %177, %174
  %186 = phi i1 [ true, %174 ], [ %184, %177 ]
  br i1 %186, label %187, label %240

187:                                              ; preds = %185
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %188 = load ptr, ptr %5, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct._VlKDForest, ptr %188, i32 0, i32 13
  %190 = load i32, ptr %189, align 8, !tbaa !31
  %191 = icmp eq i32 %190, 0
  br i1 %191, label %192, label %193

192:                                              ; preds = %187
  store i32 14, ptr %19, align 4
  br label %237

193:                                              ; preds = %187
  %194 = load ptr, ptr %5, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct._VlKDForest, ptr %194, i32 0, i32 12
  %196 = load ptr, ptr %195, align 8, !tbaa !15
  %197 = load ptr, ptr %5, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct._VlKDForest, ptr %197, i32 0, i32 12
  %199 = load ptr, ptr %198, align 8, !tbaa !15
  %200 = load ptr, ptr %5, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct._VlKDForest, ptr %200, i32 0, i32 13
  %202 = call i32 @vl_kdforest_search_heap_pop(ptr noundef %199, ptr noundef %201)
  %203 = zext i32 %202 to i64
  %204 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %196, i64 %203
  store ptr %204, ptr %18, align 8, !tbaa !5
  %205 = load i32, ptr %13, align 4, !tbaa !9
  %206 = load i32, ptr %7, align 4, !tbaa !9
  %207 = icmp eq i32 %205, %206
  br i1 %207, label %208, label %222

208:                                              ; preds = %193
  %209 = load ptr, ptr %6, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %209, i64 0
  %211 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %210, i32 0, i32 0
  %212 = load double, ptr %211, align 8, !tbaa !37
  %213 = load ptr, ptr %18, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %213, i32 0, i32 2
  %215 = load double, ptr %214, align 8, !tbaa !35
  %216 = fcmp olt double %212, %215
  br i1 %216, label %217, label %222

217:                                              ; preds = %208
  %218 = load ptr, ptr %5, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct._VlKDForest, ptr %218, i32 0, i32 19
  %220 = load i32, ptr %219, align 4, !tbaa !30
  %221 = add i32 %220, 1
  store i32 %221, ptr %219, align 4, !tbaa !30
  store i32 14, ptr %19, align 4
  br label %237

222:                                              ; preds = %208, %193
  %223 = load ptr, ptr %5, align 8, !tbaa !5
  %224 = load ptr, ptr %18, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %224, i32 0, i32 0
  %226 = load ptr, ptr %225, align 8, !tbaa !32
  %227 = load ptr, ptr %18, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %227, i32 0, i32 1
  %229 = load i32, ptr %228, align 8, !tbaa !34
  %230 = load ptr, ptr %6, align 8, !tbaa !5
  %231 = load i32, ptr %7, align 4, !tbaa !9
  %232 = load ptr, ptr %18, align 8, !tbaa !5
  %233 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %232, i32 0, i32 2
  %234 = load double, ptr %233, align 8, !tbaa !35
  %235 = load ptr, ptr %8, align 8, !tbaa !5
  %236 = call i32 @vl_kdforest_query_recursively(ptr noundef %223, ptr noundef %226, i32 noundef %229, ptr noundef %230, i32 noundef %231, ptr noundef %13, double noundef %234, ptr noundef %235)
  store i32 0, ptr %19, align 4
  br label %237

237:                                              ; preds = %222, %217, %192
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  %238 = load i32, ptr %19, align 4
  switch i32 %238, label %271 [
    i32 0, label %239
    i32 14, label %240
  ]

239:                                              ; preds = %237
  br label %174, !llvm.loop !39

240:                                              ; preds = %237, %185
  %241 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %241, ptr %9, align 4, !tbaa !9
  br label %242

242:                                              ; preds = %257, %240
  %243 = load i32, ptr %9, align 4, !tbaa !9
  %244 = load i32, ptr %7, align 4, !tbaa !9
  %245 = icmp ult i32 %243, %244
  br i1 %245, label %246, label %260

246:                                              ; preds = %242
  %247 = load ptr, ptr %6, align 8, !tbaa !5
  %248 = load i32, ptr %9, align 4, !tbaa !9
  %249 = zext i32 %248 to i64
  %250 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %247, i64 %249
  %251 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %250, i32 0, i32 1
  store i32 -1, ptr %251, align 8, !tbaa !40
  %252 = load ptr, ptr %6, align 8, !tbaa !5
  %253 = load i32, ptr %9, align 4, !tbaa !9
  %254 = zext i32 %253 to i64
  %255 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %252, i64 %254
  %256 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %255, i32 0, i32 0
  store double 0x41DFF00000000000, ptr %256, align 8, !tbaa !37
  br label %257

257:                                              ; preds = %246
  %258 = load i32, ptr %9, align 4, !tbaa !9
  %259 = add i32 %258, 1
  store i32 %259, ptr %9, align 4, !tbaa !9
  br label %242, !llvm.loop !41

260:                                              ; preds = %242
  br label %261

261:                                              ; preds = %264, %260
  %262 = load i32, ptr %13, align 4, !tbaa !9
  %263 = icmp ne i32 %262, 0
  br i1 %263, label %264, label %267

264:                                              ; preds = %261
  %265 = load ptr, ptr %6, align 8, !tbaa !5
  %266 = call i32 @vl_kdforest_neighbor_heap_pop(ptr noundef %265, ptr noundef %13)
  br label %261, !llvm.loop !42

267:                                              ; preds = %261
  %268 = load ptr, ptr %5, align 8, !tbaa !5
  %269 = getelementptr inbounds %struct._VlKDForest, ptr %268, i32 0, i32 17
  %270 = load i32, ptr %269, align 4, !tbaa !29
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  ret i32 %270

271:                                              ; preds = %237
  unreachable
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #6

; Function Attrs: nounwind uwtable
declare hidden void @vl_kdtree_calc_bounds_recursively(ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare i32 @vl_kdforest_search_heap_pop(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare i32 @vl_kdforest_neighbor_heap_pop(ptr noundef, ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { noreturn nounwind "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 = { nounwind "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 #4 = { 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 #5 = { 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 #6 = { nounwind allocsize(0,1) "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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { nounwind allocsize(0,1) }

!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, !10, i64 216}
!12 = !{!"_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}
!13 = !{!12, !10, i64 204}
!14 = !{!12, !10, i64 224}
!15 = !{!12, !6, i64 192}
!16 = !{!12, !10, i64 56}
!17 = !{!12, !6, i64 48}
!18 = !{!19, !10, i64 8}
!19 = !{!"_VlKDTree", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !10, i64 32}
!23 = !{!12, !6, i64 208}
!24 = !{!12, !10, i64 0}
!25 = !{!26, !26, i64 0}
!26 = !{!"double", !7, i64 0}
!27 = distinct !{!27, !21}
!28 = distinct !{!28, !21}
!29 = !{!12, !10, i64 220}
!30 = !{!12, !10, i64 228}
!31 = !{!12, !10, i64 200}
!32 = !{!33, !6, i64 0}
!33 = !{!"_VlKDForestSearchState", !6, i64 0, !10, i64 8, !26, i64 16}
!34 = !{!33, !10, i64 8}
!35 = !{!33, !26, i64 16}
!36 = distinct !{!36, !21}
!37 = !{!38, !26, i64 0}
!38 = !{!"_VlKDForestNeighbor", !26, i64 0, !10, i64 8}
!39 = distinct !{!39, !21}
!40 = !{!38, !10, i64 8}
!41 = distinct !{!41, !21}
!42 = distinct !{!42, !21}


; 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._VlKDForestSearchState = type { ptr, i32, double }
%struct._VlKDForestNeighbor = type { double, i32 }

@.str.1 = external hidden unnamed_addr constant [98 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.vl_kdforest_query = external hidden unnamed_addr constant [85 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @vl_kdforest_query_recursively(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_kdforest_query(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #4 {
  %5 = alloca i32, align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 216
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i32 %7, 0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  store i32 0, ptr %5, align 4, !tbaa !11
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 542, ptr noundef nonnull @__PRETTY_FUNCTION__.vl_kdforest_query) #9
  unreachable

10:                                               ; preds = %4
  %.not81 = icmp eq i32 %2, 0
  br i1 %.not81, label %11, label %12

11:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 543, ptr noundef nonnull @__PRETTY_FUNCTION__.vl_kdforest_query) #9
  unreachable

12:                                               ; preds = %10
  %.not82 = icmp eq ptr %3, null
  br i1 %.not82, label %13, label %14

13:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 544, ptr noundef nonnull @__PRETTY_FUNCTION__.vl_kdforest_query) #9
  unreachable

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %0, i64 204
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = add i32 %16, 1
  store i32 %17, ptr %15, align 4, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %0, i64 224
  store i32 0, ptr %18, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %0, i64 192
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %.not83 = icmp eq ptr %20, null
  %21 = getelementptr inbounds i8, ptr %0, i64 56
  %22 = load i32, ptr %21, align 8, !tbaa !15
  br i1 %.not83, label %.preheader88, label %.loopexit

.preheader88:                                     ; preds = %14
  %.not106 = icmp eq i32 %22, 0
  br i1 %.not106, label %.loopexit.thread.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader88
  %23 = getelementptr inbounds i8, ptr %0, i64 48
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %wide.trip.count = zext i32 %22 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %25 = icmp ult i32 %22, 4
  br i1 %25, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %26

26:                                               ; preds = %26, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %26 ]
  %.07789 = phi i32 [ 0, %.lr.ph.new ], [ %46, %26 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %26 ]
  %27 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = load i32, ptr %29, align 8, !tbaa !18
  %31 = add i32 %30, %.07789
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %32 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv.next
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = load i32, ptr %34, align 8, !tbaa !18
  %36 = add i32 %35, %31
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %37 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv.next.1
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds i8, ptr %38, i64 8
  %40 = load i32, ptr %39, align 8, !tbaa !18
  %41 = add i32 %40, %36
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %42 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv.next.2
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = getelementptr inbounds i8, ptr %43, i64 8
  %45 = load i32, ptr %44, align 8, !tbaa !18
  %46 = add i32 %45, %41
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %26, !llvm.loop !20

._crit_edge.loopexit.unr-lcssa:                   ; preds = %26, %.lr.ph
  %.lcssa131.ph = phi i32 [ poison, %.lr.ph ], [ %46, %26 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %26 ]
  %.07789.unr = phi i32 [ 0, %.lr.ph ], [ %46, %26 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.07789.epil = phi i32 [ %51, %.epil.preheader ], [ %.07789.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %47 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv.epil
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = getelementptr inbounds i8, ptr %48, i64 8
  %50 = load i32, ptr %49, align 8, !tbaa !18
  %51 = add i32 %50, %.07789.epil
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.loopexit, label %.epil.preheader, !llvm.loop !22

._crit_edge.loopexit:                             ; preds = %.epil.preheader, %._crit_edge.loopexit.unr-lcssa
  %.lcssa131 = phi i32 [ %.lcssa131.ph, %._crit_edge.loopexit.unr-lcssa ], [ %51, %.epil.preheader ]
  %52 = zext i32 %.lcssa131 to i64
  %53 = mul nuw nsw i64 %52, 24
  %54 = tail call noalias ptr @malloc(i64 noundef %53) #10
  store ptr %54, ptr %19, align 8, !tbaa !14
  %55 = getelementptr inbounds i8, ptr %0, i64 32
  %56 = load i32, ptr %55, align 8, !tbaa !24
  %57 = zext i32 %56 to i64
  %58 = tail call noalias ptr @calloc(i64 noundef 4, i64 noundef %57) #11
  %59 = getelementptr inbounds i8, ptr %0, i64 208
  store ptr %58, ptr %59, align 8, !tbaa !25
  br i1 %.not106, label %.loopexit.thread, label %.lr.ph97

.loopexit.thread.critedge:                        ; preds = %.preheader88
  %60 = tail call noalias ptr @malloc(i64 noundef 0) #10
  store ptr %60, ptr %19, align 8, !tbaa !14
  %61 = getelementptr inbounds i8, ptr %0, i64 32
  %62 = load i32, ptr %61, align 8, !tbaa !24
  %63 = zext i32 %62 to i64
  %64 = tail call noalias ptr @calloc(i64 noundef 4, i64 noundef %63) #11
  %65 = getelementptr inbounds i8, ptr %0, i64 208
  store ptr %64, ptr %65, align 8, !tbaa !25
  br label %.loopexit.thread

.loopexit.thread:                                 ; preds = %.loopexit.thread.critedge, %._crit_edge.loopexit
  %66 = getelementptr inbounds i8, ptr %0, i64 220
  store i32 0, ptr %66, align 4, !tbaa !26
  %67 = getelementptr inbounds i8, ptr %0, i64 228
  store i32 0, ptr %67, align 4, !tbaa !27
  %68 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 0, ptr %68, align 8, !tbaa !28
  br label %.preheader87

.lr.ph97:                                         ; preds = %._crit_edge.loopexit
  %69 = getelementptr inbounds i8, ptr %0, i64 48
  br label %70

70:                                               ; preds = %.lr.ph97, %._crit_edge94
  %indvars.iv111 = phi i64 [ 0, %.lr.ph97 ], [ %indvars.iv.next112, %._crit_edge94 ]
  %71 = load i32, ptr %0, align 8, !tbaa !29
  %72 = zext i32 %71 to i64
  %73 = shl nuw nsw i64 %72, 4
  %74 = tail call noalias ptr @malloc(i64 noundef %73) #10
  %75 = shl i32 %71, 1
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %74, i64 %76
  %.not108 = icmp eq i32 %75, 0
  br i1 %.not108, label %._crit_edge94, label %.lr.ph93.preheader

.lr.ph93.preheader:                               ; preds = %70
  %78 = ptrtoint ptr %74 to i64
  %79 = shl nuw nsw i64 %76, 3
  %80 = add i64 %79, %78
  %81 = add i64 %78, 16
  %umax = tail call i64 @llvm.umax.i64(i64 %80, i64 %81)
  %82 = xor i64 %78, -1
  %83 = add i64 %umax, %82
  %84 = lshr i64 %83, 4
  %85 = add nuw nsw i64 %84, 1
  %min.iters.check = icmp ult i64 %83, 48
  br i1 %min.iters.check, label %.lr.ph93.preheader130, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph93.preheader
  %n.vec = and i64 %85, 2305843009213693948
  %86 = shl i64 %n.vec, 4
  %ind.end = getelementptr i8, ptr %74, i64 %86
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 4
  %87 = or disjoint i64 %offset.idx, 32
  %next.gep = getelementptr i8, ptr %74, i64 %offset.idx
  %next.gep129 = getelementptr i8, ptr %74, i64 %87
  store <4 x double> <double 0x43EFFFFFFFF01000, double 0x41DFE00000000000, double 0x43EFFFFFFFF01000, double 0x41DFE00000000000>, ptr %next.gep, align 8, !tbaa !30
  store <4 x double> <double 0x43EFFFFFFFF01000, double 0x41DFE00000000000, double 0x43EFFFFFFFF01000, double 0x41DFE00000000000>, ptr %next.gep129, align 8, !tbaa !30
  %index.next = add nuw i64 %index, 4
  %88 = icmp eq i64 %index.next, %n.vec
  br i1 %88, label %middle.block, label %vector.body, !llvm.loop !32

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %85, %n.vec
  br i1 %cmp.n, label %._crit_edge94, label %.lr.ph93.preheader130

.lr.ph93.preheader130:                            ; preds = %middle.block, %.lr.ph93.preheader
  %.07691.ph = phi ptr [ %74, %.lr.ph93.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph93

.lr.ph93:                                         ; preds = %.lr.ph93.preheader130, %.lr.ph93
  %.07691 = phi ptr [ %89, %.lr.ph93 ], [ %.07691.ph, %.lr.ph93.preheader130 ]
  %89 = getelementptr inbounds i8, ptr %.07691, i64 16
  store <2 x double> <double 0x43EFFFFFFFF01000, double 0x41DFE00000000000>, ptr %.07691, align 8, !tbaa !30
  %90 = icmp ult ptr %89, %77
  br i1 %90, label %.lr.ph93, label %._crit_edge94, !llvm.loop !35

._crit_edge94:                                    ; preds = %.lr.ph93, %middle.block, %70
  %91 = load ptr, ptr %69, align 8, !tbaa !16
  %92 = getelementptr inbounds ptr, ptr %91, i64 %indvars.iv111
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  tail call void @vl_kdtree_calc_bounds_recursively(ptr noundef %93, i32 noundef 0, ptr noundef %74)
  tail call void @free(ptr noundef %74) #8
  %indvars.iv.next112 = add nuw nsw i64 %indvars.iv111, 1
  %94 = load i32, ptr %21, align 8, !tbaa !15
  %95 = zext i32 %94 to i64
  %96 = icmp ult i64 %indvars.iv.next112, %95
  br i1 %96, label %70, label %.loopexit, !llvm.loop !36

.loopexit:                                        ; preds = %._crit_edge94, %14
  %97 = phi i32 [ %22, %14 ], [ %94, %._crit_edge94 ]
  %98 = getelementptr inbounds i8, ptr %0, i64 220
  store i32 0, ptr %98, align 4, !tbaa !26
  %99 = getelementptr inbounds i8, ptr %0, i64 228
  store i32 0, ptr %99, align 4, !tbaa !27
  %100 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 0, ptr %100, align 8, !tbaa !28
  %101 = getelementptr inbounds i8, ptr %0, i64 56
  %.not109 = icmp eq i32 %97, 0
  br i1 %.not109, label %.preheader87, label %.lr.ph100

.lr.ph100:                                        ; preds = %.loopexit
  %102 = getelementptr inbounds i8, ptr %0, i64 48
  br label %106

.preheader87:                                     ; preds = %106, %.loopexit.thread, %.loopexit
  %103 = phi ptr [ %68, %.loopexit.thread ], [ %100, %.loopexit ], [ %100, %106 ]
  %104 = phi ptr [ %67, %.loopexit.thread ], [ %99, %.loopexit ], [ %99, %106 ]
  %105 = phi ptr [ %66, %.loopexit.thread ], [ %98, %.loopexit ], [ %98, %106 ]
  br label %119

106:                                              ; preds = %.lr.ph100, %106
  %indvars.iv114 = phi i64 [ 0, %.lr.ph100 ], [ %indvars.iv.next115, %106 ]
  %107 = load ptr, ptr %19, align 8, !tbaa !14
  %108 = load i32, ptr %100, align 8, !tbaa !28
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %107, i64 %109
  %111 = load ptr, ptr %102, align 8, !tbaa !16
  %112 = getelementptr inbounds ptr, ptr %111, i64 %indvars.iv114
  %113 = load ptr, ptr %112, align 8, !tbaa !17
  store ptr %113, ptr %110, align 8, !tbaa !37
  %114 = getelementptr inbounds i8, ptr %110, i64 8
  store i32 0, ptr %114, align 8, !tbaa !39
  %115 = getelementptr inbounds i8, ptr %110, i64 16
  store double 0.000000e+00, ptr %115, align 8, !tbaa !40
  tail call void @vl_kdforest_search_heap_push(ptr noundef %107, ptr noundef nonnull %100)
  %indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
  %116 = load i32, ptr %101, align 8, !tbaa !15
  %117 = zext i32 %116 to i64
  %118 = icmp ult i64 %indvars.iv.next115, %117
  br i1 %118, label %106, label %.preheader87, !llvm.loop !41

119:                                              ; preds = %.preheader87, %140
  br i1 %8, label %.critedge, label %120

120:                                              ; preds = %119
  %121 = load i32, ptr %105, align 4, !tbaa !26
  %122 = load i32, ptr %6, align 8, !tbaa !5
  %123 = icmp ult i32 %121, %122
  br i1 %123, label %.critedge, label %.thread

.critedge:                                        ; preds = %119, %120
  %124 = load i32, ptr %103, align 8, !tbaa !28
  %125 = icmp eq i32 %124, 0
  br i1 %125, label %.thread, label %126

126:                                              ; preds = %.critedge
  %127 = load ptr, ptr %19, align 8, !tbaa !14
  %128 = call i32 @vl_kdforest_search_heap_pop(ptr noundef %127, ptr noundef nonnull %103)
  %129 = zext i32 %128 to i64
  %130 = getelementptr inbounds %struct._VlKDForestSearchState, ptr %127, i64 %129
  %131 = load i32, ptr %5, align 4, !tbaa !11
  %132 = icmp eq i32 %131, %2
  br i1 %132, label %133, label %._crit_edge122

._crit_edge122:                                   ; preds = %126
  %.phi.trans.insert123 = getelementptr inbounds i8, ptr %130, i64 16
  %.pre124 = load double, ptr %.phi.trans.insert123, align 8, !tbaa !40
  br label %140

133:                                              ; preds = %126
  %134 = load double, ptr %1, align 8, !tbaa !42
  %135 = getelementptr inbounds i8, ptr %130, i64 16
  %136 = load double, ptr %135, align 8, !tbaa !40
  %137 = fcmp olt double %134, %136
  br i1 %137, label %.thread.thread, label %140

.thread.thread:                                   ; preds = %133
  %138 = load i32, ptr %104, align 4, !tbaa !27
  %139 = add i32 %138, 1
  store i32 %139, ptr %104, align 4, !tbaa !27
  br label %.preheader

140:                                              ; preds = %._crit_edge122, %133
  %141 = phi double [ %.pre124, %._crit_edge122 ], [ %136, %133 ]
  %142 = load ptr, ptr %130, align 8, !tbaa !37
  %143 = getelementptr inbounds i8, ptr %130, i64 8
  %144 = load i32, ptr %143, align 8, !tbaa !39
  %145 = call i32 @vl_kdforest_query_recursively(ptr noundef nonnull %0, ptr noundef %142, i32 noundef %144, ptr noundef nonnull %1, i32 noundef %2, ptr noundef nonnull %5, double noundef %141, ptr noundef nonnull %3)
  br label %119

.thread:                                          ; preds = %.critedge, %120
  %.pre125 = load i32, ptr %5, align 4, !tbaa !11
  %146 = icmp ult i32 %.pre125, %2
  br i1 %146, label %.lr.ph102.preheader, label %.preheader

.lr.ph102.preheader:                              ; preds = %.thread
  %147 = zext i32 %.pre125 to i64
  %wide.trip.count120 = zext i32 %2 to i64
  %148 = sub nsw i64 %wide.trip.count120, %147
  %xtraiter133 = and i64 %148, 3
  %lcmp.mod134.not = icmp eq i64 %xtraiter133, 0
  br i1 %lcmp.mod134.not, label %.lr.ph102.prol.loopexit, label %.lr.ph102.prol

.lr.ph102.prol:                                   ; preds = %.lr.ph102.preheader, %.lr.ph102.prol
  %indvars.iv117.prol = phi i64 [ %indvars.iv.next118.prol, %.lr.ph102.prol ], [ %147, %.lr.ph102.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph102.prol ], [ 0, %.lr.ph102.preheader ]
  %149 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %1, i64 %indvars.iv117.prol
  %150 = getelementptr inbounds i8, ptr %149, i64 8
  store i32 -1, ptr %150, align 8, !tbaa !44
  store double 0x41DFF00000000000, ptr %149, align 8, !tbaa !42
  %indvars.iv.next118.prol = add nuw nsw i64 %indvars.iv117.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter133
  br i1 %prol.iter.cmp.not, label %.lr.ph102.prol.loopexit, label %.lr.ph102.prol, !llvm.loop !45

.lr.ph102.prol.loopexit:                          ; preds = %.lr.ph102.prol, %.lr.ph102.preheader
  %indvars.iv117.unr = phi i64 [ %147, %.lr.ph102.preheader ], [ %indvars.iv.next118.prol, %.lr.ph102.prol ]
  %151 = sub nsw i64 %147, %wide.trip.count120
  %152 = icmp ugt i64 %151, -4
  br i1 %152, label %.preheader, label %.lr.ph102

.preheader:                                       ; preds = %.lr.ph102.prol.loopexit, %.lr.ph102, %.thread.thread, %.thread
  %153 = phi i32 [ 1, %.thread.thread ], [ %.pre125, %.thread ], [ %.pre125, %.lr.ph102 ], [ %.pre125, %.lr.ph102.prol.loopexit ]
  %.not84103 = icmp eq i32 %153, 0
  br i1 %.not84103, label %._crit_edge105, label %.lr.ph104

.lr.ph102:                                        ; preds = %.lr.ph102.prol.loopexit, %.lr.ph102
  %indvars.iv117 = phi i64 [ %indvars.iv.next118.3, %.lr.ph102 ], [ %indvars.iv117.unr, %.lr.ph102.prol.loopexit ]
  %154 = getelementptr inbounds %struct._VlKDForestNeighbor, ptr %1, i64 %indvars.iv117
  %155 = getelementptr inbounds i8, ptr %154, i64 8
  store i32 -1, ptr %155, align 8, !tbaa !44
  store double 0x41DFF00000000000, ptr %154, align 8, !tbaa !42
  %156 = getelementptr %struct._VlKDForestNeighbor, ptr %1, i64 %indvars.iv117
  %157 = getelementptr i8, ptr %156, i64 16
  %158 = getelementptr i8, ptr %156, i64 24
  store i32 -1, ptr %158, align 8, !tbaa !44
  store double 0x41DFF00000000000, ptr %157, align 8, !tbaa !42
  %159 = getelementptr %struct._VlKDForestNeighbor, ptr %1, i64 %indvars.iv117
  %160 = getelementptr i8, ptr %159, i64 32
  %161 = getelementptr i8, ptr %159, i64 40
  store i32 -1, ptr %161, align 8, !tbaa !44
  store double 0x41DFF00000000000, ptr %160, align 8, !tbaa !42
  %162 = getelementptr %struct._VlKDForestNeighbor, ptr %1, i64 %indvars.iv117
  %163 = getelementptr i8, ptr %162, i64 48
  %164 = getelementptr i8, ptr %162, i64 56
  store i32 -1, ptr %164, align 8, !tbaa !44
  store double 0x41DFF00000000000, ptr %163, align 8, !tbaa !42
  %indvars.iv.next118.3 = add nuw nsw i64 %indvars.iv117, 4
  %exitcond121.not.3 = icmp eq i64 %indvars.iv.next118.3, %wide.trip.count120
  br i1 %exitcond121.not.3, label %.preheader, label %.lr.ph102, !llvm.loop !46

.lr.ph104:                                        ; preds = %.preheader, %.lr.ph104
  %165 = call i32 @vl_kdforest_neighbor_heap_pop(ptr noundef nonnull %1, ptr noundef nonnull %5)
  %166 = load i32, ptr %5, align 4, !tbaa !11
  %.not84 = icmp eq i32 %166, 0
  br i1 %.not84, label %._crit_edge105, label %.lr.ph104, !llvm.loop !47

._crit_edge105:                                   ; preds = %.lr.ph104, %.preheader
  %167 = load i32, ptr %105, align 4, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  ret i32 %167
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare hidden void @vl_kdtree_calc_bounds_recursively(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare i32 @vl_kdforest_search_heap_pop(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: inlinehint nounwind uwtable
declare i32 @vl_kdforest_neighbor_heap_pop(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #7

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { noreturn nounwind "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { 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 #5 = { 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 #6 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { nounwind allocsize(0,1) }

!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 216}
!6 = !{!"_VlKDForest", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !7, i64 60, !8, i64 64, !7, i64 184, !7, i64 188, !10, i64 192, !7, i64 200, !7, i64 204, !10, i64 208, !7, i64 216, !7, i64 220, !7, i64 224, !7, i64 228}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 204}
!13 = !{!6, !7, i64 224}
!14 = !{!6, !10, i64 192}
!15 = !{!6, !7, i64 56}
!16 = !{!6, !10, i64 48}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !7, i64 8}
!19 = !{!"_VlKDTree", !10, i64 0, !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.unroll.disable"}
!24 = !{!6, !7, i64 32}
!25 = !{!6, !10, i64 208}
!26 = !{!6, !7, i64 220}
!27 = !{!6, !7, i64 228}
!28 = !{!6, !7, i64 200}
!29 = !{!6, !7, i64 0}
!30 = !{!31, !31, i64 0}
!31 = !{!"double", !8, i64 0}
!32 = distinct !{!32, !21, !33, !34}
!33 = !{!"llvm.loop.isvectorized", i32 1}
!34 = !{!"llvm.loop.unroll.runtime.disable"}
!35 = distinct !{!35, !21, !34, !33}
!36 = distinct !{!36, !21}
!37 = !{!38, !10, i64 0}
!38 = !{!"_VlKDForestSearchState", !10, i64 0, !7, i64 8, !31, i64 16}
!39 = !{!38, !7, i64 8}
!40 = !{!38, !31, i64 16}
!41 = distinct !{!41, !21}
!42 = !{!43, !31, i64 0}
!43 = !{!"_VlKDForestNeighbor", !31, i64 0, !7, i64 8}
!44 = !{!43, !7, i64 8}
!45 = distinct !{!45, !23}
!46 = distinct !{!46, !21}
!47 = distinct !{!47, !21}


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