; LLVM IR from ryanlayer/giggle :: src (giggle_index)

; 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.cache_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cache_handler = type { ptr, ptr, ptr }
%struct.bpt_node = type { ptr }
%struct.leaf_data = type { i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.leaf_data_result = type { i64, ptr, ptr }

@cache = external dso_local global %struct.cache_def, align 8
@bpt_node_cache_handler = external dso_local global %struct.cache_handler, align 8
@.str.9 = external hidden unnamed_addr constant [60 x i8], align 1
@ORDER = external dso_local global i32, align 4
@leaf_data_cache_handler = external dso_local global %struct.cache_handler, align 8
@.str.10 = external hidden unnamed_addr constant [80 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: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @giggle_collect_intersection_data_in_block(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) #3 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca ptr, align 8
  %24 = alloca i32, align 4
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  %27 = alloca ptr, align 8
  %28 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = load i32, ptr %11, align 4, !tbaa !5
  %33 = load i32, ptr %12, align 4, !tbaa !5
  %34 = call i32 @giggle_leaf_data_get_intersection_size(i32 noundef %29, i32 noundef %30, i32 noundef %31, i32 noundef %32, i32 noundef %33)
  store i32 %34, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %35 = load i32, ptr %14, align 4, !tbaa !5
  %36 = zext i32 %35 to i64
  %37 = call noalias ptr @calloc(i64 noundef %36, i64 noundef 8) #8
  store ptr %37, ptr %15, align 8, !tbaa !9
  %38 = load ptr, ptr %15, align 8, !tbaa !9
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %6
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.9) #9
  unreachable

41:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %42 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !11
  %43 = load i32, ptr %12, align 4, !tbaa !5
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = sub i32 %44, 1
  %46 = call ptr %42(i32 noundef %43, i32 noundef %45, ptr noundef @bpt_node_cache_handler)
  store ptr %46, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %47 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !11
  %48 = load i32, ptr %12, align 4, !tbaa !5
  %49 = load ptr, ptr %16, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.bpt_node, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = load i32, ptr @ORDER, align 4, !tbaa !5
  %53 = add i32 6, %52
  %54 = add i32 %53, 1
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %51, i64 %55
  %57 = getelementptr inbounds i32, ptr %56, i64 0
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = sub i32 %58, 1
  %60 = call ptr %47(i32 noundef %48, i32 noundef %59, ptr noundef @leaf_data_cache_handler)
  store ptr %60, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %61 = load ptr, ptr %17, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.leaf_data, ptr %61, i32 0, i32 0
  %63 = load i64, ptr %62, align 8, !tbaa !15
  %64 = load ptr, ptr %17, align 8, !tbaa !9
  %65 = load ptr, ptr %16, align 8, !tbaa !9
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = call i32 @leaf_data_starts_end(ptr noundef %64, ptr noundef %65, i32 noundef %66)
  %68 = zext i32 %67 to i64
  %69 = add i64 %63, %68
  %70 = load ptr, ptr %17, align 8, !tbaa !9
  %71 = load ptr, ptr %16, align 8, !tbaa !9
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = call i32 @leaf_data_ends_end(ptr noundef %70, ptr noundef %71, i32 noundef %72)
  %74 = zext i32 %73 to i64
  %75 = add i64 %69, %74
  %76 = trunc i64 %75 to i32
  store i32 %76, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %77 = load i32, ptr %18, align 4, !tbaa !5
  %78 = zext i32 %77 to i64
  %79 = call noalias ptr @calloc(i64 noundef %78, i64 noundef 8) #8
  store ptr %79, ptr %19, align 8, !tbaa !9
  %80 = load ptr, ptr %19, align 8, !tbaa !9
  %81 = icmp eq ptr %80, null
  br i1 %81, label %82, label %83

82:                                               ; preds = %41
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.9) #9
  unreachable

