; 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.uint64_t_array = type { i64, i64, ptr }
%struct.leaf_data = type { i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.uint32_t_array = type { i32, i32, ptr }

@ORDER = external dso_local global i32, align 4
@LEAF_POINTERS_SIZE = external dso_local global i64, align 8
@.str.70 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [53 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 allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; 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) #4

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @giggle_bulk_insert_write_leaf_node(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #8 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #9
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = call i64 @bpt_node_serialize(ptr noundef %19, ptr noundef %15)
  store i64 %20, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = load ptr, ptr %15, align 8, !tbaa !5
  %23 = load i64, ptr %16, align 8, !tbaa !9
  %24 = call i32 @disk_store_append(ptr noundef %21, ptr noundef %22, i64 noundef %23)
  store i32 %24, ptr %17, align 4, !tbaa !11
  %25 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %25) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #9
  %26 = call noalias ptr @malloc(i64 noundef 72) #10
  store ptr %26, ptr %18, align 8, !tbaa !5
  %27 = load ptr, ptr %18, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %7
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.70) #11
  unreachable

30:                                               ; preds = %7
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.uint64_t_array, ptr %31, i32 0, i32 0
  %33 = load i64, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %18, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.leaf_data, ptr %34, i32 0, i32 0
  store i64 %33, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.uint64_t_array, ptr %36, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !13
  %39 = load ptr, ptr %18, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.leaf_data, ptr %39, i32 0, i32 1
  store i64 %38, ptr %40, align 8, !tbaa !17
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.uint64_t_array, ptr %41, i32 0, i32 0
  %43 = load i64, ptr %42, align 8, !tbaa !13
  %44 = load ptr, ptr %18, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.leaf_data, ptr %44, i32 0, i32 2
  store i64 %43, ptr %45, align 8, !tbaa !18
  %46 = load i32, ptr @ORDER, align 4, !tbaa !11
  %47 = zext i32 %46 to i64
  %48 = load i64, ptr @LEAF_POINTERS_SIZE, align 8, !tbaa !9
  %49 = call noalias ptr @calloc(i64 noundef %47, i64 noundef %48) #12
  %50 = load ptr, ptr %18, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.leaf_data, ptr %50, i32 0, i32 3
  store ptr %49, ptr %51, align 8, !tbaa !19
  %52 = load ptr, ptr %18, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.leaf_data, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %57

56:                                               ; preds = %30
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.71) #11
  unreachable

57:                                               ; preds = %30
  %58 = load ptr, ptr %18, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.leaf_data, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.uint32_t_array, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.uint32_t_array, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 8, !tbaa !22
  %67 = zext i32 %66 to i64
  %68 = mul i64 %67, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %60, ptr align 4 %63, i64 %68, i1 false)
  %69 = load i32, ptr @ORDER, align 4, !tbaa !11
  %70 = zext i32 %69 to i64
  %71 = call noalias ptr @calloc(i64 noundef %70, i64 noundef 4) #12
  %72 = load ptr, ptr %18, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.leaf_data, ptr %72, i32 0, i32 4
  store ptr %71, ptr %73, align 8, !tbaa !23
  %74 = load ptr, ptr %18, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.leaf_data, ptr %74, i32 0, i32 4
  %76 = load ptr, ptr %75, align 8, !tbaa !23
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.uint32_t_array, ptr %77, i32 0, i32 2
  %79 = load ptr, ptr %78, align 8, !tbaa !20
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.uint32_t_array, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 8, !tbaa !22
  %83 = zext i32 %82 to i64
  %84 = mul i64 %83, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %76, ptr align 4 %79, i64 %84, i1 false)
  %85 = load ptr, ptr %18, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.leaf_data, ptr %85, i32 0, i32 0
  %87 = load i64, ptr %86, align 8, !tbaa !15
  %88 = load ptr, ptr %18, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.leaf_data, ptr %88, i32 0, i32 1
  %90 = load i64, ptr %89, align 8, !tbaa !17
  %91 = add i64 %87, %90
  %92 = load ptr, ptr %18, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.leaf_data, ptr %92, i32 0, i32 2
  %94 = load i64, ptr %93, align 8, !tbaa !18
  %95 = add i64 %91, %94
  %96 = mul i64 %95, 8
  %97 = call noalias ptr @malloc(i64 noundef %96) #10
  %98 = load ptr, ptr %18, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.leaf_data, ptr %98, i32 0, i32 8
  store ptr %97, ptr %99, align 8, !tbaa !24
  %100 = load ptr, ptr %18, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.leaf_data, ptr %100, i32 0, i32 8
  %102 = load ptr, ptr %101, align 8, !tbaa !24
  %103 = icmp eq ptr %102, null
  br i1 %103, label %104, label %105

104:                                              ; preds = %57
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.70) #11
  unreachable

105:                                              ; preds = %57
  %106 = load ptr, ptr %18, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.leaf_data, ptr %106, i32 0, i32 8
  %108 = load ptr, ptr %107, align 8, !tbaa !24
  %109 = load ptr, ptr %18, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.leaf_data, ptr %109, i32 0, i32 5
  store ptr %108, ptr %110, align 8, !tbaa !25
  %111 = load ptr, ptr %18, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.leaf_data, ptr %111, i32 0, i32 8
  %113 = load ptr, ptr %112, align 8, !tbaa !24
  %114 = load ptr, ptr %18, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.leaf_data, ptr %114, i32 0, i32 0
  %116 = load i64, ptr %115, align 8, !tbaa !15
  %117 = getelementptr inbounds i64, ptr %113, i64 %116
  %118 = load ptr, ptr %18, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.leaf_data, ptr %118, i32 0, i32 6
  store ptr %117, ptr %119, align 8, !tbaa !26
  %120 = load ptr, ptr %18, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.leaf_data, ptr %120, i32 0, i32 8
  %122 = load ptr, ptr %121, align 8, !tbaa !24
  %123 = load ptr, ptr %18, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.leaf_data, ptr %123, i32 0, i32 0
  %125 = load i64, ptr %124, align 8, !tbaa !15
  %126 = getelementptr inbounds i64, ptr %122, i64 %125
  %127 = load ptr, ptr %18, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.leaf_data, ptr %127, i32 0, i32 1
  %129 = load i64, ptr %128, align 8, !tbaa !17
  %130 = getelementptr inbounds i64, ptr %126, i64 %129
  %131 = load ptr, ptr %18, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.leaf_data, ptr %131, i32 0, i32 7
  store ptr %130, ptr %132, align 8, !tbaa !27
  %133 = load ptr, ptr %18, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.leaf_data, ptr %133, i32 0, i32 5
  %135 = load ptr, ptr %134, align 8, !tbaa !25
  %136 = load ptr, ptr %10, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.uint64_t_array, ptr %136, i32 0, i32 2
  %138 = load ptr, ptr %137, align 8, !tbaa !28
  %139 = load ptr, ptr %18, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.leaf_data, ptr %139, i32 0, i32 0
  %141 = load i64, ptr %140, align 8, !tbaa !15
  %142 = mul i64 %141, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %135, ptr align 8 %138, i64 %142, i1 false)
  %143 = load ptr, ptr %18, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.leaf_data, ptr %143, i32 0, i32 5
  %145 = load ptr, ptr %144, align 8, !tbaa !25
  %146 = load ptr, ptr %18, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.leaf_data, ptr %146, i32 0, i32 0
  %148 = load i64, ptr %147, align 8, !tbaa !15
  call void @qsort(ptr noundef %145, i64 noundef %148, i64 noundef 8, ptr noundef @uint64_t_cmp)
  %149 = load ptr, ptr %18, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.leaf_data, ptr %149, i32 0, i32 6
  %151 = load ptr, ptr %150, align 8, !tbaa !26
  %152 = load ptr, ptr %11, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.uint64_t_array, ptr %152, i32 0, i32 2
  %154 = load ptr, ptr %153, align 8, !tbaa !28
  %155 = load ptr, ptr %18, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.leaf_data, ptr %155, i32 0, i32 1
  %157 = load i64, ptr %156, align 8, !tbaa !17
  %158 = mul i64 %157, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %151, ptr align 8 %154, i64 %158, i1 false)
  %159 = load ptr, ptr %18, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.leaf_data, ptr %159, i32 0, i32 7
  %161 = load ptr, ptr %160, align 8, !tbaa !27
  %162 = load ptr, ptr %12, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.uint64_t_array, ptr %162, i32 0, i32 2
  %164 = load ptr, ptr %163, align 8, !tbaa !28
  %165 = load ptr, ptr %18, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.leaf_data, ptr %165, i32 0, i32 2
  %167 = load i64, ptr %166, align 8, !tbaa !18
  %168 = mul i64 %167, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %161, ptr align 8 %164, i64 %168, i1 false)
  %169 = load ptr, ptr %18, align 8, !tbaa !5
  %170 = call i64 @leaf_data_serialize(ptr noundef %169, ptr noundef %15)
  store i64 %170, ptr %16, align 8, !tbaa !9
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = load ptr, ptr %15, align 8, !tbaa !5
  %173 = load i64, ptr %16, align 8, !tbaa !9
  %174 = call i32 @disk_store_append(ptr noundef %171, ptr noundef %172, i64 noundef %173)
  store i32 %174, ptr %17, align 4, !tbaa !11
  %175 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %175) #9
  %176 = load ptr, ptr %18, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.leaf_data, ptr %176, i32 0, i32 3
  %178 = load ptr, ptr %177, align 8, !tbaa !19
  call void @free(ptr noundef %178) #9
  %179 = load ptr, ptr %18, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.leaf_data, ptr %179, i32 0, i32 4
  %181 = load ptr, ptr %180, align 8, !tbaa !23
  call void @free(ptr noundef %181) #9
  %182 = load ptr, ptr %18, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.leaf_data, ptr %182, i32 0, i32 8
  %184 = load ptr, ptr %183, align 8, !tbaa !24
  call void @free(ptr noundef %184) #9
  %185 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %185) #9
  %186 = load ptr, ptr %10, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.uint64_t_array, ptr %186, i32 0, i32 0
  store i64 0, ptr %187, align 8, !tbaa !13
  %188 = load ptr, ptr %11, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.uint64_t_array, ptr %188, i32 0, i32 0
  store i64 0, ptr %189, align 8, !tbaa !13
  %190 = load ptr, ptr %12, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.uint64_t_array, ptr %190, i32 0, i32 0
  store i64 0, ptr %191, align 8, !tbaa !13
  %192 = load ptr, ptr %13, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.uint32_t_array, ptr %192, i32 0, i32 2
  %194 = load ptr, ptr %193, align 8, !tbaa !20
  %195 = load ptr, ptr %13, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.uint32_t_array, ptr %195, i32 0, i32 0
  %197 = load i32, ptr %196, align 8, !tbaa !22
  %198 = zext i32 %197 to i64
  %199 = mul i64 %198, 4
  call void @llvm.memset.p0.i64(ptr align 4 %194, i8 0, i64 %199, i1 false)
  %200 = load ptr, ptr %13, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.uint32_t_array, ptr %200, i32 0, i32 0
  store i32 0, ptr %201, align 8, !tbaa !22
  %202 = load ptr, ptr %14, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.uint32_t_array, ptr %202, i32 0, i32 2
  %204 = load ptr, ptr %203, align 8, !tbaa !20
  %205 = load ptr, ptr %14, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.uint32_t_array, ptr %205, i32 0, i32 0
  %207 = load i32, ptr %206, align 8, !tbaa !22
  %208 = zext i32 %207 to i64
  %209 = mul i64 %208, 4
  call void @llvm.memset.p0.i64(ptr align 4 %204, i8 0, i64 %209, i1 false)
  %210 = load ptr, ptr %14, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.uint32_t_array, ptr %210, i32 0, i32 0
  store i32 0, ptr %211, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  ret void
}

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 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 "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 nounwind willreturn memory(argmem: write) }
attributes #8 = { 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 #9 = { nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { noreturn }
attributes #12 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"uint64_t_array", !10, i64 0, !10, i64 8, !6, i64 16}
!15 = !{!16, !10, i64 0}
!16 = !{!"leaf_data", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!17 = !{!16, !10, i64 8}
!18 = !{!16, !10, i64 16}
!19 = !{!16, !6, i64 24}
!20 = !{!21, !6, i64 8}
!21 = !{!"uint32_t_array", !12, i64 0, !12, i64 4, !6, i64 8}
!22 = !{!21, !12, i64 0}
!23 = !{!16, !6, i64 32}
!24 = !{!16, !6, i64 64}
!25 = !{!16, !6, i64 40}
!26 = !{!16, !6, i64 48}
!27 = !{!16, !6, i64 56}
!28 = !{!14, !6, 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"

@ORDER = external dso_local local_unnamed_addr global i32, align 4
@LEAF_POINTERS_SIZE = external dso_local local_unnamed_addr global i64, align 8
@.str.70 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [53 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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 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) #6

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #8

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

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

declare i64 @leaf_data_serialize(ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local void @giggle_bulk_insert_write_leaf_node(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3, ptr nocapture noundef %4, ptr nocapture noundef %5, ptr nocapture noundef %6) local_unnamed_addr #9 {
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #10
  %9 = call i64 @bpt_node_serialize(ptr noundef %0, ptr noundef nonnull %8) #10
  %10 = load ptr, ptr %8, align 8, !tbaa !5
  %11 = call i32 @disk_store_append(ptr noundef %1, ptr noundef %10, i64 noundef %9) #10
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %12) #10
  %13 = call noalias dereferenceable_or_null(72) ptr @malloc(i64 noundef 72) #11
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %7
  %17 = load i64, ptr %2, align 8, !tbaa !9
  store i64 %17, ptr %13, align 8, !tbaa !12
  %18 = load i64, ptr %3, align 8, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %13, i64 8
  store i64 %18, ptr %19, align 8, !tbaa !14
  %20 = load i64, ptr %4, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %13, i64 16
  store i64 %20, ptr %21, align 8, !tbaa !15
  %22 = load i32, ptr @ORDER, align 4, !tbaa !16
  %23 = zext i32 %22 to i64
  %24 = load i64, ptr @LEAF_POINTERS_SIZE, align 8, !tbaa !18
  %25 = call noalias ptr @calloc(i64 noundef %23, i64 noundef %24) #13
  %26 = getelementptr inbounds i8, ptr %13, i64 24
  store ptr %25, ptr %26, align 8, !tbaa !19
  %27 = icmp eq ptr %25, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %16
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.71) #12
  unreachable

29:                                               ; preds = %16
  %30 = getelementptr inbounds i8, ptr %5, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !20
  %32 = load i32, ptr %5, align 8, !tbaa !22
  %33 = zext i32 %32 to i64
  %34 = shl nuw nsw i64 %33, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %25, ptr align 4 %31, i64 %34, i1 false)
  %35 = call noalias ptr @calloc(i64 noundef %23, i64 noundef 4) #13
  %36 = getelementptr inbounds i8, ptr %13, i64 32
  store ptr %35, ptr %36, align 8, !tbaa !23
  %37 = getelementptr inbounds i8, ptr %6, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = load i32, ptr %6, align 8, !tbaa !22
  %40 = zext i32 %39 to i64
  %41 = shl nuw nsw i64 %40, 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %35, ptr align 4 %38, i64 %41, i1 false)
  %42 = add i64 %18, %17
  %43 = add i64 %42, %20
  %44 = shl i64 %43, 3
  %45 = call noalias ptr @malloc(i64 noundef %44) #11
  %46 = getelementptr inbounds i8, ptr %13, i64 64
  store ptr %45, ptr %46, align 8, !tbaa !24
  %47 = icmp eq ptr %45, null
  br i1 %47, label %48, label %49

48:                                               ; preds = %29
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.70) #12
  unreachable

49:                                               ; preds = %29
  %50 = getelementptr inbounds i8, ptr %13, i64 40
  store ptr %45, ptr %50, align 8, !tbaa !25
  %51 = getelementptr inbounds i64, ptr %45, i64 %17
  %52 = getelementptr inbounds i8, ptr %13, i64 48
  store ptr %51, ptr %52, align 8, !tbaa !26
  %53 = getelementptr inbounds i64, ptr %51, i64 %18
  %54 = getelementptr inbounds i8, ptr %13, i64 56
  store ptr %53, ptr %54, align 8, !tbaa !27
  %55 = getelementptr inbounds i8, ptr %2, i64 16
  %56 = load ptr, ptr %55, align 8, !tbaa !28
  %57 = shl i64 %17, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %45, ptr align 8 %56, i64 %57, i1 false)
  call void @qsort(ptr noundef nonnull %45, i64 noundef %17, i64 noundef 8, ptr noundef nonnull @uint64_t_cmp) #10
  %58 = getelementptr inbounds i8, ptr %3, i64 16
  %59 = load ptr, ptr %58, align 8, !tbaa !28
  %60 = shl i64 %18, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %51, ptr align 8 %59, i64 %60, i1 false)
  %61 = getelementptr inbounds i8, ptr %4, i64 16
  %62 = load ptr, ptr %61, align 8, !tbaa !28
  %63 = shl i64 %20, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %53, ptr align 8 %62, i64 %63, i1 false)
  %64 = call i64 @leaf_data_serialize(ptr noundef nonnull %13, ptr noundef nonnull %8) #10
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = call i32 @disk_store_append(ptr noundef %1, ptr noundef %65, i64 noundef %64) #10
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %67) #10
  %68 = load ptr, ptr %26, align 8, !tbaa !19
  call void @free(ptr noundef %68) #10
  %69 = load ptr, ptr %36, align 8, !tbaa !23
  call void @free(ptr noundef %69) #10
  %70 = load ptr, ptr %46, align 8, !tbaa !24
  call void @free(ptr noundef %70) #10
  call void @free(ptr noundef nonnull %13) #10
  store i64 0, ptr %2, align 8, !tbaa !9
  store i64 0, ptr %3, align 8, !tbaa !9
  store i64 0, ptr %4, align 8, !tbaa !9
  %71 = load ptr, ptr %30, align 8, !tbaa !20
  %72 = load i32, ptr %5, align 8, !tbaa !22
  %73 = zext i32 %72 to i64
  %74 = shl nuw nsw i64 %73, 2
  call void @llvm.memset.p0.i64(ptr align 4 %71, i8 0, i64 %74, i1 false)
  store i32 0, ptr %5, align 8, !tbaa !22
  %75 = load ptr, ptr %37, align 8, !tbaa !20
  %76 = load i32, ptr %6, align 8, !tbaa !22
  %77 = zext i32 %76 to i64
  %78 = shl nuw nsw i64 %77, 2
  call void @llvm.memset.p0.i64(ptr align 4 %75, i8 0, i64 %78, i1 false)
  store i32 0, ptr %6, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #10
  ret void
}

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 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 #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 = { "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 = { 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 #8 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { 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 #10 = { nounwind }
attributes #11 = { nounwind allocsize(0) }
attributes #12 = { noreturn nounwind }
attributes #13 = { 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, !11, i64 0}
!10 = !{!"uint64_t_array", !11, i64 0, !11, i64 8, !6, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"leaf_data", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!14 = !{!13, !11, i64 8}
!15 = !{!13, !11, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!13, !6, i64 24}
!20 = !{!21, !6, i64 8}
!21 = !{!"uint32_t_array", !17, i64 0, !17, i64 4, !6, i64 8}
!22 = !{!21, !17, i64 0}
!23 = !{!13, !6, i64 32}
!24 = !{!13, !6, i64 64}
!25 = !{!13, !6, i64 40}
!26 = !{!13, !6, i64 48}
!27 = !{!13, !6, i64 56}
!28 = !{!10, !6, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass