; LLVM IR from ryanlayer/giggle :: test/unit (test_bulk_insert)

; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }
%struct.giggle_index = type { ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.bpt_node = type { ptr }

@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@OFFSET_INDEX_FILE_NAME = external dso_local global ptr, align 8
@CHRM_INDEX_FILE_NAME = external dso_local global ptr, align 8
@ORDER = external dso_local global i32, align 4
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [11 x i8], align 1
@CACHE_FILE_NAME_PREFIX = external dso_local global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [61 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

declare i32 @giggle_bulk_insert_open_files(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef) #1

declare void @input_file_destroy(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind
declare i32 @stat(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @mkdir(ptr noundef, i32 noundef) #2

declare i32 @rmrf(ptr noundef) #1

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

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) #2

declare ptr @offset_index_init(i32 noundef, ptr noundef) #1

declare ptr @chrm_index_init(i32 noundef, ptr noundef) #1

declare ptr @priq_new(i32 noundef) #1

declare void @giggle_bulk_insert_prime_pqs(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

declare void @priq_free(ptr noundef) #1

declare void @giggle_bulk_insert_build_leaf_levels(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

declare void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef) #1

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

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

declare i64 @bpt_node_deserialize(ptr noundef, i64 noundef, ptr noundef) #1

declare void @giggle_index_destroy(ptr noundef) #1

declare void @disk_store_destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_bulk_insert_build_tree_on_leaves_few_order_3() #5 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca %struct.stat, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  store i32 3, ptr @ORDER, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  store ptr @.str.4, ptr %1, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store ptr @.str.9, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 144, ptr %3) #6
  call void @llvm.memset.p0.i64(ptr align 8 %3, i8 0, i64 144, i1 false)
  %22 = load ptr, ptr %2, align 8, !tbaa !9
  %23 = call i32 @stat(ptr noundef %22, ptr noundef %3) #6
  %24 = icmp eq i32 %23, -1
  br i1 %24, label %25, label %28

25:                                               ; preds = %0
  %26 = load ptr, ptr %2, align 8, !tbaa !9
  %27 = call i32 @mkdir(ptr noundef %26, i32 noundef 448) #6
  br label %33

28:                                               ; preds = %0
  %29 = load ptr, ptr %2, align 8, !tbaa !9
  %30 = call i32 @rmrf(ptr noundef %29)
  %31 = load ptr, ptr %2, align 8, !tbaa !9
  %32 = call i32 @mkdir(ptr noundef %31, i32 noundef 448) #6
  br label %33

33:                                               ; preds = %28, %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %34 = call noalias ptr @malloc(i64 noundef 64) #7
  store ptr %34, ptr %4, align 8, !tbaa !9
  %35 = load ptr, ptr %2, align 8, !tbaa !9
  %36 = call noalias ptr @strdup(ptr noundef %35) #6
  %37 = load ptr, ptr %4, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.giggle_index, ptr %37, i32 0, i32 7
  store ptr %36, ptr %38, align 8, !tbaa !11
  %39 = load ptr, ptr %4, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.giggle_index, ptr %39, i32 0, i32 4
  store ptr null, ptr %40, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store ptr null, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %41 = load ptr, ptr %1, align 8, !tbaa !9
  %42 = load ptr, ptr %4, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.giggle_index, ptr %42, i32 0, i32 7
  %44 = load ptr, ptr %43, align 8, !tbaa !11
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.giggle_index, ptr %45, i32 0, i32 4
  %47 = call i32 @giggle_bulk_insert_open_files(ptr noundef %41, ptr noundef %44, ptr noundef %5, ptr noundef %46)
  store i32 %47, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store ptr null, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %48 = load ptr, ptr %4, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.giggle_index, ptr %48, i32 0, i32 7
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !9
  %52 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %7, ptr noundef @.str.2, ptr noundef %50, ptr noundef %51) #6
  store i32 %52, ptr %8, align 4, !tbaa !5
  %53 = load ptr, ptr %7, align 8, !tbaa !9
  %54 = call ptr @offset_index_init(i32 noundef 1000, ptr noundef %53)
  %55 = load ptr, ptr %4, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.giggle_index, ptr %55, i32 0, i32 5
  store ptr %54, ptr %56, align 8, !tbaa !14
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %57) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store ptr null, ptr %9, align 8, !tbaa !9
  %58 = load ptr, ptr %4, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.giggle_index, ptr %58, i32 0, i32 7
  %60 = load ptr, ptr %59, align 8, !tbaa !11
  %61 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !9
  %62 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %9, ptr noundef @.str.2, ptr noundef %60, ptr noundef %61) #6
  store i32 %62, ptr %8, align 4, !tbaa !5
  %63 = load ptr, ptr %9, align 8, !tbaa !9
  %64 = call ptr @chrm_index_init(i32 noundef 24, ptr noundef %63)
  %65 = load ptr, ptr %4, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.giggle_index, ptr %65, i32 0, i32 3
  store ptr %64, ptr %66, align 8, !tbaa !15
  %67 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %67) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = call ptr @priq_new(i32 noundef %68)
  store ptr %69, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = zext i32 %70 to i64
  %72 = mul i64 %71, 16
  %73 = call noalias ptr @malloc(i64 noundef %72) #7
  store ptr %73, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = call ptr @priq_new(i32 noundef %74)
  store ptr %75, ptr %12, align 8, !tbaa !9
  %76 = load ptr, ptr %4, align 8, !tbaa !9
  %77 = load ptr, ptr %11, align 8, !tbaa !9
  %78 = load ptr, ptr %5, align 8, !tbaa !9
  %79 = load i32, ptr %6, align 4, !tbaa !5
  call void @giggle_bulk_insert_prime_pqs(ptr noundef %76, ptr noundef %10, ptr noundef %77, ptr noundef %12, ptr noundef %78, i32 noundef %79)
  %80 = load ptr, ptr %4, align 8, !tbaa !9
  %81 = load ptr, ptr %11, align 8, !tbaa !9
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  %83 = load i32, ptr %6, align 4, !tbaa !5
  call void @giggle_bulk_insert_build_leaf_levels(ptr noundef %80, ptr noundef %10, ptr noundef %81, ptr noundef %12, ptr noundef %82, i32 noundef %83)
  %84 = load ptr, ptr %12, align 8, !tbaa !9
  call void @priq_free(ptr noundef %84)
  %85 = load ptr, ptr %10, align 8, !tbaa !9
  call void @priq_free(ptr noundef %85)
  %86 = load ptr, ptr %11, align 8, !tbaa !9
  call void @free(ptr noundef %86) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %96, %33
  %88 = load i32, ptr %13, align 4, !tbaa !5
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = icmp ult i32 %88, %89
  br i1 %90, label %91, label %99

91:                                               ; preds = %87
  %92 = load ptr, ptr %5, align 8, !tbaa !9
  %93 = load i32, ptr %13, align 4, !tbaa !5
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds ptr, ptr %92, i64 %94
  call void @input_file_destroy(ptr noundef %95)
  br label %96

96:                                               ; preds = %91
  %97 = load i32, ptr %13, align 4, !tbaa !5
  %98 = add i32 %97, 1
  store i32 %98, ptr %13, align 4, !tbaa !5
  br label %87, !llvm.loop !16

99:                                               ; preds = %87
  %100 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %100) #6
  %101 = load ptr, ptr %4, align 8, !tbaa !9
  call void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef %101)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %102 = load ptr, ptr %4, align 8, !tbaa !9
  %103 = getelementptr inbounds %struct.giggle_index, ptr %102, i32 0, i32 0
  %104 = load ptr, ptr %103, align 8, !tbaa !18
  %105 = getelementptr inbounds i32, ptr %104, i64 0
  %106 = load i32, ptr %105, align 4, !tbaa !5
  store i32 %106, ptr %14, align 4, !tbaa !5
  %107 = load i32, ptr %14, align 4, !tbaa !5
  %108 = zext i32 %107 to i64
  call void @UnityAssertEqualNumber(i64 noundef 24, i64 noundef %108, ptr noundef null, i64 noundef 1710, i32 noundef 148)
  call void @giggle_index_destroy(ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store ptr null, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store ptr null, ptr %16, align 8, !tbaa !9
  %109 = load ptr, ptr %2, align 8, !tbaa !9
  %110 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !9
  %111 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %15, ptr noundef @.str.6, ptr noundef %109, ptr noundef %110) #6
  store i32 %111, ptr %8, align 4, !tbaa !5
  %112 = load ptr, ptr %2, align 8, !tbaa !9
  %113 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !9
  %114 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %16, ptr noundef @.str.7, ptr noundef %112, ptr noundef %113) #6
  store i32 %114, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %115 = load ptr, ptr %15, align 8, !tbaa !9
  %116 = load ptr, ptr %16, align 8, !tbaa !9
  %117 = call ptr @disk_store_load(ptr noundef null, ptr noundef %115, ptr noundef null, ptr noundef %116)
  store ptr %117, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %118 = load ptr, ptr %17, align 8, !tbaa !9
  %119 = load i32, ptr %14, align 4, !tbaa !5
  %120 = sub i32 %119, 1
  %121 = call ptr @disk_store_get(ptr noundef %118, i32 noundef %120, ptr noundef %18)
  store ptr %121, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %122 = load ptr, ptr %19, align 8, !tbaa !9
  %123 = load i64, ptr %18, align 8, !tbaa !19
  %124 = call i64 @bpt_node_deserialize(ptr noundef %122, i64 noundef %123, ptr noundef %20)
  store i64 %124, ptr %21, align 8, !tbaa !19
  %125 = load ptr, ptr %19, align 8, !tbaa !9
  call void @free(ptr noundef %125) #6
  %126 = load ptr, ptr %20, align 8, !tbaa !9
  %127 = getelementptr inbounds %struct.bpt_node, ptr %126, i32 0, i32 0
  %128 = load ptr, ptr %127, align 8, !tbaa !21
  %129 = getelementptr inbounds i32, ptr %128, i64 5
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = zext i32 %130 to i64
  call void @UnityAssertEqualNumber(i64 noundef 2, i64 noundef %131, ptr noundef null, i64 noundef 1737, i32 noundef 148)
  %132 = load ptr, ptr %20, align 8, !tbaa !9
  %133 = getelementptr inbounds %struct.bpt_node, ptr %132, i32 0, i32 0
  %134 = load ptr, ptr %133, align 8, !tbaa !21
  %135 = getelementptr inbounds i32, ptr %134, i64 6
  %136 = getelementptr inbounds i32, ptr %135, i64 0
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = zext i32 %137 to i64
  call void @UnityAssertEqualNumber(i64 noundef 51, i64 noundef %138, ptr noundef null, i64 noundef 1738, i32 noundef 148)
  %139 = load ptr, ptr %20, align 8, !tbaa !9
  %140 = getelementptr inbounds %struct.bpt_node, ptr %139, i32 0, i32 0
  %141 = load ptr, ptr %140, align 8, !tbaa !21
  %142 = getelementptr inbounds i32, ptr %141, i64 6
  %143 = getelementptr inbounds i32, ptr %142, i64 1
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = zext i32 %144 to i64
  call void @UnityAssertEqualNumber(i64 noundef 80, i64 noundef %145, ptr noundef null, i64 noundef 1739, i32 noundef 148)
  %146 = load ptr, ptr %20, align 8, !tbaa !9
  %147 = getelementptr inbounds %struct.bpt_node, ptr %146, i32 0, i32 0
  %148 = load ptr, ptr %147, align 8, !tbaa !21
  %149 = load i32, ptr @ORDER, align 4, !tbaa !5
  %150 = add i32 6, %149
  %151 = add i32 %150, 2
  %152 = zext i32 %151 to i64
  %153 = getelementptr inbounds i32, ptr %148, i64 %152
  %154 = getelementptr inbounds i32, ptr %153, i64 0
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = zext i32 %155 to i64
  call void @UnityAssertEqualNumber(i64 noundef 21, i64 noundef %156, ptr noundef null, i64 noundef 1740, i32 noundef 148)
  %157 = load ptr, ptr %20, align 8, !tbaa !9
  %158 = getelementptr inbounds %struct.bpt_node, ptr %157, i32 0, i32 0
  %159 = load ptr, ptr %158, align 8, !tbaa !21
  %160 = load i32, ptr @ORDER, align 4, !tbaa !5
  %161 = add i32 6, %160
  %162 = add i32 %161, 2
  %163 = zext i32 %162 to i64
  %164 = getelementptr inbounds i32, ptr %159, i64 %163
  %165 = getelementptr inbounds i32, ptr %164, i64 1
  %166 = load i32, ptr %165, align 4, !tbaa !5
  %167 = zext i32 %166 to i64
  call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %167, ptr noundef null, i64 noundef 1741, i32 noundef 148)
  %168 = load ptr, ptr %20, align 8, !tbaa !9
  %169 = getelementptr inbounds %struct.bpt_node, ptr %168, i32 0, i32 0
  %170 = load ptr, ptr %169, align 8, !tbaa !21
  %171 = load i32, ptr @ORDER, align 4, !tbaa !5
  %172 = add i32 6, %171
  %173 = add i32 %172, 2
  %174 = zext i32 %173 to i64
  %175 = getelementptr inbounds i32, ptr %170, i64 %174
  %176 = getelementptr inbounds i32, ptr %175, i64 2
  %177 = load i32, ptr %176, align 4, !tbaa !5
  %178 = zext i32 %177 to i64
  call void @UnityAssertEqualNumber(i64 noundef 23, i64 noundef %178, ptr noundef null, i64 noundef 1742, i32 noundef 148)
  call void @disk_store_destroy(ptr noundef %17)
  %179 = load ptr, ptr %2, align 8, !tbaa !9
  %180 = call i32 @rmrf(ptr noundef %179)
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 144, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #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 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 48}
!12 = !{!"giggle_index", !10, i64 0, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !10, i64 32}
!15 = !{!12, !10, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !10, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!22, !10, i64 0}
!22 = !{!"bpt_node", !10, i64 0}


; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@OFFSET_INDEX_FILE_NAME = external dso_local local_unnamed_addr global ptr, align 8
@CHRM_INDEX_FILE_NAME = external dso_local local_unnamed_addr global ptr, align 8
@ORDER = external dso_local local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [11 x i8], align 1
@CACHE_FILE_NAME_PREFIX = external dso_local local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [61 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

declare i32 @giggle_bulk_insert_open_files(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

declare void @input_file_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nofree nounwind
declare noundef i32 @stat(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @mkdir(ptr nocapture noundef readonly, i32 noundef) local_unnamed_addr #4

declare i32 @rmrf(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #7

declare ptr @offset_index_init(i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @chrm_index_init(i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @priq_new(i32 noundef) local_unnamed_addr #1

declare void @giggle_bulk_insert_prime_pqs(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @priq_free(ptr noundef) local_unnamed_addr #1

declare void @giggle_bulk_insert_build_leaf_levels(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef) local_unnamed_addr #1

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

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

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

declare void @giggle_index_destroy(ptr noundef) local_unnamed_addr #1

declare void @disk_store_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_bulk_insert_build_tree_on_leaves_few_order_3() local_unnamed_addr #8 {
  %1 = alloca %struct.stat, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  store i32 3, ptr @ORDER, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %1) #9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(144) %1, i8 0, i64 144, i1 false)
  %13 = call i32 @stat(ptr noundef nonnull @.str.9, ptr noundef nonnull %1) #9
  %14 = icmp eq i32 %13, -1
  br i1 %14, label %17, label %15

15:                                               ; preds = %0
  %16 = tail call i32 @rmrf(ptr noundef nonnull @.str.9) #9
  br label %17

17:                                               ; preds = %0, %15
  %18 = tail call i32 @mkdir(ptr noundef nonnull @.str.9, i32 noundef 448) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #9
  %19 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #10
  store ptr %19, ptr %2, align 8, !tbaa !9
  %20 = tail call noalias ptr @strdup(ptr noundef nonnull @.str.9) #9
  %21 = getelementptr inbounds i8, ptr %19, i64 48
  store ptr %20, ptr %21, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %19, i64 24
  store ptr null, ptr %22, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #9
  store ptr null, ptr %3, align 8, !tbaa !9
  %23 = call i32 @giggle_bulk_insert_open_files(ptr noundef nonnull @.str.4, ptr noundef %20, ptr noundef nonnull %3, ptr noundef nonnull %22) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #9
  store ptr null, ptr %4, align 8, !tbaa !9
  %24 = load ptr, ptr %21, align 8, !tbaa !11
  %25 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !9
  %26 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.2, ptr noundef %24, ptr noundef %25) #9
  %27 = load ptr, ptr %4, align 8, !tbaa !9
  %28 = call ptr @offset_index_init(i32 noundef 1000, ptr noundef %27) #9
  %29 = getelementptr inbounds i8, ptr %19, i64 32
  store ptr %28, ptr %29, align 8, !tbaa !14
  %30 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %30) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #9
  store ptr null, ptr %5, align 8, !tbaa !9
  %31 = load ptr, ptr %21, align 8, !tbaa !11
  %32 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !9
  %33 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %5, ptr noundef nonnull @.str.2, ptr noundef %31, ptr noundef %32) #9
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = call ptr @chrm_index_init(i32 noundef 24, ptr noundef %34) #9
  %36 = getelementptr inbounds i8, ptr %19, i64 16
  store ptr %35, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %37) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #9
  %38 = call ptr @priq_new(i32 noundef %23) #9
  store ptr %38, ptr %6, align 8, !tbaa !9
  %39 = zext i32 %23 to i64
  %40 = shl nuw nsw i64 %39, 4
  %41 = call noalias ptr @malloc(i64 noundef %40) #10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #9
  %42 = call ptr @priq_new(i32 noundef %23) #9
  store ptr %42, ptr %7, align 8, !tbaa !9
  %43 = load ptr, ptr %3, align 8, !tbaa !9
  call void @giggle_bulk_insert_prime_pqs(ptr noundef %19, ptr noundef nonnull %6, ptr noundef %41, ptr noundef nonnull %7, ptr noundef %43, i32 noundef %23) #9
  %44 = load ptr, ptr %3, align 8, !tbaa !9
  call void @giggle_bulk_insert_build_leaf_levels(ptr noundef %19, ptr noundef nonnull %6, ptr noundef %41, ptr noundef nonnull %7, ptr noundef %44, i32 noundef %23) #9
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  call void @priq_free(ptr noundef %45) #9
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  call void @priq_free(ptr noundef %46) #9
  call void @free(ptr noundef %41) #9
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %17, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %17 ]
  %47 = load ptr, ptr %3, align 8, !tbaa !9
  %48 = getelementptr inbounds ptr, ptr %47, i64 %indvars.iv
  call void @input_file_destroy(ptr noundef %48) #9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %39
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %17
  %49 = load ptr, ptr %3, align 8, !tbaa !9
  call void @free(ptr noundef %49) #9
  call void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef %19) #9
  %50 = load ptr, ptr %19, align 8, !tbaa !18
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = zext i32 %51 to i64
  call void @UnityAssertEqualNumber(i64 noundef 24, i64 noundef %52, ptr noundef null, i64 noundef 1710, i32 noundef 148) #9
  call void @giggle_index_destroy(ptr noundef nonnull %2) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #9
  store ptr null, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #9
  store ptr null, ptr %9, align 8, !tbaa !9
  %53 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !9
  %54 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %8, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.9, ptr noundef %53) #9
  %55 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !9
  %56 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.9, ptr noundef %55) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #9
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  %58 = load ptr, ptr %9, align 8, !tbaa !9
  %59 = call ptr @disk_store_load(ptr noundef null, ptr noundef %57, ptr noundef null, ptr noundef %58) #9
  store ptr %59, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #9
  %60 = add i32 %51, -1
  %61 = call ptr @disk_store_get(ptr noundef %59, i32 noundef %60, ptr noundef nonnull %11) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #9
  %62 = load i64, ptr %11, align 8, !tbaa !19
  %63 = call i64 @bpt_node_deserialize(ptr noundef %61, i64 noundef %62, ptr noundef nonnull %12) #9
  call void @free(ptr noundef %61) #9
  %64 = load ptr, ptr %12, align 8, !tbaa !9
  %65 = load ptr, ptr %64, align 8, !tbaa !21
  %66 = getelementptr inbounds i8, ptr %65, i64 20
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = zext i32 %67 to i64
  call void @UnityAssertEqualNumber(i64 noundef 2, i64 noundef %68, ptr noundef null, i64 noundef 1737, i32 noundef 148) #9
  %69 = load ptr, ptr %12, align 8, !tbaa !9
  %70 = load ptr, ptr %69, align 8, !tbaa !21
  %71 = getelementptr inbounds i8, ptr %70, i64 24
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = zext i32 %72 to i64
  call void @UnityAssertEqualNumber(i64 noundef 51, i64 noundef %73, ptr noundef null, i64 noundef 1738, i32 noundef 148) #9
  %74 = load ptr, ptr %12, align 8, !tbaa !9
  %75 = load ptr, ptr %74, align 8, !tbaa !21
  %76 = getelementptr inbounds i8, ptr %75, i64 28
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = zext i32 %77 to i64
  call void @UnityAssertEqualNumber(i64 noundef 80, i64 noundef %78, ptr noundef null, i64 noundef 1739, i32 noundef 148) #9
  %79 = load ptr, ptr %12, align 8, !tbaa !9
  %80 = load ptr, ptr %79, align 8, !tbaa !21
  %81 = load i32, ptr @ORDER, align 4, !tbaa !5
  %82 = add i32 %81, 8
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds i32, ptr %80, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = zext i32 %85 to i64
  call void @UnityAssertEqualNumber(i64 noundef 21, i64 noundef %86, ptr noundef null, i64 noundef 1740, i32 noundef 148) #9
  %87 = load ptr, ptr %12, align 8, !tbaa !9
  %88 = load ptr, ptr %87, align 8, !tbaa !21
  %89 = load i32, ptr @ORDER, align 4, !tbaa !5
  %90 = add i32 %89, 8
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr %88, i64 %91
  %93 = getelementptr inbounds i8, ptr %92, i64 4
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = zext i32 %94 to i64
  call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %95, ptr noundef null, i64 noundef 1741, i32 noundef 148) #9
  %96 = load ptr, ptr %12, align 8, !tbaa !9
  %97 = load ptr, ptr %96, align 8, !tbaa !21
  %98 = load i32, ptr @ORDER, align 4, !tbaa !5
  %99 = add i32 %98, 8
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds i32, ptr %97, i64 %100
  %102 = getelementptr inbounds i8, ptr %101, i64 8
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = zext i32 %103 to i64
  call void @UnityAssertEqualNumber(i64 noundef 23, i64 noundef %104, ptr noundef null, i64 noundef 1742, i32 noundef 148) #9
  call void @disk_store_destroy(ptr noundef nonnull %10) #9
  %105 = call i32 @rmrf(ptr noundef nonnull @.str.9) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #9
  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
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %1) #9
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nofree 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 = { 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 #6 = { mustprogress nofree nounwind willreturn 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 "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 = { 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) }

!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 48}
!12 = !{!"giggle_index", !10, i64 0, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !10, i64 32}
!15 = !{!12, !10, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !10, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!22, !10, i64 0}
!22 = !{!"bpt_node", !10, i64 0}


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