83:                                               ; preds = %41
  %84 = load ptr, ptr %19, align 8, !tbaa !9
  %85 = load ptr, ptr %17, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.leaf_data, ptr %85, i32 0, i32 5
  %87 = load ptr, ptr %86, align 8, !tbaa !18
  %88 = load ptr, ptr %17, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.leaf_data, ptr %88, i32 0, i32 0
  %90 = load i64, ptr %89, align 8, !tbaa !15
  %91 = mul i64 %90, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %84, ptr align 8 %87, i64 %91, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  %92 = load ptr, ptr %19, align 8, !tbaa !9
  %93 = load ptr, ptr %17, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.leaf_data, ptr %93, i32 0, i32 0
  %95 = load i64, ptr %94, align 8, !tbaa !15
  %96 = getelementptr inbounds i64, ptr %92, i64 %95
  %97 = load ptr, ptr %17, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.leaf_data, ptr %97, i32 0, i32 6
  %99 = load ptr, ptr %98, align 8, !tbaa !19
  %100 = load ptr, ptr %17, align 8, !tbaa !9
  %101 = load ptr, ptr %16, align 8, !tbaa !9
  %102 = load i32, ptr %9, align 4, !tbaa !5
  %103 = call i32 @leaf_data_starts_end(ptr noundef %100, ptr noundef %101, i32 noundef %102)
  %104 = zext i32 %103 to i64
  %105 = mul i64 %104, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %96, ptr align 8 %99, i64 %105, i1 false)
  %106 = load ptr, ptr %19, align 8, !tbaa !9
  %107 = load ptr, ptr %17, align 8, !tbaa !9
  %108 = getelementptr inbounds %struct.leaf_data, ptr %107, i32 0, i32 0
  %109 = load i64, ptr %108, align 8, !tbaa !15
  %110 = getelementptr inbounds i64, ptr %106, i64 %109
  %111 = load ptr, ptr %17, align 8, !tbaa !9
  %112 = load ptr, ptr %16, align 8, !tbaa !9
  %113 = load i32, ptr %9, align 4, !tbaa !5
  %114 = call i32 @leaf_data_starts_end(ptr noundef %111, ptr noundef %112, i32 noundef %113)
  %115 = zext i32 %114 to i64
  %116 = getelementptr inbounds i64, ptr %110, i64 %115
  %117 = load ptr, ptr %17, align 8, !tbaa !9
  %118 = getelementptr inbounds %struct.leaf_data, ptr %117, i32 0, i32 7
  %119 = load ptr, ptr %118, align 8, !tbaa !20
  %120 = load ptr, ptr %17, align 8, !tbaa !9
  %121 = load ptr, ptr %16, align 8, !tbaa !9
  %122 = load i32, ptr %9, align 4, !tbaa !5
  %123 = call i32 @leaf_data_ends_end(ptr noundef %120, ptr noundef %121, i32 noundef %122)
  %124 = zext i32 %123 to i64
  %125 = mul i64 %124, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %116, ptr align 8 %119, i64 %125, i1 false)
  %126 = load ptr, ptr %19, align 8, !tbaa !9
  %127 = load i32, ptr %18, align 4, !tbaa !5
  %128 = zext i32 %127 to i64
  call void @qsort(ptr noundef %126, i64 noundef %128, i64 noundef 8, ptr noundef @uint64_t_cmp)
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 0, ptr %22, align 4, !tbaa !5
  store i32 0, ptr %21, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %173, %83
  %130 = load i32, ptr %21, align 4, !tbaa !5
  %131 = load i32, ptr %18, align 4, !tbaa !5
  %132 = icmp ult i32 %130, %131
  br i1 %132, label %133, label %176

133:                                              ; preds = %129
  %134 = load i32, ptr %21, align 4, !tbaa !5
  %135 = add i32 %134, 1
  %136 = load i32, ptr %18, align 4, !tbaa !5
  %137 = icmp eq i32 %135, %136
  br i1 %137, label %151, label %138

138:                                              ; preds = %133
  %139 = load ptr, ptr %19, align 8, !tbaa !9
  %140 = load i32, ptr %21, align 4, !tbaa !5
  %141 = zext i32 %140 to i64
  %142 = getelementptr inbounds i64, ptr %139, i64 %141
  %143 = load i64, ptr %142, align 8, !tbaa !21
  %144 = load ptr, ptr %19, align 8, !tbaa !9
  %145 = load i32, ptr %21, align 4, !tbaa !5
  %146 = add i32 %145, 1
  %147 = zext i32 %146 to i64
  %148 = getelementptr inbounds i64, ptr %144, i64 %147
  %149 = load i64, ptr %148, align 8, !tbaa !21
  %150 = icmp ne i64 %143, %149
  br i1 %150, label %151, label %169

151:                                              ; preds = %138, %133
  %152 = load ptr, ptr %19, align 8, !tbaa !9
  %153 = load i32, ptr %21, align 4, !tbaa !5
  %154 = zext i32 %153 to i64
  %155 = getelementptr inbounds i64, ptr %152, i64 %154
  %156 = load i64, ptr %155, align 8, !tbaa !21
  %157 = load ptr, ptr %15, align 8, !tbaa !9
  %158 = load i32, ptr %22, align 4, !tbaa !5
  %159 = add i32 %158, 1
  store i32 %159, ptr %22, align 4, !tbaa !5
  %160 = zext i32 %158 to i64
  %161 = getelementptr inbounds i64, ptr %157, i64 %160
  store i64 %156, ptr %161, align 8, !tbaa !21
  %162 = load i32, ptr %22, align 4, !tbaa !5
  %163 = load i32, ptr %14, align 4, !tbaa !5
  %164 = icmp ugt i32 %162, %163
  br i1 %164, label %165, label %168

