; 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.chrm_index = type { ptr, ptr }
%struct.file_index = type { 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
@stderr = external global ptr, align 8
@.str.23 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [30 x i8], align 1
@.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

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

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) #1

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

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

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

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

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

23:                                               ; preds = %5
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.23) #7
  unreachable

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

28:                                               ; preds = %24
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  %30 = call i32 @mkdir(ptr noundef %29, i32 noundef 448) #8
  br label %44

31:                                               ; preds = %24
  %32 = load i32, ptr %10, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %39

34:                                               ; preds = %31
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = call i32 @rmrf(ptr noundef %35)
  %37 = load ptr, ptr %8, align 8, !tbaa !9
  %38 = call i32 @mkdir(ptr noundef %37, i32 noundef 448) #8
  br label %43

39:                                               ; preds = %31
  %40 = load ptr, ptr @stderr, align 8, !tbaa !9
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.24, ptr noundef %41) #8
  store ptr null, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %129

43:                                               ; preds = %34
  br label %44

44:                                               ; preds = %43, %28
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = zext i32 %45 to i64
  %47 = call noalias ptr @calloc(i64 noundef %46, i64 noundef 8) #9
  store ptr %47, ptr %12, align 8, !tbaa !9
  %48 = load ptr, ptr %12, align 8, !tbaa !9
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %51

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

51:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %65, %51
  %53 = load i32, ptr %15, align 4, !tbaa !5
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = icmp ult i32 %53, %54
  br i1 %55, label %56, label %68

56:                                               ; preds = %52
  %57 = load ptr, ptr %12, align 8, !tbaa !9
  %58 = load i32, ptr %15, align 4, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %8, align 8, !tbaa !9
  %62 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !9
  %63 = load i32, ptr %15, align 4, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %60, ptr noundef @.str.26, ptr noundef %61, ptr noundef %62, i32 noundef %63) #8
  store i32 %64, ptr %16, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %56
  %66 = load i32, ptr %15, align 4, !tbaa !5
  %67 = add i32 %66, 1
  store i32 %67, ptr %15, align 4, !tbaa !5
  br label %52, !llvm.loop !11

68:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  store ptr null, ptr %17, align 8, !tbaa !9
  %69 = load ptr, ptr %8, align 8, !tbaa !9
  %70 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !9
  %71 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %17, ptr noundef @.str.27, ptr noundef %69, ptr noundef %70) #8
  store i32 %71, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  store ptr null, ptr %18, align 8, !tbaa !9
  %72 = load ptr, ptr %9, align 8, !tbaa !9
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %78

74:                                               ; preds = %68
  %75 = load ptr, ptr %8, align 8, !tbaa !9
  %76 = load ptr, ptr @METADATA_INDEX_FILE_NAME, align 8, !tbaa !9
  %77 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %18, ptr noundef @.str.27, ptr noundef %75, ptr noundef %76) #8
  store i32 %77, ptr %16, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %74, %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = load ptr, ptr %17, align 8, !tbaa !9
  %81 = load ptr, ptr %9, align 8, !tbaa !9
  %82 = load ptr, ptr %18, align 8, !tbaa !9
  %83 = call ptr @giggle_init_index_with_metadata(i32 noundef %79, ptr noundef %80, ptr noundef %81, ptr noundef %82)
  store ptr %83, ptr %19, align 8, !tbaa !9
  %84 = load ptr, ptr %8, align 8, !tbaa !9
  %85 = call noalias ptr @strdup(ptr noundef %84) #8
  %86 = load ptr, ptr %19, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.giggle_index, ptr %86, i32 0, i32 7
  store ptr %85, ptr %87, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = load ptr, ptr %12, align 8, !tbaa !9
  %90 = call ptr @simple_cache_init(i32 noundef 1000, i32 noundef %88, ptr noundef %89)
  store ptr %90, ptr %20, align 8, !tbaa !9
  %91 = load ptr, ptr %11, align 8, !tbaa !9
  call void (...) %91()
  %92 = load ptr, ptr %19, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.giggle_index, ptr %92, i32 0, i32 3
  %94 = load ptr, ptr %93, align 8, !tbaa !15
  %95 = getelementptr inbounds %struct.chrm_index, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %8, align 8, !tbaa !9
  %97 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !9
  %98 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %95, ptr noundef @.str.27, ptr noundef %96, ptr noundef %97) #8
  store i32 %98, ptr %16, align 4, !tbaa !5
  %99 = load ptr, ptr %19, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct.giggle_index, ptr %99, i32 0, i32 4
  %101 = load ptr, ptr %100, align 8, !tbaa !16
  %102 = getelementptr inbounds %struct.file_index, ptr %101, i32 0, i32 0
  %103 = load ptr, ptr %8, align 8, !tbaa !9
  %104 = load ptr, ptr @FILE_INDEX_FILE_NAME, align 8, !tbaa !9
  %105 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %102, ptr noundef @.str.27, ptr noundef %103, ptr noundef %104) #8
  store i32 %105, ptr %16, align 4, !tbaa !5
  %106 = load ptr, ptr %19, align 8, !tbaa !9
  %107 = getelementptr inbounds %struct.giggle_index, ptr %106, i32 0, i32 8
  %108 = load ptr, ptr %8, align 8, !tbaa !9
  %109 = load ptr, ptr @ROOT_IDS_FILE_NAME, align 8, !tbaa !9
  %110 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %107, ptr noundef @.str.27, ptr noundef %108, ptr noundef %109) #8
  store i32 %110, ptr %16, align 4, !tbaa !5
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %121, %78
  %112 = load i32, ptr %15, align 4, !tbaa !5
  %113 = load i32, ptr %7, align 4, !tbaa !5
  %114 = icmp ult i32 %112, %113
  br i1 %114, label %115, label %124

115:                                              ; preds = %111
  %116 = load ptr, ptr %12, align 8, !tbaa !9
  %117 = load i32, ptr %15, align 4, !tbaa !5
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds ptr, ptr %116, i64 %118
  %120 = load ptr, ptr %119, align 8, !tbaa !9
  call void @free(ptr noundef %120) #8
  br label %121

121:                                              ; preds = %115
  %122 = load i32, ptr %15, align 4, !tbaa !5
  %123 = add i32 %122, 1
  store i32 %123, ptr %15, align 4, !tbaa !5
  br label %111, !llvm.loop !17

124:                                              ; preds = %111
  %125 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %125) #8
  %126 = load ptr, ptr %17, align 8, !tbaa !9
  call void @free(ptr noundef %126) #8
  %127 = load ptr, ptr %18, align 8, !tbaa !9
  call void @free(ptr noundef %127) #8
  %128 = load ptr, ptr %19, align 8, !tbaa !9
  store ptr %128, ptr %6, align 8
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %129

129:                                              ; preds = %124, %39
  call void @llvm.lifetime.end.p0(i64 144, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  %130 = load ptr, ptr %6, align 8
  ret ptr %130
}

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

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

declare i32 @rmrf(ptr noundef) #6

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { noreturn }
attributes #8 = { nounwind }
attributes #9 = { 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 48}
!14 = !{!"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}
!15 = !{!14, !10, i64 16}
!16 = !{!14, !10, i64 24}
!17 = distinct !{!17, !12}


; 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
@stderr = external local_unnamed_addr global ptr, align 8
@.str.23 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [30 x i8], align 1
@.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

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

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; 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 #2

; Function Attrs: noreturn
declare void @errx(i32 noundef, 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 #3

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @giggle_init_with_metadata(i32 noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #4 {
  %6 = alloca %struct.stat, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = icmp eq ptr %1, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %5
  tail call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.23) #10
  unreachable

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

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

16:                                               ; preds = %14
  %17 = tail call i32 @rmrf(ptr noundef nonnull %1) #11
  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 nonnull %1) #12
  br label %58

21:                                               ; preds = %11, %16
  %22 = tail call i32 @mkdir(ptr noundef nonnull %1, i32 noundef 448) #11
  %23 = zext i32 %0 to i64
  %24 = tail call noalias ptr @calloc(i64 noundef %23, i64 noundef 8) #13
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %.preheader

.preheader:                                       ; preds = %21
  %.not48 = icmp eq i32 %0, 0
  br i1 %.not48, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %27 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv
  %28 = load ptr, ptr @CACHE_FILE_NAME_PREFIX, align 8, !tbaa !5
  %29 = trunc nuw i64 %indvars.iv to i32
  %30 = tail call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %27, ptr noundef nonnull @.str.26, ptr noundef nonnull %1, ptr noundef %28, i32 noundef %29) #11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %23
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #11
  store ptr null, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr @OFFSET_INDEX_FILE_NAME, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %7, ptr noundef nonnull @.str.27, ptr noundef nonnull %1, ptr noundef %31) #11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #11
  store ptr null, ptr %8, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %36, label %33

33:                                               ; preds = %._crit_edge
  %34 = load ptr, ptr @METADATA_INDEX_FILE_NAME, align 8, !tbaa !5
  %35 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %8, ptr noundef nonnull @.str.27, ptr noundef nonnull %1, ptr noundef %34) #11
  %.pre = load ptr, ptr %8, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %33, %._crit_edge
  %37 = phi ptr [ %.pre, %33 ], [ null, %._crit_edge ]
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = call ptr @giggle_init_index_with_metadata(i32 noundef %0, ptr noundef %38, ptr noundef %2, ptr noundef %37)
  %40 = call noalias ptr @strdup(ptr noundef nonnull %1) #11
  %41 = getelementptr inbounds i8, ptr %39, i64 48
  store ptr %40, ptr %41, align 8, !tbaa !11
  %42 = call ptr @simple_cache_init(i32 noundef 1000, i32 noundef %0, ptr noundef nonnull %24) #11
  call void (...) %4() #11
  %43 = getelementptr inbounds i8, ptr %39, i64 16
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = load ptr, ptr @CHRM_INDEX_FILE_NAME, align 8, !tbaa !5
  %46 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %44, ptr noundef nonnull @.str.27, ptr noundef nonnull %1, ptr noundef %45) #11
  %47 = getelementptr inbounds i8, ptr %39, i64 24
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr @FILE_INDEX_FILE_NAME, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %48, ptr noundef nonnull @.str.27, ptr noundef nonnull %1, ptr noundef %49) #11
  %51 = getelementptr inbounds i8, ptr %39, i64 56
  %52 = load ptr, ptr @ROOT_IDS_FILE_NAME, align 8, !tbaa !5
  %53 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %51, ptr noundef nonnull @.str.27, ptr noundef nonnull %1, ptr noundef %52) #11
  br i1 %.not48, label %._crit_edge47, label %.lr.ph46

.lr.ph46:                                         ; preds = %36, %.lr.ph46
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %.lr.ph46 ], [ 0, %36 ]
  %54 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv51
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  call void @free(ptr noundef %55) #11
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %exitcond55.not = icmp eq i64 %indvars.iv.next52, %23
  br i1 %exitcond55.not, label %._crit_edge47, label %.lr.ph46, !llvm.loop !16

._crit_edge47:                                    ; preds = %.lr.ph46, %36
  call void @free(ptr noundef %24) #11
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %56) #11
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %57) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #11
  br label %58

58:                                               ; preds = %._crit_edge47, %18
  %.0 = phi ptr [ %39, %._crit_edge47 ], [ null, %18 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %6) #11
  ret ptr %.0
}

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

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

declare i32 @rmrf(ptr noundef) local_unnamed_addr #7

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { "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 "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 = { noreturn nounwind }
attributes #11 = { nounwind }
attributes #12 = { cold nounwind }
attributes #13 = { nounwind allocsize(0,1) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 48}
!12 = !{!"giggle_index", !6, i64 0, !13, i64 8, !13, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = distinct !{!16, !10}


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