; 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.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.file_index = type { ptr, ptr }
%struct.unordered_list = type { ptr, i32, i32 }
%struct.file_data = type { ptr, i32, double }
%struct.offset_index = type { ptr, ptr, i32, ptr, i32 }
%struct.file_id_offset_pairs = type { i64, i64, ptr }

@CHRM_INDEX_FILE_NAME = external dso_local global ptr, align 8
@stderr = external global ptr, align 8
@.str.24 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [6 x i8], align 1
@OFFSET_INDEX_FILE_NAME = external dso_local global ptr, align 8
@METADATA_INDEX_FILE_NAME = external dso_local global ptr, align 8
@.str.28 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [37 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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #3

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

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

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

declare ptr @metadata_index_init(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @file_index_destroy(ptr noundef) #5

declare void @offset_index_destroy(ptr noundef) #3

declare void @metadata_index_destroy(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @chrm_index_destroy(ptr noundef) #5

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

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

declare void @input_file_destroy(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

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

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

declare i32 @rmrf(ptr noundef) #3

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

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

declare i32 @fclose(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @chrm_index_store(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @file_index_store(ptr noundef) #5

declare void @offset_index_store(ptr noundef) #3

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

30:                                               ; preds = %4
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call i32 @mkdir(ptr noundef %31, i32 noundef 448) #7
  br label %46

33:                                               ; preds = %4
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %41

36:                                               ; preds = %33
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call i32 @rmrf(ptr noundef %37)
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = call i32 @mkdir(ptr noundef %39, i32 noundef 448) #7
  br label %45

41:                                               ; preds = %33
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.24, ptr noundef %43) #7
  store i64 0, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %277

45:                                               ; preds = %36
  br label %46

46:                                               ; preds = %45, %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %47 = call noalias ptr @malloc(i64 noundef 64) #8
  store ptr %47, ptr %12, align 8, !tbaa !5
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %51

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

51:                                               ; preds = %46
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = call noalias ptr @strdup(ptr noundef %52) #7
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.giggle_index, ptr %54, i32 0, i32 7
  store ptr %53, ptr %55, align 8, !tbaa !11
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.giggle_index, ptr %56, i32 0, i32 4
  store ptr null, ptr %57, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.giggle_index, ptr %59, i32 0, i32 7
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.giggle_index, ptr %62, i32 0, i32 4
  %64 = call i32 @giggle_bulk_insert_open_files(ptr noundef %58, ptr noundef %61, ptr noundef %13, ptr noundef %63)
  store i32 %64, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.giggle_index, ptr %65, i32 0, i32 7
  %67 = load ptr, ptr %66, align 8, !tbaa !11
  %68 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !5
  %69 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %15, ptr noundef @.str.27, ptr noundef %67, ptr noundef %68) #7
  store i32 %69, ptr %16, align 4, !tbaa !9
  %70 = load ptr, ptr %15, align 8, !tbaa !5
  %71 = call ptr @offset_index_init(i32 noundef 1000, ptr noundef %70)
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.giggle_index, ptr %72, i32 0, i32 5
  store ptr %71, ptr %73, align 8, !tbaa !14
  %74 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %74) #7
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.giggle_index, ptr %75, i32 0, i32 6
  store ptr null, ptr %76, align 8, !tbaa !15
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %91

79:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  store ptr null, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.giggle_index, ptr %80, i32 0, i32 7
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = load ptr, ptr @METADATA_INDEX_FILE_NAME, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %17, ptr noundef @.str.27, ptr noundef %82, ptr noundef %83) #7
  store i32 %84, ptr %18, align 4, !tbaa !9
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = load ptr, ptr %17, align 8, !tbaa !5
  %87 = call ptr @metadata_index_init(ptr noundef %85, ptr noundef %86)
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.giggle_index, ptr %88, i32 0, i32 6
  store ptr %87, ptr %89, align 8, !tbaa !15
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %90) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %91

91:                                               ; preds = %79, %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  store ptr null, ptr %19, align 8, !tbaa !5
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.giggle_index, ptr %92, i32 0, i32 7
  %94 = load ptr, ptr %93, align 8, !tbaa !11
  %95 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !5
  %96 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %19, ptr noundef @.str.27, ptr noundef %94, ptr noundef %95) #7
  store i32 %96, ptr %16, align 4, !tbaa !9
  %97 = load ptr, ptr %19, align 8, !tbaa !5
  %98 = call ptr @chrm_index_init(i32 noundef 24, ptr noundef %97)
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.giggle_index, ptr %99, i32 0, i32 3
  store ptr %98, ptr %100, align 8, !tbaa !16
  %101 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %101) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %102 = load i32, ptr %14, align 4, !tbaa !9
  %103 = call ptr @priq_new(i32 noundef %102)
  store ptr %103, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %104 = load i32, ptr %14, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  %106 = mul i64 %105, 16
  %107 = call noalias ptr @malloc(i64 noundef %106) #8
  store ptr %107, ptr %21, align 8, !tbaa !5
  %108 = load ptr, ptr %21, align 8, !tbaa !5
  %109 = icmp eq ptr %108, null
  br i1 %109, label %110, label %111

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

111:                                              ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %112 = load i32, ptr %14, align 4, !tbaa !9
  %113 = call ptr @priq_new(i32 noundef %112)
  store ptr %113, ptr %22, align 8, !tbaa !5
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  %115 = load ptr, ptr %21, align 8, !tbaa !5
  %116 = load ptr, ptr %13, align 8, !tbaa !5
  %117 = load i32, ptr %14, align 4, !tbaa !9
  call void @giggle_bulk_insert_prime_pqs(ptr noundef %114, ptr noundef %20, ptr noundef %115, ptr noundef %22, ptr noundef %116, i32 noundef %117)
  %118 = load ptr, ptr %12, align 8, !tbaa !5
  %119 = load ptr, ptr %21, align 8, !tbaa !5
  %120 = load ptr, ptr %13, align 8, !tbaa !5
  %121 = load i32, ptr %14, align 4, !tbaa !9
  call void @giggle_bulk_insert_build_leaf_levels(ptr noundef %118, ptr noundef %20, ptr noundef %119, ptr noundef %22, ptr noundef %120, i32 noundef %121)
  %122 = load ptr, ptr %22, align 8, !tbaa !5
  call void @priq_free(ptr noundef %122)
  %123 = load ptr, ptr %20, align 8, !tbaa !5
  call void @priq_free(ptr noundef %123)
  %124 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %124) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %134, %111
  %126 = load i32, ptr %23, align 4, !tbaa !9
  %127 = load i32, ptr %14, align 4, !tbaa !9
  %128 = icmp ult i32 %126, %127
  br i1 %128, label %129, label %137

129:                                              ; preds = %125
  %130 = load ptr, ptr %13, align 8, !tbaa !5
  %131 = load i32, ptr %23, align 4, !tbaa !9
  %132 = zext i32 %131 to i64
  %133 = getelementptr inbounds ptr, ptr %130, i64 %132
  call void @input_file_destroy(ptr noundef %133)
  br label %134

134:                                              ; preds = %129
  %135 = load i32, ptr %23, align 4, !tbaa !9
  %136 = add i32 %135, 1
  store i32 %136, ptr %23, align 4, !tbaa !9
  br label %125, !llvm.loop !17

137:                                              ; preds = %125
  %138 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %138) #7
  %139 = load ptr, ptr %12, align 8, !tbaa !5
  call void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef %139)
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %166, %137
  %141 = load i32, ptr %23, align 4, !tbaa !9
  %142 = load ptr, ptr %12, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.giggle_index, ptr %142, i32 0, i32 4
  %144 = load ptr, ptr %143, align 8, !tbaa !13
  %145 = getelementptr inbounds %struct.file_index, ptr %144, i32 0, i32 1
  %146 = load ptr, ptr %145, align 8, !tbaa !19
  %147 = getelementptr inbounds %struct.unordered_list, ptr %146, i32 0, i32 1
  %148 = load i32, ptr %147, align 8, !tbaa !21
  %149 = icmp ult i32 %141, %148
  br i1 %149, label %150, label %169

150:                                              ; preds = %140
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  %151 = load ptr, ptr %12, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.giggle_index, ptr %151, i32 0, i32 4
  %153 = load ptr, ptr %152, align 8, !tbaa !13
  %154 = load i32, ptr %23, align 4, !tbaa !9
  %155 = call ptr @file_index_get(ptr noundef %153, i32 noundef %154)
  store ptr %155, ptr %24, align 8, !tbaa !5
  %156 = load ptr, ptr %24, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.file_data, ptr %156, i32 0, i32 2
  %158 = load double, ptr %157, align 8, !tbaa !23
  %159 = load ptr, ptr %24, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.file_data, ptr %159, i32 0, i32 1
  %161 = load i32, ptr %160, align 8, !tbaa !26
  %162 = uitofp i32 %161 to double
  %163 = fdiv double %158, %162
  %164 = load ptr, ptr %24, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.file_data, ptr %164, i32 0, i32 2
  store double %163, ptr %165, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  br label %166

166:                                              ; preds = %150
  %167 = load i32, ptr %23, align 4, !tbaa !9
  %168 = add i32 %167, 1
  store i32 %168, ptr %23, align 4, !tbaa !9
  br label %140, !llvm.loop !27

169:                                              ; preds = %140
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #7
  %170 = load ptr, ptr %12, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.giggle_index, ptr %170, i32 0, i32 8
  %172 = load ptr, ptr %171, align 8, !tbaa !28
  %173 = call noalias ptr @fopen(ptr noundef %172, ptr noundef @.str.28)
  store ptr %173, ptr %25, align 8, !tbaa !5
  %174 = load ptr, ptr %12, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.giggle_index, ptr %174, i32 0, i32 1
  %176 = load ptr, ptr %25, align 8, !tbaa !5
  %177 = call i64 @fwrite(ptr noundef %175, i64 noundef 4, i64 noundef 1, ptr noundef %176)
  %178 = icmp ne i64 %177, 1
  br i1 %178, label %179, label %183

179:                                              ; preds = %169
  %180 = load ptr, ptr %12, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.giggle_index, ptr %180, i32 0, i32 8
  %182 = load ptr, ptr %181, align 8, !tbaa !28
  call void (i32, ptr, ...) @err(i32 noundef 74, ptr noundef @.str.29, ptr noundef %182) #9
  unreachable

183:                                              ; preds = %169
  %184 = load ptr, ptr %12, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.giggle_index, ptr %184, i32 0, i32 2
  %186 = load ptr, ptr %25, align 8, !tbaa !5
  %187 = call i64 @fwrite(ptr noundef %185, i64 noundef 4, i64 noundef 1, ptr noundef %186)
  %188 = icmp ne i64 %187, 1
  br i1 %188, label %189, label %193

189:                                              ; preds = %183
  %190 = load ptr, ptr %12, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.giggle_index, ptr %190, i32 0, i32 8
  %192 = load ptr, ptr %191, align 8, !tbaa !28
  call void (i32, ptr, ...) @err(i32 noundef 74, ptr noundef @.str.30, ptr noundef %192) #9
  unreachable

193:                                              ; preds = %183
  %194 = load ptr, ptr %12, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.giggle_index, ptr %194, i32 0, i32 0
  %196 = load ptr, ptr %195, align 8, !tbaa !29
  %197 = load ptr, ptr %12, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.giggle_index, ptr %197, i32 0, i32 1
  %199 = load i32, ptr %198, align 8, !tbaa !30
  %200 = zext i32 %199 to i64
  %201 = load ptr, ptr %25, align 8, !tbaa !5
  %202 = call i64 @fwrite(ptr noundef %196, i64 noundef 4, i64 noundef %200, ptr noundef %201)
  %203 = load ptr, ptr %12, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.giggle_index, ptr %203, i32 0, i32 1
  %205 = load i32, ptr %204, align 8, !tbaa !30
  %206 = zext i32 %205 to i64
  %207 = icmp ne i64 %202, %206
  br i1 %207, label %208, label %212

208:                                              ; preds = %193
  %209 = load ptr, ptr %12, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.giggle_index, ptr %209, i32 0, i32 8
  %211 = load ptr, ptr %210, align 8, !tbaa !28
  call void (i32, ptr, ...) @err(i32 noundef 74, ptr noundef @.str.31, ptr noundef %211) #9
  unreachable

212:                                              ; preds = %193
  %213 = load ptr, ptr %25, align 8, !tbaa !5
  %214 = call i32 @fclose(ptr noundef %213)
  %215 = load ptr, ptr %12, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.giggle_index, ptr %215, i32 0, i32 3
  %217 = load ptr, ptr %216, align 8, !tbaa !16
  call void @chrm_index_store(ptr noundef %217)
  %218 = load ptr, ptr %12, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.giggle_index, ptr %218, i32 0, i32 4
  %220 = load ptr, ptr %219, align 8, !tbaa !13
  call void @file_index_store(ptr noundef %220)
  %221 = load ptr, ptr %12, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.giggle_index, ptr %221, i32 0, i32 5
  %223 = load ptr, ptr %222, align 8, !tbaa !14
  call void @offset_index_store(ptr noundef %223)
  %224 = load ptr, ptr %12, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.giggle_index, ptr %224, i32 0, i32 6
  %226 = load ptr, ptr %225, align 8, !tbaa !15
  %227 = icmp ne ptr %226, null
  br i1 %227, label %228, label %232

228:                                              ; preds = %212
  %229 = load ptr, ptr %12, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.giggle_index, ptr %229, i32 0, i32 6
  %231 = load ptr, ptr %230, align 8, !tbaa !15
  call void @metadata_index_store(ptr noundef %231)
  br label %232

232:                                              ; preds = %228, %212
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #7
  %233 = load ptr, ptr %12, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.giggle_index, ptr %233, i32 0, i32 5
  %235 = load ptr, ptr %234, align 8, !tbaa !14
  %236 = getelementptr inbounds %struct.offset_index, ptr %235, i32 0, i32 0
  %237 = load ptr, ptr %236, align 8, !tbaa !31
  %238 = getelementptr inbounds %struct.file_id_offset_pairs, ptr %237, i32 0, i32 0
  %239 = load i64, ptr %238, align 8, !tbaa !33
  store i64 %239, ptr %26, align 8, !tbaa !36
  %240 = load ptr, ptr %12, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.giggle_index, ptr %240, i32 0, i32 8
  %242 = load ptr, ptr %241, align 8, !tbaa !28
  %243 = icmp ne ptr %242, null
  br i1 %243, label %244, label %248

244:                                              ; preds = %232
  %245 = load ptr, ptr %12, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.giggle_index, ptr %245, i32 0, i32 8
  %247 = load ptr, ptr %246, align 8, !tbaa !28
  call void @free(ptr noundef %247) #7
  br label %248

248:                                              ; preds = %244, %232
  %249 = load ptr, ptr %12, align 8, !tbaa !5
  %250 = getelementptr inbounds %struct.giggle_index, ptr %249, i32 0, i32 7
  %251 = load ptr, ptr %250, align 8, !tbaa !11
  %252 = icmp ne ptr %251, null
  br i1 %252, label %253, label %257

253:                                              ; preds = %248
  %254 = load ptr, ptr %12, align 8, !tbaa !5
  %255 = getelementptr inbounds %struct.giggle_index, ptr %254, i32 0, i32 7
  %256 = load ptr, ptr %255, align 8, !tbaa !11
  call void @free(ptr noundef %256) #7
  br label %257

257:                                              ; preds = %253, %248
  %258 = load ptr, ptr %12, align 8, !tbaa !5
  %259 = getelementptr inbounds %struct.giggle_index, ptr %258, i32 0, i32 0
  %260 = load ptr, ptr %259, align 8, !tbaa !29
  call void @free(ptr noundef %260) #7
  %261 = load ptr, ptr %12, align 8, !tbaa !5
  %262 = getelementptr inbounds %struct.giggle_index, ptr %261, i32 0, i32 4
  call void @file_index_destroy(ptr noundef %262)
  %263 = load ptr, ptr %12, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct.giggle_index, ptr %263, i32 0, i32 5
  call void @offset_index_destroy(ptr noundef %264)
  %265 = load ptr, ptr %12, align 8, !tbaa !5
  %266 = getelementptr inbounds %struct.giggle_index, ptr %265, i32 0, i32 6
  %267 = load ptr, ptr %266, align 8, !tbaa !15
  %268 = icmp ne ptr %267, null
  br i1 %268, label %269, label %272

269:                                              ; preds = %257
  %270 = load ptr, ptr %12, align 8, !tbaa !5
  %271 = getelementptr inbounds %struct.giggle_index, ptr %270, i32 0, i32 6
  call void @metadata_index_destroy(ptr noundef %271)
  br label %272

272:                                              ; preds = %269, %257
  %273 = load ptr, ptr %12, align 8, !tbaa !5
  %274 = getelementptr inbounds %struct.giggle_index, ptr %273, i32 0, i32 3
  call void @chrm_index_destroy(ptr noundef %274)
  %275 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %275) #7
  store ptr null, ptr %12, align 8, !tbaa !5
  %276 = load i64, ptr %26, align 8, !tbaa !36
  store i64 %276, ptr %5, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #7
  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
  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 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %277

277:                                              ; preds = %272, %41
  call void @llvm.lifetime.end.p0(i64 144, ptr %10) #7
  %278 = load i64, ptr %5, align 8
  ret i64 %278
}

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

declare ptr @priq_new(i32 noundef) #3

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

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

declare void @priq_free(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef) #5

declare void @metadata_index_store(ptr noundef) #3

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 48}
!12 = !{!"giggle_index", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!12, !6, i64 24}
!14 = !{!12, !6, i64 32}
!15 = !{!12, !6, i64 40}
!16 = !{!12, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !6, i64 8}
!20 = !{!"file_index", !6, i64 0, !6, i64 8}
!21 = !{!22, !10, i64 8}
!22 = !{!"unordered_list", !6, i64 0, !10, i64 8, !10, i64 12}
!23 = !{!24, !25, i64 16}
!24 = !{!"file_data", !6, i64 0, !10, i64 8, !25, i64 16}
!25 = !{!"double", !7, i64 0}
!26 = !{!24, !10, i64 8}
!27 = distinct !{!27, !18}
!28 = !{!12, !6, i64 56}
!29 = !{!12, !6, i64 0}
!30 = !{!12, !10, i64 8}
!31 = !{!32, !6, i64 0}
!32 = !{!"offset_index", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32}
!33 = !{!34, !35, i64 0}
!34 = !{!"file_id_offset_pairs", !35, i64 0, !35, i64 8, !6, i64 16}
!35 = !{!"long", !7, i64 0}
!36 = !{!35, !35, 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 }

@CHRM_INDEX_FILE_NAME = external dso_local local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.24 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [6 x i8], align 1
@OFFSET_INDEX_FILE_NAME = external dso_local local_unnamed_addr global ptr, align 8
@METADATA_INDEX_FILE_NAME = external dso_local local_unnamed_addr global ptr, align 8
@.str.28 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [37 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: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @file_index_destroy(ptr noundef) local_unnamed_addr #5

declare void @offset_index_destroy(ptr noundef) local_unnamed_addr #6

declare void @metadata_index_destroy(ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare dso_local void @chrm_index_destroy(ptr noundef) local_unnamed_addr #5

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

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

declare void @input_file_destroy(ptr noundef) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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

declare i32 @rmrf(ptr noundef) local_unnamed_addr #6

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

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

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @chrm_index_store(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local void @file_index_store(ptr noundef) local_unnamed_addr #5

declare void @offset_index_store(ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local i64 @giggle_bulk_insert_with_metadata(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #5 {
  %5 = alloca %struct.stat, 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 ptr, align 8
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %5) #10
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(144) %5, i8 0, i64 144, i1 false)
  %12 = call i32 @stat(ptr noundef %1, ptr noundef nonnull %5) #10
  %13 = icmp eq i32 %12, -1
  br i1 %13, label %21, label %14

14:                                               ; preds = %4
  %15 = icmp eq i32 %3, 1
  br i1 %15, label %16, label %18

16:                                               ; preds = %14
  %17 = tail call i32 @rmrf(ptr noundef %1) #10
  br label %21

18:                                               ; preds = %14
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.24, ptr noundef %1) #11
  br label %131

21:                                               ; preds = %4, %16
  %22 = tail call i32 @mkdir(ptr noundef %1, i32 noundef 448) #10
  %23 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #12
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.58) #13
  unreachable

26:                                               ; preds = %21
  %27 = tail call noalias ptr @strdup(ptr noundef %1) #10
  %28 = getelementptr inbounds i8, ptr %23, i64 48
  store ptr %27, ptr %28, align 8, !tbaa !9
  %29 = getelementptr inbounds i8, ptr %23, i64 24
  store ptr null, ptr %29, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #10
  store ptr null, ptr %6, align 8, !tbaa !5
  %30 = call i32 @giggle_bulk_insert_open_files(ptr noundef %0, ptr noundef %27, ptr noundef nonnull %6, ptr noundef nonnull %29)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #10
  store ptr null, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %28, align 8, !tbaa !9
  %32 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !5
  %33 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %7, ptr noundef nonnull @.str.27, ptr noundef %31, ptr noundef %32) #10
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = call ptr @offset_index_init(i32 noundef 1000, ptr noundef %34) #10
  %36 = getelementptr inbounds i8, ptr %23, i64 32
  store ptr %35, ptr %36, align 8, !tbaa !13
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %37) #10
  %38 = getelementptr inbounds i8, ptr %23, i64 40
  store ptr null, ptr %38, align 8, !tbaa !14
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %46, label %39

39:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #10
  store ptr null, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %28, align 8, !tbaa !9
  %41 = load ptr, ptr @METADATA_INDEX_FILE_NAME, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %8, ptr noundef nonnull @.str.27, ptr noundef %40, ptr noundef %41) #10
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = call ptr @metadata_index_init(ptr noundef nonnull %2, ptr noundef %43) #10
  store ptr %44, ptr %38, align 8, !tbaa !14
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %45) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #10
  br label %46

46:                                               ; preds = %39, %26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #10
  store ptr null, ptr %9, align 8, !tbaa !5
  %47 = load ptr, ptr %28, align 8, !tbaa !9
  %48 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.27, ptr noundef %47, ptr noundef %48) #10
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = call ptr @chrm_index_init(i32 noundef 24, ptr noundef %50)
  %52 = getelementptr inbounds i8, ptr %23, i64 16
  store ptr %51, ptr %52, align 8, !tbaa !15
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %53) #10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #10
  %54 = call ptr @priq_new(i32 noundef %30) #10
  store ptr %54, ptr %10, align 8, !tbaa !5
  %55 = zext i32 %30 to i64
  %56 = shl nuw nsw i64 %55, 4
  %57 = call noalias ptr @malloc(i64 noundef %56) #12
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %60

59:                                               ; preds = %46
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.58) #13
  unreachable

60:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #10
  %61 = call ptr @priq_new(i32 noundef %30) #10
  store ptr %61, ptr %11, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  call void @giggle_bulk_insert_prime_pqs(ptr noundef nonnull %23, ptr noundef nonnull %10, ptr noundef nonnull %57, ptr noundef nonnull %11, ptr noundef %62, i32 noundef %30)
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  call void @giggle_bulk_insert_build_leaf_levels(ptr noundef nonnull %23, ptr noundef nonnull %10, ptr noundef nonnull %57, ptr noundef nonnull %11, ptr noundef %63, i32 noundef %30)
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  call void @priq_free(ptr noundef %64) #10
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  call void @priq_free(ptr noundef %65) #10
  call void @free(ptr noundef nonnull %57) #10
  %.not96 = icmp eq i32 %30, 0
  br i1 %.not96, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %60, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %60 ]
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds ptr, ptr %66, i64 %indvars.iv
  call void @input_file_destroy(ptr noundef %67) #10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %55
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %60
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %68) #10
  call void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef nonnull %23)
  %69 = load ptr, ptr %29, align 8, !tbaa !12
  %70 = getelementptr inbounds i8, ptr %69, i64 8
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = getelementptr inbounds i8, ptr %71, i64 8
  %73 = load i32, ptr %72, align 8, !tbaa !20
  %.not97 = icmp eq i32 %73, 0
  br i1 %.not97, label %._crit_edge95, label %.lr.ph94

.lr.ph94:                                         ; preds = %._crit_edge, %.lr.ph94
  %74 = phi ptr [ %83, %.lr.ph94 ], [ %69, %._crit_edge ]
  %.192 = phi i32 [ %82, %.lr.ph94 ], [ 0, %._crit_edge ]
  %75 = call ptr @file_index_get(ptr noundef nonnull %74, i32 noundef %.192)
  %76 = getelementptr inbounds i8, ptr %75, i64 16
  %77 = load double, ptr %76, align 8, !tbaa !22
  %78 = getelementptr inbounds i8, ptr %75, i64 8
  %79 = load i32, ptr %78, align 8, !tbaa !25
  %80 = uitofp i32 %79 to double
  %81 = fdiv double %77, %80
  store double %81, ptr %76, align 8, !tbaa !22
  %82 = add nuw i32 %.192, 1
  %83 = load ptr, ptr %29, align 8, !tbaa !12
  %84 = getelementptr inbounds i8, ptr %83, i64 8
  %85 = load ptr, ptr %84, align 8, !tbaa !18
  %86 = getelementptr inbounds i8, ptr %85, i64 8
  %87 = load i32, ptr %86, align 8, !tbaa !20
  %88 = icmp ult i32 %82, %87
  br i1 %88, label %.lr.ph94, label %._crit_edge95, !llvm.loop !26

._crit_edge95:                                    ; preds = %.lr.ph94, %._crit_edge
  %89 = getelementptr inbounds i8, ptr %23, i64 56
  %90 = load ptr, ptr %89, align 8, !tbaa !27
  %91 = call noalias ptr @fopen(ptr noundef %90, ptr noundef nonnull @.str.28)
  %92 = getelementptr inbounds i8, ptr %23, i64 8
  %93 = call i64 @fwrite(ptr noundef nonnull %92, i64 noundef 4, i64 noundef 1, ptr noundef %91)
  %.not84 = icmp eq i64 %93, 1
  br i1 %.not84, label %96, label %94

94:                                               ; preds = %._crit_edge95
  %95 = load ptr, ptr %89, align 8, !tbaa !27
  call void (i32, ptr, ...) @err(i32 noundef 74, ptr noundef nonnull @.str.29, ptr noundef %95) #13
  unreachable

96:                                               ; preds = %._crit_edge95
  %97 = getelementptr inbounds i8, ptr %23, i64 12
  %98 = call i64 @fwrite(ptr noundef nonnull %97, i64 noundef 4, i64 noundef 1, ptr noundef %91)
  %.not85 = icmp eq i64 %98, 1
  br i1 %.not85, label %101, label %99

99:                                               ; preds = %96
  %100 = load ptr, ptr %89, align 8, !tbaa !27
  call void (i32, ptr, ...) @err(i32 noundef 74, ptr noundef nonnull @.str.30, ptr noundef %100) #13
  unreachable

101:                                              ; preds = %96
  %102 = load ptr, ptr %23, align 8, !tbaa !28
  %103 = load i32, ptr %92, align 8, !tbaa !29
  %104 = zext i32 %103 to i64
  %105 = call i64 @fwrite(ptr noundef %102, i64 noundef 4, i64 noundef %104, ptr noundef %91)
  %106 = load i32, ptr %92, align 8, !tbaa !29
  %107 = zext i32 %106 to i64
  %.not86 = icmp eq i64 %105, %107
  br i1 %.not86, label %110, label %108

108:                                              ; preds = %101
  %109 = load ptr, ptr %89, align 8, !tbaa !27
  call void (i32, ptr, ...) @err(i32 noundef 74, ptr noundef nonnull @.str.31, ptr noundef %109) #13
  unreachable

110:                                              ; preds = %101
  %111 = call i32 @fclose(ptr noundef %91)
  %112 = load ptr, ptr %52, align 8, !tbaa !15
  call void @chrm_index_store(ptr noundef %112)
  %113 = load ptr, ptr %29, align 8, !tbaa !12
  call void @file_index_store(ptr noundef %113)
  %114 = load ptr, ptr %36, align 8, !tbaa !13
  call void @offset_index_store(ptr noundef %114) #10
  %115 = load ptr, ptr %38, align 8, !tbaa !14
  %.not87 = icmp eq ptr %115, null
  br i1 %.not87, label %117, label %116

116:                                              ; preds = %110
  call void @metadata_index_store(ptr noundef nonnull %115) #10
  br label %117

117:                                              ; preds = %116, %110
  %118 = load ptr, ptr %36, align 8, !tbaa !13
  %119 = load ptr, ptr %118, align 8, !tbaa !30
  %120 = load i64, ptr %119, align 8, !tbaa !32
  %121 = load ptr, ptr %89, align 8, !tbaa !27
  %.not88 = icmp eq ptr %121, null
  br i1 %.not88, label %123, label %122

122:                                              ; preds = %117
  call void @free(ptr noundef nonnull %121) #10
  br label %123

123:                                              ; preds = %122, %117
  %124 = load ptr, ptr %28, align 8, !tbaa !9
  %.not89 = icmp eq ptr %124, null
  br i1 %.not89, label %126, label %125

125:                                              ; preds = %123
  call void @free(ptr noundef nonnull %124) #10
  br label %126

126:                                              ; preds = %125, %123
  %127 = load ptr, ptr %23, align 8, !tbaa !28
  call void @free(ptr noundef %127) #10
  call void @file_index_destroy(ptr noundef nonnull %29)
  call void @offset_index_destroy(ptr noundef nonnull %36) #10
  %128 = load ptr, ptr %38, align 8, !tbaa !14
  %.not90 = icmp eq ptr %128, null
  br i1 %.not90, label %130, label %129

129:                                              ; preds = %126
  call void @metadata_index_destroy(ptr noundef nonnull %38) #10
  br label %130

130:                                              ; preds = %129, %126
  call void @chrm_index_destroy(ptr noundef nonnull %52)
  call void @free(ptr noundef nonnull %23) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #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 %131

131:                                              ; preds = %130, %18
  %.0 = phi i64 [ %120, %130 ], [ 0, %18 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %5) #10
  ret i64 %.0
}

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

declare ptr @priq_new(i32 noundef) local_unnamed_addr #6

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

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

declare void @priq_free(ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare dso_local void @giggle_bulk_insert_build_tree_on_leaves(ptr noundef) local_unnamed_addr #5

declare void @metadata_index_store(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 = { 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 #4 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { 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 #9 = { 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 #10 = { nounwind }
attributes #11 = { cold nounwind }
attributes #12 = { nounwind allocsize(0) }
attributes #13 = { noreturn 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 48}
!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 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 32}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !6, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !6, i64 8}
!19 = !{!"file_index", !6, i64 0, !6, i64 8}
!20 = !{!21, !11, i64 8}
!21 = !{!"unordered_list", !6, i64 0, !11, i64 8, !11, i64 12}
!22 = !{!23, !24, i64 16}
!23 = !{!"file_data", !6, i64 0, !11, i64 8, !24, i64 16}
!24 = !{!"double", !7, i64 0}
!25 = !{!23, !11, i64 8}
!26 = distinct !{!26, !17}
!27 = !{!10, !6, i64 56}
!28 = !{!10, !6, i64 0}
!29 = !{!10, !11, i64 8}
!30 = !{!31, !6, i64 0}
!31 = !{!"offset_index", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !11, i64 32}
!32 = !{!33, !34, i64 0}
!33 = !{!"file_id_offset_pairs", !34, i64 0, !34, i64 8, !6, i64 16}
!34 = !{!"long", !7, i64 0}


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