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

@CHRM_INDEX_FILE_NAME = external dso_local global ptr, align 8
@FILE_INDEX_FILE_NAME = external dso_local global ptr, align 8
@ROOT_IDS_FILE_NAME = external dso_local global ptr, align 8
@CACHE_FILE_NAME_PREFIX = external dso_local global ptr, align 8
@.str.26 = external hidden unnamed_addr constant [8 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.32 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [27 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

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

declare void @check_file_read(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind
declare void @free(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
declare i32 @stat(ptr noundef, ptr noundef) #5

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

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

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

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

declare i32 @fclose(ptr noundef) #3

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

23:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %197

24:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 144, ptr %8) #8
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 144, i1 false)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call i32 @stat(ptr noundef %25, ptr noundef %8) #8
  %27 = icmp eq i32 %26, -1
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %196

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %30 = call noalias ptr @malloc(i64 noundef 64) #9
  store ptr %30, ptr %10, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %29
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.32) #10
  unreachable

34:                                               ; preds = %29
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call noalias ptr @strdup(ptr noundef %35) #8
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.giggle_index, ptr %37, i32 0, i32 7
  store ptr %36, ptr %38, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.giggle_index, ptr %39, i32 0, i32 8
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load ptr, ptr @ROOT_IDS_FILE_NAME, align 8, !tbaa !5
  %43 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %40, ptr noundef @.str.27, ptr noundef %41, ptr noundef %42) #8
  store i32 %43, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.giggle_index, ptr %44, i32 0, i32 8
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = call noalias ptr @fopen(ptr noundef %46, ptr noundef @.str.33)
  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 %54

50:                                               ; preds = %34
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.giggle_index, ptr %51, i32 0, i32 8
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.34, ptr noundef %53) #10
  unreachable

54:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.giggle_index, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = call i64 @fread(ptr noundef %56, i64 noundef 4, i64 noundef 1, ptr noundef %57)
  store i64 %58, ptr %13, align 8, !tbaa !14
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.giggle_index, ptr %59, i32 0, i32 8
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = load i64, ptr %13, align 8, !tbaa !14
  call void @check_file_read(ptr noundef %61, ptr noundef %62, i64 noundef 1, i64 noundef %63)
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.giggle_index, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = call i64 @fread(ptr noundef %65, i64 noundef 4, i64 noundef 1, ptr noundef %66)
  store i64 %67, ptr %13, align 8, !tbaa !14
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.giggle_index, ptr %68, i32 0, i32 8
  %70 = load ptr, ptr %69, align 8, !tbaa !13
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load i64, ptr %13, align 8, !tbaa !14
  call void @check_file_read(ptr noundef %70, ptr noundef %71, i64 noundef 1, i64 noundef %72)
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.giggle_index, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 8, !tbaa !16
  %76 = zext i32 %75 to i64
  %77 = call noalias ptr @calloc(i64 noundef %76, i64 noundef 4) #11
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.giggle_index, ptr %78, i32 0, i32 0
  store ptr %77, ptr %79, align 8, !tbaa !17
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.giggle_index, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !17
  %83 = icmp eq ptr %82, null
  br i1 %83, label %84, label %85

84:                                               ; preds = %54
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.32) #10
  unreachable