165:                                              ; preds = %151
  %166 = load ptr, ptr %16, align 8, !tbaa !9
  call void @bpt_print_node(ptr noundef %166)
  %167 = load ptr, ptr %17, align 8, !tbaa !9
  call void @leaf_data_print(ptr noundef %167)
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.10) #9
  unreachable

168:                                              ; preds = %151
  br label %172

169:                                              ; preds = %138
  %170 = load i32, ptr %21, align 4, !tbaa !5
  %171 = add i32 %170, 1
  store i32 %171, ptr %21, align 4, !tbaa !5
  br label %172

172:                                              ; preds = %169, %168
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %21, align 4, !tbaa !5
  %175 = add i32 %174, 1
  store i32 %175, ptr %21, align 4, !tbaa !5
  br label %129, !llvm.loop !22

176:                                              ; preds = %129
  %177 = load ptr, ptr %19, align 8, !tbaa !9
  call void @free(ptr noundef %177) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %178 = load ptr, ptr %16, align 8, !tbaa !9
  store ptr %178, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  %179 = load i32, ptr %9, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %24, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  br label %181

181:                                              ; preds = %189, %176
  %182 = load ptr, ptr %23, align 8, !tbaa !9
  %183 = getelementptr inbounds %struct.bpt_node, ptr %182, i32 0, i32 0
  %184 = load ptr, ptr %183, align 8, !tbaa !13
  %185 = getelementptr inbounds i32, ptr %184, i64 0
  %186 = load i32, ptr %185, align 4, !tbaa !5
  %187 = load i32, ptr %10, align 4, !tbaa !5
  %188 = icmp ne i32 %186, %187
  br i1 %188, label %189, label %246

189:                                              ; preds = %181
  %190 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !11
  %191 = load i32, ptr %12, align 4, !tbaa !5
  %192 = load ptr, ptr %23, align 8, !tbaa !9
  %193 = getelementptr inbounds %struct.bpt_node, ptr %192, i32 0, i32 0
  %194 = load ptr, ptr %193, align 8, !tbaa !13
  %195 = load i32, ptr @ORDER, align 4, !tbaa !5
  %196 = add i32 6, %195
  %197 = add i32 %196, 1
  %198 = zext i32 %197 to i64
  %199 = getelementptr inbounds i32, ptr %194, i64 %198
  %200 = getelementptr inbounds i32, ptr %199, i64 0
  %201 = load i32, ptr %200, align 4, !tbaa !5
  %202 = sub i32 %201, 1
  %203 = call ptr %190(i32 noundef %191, i32 noundef %202, ptr noundef @leaf_data_cache_handler)
  store ptr %203, ptr %25, align 8, !tbaa !9
  %204 = load ptr, ptr %25, align 8, !tbaa !9
  %205 = load ptr, ptr %23, align 8, !tbaa !9
  %206 = load ptr, ptr %23, align 8, !tbaa !9
  %207 = getelementptr inbounds %struct.bpt_node, ptr %206, i32 0, i32 0
  %208 = load ptr, ptr %207, align 8, !tbaa !13
  %209 = getelementptr inbounds i32, ptr %208, i64 5
  %210 = load i32, ptr %209, align 4, !tbaa !5
  %211 = sub i32 %210, 1
  %212 = call i32 @leaf_data_starts_end(ptr noundef %204, ptr noundef %205, i32 noundef %211)
  %213 = load ptr, ptr %25, align 8, !tbaa !9
  %214 = load ptr, ptr %23, align 8, !tbaa !9
  %215 = load i32, ptr %24, align 4, !tbaa !5
  %216 = call i32 @leaf_data_starts_start(ptr noundef %213, ptr noundef %214, i32 noundef %215)
  %217 = sub i32 %212, %216
  store i32 %217, ptr %26, align 4, !tbaa !5
  %218 = load ptr, ptr %15, align 8, !tbaa !9
  %219 = load i32, ptr %22, align 4, !tbaa !5
  %220 = zext i32 %219 to i64
  %221 = getelementptr inbounds i64, ptr %218, i64 %220
  %222 = load ptr, ptr %25, align 8, !tbaa !9
  %223 = getelementptr inbounds %struct.leaf_data, ptr %222, i32 0, i32 6
  %224 = load ptr, ptr %223, align 8, !tbaa !19
  %225 = load ptr, ptr %25, align 8, !tbaa !9
  %226 = load ptr, ptr %23, align 8, !tbaa !9
  %227 = load i32, ptr %24, align 4, !tbaa !5
  %228 = call i32 @leaf_data_starts_start(ptr noundef %225, ptr noundef %226, i32 noundef %227)
  %229 = zext i32 %228 to i64
  %230 = getelementptr inbounds i64, ptr %224, i64 %229
  %231 = load i32, ptr %26, align 4, !tbaa !5
  %232 = zext i32 %231 to i64
  %233 = mul i64 %232, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %221, ptr align 8 %230, i64 %233, i1 false)
  %234 = load i32, ptr %26, align 4, !tbaa !5
  %235 = load i32, ptr %22, align 4, !tbaa !5
  %236 = add i32 %235, %234
  store i32 %236, ptr %22, align 4, !tbaa !5
  %237 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !11
  %238 = load i32, ptr %12, align 4, !tbaa !5
  %239 = load ptr, ptr %23, align 8, !tbaa !9
  %240 = getelementptr inbounds %struct.bpt_node, ptr %239, i32 0, i32 0
  %241 = load ptr, ptr %240, align 8, !tbaa !13
  %242 = getelementptr inbounds i32, ptr %241, i64 4
  %243 = load i32, ptr %242, align 4, !tbaa !5
  %244 = sub i32 %243, 1
  %245 = call ptr %237(i32 noundef %238, i32 noundef %244, ptr noundef @bpt_node_cache_handler)
  store ptr %245, ptr %23, align 8, !tbaa !9
  store i32 0, ptr %24, align 4, !tbaa !5
  br label %181, !llvm.loop !24

246:                                              ; preds = %181
  %247 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !11
  %248 = load i32, ptr %12, align 4, !tbaa !5
  %249 = load ptr, ptr %23, align 8, !tbaa !9
  %250 = getelementptr inbounds %struct.bpt_node, ptr %249, i32 0, i32 0
  %251 = load ptr, ptr %250, align 8, !tbaa !13
  %252 = load i32, ptr @ORDER, align 4, !tbaa !5
  %253 = add i32 6, %252
  %254 = add i32 %253, 1
  %255 = zext i32 %254 to i64
  %256 = getelementptr inbounds i32, ptr %251, i64 %255
  %257 = getelementptr inbounds i32, ptr %256, i64 0
  %258 = load i32, ptr %257, align 4, !tbaa !5
  %259 = sub i32 %258, 1
  %260 = call ptr %247(i32 noundef %248, i32 noundef %259, ptr noundef @leaf_data_cache_handler)
  store ptr %260, ptr %25, align 8, !tbaa !9
  %261 = load ptr, ptr %25, align 8, !tbaa !9
  %262 = load ptr, ptr %23, align 8, !tbaa !9
  %263 = load i32, ptr %11, align 4, !tbaa !5
  %264 = call i32 @leaf_data_starts_end(ptr noundef %261, ptr noundef %262, i32 noundef %263)
  %265 = load ptr, ptr %25, align 8, !tbaa !9
  %266 = load ptr, ptr %23, align 8, !tbaa !9
  %267 = load i32, ptr %24, align 4, !tbaa !5
  %268 = call i32 @leaf_data_starts_start(ptr noundef %265, ptr noundef %266, i32 noundef %267)
  %269 = sub i32 %264, %268
  store i32 %269, ptr %26, align 4, !tbaa !5
  %270 = load ptr, ptr %15, align 8, !tbaa !9
  %271 = load i32, ptr %22, align 4, !tbaa !5
  %272 = zext i32 %271 to i64
  %273 = getelementptr inbounds i64, ptr %270, i64 %272
  %274 = load ptr, ptr %25, align 8, !tbaa !9
  %275 = getelementptr inbounds %struct.leaf_data, ptr %274, i32 0, i32 6
  %276 = load ptr, ptr %275, align 8, !tbaa !19
  %277 = load ptr, ptr %25, align 8, !tbaa !9
  %278 = load ptr, ptr %23, align 8, !tbaa !9
  %279 = load i32, ptr %24, align 4, !tbaa !5
  %280 = call i32 @leaf_data_starts_start(ptr noundef %277, ptr noundef %278, i32 noundef %279)
  %281 = zext i32 %280 to i64
  %282 = getelementptr inbounds i64, ptr %276, i64 %281
  %283 = load i32, ptr %26, align 4, !tbaa !5
  %284 = zext i32 %283 to i64
  %285 = mul i64 %284, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %273, ptr align 8 %282, i64 %285, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #7
  %286 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 24) #8
  store ptr %286, ptr %27, align 8, !tbaa !9
  %287 = load ptr, ptr %27, align 8, !tbaa !9
  %288 = icmp eq ptr %287, null
  br i1 %288, label %289, label %290

289:                                              ; preds = %246
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.9) #9
  unreachable

290:                                              ; preds = %246
  %291 = load i32, ptr %14, align 4, !tbaa !5
  %292 = zext i32 %291 to i64
  %293 = load ptr, ptr %27, align 8, !tbaa !9
  %294 = getelementptr inbounds %struct.leaf_data_result, ptr %293, i32 0, i32 0
  store i64 %292, ptr %294, align 8, !tbaa !25
  %295 = load ptr, ptr %15, align 8, !tbaa !9
  %296 = load ptr, ptr %27, align 8, !tbaa !9
  %297 = getelementptr inbounds %struct.leaf_data_result, ptr %296, i32 0, i32 1
  store ptr %295, ptr %297, align 8, !tbaa !27
  %298 = load ptr, ptr %27, align 8, !tbaa !9
  %299 = getelementptr inbounds %struct.leaf_data_result, ptr %298, i32 0, i32 2
  store ptr null, ptr %299, align 8, !tbaa !28
  %300 = load ptr, ptr %13, align 8, !tbaa !9
  %301 = icmp eq ptr %300, null
  br i1 %301, label %306, label %302

302:                                              ; preds = %290
  %303 = load ptr, ptr %13, align 8, !tbaa !9
  %304 = load ptr, ptr %303, align 8, !tbaa !9
  %305 = icmp eq ptr %304, null
  br i1 %305, label %306, label %308

306:                                              ; preds = %302, %290
  %307 = load ptr, ptr %27, align 8, !tbaa !9
  store ptr %307, ptr %7, align 8
  store i32 1, ptr %28, align 4
  br label %315

308:                                              ; preds = %302
  %309 = load ptr, ptr %27, align 8, !tbaa !9
  %310 = load ptr, ptr %13, align 8, !tbaa !9
  %311 = load ptr, ptr %310, align 8, !tbaa !9
  %312 = getelementptr inbounds %struct.leaf_data_result, ptr %311, i32 0, i32 2
  store ptr %309, ptr %312, align 8, !tbaa !28
  br label %313

313:                                              ; preds = %308
  %314 = load ptr, ptr %27, align 8, !tbaa !9
  store ptr %314, ptr %7, align 8
  store i32 1, ptr %28, align 4
  br label %315

315:                                              ; preds = %313, %306
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #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
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  %316 = load ptr, ptr %7, align 8
  ret ptr %316
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @giggle_leaf_data_get_intersection_size(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @leaf_data_starts_end(ptr noundef, ptr noundef, i32 noundef) #4

declare i32 @leaf_data_ends_end(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

declare i32 @uint64_t_cmp(ptr noundef, ptr noundef) #4

declare void @bpt_print_node(ptr noundef) #4

declare void @leaf_data_print(ptr noundef) #4

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) #1

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

declare i32 @leaf_data_starts_start(ptr noundef, ptr noundef, i32 noundef) #4

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"cache_def", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!13 = !{!14, !10, i64 0}
!14 = !{!"bpt_node", !10, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"leaf_data", !17, i64 0, !17, i64 8, !17, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!17 = !{!"long", !7, i64 0}
!18 = !{!16, !10, i64 40}
!19 = !{!16, !10, i64 48}
!20 = !{!16, !10, i64 56}
!21 = !{!17, !17, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = !{!26, !17, i64 0}
!26 = !{!"leaf_data_result", !17, i64 0, !10, i64 8, !10, i64 16}
!27 = !{!26, !10, i64 8}
!28 = !{!26, !10, 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.cache_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cache_handler = type { ptr, ptr, ptr }

@cache = external dso_local local_unnamed_addr global %struct.cache_def, align 8
@bpt_node_cache_handler = external dso_local global %struct.cache_handler, align 8
@.str.9 = external hidden unnamed_addr constant [60 x i8], align 1
@ORDER = external dso_local local_unnamed_addr global i32, align 4
@leaf_data_cache_handler = external dso_local global %struct.cache_handler, align 8
@.str.10 = external hidden unnamed_addr constant [80 x i8], align 1

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; 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 #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @giggle_collect_intersection_data_in_block(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef readonly %5) local_unnamed_addr #2 {
  %7 = tail call i32 @giggle_leaf_data_get_intersection_size(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4)
  %8 = zext i32 %7 to i64
  %9 = tail call noalias ptr @calloc(i64 noundef %8, i64 noundef 8) #7
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.9) #8
  unreachable

12:                                               ; preds = %6
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !5
  %14 = add i32 %0, -1
  %15 = tail call ptr %13(i32 noundef %4, i32 noundef %14, ptr noundef nonnull @bpt_node_cache_handler) #9
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !5
  %17 = load ptr, ptr %15, align 8, !tbaa !10
  %18 = load i32, ptr @ORDER, align 4, !tbaa !12
  %19 = add i32 %18, 7
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr %17, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !12
  %23 = add i32 %22, -1
  %24 = tail call ptr %16(i32 noundef %4, i32 noundef %23, ptr noundef nonnull @leaf_data_cache_handler) #9
  %25 = load i64, ptr %24, align 8, !tbaa !14
  %26 = tail call i32 @leaf_data_starts_end(ptr noundef nonnull %24, ptr noundef nonnull %15, i32 noundef %1) #9
  %27 = tail call i32 @leaf_data_ends_end(ptr noundef nonnull %24, ptr noundef nonnull %15, i32 noundef %1) #9
  %28 = trunc i64 %25 to i32
  %29 = add i32 %26, %28
  %30 = add i32 %29, %27
  %31 = zext i32 %30 to i64
  %32 = tail call noalias ptr @calloc(i64 noundef %31, i64 noundef 8) #7
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %12
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.9) #8
  unreachable

35:                                               ; preds = %12
  %36 = getelementptr inbounds i8, ptr %24, i64 40
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load i64, ptr %24, align 8, !tbaa !14
  %39 = shl i64 %38, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %32, ptr align 8 %37, i64 %39, i1 false)
  %40 = getelementptr inbounds i64, ptr %32, i64 %38
  %41 = getelementptr inbounds i8, ptr %24, i64 48
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = tail call i32 @leaf_data_starts_end(ptr noundef nonnull %24, ptr noundef nonnull %15, i32 noundef %1) #9
  %44 = zext i32 %43 to i64
  %45 = shl nuw nsw i64 %44, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %40, ptr align 8 %42, i64 %45, i1 false)
  %46 = load i64, ptr %24, align 8, !tbaa !14
  %47 = getelementptr inbounds i64, ptr %32, i64 %46
  %48 = tail call i32 @leaf_data_starts_end(ptr noundef nonnull %24, ptr noundef nonnull %15, i32 noundef %1) #9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i64, ptr %47, i64 %49
  %51 = getelementptr inbounds i8, ptr %24, i64 56
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  %53 = tail call i32 @leaf_data_ends_end(ptr noundef nonnull %24, ptr noundef nonnull %15, i32 noundef %1) #9
  %54 = zext i32 %53 to i64
  %55 = shl nuw nsw i64 %54, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %50, ptr align 8 %52, i64 %55, i1 false)
  tail call void @qsort(ptr noundef nonnull %32, i64 noundef %31, i64 noundef 8, ptr noundef nonnull @uint64_t_cmp) #9
  %.not136 = icmp eq i32 %30, 0
  br i1 %.not136, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %35, %67
  %.0111124 = phi i32 [ %.1, %67 ], [ 0, %35 ]
  %.0112123 = phi i32 [ %.pre-phi144, %67 ], [ 0, %35 ]
  %56 = add nuw i32 %.0112123, 1
  %57 = icmp eq i32 %56, %30
  %.phi.trans.insert = zext i32 %.0112123 to i64
  %.phi.trans.insert141 = getelementptr inbounds i64, ptr %32, i64 %.phi.trans.insert
  %.pre = load i64, ptr %.phi.trans.insert141, align 8, !tbaa !20
  br i1 %57, label %.lr.ph._crit_edge, label %58

58:                                               ; preds = %.lr.ph
  %59 = zext i32 %56 to i64
  %60 = getelementptr inbounds i64, ptr %32, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !20
  %.not121 = icmp eq i64 %.pre, %61
  br i1 %.not121, label %._crit_edge142, label %.lr.ph._crit_edge

._crit_edge142:                                   ; preds = %58
  %.pre143 = add i32 %.0112123, 2
  br label %67

.lr.ph._crit_edge:                                ; preds = %.lr.ph, %58
  %62 = add i32 %.0111124, 1
  %63 = zext i32 %.0111124 to i64
  %64 = getelementptr inbounds i64, ptr %9, i64 %63
  store i64 %.pre, ptr %64, align 8, !tbaa !20
  %65 = icmp ugt i32 %62, %7
  br i1 %65, label %66, label %67

66:                                               ; preds = %.lr.ph._crit_edge
  tail call void @bpt_print_node(ptr noundef nonnull %15) #9
  tail call void @leaf_data_print(ptr noundef nonnull %24) #9
  tail call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.10) #8
  unreachable

67:                                               ; preds = %._crit_edge142, %.lr.ph._crit_edge
  %.pre-phi144 = phi i32 [ %.pre143, %._crit_edge142 ], [ %56, %.lr.ph._crit_edge ]
  %.1 = phi i32 [ %.0111124, %._crit_edge142 ], [ %62, %.lr.ph._crit_edge ]
  %68 = icmp ult i32 %.pre-phi144, %30
  br i1 %68, label %.lr.ph, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %67, %35
  %.0111.lcssa = phi i32 [ 0, %35 ], [ %.1, %67 ]
  tail call void @free(ptr noundef nonnull %32) #9
  %69 = add nsw i32 %1, 1
  %70 = load ptr, ptr %15, align 8, !tbaa !10
  %71 = load i32, ptr %70, align 4, !tbaa !12
  %.not125 = icmp eq i32 %71, %2
  br i1 %.not125, label %._crit_edge131, label %.lr.ph130.preheader

.lr.ph130.preheader:                              ; preds = %._crit_edge
  %72 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !5
  %73 = load i32, ptr @ORDER, align 4, !tbaa !12
  %74 = add i32 %73, 7
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %70, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !12
  %78 = add i32 %77, -1
  %79 = tail call ptr %72(i32 noundef %4, i32 noundef %78, ptr noundef nonnull @leaf_data_cache_handler) #9
  %80 = load ptr, ptr %15, align 8, !tbaa !10
  %81 = getelementptr inbounds i8, ptr %80, i64 20
  %82 = load i32, ptr %81, align 4, !tbaa !12
  %83 = add i32 %82, -1
  %84 = tail call i32 @leaf_data_starts_end(ptr noundef %79, ptr noundef nonnull %15, i32 noundef %83) #9
  %85 = tail call i32 @leaf_data_starts_start(ptr noundef %79, ptr noundef nonnull %15, i32 noundef %69) #9
  %86 = sub i32 %84, %85
  %87 = zext i32 %.0111.lcssa to i64
  %88 = getelementptr inbounds i64, ptr %9, i64 %87
  %89 = getelementptr inbounds i8, ptr %79, i64 48
  %90 = load ptr, ptr %89, align 8, !tbaa !18
  %91 = tail call i32 @leaf_data_starts_start(ptr noundef %79, ptr noundef nonnull %15, i32 noundef %69) #9
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds i64, ptr %90, i64 %92
  %94 = zext i32 %86 to i64
  %95 = shl nuw nsw i64 %94, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %88, ptr align 8 %93, i64 %95, i1 false)
  %96 = add i32 %86, %.0111.lcssa
  %97 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !5
  %98 = load ptr, ptr %15, align 8, !tbaa !10
  %99 = getelementptr inbounds i8, ptr %98, i64 16
  %100 = load i32, ptr %99, align 4, !tbaa !12
  %101 = add i32 %100, -1
  %102 = tail call ptr %97(i32 noundef %4, i32 noundef %101, ptr noundef nonnull @bpt_node_cache_handler) #9
  %103 = load ptr, ptr %102, align 8, !tbaa !10
  %104 = load i32, ptr %103, align 4, !tbaa !12
  %.not.peel = icmp eq i32 %104, %2
  br i1 %.not.peel, label %._crit_edge131, label %.lr.ph130

.lr.ph130:                                        ; preds = %.lr.ph130.preheader, %.lr.ph130
  %105 = phi ptr [ %137, %.lr.ph130 ], [ %103, %.lr.ph130.preheader ]
  %.0110127 = phi ptr [ %136, %.lr.ph130 ], [ %102, %.lr.ph130.preheader ]
  %.2126 = phi i32 [ %130, %.lr.ph130 ], [ %96, %.lr.ph130.preheader ]
  %106 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !5
  %107 = load i32, ptr @ORDER, align 4, !tbaa !12
  %108 = add i32 %107, 7
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds i32, ptr %105, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !12
  %112 = add i32 %111, -1
  %113 = tail call ptr %106(i32 noundef %4, i32 noundef %112, ptr noundef nonnull @leaf_data_cache_handler) #9
  %114 = load ptr, ptr %.0110127, align 8, !tbaa !10
  %115 = getelementptr inbounds i8, ptr %114, i64 20
  %116 = load i32, ptr %115, align 4, !tbaa !12
  %117 = add i32 %116, -1
  %118 = tail call i32 @leaf_data_starts_end(ptr noundef %113, ptr noundef nonnull %.0110127, i32 noundef %117) #9
  %119 = tail call i32 @leaf_data_starts_start(ptr noundef %113, ptr noundef nonnull %.0110127, i32 noundef 0) #9
  %120 = sub i32 %118, %119
  %121 = zext i32 %.2126 to i64
  %122 = getelementptr inbounds i64, ptr %9, i64 %121
  %123 = getelementptr inbounds i8, ptr %113, i64 48
  %124 = load ptr, ptr %123, align 8, !tbaa !18
  %125 = tail call i32 @leaf_data_starts_start(ptr noundef %113, ptr noundef nonnull %.0110127, i32 noundef 0) #9
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds i64, ptr %124, i64 %126
  %128 = zext i32 %120 to i64
  %129 = shl nuw nsw i64 %128, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %122, ptr align 8 %127, i64 %129, i1 false)
  %130 = add i32 %120, %.2126
  %131 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !5
  %132 = load ptr, ptr %.0110127, align 8, !tbaa !10
  %133 = getelementptr inbounds i8, ptr %132, i64 16
  %134 = load i32, ptr %133, align 4, !tbaa !12
  %135 = add i32 %134, -1
  %136 = tail call ptr %131(i32 noundef %4, i32 noundef %135, ptr noundef nonnull @bpt_node_cache_handler) #9
  %137 = load ptr, ptr %136, align 8, !tbaa !10
  %138 = load i32, ptr %137, align 4, !tbaa !12
  %.not = icmp eq i32 %138, %2
  br i1 %.not, label %._crit_edge131, label %.lr.ph130, !llvm.loop !23

._crit_edge131:                                   ; preds = %.lr.ph130, %.lr.ph130.preheader, %._crit_edge
  %.2.lcssa = phi i32 [ %.0111.lcssa, %._crit_edge ], [ %96, %.lr.ph130.preheader ], [ %130, %.lr.ph130 ]
  %.0110.lcssa = phi ptr [ %15, %._crit_edge ], [ %102, %.lr.ph130.preheader ], [ %136, %.lr.ph130 ]
  %.0109.lcssa = phi i32 [ %69, %._crit_edge ], [ 0, %.lr.ph130.preheader ], [ 0, %.lr.ph130 ]
  %.lcssa = phi ptr [ %70, %._crit_edge ], [ %103, %.lr.ph130.preheader ], [ %137, %.lr.ph130 ]
  %139 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !5
  %140 = load i32, ptr @ORDER, align 4, !tbaa !12
  %141 = add i32 %140, 7
  %142 = zext i32 %141 to i64
  %143 = getelementptr inbounds i32, ptr %.lcssa, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !12
  %145 = add i32 %144, -1
  %146 = tail call ptr %139(i32 noundef %4, i32 noundef %145, ptr noundef nonnull @leaf_data_cache_handler) #9
  %147 = tail call i32 @leaf_data_starts_end(ptr noundef %146, ptr noundef nonnull %.0110.lcssa, i32 noundef %3) #9
  %148 = tail call i32 @leaf_data_starts_start(ptr noundef %146, ptr noundef nonnull %.0110.lcssa, i32 noundef %.0109.lcssa) #9
  %149 = sub i32 %147, %148
  %150 = zext i32 %.2.lcssa to i64
  %151 = getelementptr inbounds i64, ptr %9, i64 %150
  %152 = getelementptr inbounds i8, ptr %146, i64 48
  %153 = load ptr, ptr %152, align 8, !tbaa !18
  %154 = tail call i32 @leaf_data_starts_start(ptr noundef %146, ptr noundef nonnull %.0110.lcssa, i32 noundef %.0109.lcssa) #9
  %155 = zext i32 %154 to i64
  %156 = getelementptr inbounds i64, ptr %153, i64 %155
  %157 = zext i32 %149 to i64
  %158 = shl nuw nsw i64 %157, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %151, ptr align 8 %156, i64 %158, i1 false)
  %159 = tail call noalias dereferenceable_or_null(24) ptr @calloc(i64 noundef 1, i64 noundef 24) #7
  %160 = icmp eq ptr %159, null
  br i1 %160, label %161, label %162

161:                                              ; preds = %._crit_edge131
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.9) #8
  unreachable

162:                                              ; preds = %._crit_edge131
  store i64 %8, ptr %159, align 8, !tbaa !25
  %163 = getelementptr inbounds i8, ptr %159, i64 8
  store ptr %9, ptr %163, align 8, !tbaa !27
  %164 = icmp eq ptr %5, null
  br i1 %164, label %170, label %165

165:                                              ; preds = %162
  %166 = load ptr, ptr %5, align 8, !tbaa !28
  %167 = icmp eq ptr %166, null
  br i1 %167, label %170, label %168

168:                                              ; preds = %165
  %169 = getelementptr inbounds i8, ptr %166, i64 16
  store ptr %159, ptr %169, align 8, !tbaa !29
  br label %170

170:                                              ; preds = %162, %165, %168
  ret ptr %159
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @giggle_leaf_data_get_intersection_size(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @leaf_data_starts_end(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @leaf_data_ends_end(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #5

declare i32 @uint64_t_cmp(ptr noundef, ptr noundef) #3

declare void @bpt_print_node(ptr noundef) local_unnamed_addr #3

declare void @leaf_data_print(ptr noundef) local_unnamed_addr #3

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

declare i32 @leaf_data_starts_start(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { noreturn "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 = { 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 #2 = { 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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nofree "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 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 #7 = { nounwind allocsize(0,1) }
attributes #8 = { noreturn nounwind }
attributes #9 = { 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, !7, i64 24}
!6 = !{!"cache_def", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"bpt_node", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"leaf_data", !16, i64 0, !16, i64 8, !16, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!16 = !{!"long", !8, i64 0}
!17 = !{!15, !7, i64 40}
!18 = !{!15, !7, i64 48}
!19 = !{!15, !7, i64 56}
!20 = !{!16, !16, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22, !24}
!24 = !{!"llvm.loop.peeled.count", i32 1}
!25 = !{!26, !16, i64 0}
!26 = !{!"leaf_data_result", !16, i64 0, !7, i64 8, !7, i64 16}
!27 = !{!26, !7, i64 8}
!28 = !{!7, !7, i64 0}
!29 = !{!26, !7, i64 16}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass