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

@ROOT_IDS_FILE_NAME = external dso_local global ptr, align 8
@CACHE_FILE_NAME_PREFIX = external dso_local global ptr, align 8
@.str.27 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [12 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: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
define dso_local void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %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 i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.giggle_index, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.chrm_index, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds %struct.ordered_set, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.giggle_index, ptr %21, i32 0, i32 1
  store i32 %20, ptr %22, align 8, !tbaa !16
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.giggle_index, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !16
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.giggle_index, ptr %26, i32 0, i32 2
  store i32 %25, ptr %27, align 4, !tbaa !17
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.giggle_index, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !17
  %31 = zext i32 %30 to i64
  %32 = mul i64 %31, 4
  %33 = call noalias ptr @malloc(i64 noundef %32) #6
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.giggle_index, ptr %34, i32 0, i32 0
  store ptr %33, ptr %35, align 8, !tbaa !18
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.giggle_index, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

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

41:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.giggle_index, ptr %42, i32 0, i32 8
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.giggle_index, ptr %44, i32 0, i32 7
  %46 = load ptr, ptr %45, align 8, !tbaa !19
  %47 = load ptr, ptr @ROOT_IDS_FILE_NAME, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %43, ptr noundef @.str.27, ptr noundef %46, ptr noundef %47) #8
  store i32 %48, ptr %3, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #8
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #8
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 0, ptr %7, align 4, !tbaa !20
  br label %49

49:                                               ; preds = %122, %41
  %50 = load i32, ptr %7, align 4, !tbaa !20
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.giggle_index, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.chrm_index, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !12
  %56 = getelementptr inbounds %struct.ordered_set, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !14
  %58 = icmp ult i32 %50, %57
  br i1 %58, label %59, label %125

59:                                               ; preds = %49
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.giggle_index, ptr %60, i32 0, i32 7
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  %63 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !20
  %65 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %4, ptr noundef @.str.60, ptr noundef %62, ptr noundef %63, i32 noundef %64) #8
  store i32 %65, ptr %3, align 4, !tbaa !20
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.giggle_index, ptr %66, i32 0, i32 7
  %68 = load ptr, ptr %67, align 8, !tbaa !19
  %69 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !5
  %70 = load i32, ptr %7, align 4, !tbaa !20
  %71 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %5, ptr noundef @.str.61, ptr noundef %68, ptr noundef %69, i32 noundef %70) #8
  store i32 %71, ptr %3, align 4, !tbaa !20
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = call ptr @disk_store_load(ptr noundef null, ptr noundef %72, ptr noundef null, ptr noundef %73)
  store ptr %74, ptr %6, align 8, !tbaa !5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %75) #8
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %76) #8
  store ptr null, ptr %4, align 8, !tbaa !5
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.disk_store, ptr %77, i32 0, i32 5
  %79 = load i32, ptr %78, align 4, !tbaa !21
  store i32 %79, ptr %8, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %80 = load i32, ptr %8, align 4, !tbaa !20
  %81 = udiv i32 %80, 2
  store i32 %81, ptr %9, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 1, ptr %10, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 1, ptr %11, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = load i32, ptr %10, align 4, !tbaa !20
  %84 = load i32, ptr %9, align 4, !tbaa !20
  %85 = load i32, ptr %11, align 4, !tbaa !20
  %86 = call i32 @giggle_bulk_insert_add_tree_level(ptr noundef %82, i32 noundef %83, i32 noundef %84, i32 noundef %85, ptr noundef %12)
  store i32 %86, ptr %13, align 4, !tbaa !20
  br label %87

87:                                               ; preds = %90, %59
  %88 = load i32, ptr %13, align 4, !tbaa !20
  %89 = icmp ugt i32 %88, 1
  br i1 %89, label %90, label %98

90:                                               ; preds = %87
  %91 = load i32, ptr %13, align 4, !tbaa !20
  store i32 %91, ptr %9, align 4, !tbaa !20
  %92 = load i32, ptr %12, align 4, !tbaa !20
  store i32 %92, ptr %10, align 4, !tbaa !20
  store i32 0, ptr %11, align 4, !tbaa !20
  store i32 0, ptr %12, align 4, !tbaa !20
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load i32, ptr %10, align 4, !tbaa !20
  %95 = load i32, ptr %9, align 4, !tbaa !20
  %96 = load i32, ptr %11, align 4, !tbaa !20
  %97 = call i32 @giggle_bulk_insert_add_tree_level(ptr noundef %93, i32 noundef %94, i32 noundef %95, i32 noundef %96, ptr noundef %12)
  store i32 %97, ptr %13, align 4, !tbaa !20
  br label %87, !llvm.loop !24

98:                                               ; preds = %87
  %99 = load i32, ptr %13, align 4, !tbaa !20
  %100 = icmp eq i32 %99, 1
  br i1 %100, label %101, label %109

101:                                              ; preds = %98
  %102 = load i32, ptr %12, align 4, !tbaa !20
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.giggle_index, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !18
  %106 = load i32, ptr %7, align 4, !tbaa !20
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds i32, ptr %105, i64 %107
  store i32 %102, ptr %108, align 4, !tbaa !20
  br label %121

109:                                              ; preds = %98
  %110 = load i32, ptr %13, align 4, !tbaa !20
  %111 = icmp eq i32 %110, 0
  br i1 %111, label %112, label %120

112:                                              ; preds = %109
  %113 = load i32, ptr %10, align 4, !tbaa !20
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.giggle_index, ptr %114, i32 0, i32 0
  %116 = load ptr, ptr %115, align 8, !tbaa !18
  %117 = load i32, ptr %7, align 4, !tbaa !20
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr %116, i64 %118
  store i32 %113, ptr %119, align 4, !tbaa !20
  br label %120

120:                                              ; preds = %112, %109
  br label %121

121:                                              ; preds = %120, %101
  call void @disk_store_destroy(ptr noundef %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %122

122:                                              ; preds = %121
  %123 = load i32, ptr %7, align 4, !tbaa !20
  %124 = add i32 %123, 1
  store i32 %124, ptr %7, align 4, !tbaa !20
  br label %49, !llvm.loop !26

125:                                              ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  ret void
}

declare ptr @disk_store_load(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

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

declare void @disk_store_destroy(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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { noreturn }
attributes #8 = { nounwind }

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

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


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

@ROOT_IDS_FILE_NAME = external dso_local local_unnamed_addr global ptr, align 8
@CACHE_FILE_NAME_PREFIX = external dso_local local_unnamed_addr global ptr, align 8
@.str.27 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [12 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: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef %0) local_unnamed_addr #5 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %11, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %11, ptr %13, align 4, !tbaa !16
  %14 = zext i32 %11 to i64
  %15 = shl nuw nsw i64 %14, 2
  %16 = tail call noalias ptr @malloc(i64 noundef %15) #7
  store ptr %16, ptr %0, align 8, !tbaa !17
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

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

19:                                               ; preds = %1
  %20 = getelementptr inbounds i8, ptr %0, i64 56
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %23 = load ptr, ptr @ROOT_IDS_FILE_NAME, align 8, !tbaa !19
  %24 = tail call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %20, ptr noundef nonnull @.str.27, ptr noundef %22, ptr noundef %23) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #9
  store ptr null, ptr %2, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #9
  store ptr null, ptr %3, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #9
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !13
  %.not = icmp eq i32 %29, 0
  br i1 %.not, label %._crit_edge38, label %.lr.ph37

.lr.ph37:                                         ; preds = %19, %._crit_edge
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge ], [ 0, %19 ]
  %30 = load ptr, ptr %21, align 8, !tbaa !18
  %31 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !19
  %32 = trunc nuw i64 %indvars.iv to i32
  %33 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %2, ptr noundef nonnull @.str.60, ptr noundef %30, ptr noundef %31, i32 noundef %32) #9
  %34 = load ptr, ptr %21, align 8, !tbaa !18
  %35 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !19
  %36 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.61, ptr noundef %34, ptr noundef %35, i32 noundef %32) #9
  %37 = load ptr, ptr %2, align 8, !tbaa !19
  %38 = load ptr, ptr %3, align 8, !tbaa !19
  %39 = call ptr @disk_store_load(ptr noundef null, ptr noundef %37, ptr noundef null, ptr noundef %38) #9
  store ptr %39, ptr %4, align 8, !tbaa !19
  %40 = load ptr, ptr %2, align 8, !tbaa !19
  call void @free(ptr noundef %40) #9
  %41 = load ptr, ptr %3, align 8, !tbaa !19
  call void @free(ptr noundef %41) #9
  store ptr null, ptr %2, align 8, !tbaa !19
  store ptr null, ptr %3, align 8, !tbaa !19
  %42 = load ptr, ptr %4, align 8, !tbaa !19
  %43 = getelementptr inbounds i8, ptr %42, i64 36
  %44 = load i32, ptr %43, align 4, !tbaa !20
  %45 = lshr i32 %44, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #9
  store i32 0, ptr %5, align 4, !tbaa !23
  %46 = call i32 @giggle_bulk_insert_add_tree_level(ptr noundef %42, i32 noundef 1, i32 noundef %45, i32 noundef 1, ptr noundef nonnull %5)
  %47 = icmp ugt i32 %46, 1
  br i1 %47, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph37, %.lr.ph
  %.033 = phi i32 [ %50, %.lr.ph ], [ %46, %.lr.ph37 ]
  %48 = load i32, ptr %5, align 4, !tbaa !23
  store i32 0, ptr %5, align 4, !tbaa !23
  %49 = load ptr, ptr %4, align 8, !tbaa !19
  %50 = call i32 @giggle_bulk_insert_add_tree_level(ptr noundef %49, i32 noundef %48, i32 noundef %.033, i32 noundef 0, ptr noundef nonnull %5)
  %51 = icmp ugt i32 %50, 1
  br i1 %51, label %.lr.ph, label %._crit_edge, !llvm.loop !24

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph37
  %.031.lcssa = phi i32 [ 1, %.lr.ph37 ], [ %48, %.lr.ph ]
  %.0.lcssa = phi i32 [ %46, %.lr.ph37 ], [ %50, %.lr.ph ]
  %.not39 = icmp eq i32 %.0.lcssa, 0
  %52 = load i32, ptr %5, align 4
  %.031.lcssa.sink = select i1 %.not39, i32 %.031.lcssa, i32 %52
  %53 = load ptr, ptr %0, align 8, !tbaa !17
  %54 = getelementptr inbounds i32, ptr %53, i64 %indvars.iv
  store i32 %.031.lcssa.sink, ptr %54, align 4, !tbaa !23
  call void @disk_store_destroy(ptr noundef nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 8
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = getelementptr inbounds i8, ptr %57, i64 8
  %59 = load i32, ptr %58, align 8, !tbaa !13
  %60 = zext i32 %59 to i64
  %61 = icmp ult i64 %indvars.iv.next, %60
  br i1 %61, label %.lr.ph37, label %._crit_edge38, !llvm.loop !26

._crit_edge38:                                    ; preds = %._crit_edge, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #9
  ret void
}

declare ptr @disk_store_load(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

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

declare void @disk_store_destroy(ptr noundef) local_unnamed_addr #6

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 = { 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 #5 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { "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) }
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 16}
!6 = !{!"giggle_index", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 8}
!12 = !{!"chrm_index", !7, i64 0, !7, i64 8}
!13 = !{!14, !10, i64 8}
!14 = !{!"ordered_set", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 24, !7, i64 32}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !10, i64 12}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !7, i64 48}
!19 = !{!7, !7, i64 0}
!20 = !{!21, !10, i64 36}
!21 = !{!"disk_store", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !22, i64 40, !22, i64 48, !7, i64 56, !7, i64 64, !8, i64 72, !7, i64 80}
!22 = !{!"long", !8, i64 0}
!23 = !{!10, !10, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}


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