85:                                               ; preds = %54
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.giggle_index, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !17
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.giggle_index, ptr %89, i32 0, i32 1
  %91 = load i32, ptr %90, align 8, !tbaa !16
  %92 = zext i32 %91 to i64
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = call i64 @fread(ptr noundef %88, i64 noundef 4, i64 noundef %92, ptr noundef %93)
  store i64 %94, ptr %13, align 8, !tbaa !14
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.giggle_index, ptr %95, i32 0, i32 8
  %97 = load ptr, ptr %96, align 8, !tbaa !13
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.giggle_index, ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 8, !tbaa !16
  %102 = zext i32 %101 to i64
  %103 = load i64, ptr %13, align 8, !tbaa !14
  call void @check_file_read(ptr noundef %97, ptr noundef %98, i64 noundef %102, i64 noundef %103)
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  %105 = call i32 @fclose(ptr noundef %104)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  store ptr null, ptr %14, align 8, !tbaa !5
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %14, ptr noundef @.str.27, ptr noundef %106, ptr noundef %107) #8
  store i32 %108, ptr %11, align 4, !tbaa !9
  %109 = load ptr, ptr %14, align 8, !tbaa !5
  %110 = call ptr @chrm_index_load(ptr noundef %109)
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.giggle_index, ptr %111, i32 0, i32 3
  store ptr %110, ptr %112, align 8, !tbaa !18
  %113 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %113) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  store ptr null, ptr %15, align 8, !tbaa !5
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = load ptr, ptr @FILE_INDEX_FILE_NAME, align 8, !tbaa !5
  %116 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %15, ptr noundef @.str.27, ptr noundef %114, ptr noundef %115) #8
  store i32 %116, ptr %11, align 4, !tbaa !9
  %117 = load ptr, ptr %15, align 8, !tbaa !5
  %118 = call ptr @file_index_load(ptr noundef %117)
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.giggle_index, ptr %119, i32 0, i32 4
  store ptr %118, ptr %120, align 8, !tbaa !19
  %121 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %121) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  store ptr null, ptr %16, align 8, !tbaa !5
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !5
  %124 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %16, ptr noundef @.str.27, ptr noundef %122, ptr noundef %123) #8
  store i32 %124, ptr %11, align 4, !tbaa !9
  %125 = load ptr, ptr %16, align 8, !tbaa !5
  %126 = call ptr @offset_index_load(ptr noundef %125)
  %127 = load ptr, ptr %10, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.giggle_index, ptr %127, i32 0, i32 5
  store ptr %126, ptr %128, align 8, !tbaa !20
  %129 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %129) #8
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.giggle_index, ptr %130, i32 0, i32 6
  store ptr null, ptr %131, align 8, !tbaa !21
  %132 = load i32, ptr %6, align 4, !tbaa !9
  %133 = icmp ne i32 %132, 0
  br i1 %133, label %134, label %143

134:                                              ; preds = %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  store ptr null, ptr %17, align 8, !tbaa !5
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = load ptr, ptr @METADATA_INDEX_FILE_NAME, align 8, !tbaa !5
  %137 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %17, ptr noundef @.str.27, ptr noundef %135, ptr noundef %136) #8
  store i32 %137, ptr %11, align 4, !tbaa !9
  %138 = load ptr, ptr %17, align 8, !tbaa !5
  %139 = call ptr @metadata_index_load(ptr noundef %138)
  %140 = load ptr, ptr %10, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.giggle_index, ptr %140, i32 0, i32 6
  store ptr %139, ptr %141, align 8, !tbaa !21
  %142 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %142) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  br label %143

143:                                              ; preds = %134, %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %144 = load ptr, ptr %10, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.giggle_index, ptr %144, i32 0, i32 1
  %146 = load i32, ptr %145, align 8, !tbaa !16
  %147 = zext i32 %146 to i64
  %148 = call noalias ptr @calloc(i64 noundef %147, i64 noundef 8) #11
  store ptr %148, ptr %18, align 8, !tbaa !5
  %149 = load ptr, ptr %18, align 8, !tbaa !5
  %150 = icmp eq ptr %149, null
  br i1 %150, label %151, label %152

151:                                              ; preds = %143
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.32) #10
  unreachable

152:                                              ; preds = %143
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %153

153:                                              ; preds = %168, %152
  %154 = load i32, ptr %19, align 4, !tbaa !9
  %155 = load ptr, ptr %10, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.giggle_index, ptr %155, i32 0, i32 1
  %157 = load i32, ptr %156, align 8, !tbaa !16
  %158 = icmp ult i32 %154, %157
  br i1 %158, label %159, label %171

159:                                              ; preds = %153
  %160 = load ptr, ptr %18, align 8, !tbaa !5
  %161 = load i32, ptr %19, align 4, !tbaa !9
  %162 = zext i32 %161 to i64
  %163 = getelementptr inbounds ptr, ptr %160, i64 %162
  %164 = load ptr, ptr %5, align 8, !tbaa !5
  %165 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !5
  %166 = load i32, ptr %19, align 4, !tbaa !9
  %167 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %163, ptr noundef @.str.26, ptr noundef %164, ptr noundef %165, i32 noundef %166) #8
  store i32 %167, ptr %11, align 4, !tbaa !9
  br label %168

168:                                              ; preds = %159
  %169 = load i32, ptr %19, align 4, !tbaa !9
  %170 = add i32 %169, 1
  store i32 %170, ptr %19, align 4, !tbaa !9
  br label %153, !llvm.loop !22

171:                                              ; preds = %153
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %172 = load ptr, ptr %10, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.giggle_index, ptr %172, i32 0, i32 1
  %174 = load i32, ptr %173, align 8, !tbaa !16
  %175 = load ptr, ptr %18, align 8, !tbaa !5
  %176 = call ptr @simple_cache_init(i32 noundef 1000, i32 noundef %174, ptr noundef %175)
  store ptr %176, ptr %20, align 8, !tbaa !5
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %177

177:                                              ; preds = %189, %171
  %178 = load i32, ptr %19, align 4, !tbaa !9
  %179 = load ptr, ptr %10, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.giggle_index, ptr %179, i32 0, i32 1
  %181 = load i32, ptr %180, align 8, !tbaa !16
  %182 = icmp ult i32 %178, %181
  br i1 %182, label %183, label %192

183:                                              ; preds = %177
  %184 = load ptr, ptr %18, align 8, !tbaa !5
  %185 = load i32, ptr %19, align 4, !tbaa !9
  %186 = zext i32 %185 to i64
  %187 = getelementptr inbounds ptr, ptr %184, i64 %186
  %188 = load ptr, ptr %187, align 8, !tbaa !5
  call void @free(ptr noundef %188) #8
  br label %189

189:                                              ; preds = %183
  %190 = load i32, ptr %19, align 4, !tbaa !9
  %191 = add i32 %190, 1
  store i32 %191, ptr %19, align 4, !tbaa !9
  br label %177, !llvm.loop !24

192:                                              ; preds = %177
  %193 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %193) #8
  %194 = load ptr, ptr %7, align 8, !tbaa !5
  call void %194()
  %195 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %195, ptr %4, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %196

196:                                              ; preds = %192, %28
  call void @llvm.lifetime.end.p0(i64 144, ptr %8) #8
  br label %197

197:                                              ; preds = %196, %23
  %198 = load ptr, ptr %4, align 8
  ret ptr %198
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @chrm_index_load(ptr noundef) #7

; Function Attrs: nounwind uwtable
declare dso_local ptr @file_index_load(ptr noundef) #7

declare ptr @offset_index_load(ptr noundef) #3

declare ptr @metadata_index_load(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 allocsize(0,1) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { noreturn }
attributes #11 = { nounwind allocsize(0,1) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"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 56}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !10, i64 8}
!17 = !{!12, !6, i64 0}
!18 = !{!12, !6, i64 16}
!19 = !{!12, !6, i64 24}
!20 = !{!12, !6, i64 32}
!21 = !{!12, !6, i64 40}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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
@FILE_INDEX_FILE_NAME = external dso_local local_unnamed_addr global ptr, align 8
@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.26 = external hidden unnamed_addr constant [8 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.32 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [27 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: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

declare void @check_file_read(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

; 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: nofree nounwind
declare noundef i32 @stat(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #3

; 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

declare ptr @simple_cache_init(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; 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
define dso_local noundef ptr @giggle_load_with_metadata(ptr noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #10 {
  %4 = alloca %struct.stat, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = icmp eq ptr %0, null
  br i1 %9, label %92, label %10

10:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %4) #11
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(144) %4, i8 0, i64 144, i1 false)
  %11 = call i32 @stat(ptr noundef nonnull %0, ptr noundef nonnull %4) #11
  %12 = icmp eq i32 %11, -1
  br i1 %12, label %91, label %13

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

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

17:                                               ; preds = %13
  %18 = tail call noalias ptr @strdup(ptr noundef nonnull %0) #11
  %19 = getelementptr inbounds i8, ptr %14, i64 48
  store ptr %18, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %14, i64 56
  %21 = load ptr, ptr @ROOT_IDS_FILE_NAME, align 8, !tbaa !11
  %22 = tail call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %20, ptr noundef nonnull @.str.27, ptr noundef nonnull %0, ptr noundef %21) #11
  %23 = load ptr, ptr %20, align 8, !tbaa !12
  %24 = tail call noalias ptr @fopen(ptr noundef %23, ptr noundef nonnull @.str.33)
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %28

26:                                               ; preds = %17
  %27 = load ptr, ptr %20, align 8, !tbaa !12
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.34, ptr noundef %27) #13
  unreachable

28:                                               ; preds = %17
  %29 = getelementptr inbounds i8, ptr %14, i64 8
  %30 = tail call i64 @fread(ptr noundef nonnull %29, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %24)
  %31 = load ptr, ptr %20, align 8, !tbaa !12
  tail call void @check_file_read(ptr noundef %31, ptr noundef nonnull %24, i64 noundef 1, i64 noundef %30) #11
  %32 = getelementptr inbounds i8, ptr %14, i64 12
  %33 = tail call i64 @fread(ptr noundef nonnull %32, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %24)
  %34 = load ptr, ptr %20, align 8, !tbaa !12
  tail call void @check_file_read(ptr noundef %34, ptr noundef nonnull %24, i64 noundef 1, i64 noundef %33) #11
  %35 = load i32, ptr %29, align 8, !tbaa !13
  %36 = zext i32 %35 to i64
  %37 = tail call noalias ptr @calloc(i64 noundef %36, i64 noundef 4) #14
  store ptr %37, ptr %14, align 8, !tbaa !14
  %38 = icmp eq ptr %37, null
  br i1 %38, label %39, label %40

39:                                               ; preds = %28
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.32) #13
  unreachable

40:                                               ; preds = %28
  %41 = tail call i64 @fread(ptr noundef nonnull %37, i64 noundef 4, i64 noundef %36, ptr noundef nonnull %24)
  %42 = load ptr, ptr %20, align 8, !tbaa !12
  %43 = load i32, ptr %29, align 8, !tbaa !13
  %44 = zext i32 %43 to i64
  tail call void @check_file_read(ptr noundef %42, ptr noundef nonnull %24, i64 noundef %44, i64 noundef %41) #11
  %45 = tail call i32 @fclose(ptr noundef nonnull %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #11
  store ptr null, ptr %5, align 8, !tbaa !11
  %46 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !11
  %47 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %5, ptr noundef nonnull @.str.27, ptr noundef nonnull %0, ptr noundef %46) #11
  %48 = load ptr, ptr %5, align 8, !tbaa !11
  %49 = call ptr @chrm_index_load(ptr noundef %48)
  %50 = getelementptr inbounds i8, ptr %14, i64 16
  store ptr %49, ptr %50, align 8, !tbaa !15
  %51 = load ptr, ptr %5, align 8, !tbaa !11
  call void @free(ptr noundef %51) #11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #11
  store ptr null, ptr %6, align 8, !tbaa !11
  %52 = load ptr, ptr @FILE_INDEX_FILE_NAME, align 8, !tbaa !11
  %53 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %6, ptr noundef nonnull @.str.27, ptr noundef nonnull %0, ptr noundef %52) #11
  %54 = load ptr, ptr %6, align 8, !tbaa !11
  %55 = call ptr @file_index_load(ptr noundef %54)
  %56 = getelementptr inbounds i8, ptr %14, i64 24
  store ptr %55, ptr %56, align 8, !tbaa !16
  %57 = load ptr, ptr %6, align 8, !tbaa !11
  call void @free(ptr noundef %57) #11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #11
  store ptr null, ptr %7, align 8, !tbaa !11
  %58 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !11
  %59 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %7, ptr noundef nonnull @.str.27, ptr noundef nonnull %0, ptr noundef %58) #11
  %60 = load ptr, ptr %7, align 8, !tbaa !11
  %61 = call ptr @offset_index_load(ptr noundef %60) #11
  %62 = getelementptr inbounds i8, ptr %14, i64 32
  store ptr %61, ptr %62, align 8, !tbaa !17
  %63 = load ptr, ptr %7, align 8, !tbaa !11
  call void @free(ptr noundef %63) #11
  %64 = getelementptr inbounds i8, ptr %14, i64 40
  store ptr null, ptr %64, align 8, !tbaa !18
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %71, label %65

65:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #11
  store ptr null, ptr %8, align 8, !tbaa !11
  %66 = load ptr, ptr @METADATA_INDEX_FILE_NAME, align 8, !tbaa !11
  %67 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %8, ptr noundef nonnull @.str.27, ptr noundef nonnull %0, ptr noundef %66) #11
  %68 = load ptr, ptr %8, align 8, !tbaa !11
  %69 = call ptr @metadata_index_load(ptr noundef %68) #11
  store ptr %69, ptr %64, align 8, !tbaa !18
  %70 = load ptr, ptr %8, align 8, !tbaa !11
  call void @free(ptr noundef %70) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #11
  br label %71

71:                                               ; preds = %65, %40
  %72 = load i32, ptr %29, align 8, !tbaa !13
  %73 = zext i32 %72 to i64
  %74 = call noalias ptr @calloc(i64 noundef %73, i64 noundef 8) #14
  %75 = icmp eq ptr %74, null
  br i1 %75, label %76, label %.preheader

.preheader:                                       ; preds = %71
  %.not73 = icmp eq i32 %72, 0
  br i1 %.not73, label %._crit_edge, label %.lr.ph

76:                                               ; preds = %71
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.32) #13
  unreachable

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %77 = getelementptr inbounds ptr, ptr %74, i64 %indvars.iv
  %78 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !11
  %79 = trunc nuw i64 %indvars.iv to i32
  %80 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %77, ptr noundef nonnull @.str.26, ptr noundef nonnull %0, ptr noundef %78, i32 noundef %79) #11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %81 = load i32, ptr %29, align 8, !tbaa !13
  %82 = zext i32 %81 to i64
  %83 = icmp ult i64 %indvars.iv.next, %82
  br i1 %83, label %.lr.ph, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.lcssa = phi i32 [ 0, %.preheader ], [ %81, %.lr.ph ]
  %84 = call ptr @simple_cache_init(i32 noundef 1000, i32 noundef %.lcssa, ptr noundef nonnull %74) #11
  %85 = load i32, ptr %29, align 8, !tbaa !13
  %.not74 = icmp eq i32 %85, 0
  br i1 %.not74, label %._crit_edge72, label %.lr.ph71

.lr.ph71:                                         ; preds = %._crit_edge, %.lr.ph71
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %.lr.ph71 ], [ 0, %._crit_edge ]
  %86 = getelementptr inbounds ptr, ptr %74, i64 %indvars.iv77
  %87 = load ptr, ptr %86, align 8, !tbaa !11
  call void @free(ptr noundef %87) #11
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %88 = load i32, ptr %29, align 8, !tbaa !13
  %89 = zext i32 %88 to i64
  %90 = icmp ult i64 %indvars.iv.next78, %89
  br i1 %90, label %.lr.ph71, label %._crit_edge72, !llvm.loop !21

._crit_edge72:                                    ; preds = %.lr.ph71, %._crit_edge
  call void @free(ptr noundef %74) #11
  call void %2() #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #11
  br label %91

91:                                               ; preds = %10, %._crit_edge72
  %.0 = phi ptr [ %14, %._crit_edge72 ], [ null, %10 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %4) #11
  br label %92

92:                                               ; preds = %3, %91
  %.1 = phi ptr [ %.0, %91 ], [ null, %3 ]
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @chrm_index_load(ptr noundef) local_unnamed_addr #10

; Function Attrs: nounwind uwtable
declare dso_local ptr @file_index_load(ptr noundef) local_unnamed_addr #10

declare ptr @offset_index_load(ptr noundef) local_unnamed_addr #4

declare ptr @metadata_index_load(ptr noundef) local_unnamed_addr #4

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 = { "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,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #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 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 #11 = { nounwind }
attributes #12 = { nounwind allocsize(0) }
attributes #13 = { noreturn nounwind }
attributes #14 = { nounwind allocsize(0,1) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 48}
!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 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 56}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !7, i64 24}
!17 = !{!6, !7, i64 32}
!18 = !{!6, !7, i64 40}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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