; 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.bpt_node = type { ptr }
%struct.disk_store = type { ptr, ptr, ptr, ptr, i32, i32, i64, i64, ptr, ptr, i8, ptr }

@ORDER = external dso_local global i32, align 4
@.str.72 = external hidden unnamed_addr constant [52 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
declare void @err(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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare i64 @bpt_node_serialize(ptr noundef, ptr noundef) #5

declare i32 @disk_store_append(ptr noundef, ptr noundef, i64 noundef) #5

; Function Attrs: nounwind uwtable
define dso_local i32 @giggle_bulk_insert_add_tree_level(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #6 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca i64, align 8
  %26 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %32

29:                                               ; preds = %5
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %30, ptr %31, align 4, !tbaa !9
  store i32 0, ptr %6, align 4
  br label %209

32:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %33 = call noalias ptr @malloc(i64 noundef 8) #8
  store ptr %33, ptr %12, align 8, !tbaa !5
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

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

37:                                               ; preds = %32
  %38 = load i32, ptr @ORDER, align 4, !tbaa !9
  %39 = mul i32 2, %38
  %40 = add i32 %39, 10
  %41 = zext i32 %40 to i64
  %42 = mul i64 %41, 4
  %43 = call noalias ptr @malloc(i64 noundef %42) #8
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.bpt_node, ptr %44, i32 0, i32 0
  store ptr %43, ptr %45, align 8, !tbaa !11
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.bpt_node, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %51

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

51:                                               ; preds = %37
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.bpt_node, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = load i32, ptr @ORDER, align 4, !tbaa !9
  %56 = mul i32 2, %55
  %57 = add i32 %56, 10
  %58 = zext i32 %57 to i64
  %59 = mul i64 %58, 4
  call void @llvm.memset.p0.i64(ptr align 4 %54, i8 0, i64 %59, i1 false)
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.disk_store, ptr %60, i32 0, i32 5
  %62 = load i32, ptr %61, align 4, !tbaa !13
  %63 = add i32 %62, 1
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %63, ptr %64, align 4, !tbaa !9
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.disk_store, ptr %65, i32 0, i32 5
  %67 = load i32, ptr %66, align 4, !tbaa !13
  %68 = add i32 %67, 1
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.bpt_node, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = getelementptr inbounds i32, ptr %71, i64 0
  store i32 %68, ptr %72, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !9
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.bpt_node, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !11
  %77 = load i32, ptr @ORDER, align 4, !tbaa !9
  %78 = add i32 6, %77
  %79 = add i32 %78, 2
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds i32, ptr %76, i64 %80
  %82 = getelementptr inbounds i32, ptr %81, i64 0
  store i32 %73, ptr %82, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  store i64 0, ptr %20, align 8, !tbaa !16
  store i32 1, ptr %14, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %187, %51
  %84 = load i32, ptr %14, align 4, !tbaa !9
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = icmp ult i32 %84, %85
  br i1 %86, label %87, label %190

87:                                               ; preds = %83
  %88 = load i32, ptr %10, align 4, !tbaa !9
  %89 = icmp eq i32 %88, 1
  br i1 %89, label %90, label %96

90:                                               ; preds = %87
  %91 = load i32, ptr %8, align 4, !tbaa !9
  %92 = load i32, ptr %14, align 4, !tbaa !9
  %93 = mul i32 %92, 2
  %94 = add i32 %91, %93
  %95 = zext i32 %94 to i64
  store i64 %95, ptr %20, align 8, !tbaa !16
  br label %101

96:                                               ; preds = %87
  %97 = load i32, ptr %8, align 4, !tbaa !9
  %98 = load i32, ptr %14, align 4, !tbaa !9
  %99 = add i32 %97, %98
  %100 = zext i32 %99 to i64
  store i64 %100, ptr %20, align 8, !tbaa !16
  br label %101

101:                                              ; preds = %96, %90
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = load i64, ptr %20, align 8, !tbaa !16
  %104 = sub i64 %103, 1
  %105 = trunc i64 %104 to i32
  %106 = call ptr @disk_store_get(ptr noundef %102, i32 noundef %105, ptr noundef %16)
  store ptr %106, ptr %17, align 8, !tbaa !5
  %107 = load ptr, ptr %17, align 8, !tbaa !5
  %108 = load i64, ptr %16, align 8, !tbaa !16
  %109 = call i64 @bpt_node_deserialize(ptr noundef %107, i64 noundef %108, ptr noundef %18)
  store i64 %109, ptr %19, align 8, !tbaa !16
  %110 = load ptr, ptr %18, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.bpt_node, ptr %110, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8, !tbaa !11
  %113 = getelementptr inbounds i32, ptr %112, i64 6
  %114 = getelementptr inbounds i32, ptr %113, i64 0
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.bpt_node, ptr %116, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !11
  %119 = getelementptr inbounds i32, ptr %118, i64 6
  %120 = load i32, ptr %15, align 4, !tbaa !9
  %121 = zext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr %119, i64 %121
  store i32 %115, ptr %122, align 4, !tbaa !9
  %123 = load ptr, ptr %12, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.bpt_node, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !11
  %126 = getelementptr inbounds i32, ptr %125, i64 5
  %127 = load i32, ptr %126, align 4, !tbaa !9
  %128 = add i32 %127, 1
  %129 = load ptr, ptr %12, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.bpt_node, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !11
  %132 = getelementptr inbounds i32, ptr %131, i64 5
  store i32 %128, ptr %132, align 4, !tbaa !9
  %133 = load ptr, ptr %18, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.bpt_node, ptr %133, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !11
  %136 = getelementptr inbounds i32, ptr %135, i64 0
  %137 = load i32, ptr %136, align 4, !tbaa !9
  %138 = load ptr, ptr %12, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.bpt_node, ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !11
  %141 = load i32, ptr @ORDER, align 4, !tbaa !9
  %142 = add i32 6, %141
  %143 = add i32 %142, 2
  %144 = zext i32 %143 to i64
  %145 = getelementptr inbounds i32, ptr %140, i64 %144
  %146 = load i32, ptr %15, align 4, !tbaa !9
  %147 = add i32 %146, 1
  %148 = zext i32 %147 to i64
  %149 = getelementptr inbounds i32, ptr %145, i64 %148
  store i32 %137, ptr %149, align 4, !tbaa !9
  %150 = load i32, ptr %15, align 4, !tbaa !9
  %151 = add i32 %150, 1
  store i32 %151, ptr %15, align 4, !tbaa !9
  %152 = load i32, ptr %15, align 4, !tbaa !9
  %153 = load i32, ptr @ORDER, align 4, !tbaa !9
  %154 = icmp eq i32 %152, %153
  br i1 %154, label %155, label %181

155:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %156 = load ptr, ptr %12, align 8, !tbaa !5
  %157 = call i64 @bpt_node_serialize(ptr noundef %156, ptr noundef %21)
  store i64 %157, ptr %22, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  %158 = load ptr, ptr %7, align 8, !tbaa !5
  %159 = load ptr, ptr %21, align 8, !tbaa !5
  %160 = load i64, ptr %22, align 8, !tbaa !16
  %161 = call i32 @disk_store_append(ptr noundef %158, ptr noundef %159, i64 noundef %160)
  store i32 %161, ptr %23, align 4, !tbaa !9
  %162 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %162) #7
  %163 = load ptr, ptr %12, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.bpt_node, ptr %163, i32 0, i32 0
  %165 = load ptr, ptr %164, align 8, !tbaa !11
  %166 = load i32, ptr @ORDER, align 4, !tbaa !9
  %167 = mul i32 2, %166
  %168 = add i32 %167, 10
  %169 = zext i32 %168 to i64
  %170 = mul i64 %169, 4
  call void @llvm.memset.p0.i64(ptr align 4 %165, i8 0, i64 %170, i1 false)
  %171 = load ptr, ptr %7, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.disk_store, ptr %171, i32 0, i32 5
  %173 = load i32, ptr %172, align 4, !tbaa !13
  %174 = add i32 %173, 1
  %175 = load ptr, ptr %12, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.bpt_node, ptr %175, i32 0, i32 0
  %177 = load ptr, ptr %176, align 8, !tbaa !11
  %178 = getelementptr inbounds i32, ptr %177, i64 0
  store i32 %174, ptr %178, align 4, !tbaa !9
  store i32 0, ptr %15, align 4, !tbaa !9
  %179 = load i32, ptr %13, align 4, !tbaa !9
  %180 = add i32 %179, 1
  store i32 %180, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %181

181:                                              ; preds = %155, %101
  %182 = load ptr, ptr %18, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.bpt_node, ptr %182, i32 0, i32 0
  %184 = load ptr, ptr %183, align 8, !tbaa !11
  call void @free(ptr noundef %184) #7
  %185 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %185) #7
  %186 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %186) #7
  store ptr null, ptr %17, align 8, !tbaa !5
  br label %187

187:                                              ; preds = %181
  %188 = load i32, ptr %14, align 4, !tbaa !9
  %189 = add i32 %188, 1
  store i32 %189, ptr %14, align 4, !tbaa !9
  br label %83, !llvm.loop !17

190:                                              ; preds = %83
  %191 = load i32, ptr %15, align 4, !tbaa !9
  %192 = icmp ugt i32 %191, 0
  br i1 %192, label %193, label %203

193:                                              ; preds = %190
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #7
  %194 = load ptr, ptr %12, align 8, !tbaa !5
  %195 = call i64 @bpt_node_serialize(ptr noundef %194, ptr noundef %24)
  store i64 %195, ptr %25, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  %196 = load ptr, ptr %7, align 8, !tbaa !5
  %197 = load ptr, ptr %24, align 8, !tbaa !5
  %198 = load i64, ptr %25, align 8, !tbaa !16
  %199 = call i32 @disk_store_append(ptr noundef %196, ptr noundef %197, i64 noundef %198)
  store i32 %199, ptr %26, align 4, !tbaa !9
  %200 = load ptr, ptr %24, align 8, !tbaa !5
  call void @free(ptr noundef %200) #7
  %201 = load i32, ptr %13, align 4, !tbaa !9
  %202 = add i32 %201, 1
  store i32 %202, ptr %13, align 4, !tbaa !9
  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 8, ptr %24) #7
  br label %203

203:                                              ; preds = %193, %190
  %204 = load ptr, ptr %12, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.bpt_node, ptr %204, i32 0, i32 0
  %206 = load ptr, ptr %205, align 8, !tbaa !11
  call void @free(ptr noundef %206) #7
  %207 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %207) #7
  %208 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %208, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, 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 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %209

209:                                              ; preds = %203, %29
  %210 = load i32, ptr %6, align 4
  ret i32 %210
}

declare ptr @disk_store_get(ptr noundef, i32 noundef, ptr noundef) #5

declare i64 @bpt_node_deserialize(ptr noundef, i64 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 "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { "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 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
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 = !{!"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, !6, i64 0}
!12 = !{!"bpt_node", !6, i64 0}
!13 = !{!14, !10, i64 36}
!14 = !{!"disk_store", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !15, i64 40, !15, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !6, i64 80}
!15 = !{!"long", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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"

@ORDER = external dso_local local_unnamed_addr global i32, align 4
@.str.72 = external hidden unnamed_addr constant [52 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
declare void @err(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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare i64 @bpt_node_serialize(ptr noundef, ptr noundef) local_unnamed_addr #5

declare i32 @disk_store_append(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local i32 @giggle_bulk_insert_add_tree_level(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #6 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = icmp eq i32 %2, 1
  br i1 %10, label %11, label %12

11:                                               ; preds = %5
  store i32 %1, ptr %4, align 4, !tbaa !5
  br label %89

12:                                               ; preds = %5
  %13 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #8
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %12
  %17 = load i32, ptr @ORDER, align 4, !tbaa !5
  %18 = shl i32 %17, 1
  %19 = add i32 %18, 10
  %20 = zext i32 %19 to i64
  %21 = shl nuw nsw i64 %20, 2
  %calloc = tail call ptr @calloc(i64 1, i64 %21)
  store ptr %calloc, ptr %13, align 8, !tbaa !9
  %22 = icmp eq ptr %calloc, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %16
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.72) #9
  unreachable

24:                                               ; preds = %16
  %25 = getelementptr inbounds i8, ptr %0, i64 36
  %26 = load i32, ptr %25, align 4, !tbaa !12
  %27 = add i32 %26, 1
  store i32 %27, ptr %4, align 4, !tbaa !5
  %28 = load i32, ptr %25, align 4, !tbaa !12
  %29 = add i32 %28, 1
  store i32 %29, ptr %calloc, align 4, !tbaa !5
  %30 = load i32, ptr @ORDER, align 4, !tbaa !5
  %31 = add i32 %30, 8
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %calloc, i64 %32
  store i32 %1, ptr %33, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #10
  %.not61 = icmp eq i32 %2, 0
  br i1 %.not61, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %24
  %34 = icmp eq i32 %3, 1
  %35 = zext i1 %34 to i32
  %.052.in = add i32 %1, -1
  br label %36

36:                                               ; preds = %.lr.ph, %77
  %.04859 = phi i32 [ 0, %.lr.ph ], [ %.1, %77 ]
  %.04958 = phi i32 [ 1, %.lr.ph ], [ %80, %77 ]
  %.05057 = phi i32 [ 0, %.lr.ph ], [ %.151, %77 ]
  %.pn = shl i32 %.04958, %35
  %37 = add i32 %.052.in, %.pn
  %38 = call ptr @disk_store_get(ptr noundef %0, i32 noundef %37, ptr noundef nonnull %6) #10
  %39 = load i64, ptr %6, align 8, !tbaa !15
  %40 = call i64 @bpt_node_deserialize(ptr noundef %38, i64 noundef %39, ptr noundef nonnull %7) #10
  %41 = load ptr, ptr %7, align 8, !tbaa !16
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %42, i64 24
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load ptr, ptr %13, align 8, !tbaa !9
  %46 = getelementptr inbounds i8, ptr %45, i64 24
  %47 = zext i32 %.05057 to i64
  %48 = getelementptr inbounds i32, ptr %46, i64 %47
  store i32 %44, ptr %48, align 4, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %45, i64 20
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = add i32 %50, 1
  store i32 %51, ptr %49, align 4, !tbaa !5
  %52 = load i32, ptr %42, align 4, !tbaa !5
  %53 = load i32, ptr @ORDER, align 4, !tbaa !5
  %54 = add i32 %53, 8
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %45, i64 %55
  %57 = add i32 %.05057, 1
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr %56, i64 %58
  store i32 %52, ptr %59, align 4, !tbaa !5
  %60 = load i32, ptr @ORDER, align 4, !tbaa !5
  %61 = icmp eq i32 %57, %60
  br i1 %61, label %62, label %77

62:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #10
  %63 = call i64 @bpt_node_serialize(ptr noundef nonnull %13, ptr noundef nonnull %8) #10
  %64 = load ptr, ptr %8, align 8, !tbaa !16
  %65 = call i32 @disk_store_append(ptr noundef %0, ptr noundef %64, i64 noundef %63) #10
  %66 = load ptr, ptr %8, align 8, !tbaa !16
  call void @free(ptr noundef %66) #10
  %67 = load ptr, ptr %13, align 8, !tbaa !9
  %68 = load i32, ptr @ORDER, align 4, !tbaa !5
  %69 = shl i32 %68, 1
  %70 = add i32 %69, 10
  %71 = zext i32 %70 to i64
  %72 = shl nuw nsw i64 %71, 2
  call void @llvm.memset.p0.i64(ptr align 4 %67, i8 0, i64 %72, i1 false)
  %73 = load i32, ptr %25, align 4, !tbaa !12
  %74 = add i32 %73, 1
  %75 = load ptr, ptr %13, align 8, !tbaa !9
  store i32 %74, ptr %75, align 4, !tbaa !5
  %76 = add i32 %.04859, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #10
  %.pre = load ptr, ptr %7, align 8, !tbaa !16
  %.pre62 = load ptr, ptr %.pre, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %62, %36
  %78 = phi ptr [ %.pre62, %62 ], [ %42, %36 ]
  %.151 = phi i32 [ 0, %62 ], [ %57, %36 ]
  %.1 = phi i32 [ %76, %62 ], [ %.04859, %36 ]
  call void @free(ptr noundef %78) #10
  %79 = load ptr, ptr %7, align 8, !tbaa !16
  call void @free(ptr noundef %79) #10
  call void @free(ptr noundef %38) #10
  %80 = add nuw i32 %.04958, 1
  %exitcond.not = icmp eq i32 %80, %2
  br i1 %exitcond.not, label %._crit_edge, label %36, !llvm.loop !17

._crit_edge:                                      ; preds = %77
  %81 = icmp eq i32 %.151, 0
  br i1 %81, label %._crit_edge.thread, label %82

82:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #10
  %83 = call i64 @bpt_node_serialize(ptr noundef nonnull %13, ptr noundef nonnull %9) #10
  %84 = load ptr, ptr %9, align 8, !tbaa !16
  %85 = call i32 @disk_store_append(ptr noundef %0, ptr noundef %84, i64 noundef %83) #10
  %86 = load ptr, ptr %9, align 8, !tbaa !16
  call void @free(ptr noundef %86) #10
  %87 = add i32 %.1, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #10
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %24, %82, %._crit_edge
  %.2 = phi i32 [ %87, %82 ], [ %.1, %._crit_edge ], [ 0, %24 ]
  %88 = load ptr, ptr %13, align 8, !tbaa !9
  call void @free(ptr noundef %88) #10
  call void @free(ptr noundef nonnull %13) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #10
  br label %89

89:                                               ; preds = %._crit_edge.thread, %11
  %.0 = phi i32 [ 0, %11 ], [ %.2, %._crit_edge.thread ]
  ret i32 %.0
}

declare ptr @disk_store_get(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

declare i64 @bpt_node_deserialize(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #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 "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { "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 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 #7 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"bpt_node", !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 36}
!13 = !{!"disk_store", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !6, i64 36, !14, i64 40, !14, i64 48, !11, i64 56, !11, i64 64, !7, i64 72, !11, i64 80}
!14 = !{!"long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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