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

; 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.cache_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__kstring_t = type { i64, i64, ptr }
%struct.giggle_index = type { ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.input_file = type { ptr, ptr, ptr, ptr, ptr, ptr, i64, i32, ptr, ptr, ptr }
%struct.file_data = type { ptr, i32, double }

@ORDER = external dso_local global i32, align 4
@cache = external dso_local global %struct.cache_def, align 8
@.str.33 = external hidden unnamed_addr constant [4 x i8], align 1
@__const.test_valid_giggle_index_many.files = external hidden unnamed_addr constant [21 x ptr], align 16

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

declare void @uint64_t_ll_giggle_set_data_handler(...) #1

declare i32 @giggle_insert(i32 noundef, ptr noundef, i32 noundef, i32 noundef, i64 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
declare void @free(ptr noundef) #2

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

declare void @giggle_index_destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @valid_giggle_index(ptr noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

declare ptr @input_file_init(ptr noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 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

declare void @input_file_destroy(ptr noundef) #1

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

declare i32 @rmrf(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_valid_giggle_index_many() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca [21 x ptr], align 16
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca %struct.__kstring_t, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i32 100, ptr @ORDER, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #7
  %20 = call ptr @giggle_init(i32 noundef 24, ptr noundef @.str.33, i32 noundef 1, ptr noundef @uint64_t_ll_giggle_set_data_handler)
  store ptr %20, ptr %1, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 168, ptr %3) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.test_valid_giggle_index_many.files, i64 168, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %109, %0
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp ult i32 %22, 21
  br i1 %23, label %24, label %112

24:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds [21 x ptr], ptr %3, i64 0, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  store ptr %28, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = call ptr @input_file_init(ptr noundef %29)
  store ptr %30, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 10, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = mul i64 %32, 1
  %34 = call noalias ptr @malloc(i64 noundef %33) #8
  store ptr %34, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #7
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %35 = load ptr, ptr %1, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.giggle_index, ptr %35, i32 0, i32 4
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %5, align 8, !tbaa !9
  %39 = call i32 @file_index_add(ptr noundef %37, ptr noundef %38)
  store i32 %39, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %40 = load ptr, ptr %1, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.giggle_index, ptr %40, i32 0, i32 4
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = load i32, ptr %13, align 4, !tbaa !5
  %44 = call ptr @file_index_get(ptr noundef %42, i32 noundef %43)
  store ptr %44, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  br label %45

45:                                               ; preds = %52, %24
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.input_file, ptr %46, i32 0, i32 8
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = call i32 %48(ptr noundef %49, ptr noundef %8, ptr noundef %7, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %12)
  %51 = icmp sge i32 %50, 0
  br i1 %51, label %52, label %90

52:                                               ; preds = %45
  %53 = load ptr, ptr %1, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.giggle_index, ptr %53, i32 0, i32 5
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  %56 = load i64, ptr %11, align 8, !tbaa !17
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = call i64 @offset_index_add(ptr noundef %55, i64 noundef %56, ptr noundef %12, i32 noundef %57)
  %59 = trunc i64 %58 to i32
  store i32 %59, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %60 = load ptr, ptr %1, align 8, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !9
  %62 = call i32 @giggle_get_chrm_id(ptr noundef %60, ptr noundef %61)
  store i32 %62, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  %63 = load i32, ptr %18, align 4, !tbaa !5
  %64 = load ptr, ptr %1, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.giggle_index, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !18
  %67 = load i32, ptr %18, align 4, !tbaa !5
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds i32, ptr %66, i64 %68
  %70 = load i32, ptr %9, align 4, !tbaa !5
  %71 = load i32, ptr %10, align 4, !tbaa !5
  %72 = load i32, ptr %17, align 4, !tbaa !5
  %73 = zext i32 %72 to i64
  %74 = call i32 @giggle_insert(i32 noundef %63, ptr noundef %69, i32 noundef %70, i32 noundef %71, i64 noundef %73)
  store i32 %74, ptr %19, align 4, !tbaa !5
  %75 = load ptr, ptr %1, align 8, !tbaa !9
  call void @valid_giggle_index(ptr noundef %75)
  %76 = load i32, ptr %10, align 4, !tbaa !5
  %77 = load i32, ptr %9, align 4, !tbaa !5
  %78 = sub i32 %76, %77
  %79 = uitofp i32 %78 to double
  %80 = load ptr, ptr %14, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.file_data, ptr %80, i32 0, i32 2
  %82 = load double, ptr %81, align 8, !tbaa !19
  %83 = fadd double %82, %79
  store double %83, ptr %81, align 8, !tbaa !19
  %84 = load ptr, ptr %14, align 8, !tbaa !9
  %85 = getelementptr inbounds %struct.file_data, ptr %84, i32 0, i32 1
  %86 = load i32, ptr %85, align 8, !tbaa !22
  %87 = add i32 %86, 1
  store i32 %87, ptr %85, align 8, !tbaa !22
  %88 = load i32, ptr %15, align 4, !tbaa !5
  %89 = add i32 %88, 1
  store i32 %89, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %45, !llvm.loop !23

90:                                               ; preds = %45
  %91 = load ptr, ptr %14, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct.file_data, ptr %91, i32 0, i32 2
  %93 = load double, ptr %92, align 8, !tbaa !19
  %94 = load ptr, ptr %14, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct.file_data, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 8, !tbaa !22
  %97 = uitofp i32 %96 to double
  %98 = fdiv double %93, %97
  %99 = load ptr, ptr %14, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct.file_data, ptr %99, i32 0, i32 2
  store double %98, ptr %100, align 8, !tbaa !19
  call void @input_file_destroy(ptr noundef %6)
  %101 = getelementptr inbounds %struct.__kstring_t, ptr %12, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !25
  %103 = icmp ne ptr %102, null
  br i1 %103, label %104, label %107

104:                                              ; preds = %90
  %105 = getelementptr inbounds %struct.__kstring_t, ptr %12, i32 0, i32 2
  %106 = load ptr, ptr %105, align 8, !tbaa !25
  call void @free(ptr noundef %106) #7
  br label %107

107:                                              ; preds = %104, %90
  %108 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %108) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %109

109:                                              ; preds = %107
  %110 = load i32, ptr %4, align 4, !tbaa !5
  %111 = add i32 %110, 1
  store i32 %111, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !27

112:                                              ; preds = %21
  call void @giggle_index_destroy(ptr noundef %1)
  %113 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 6), align 8, !tbaa !28
  call void (...) %113()
  %114 = call i32 @rmrf(ptr noundef @.str.33)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 168, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #7
  ret void
}

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

declare i64 @offset_index_add(ptr noundef, i64 noundef, ptr noundef, i32 noundef) #1

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

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

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


; 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.cache_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__kstring_t = type { i64, i64, ptr }

@ORDER = external dso_local local_unnamed_addr global i32, align 4
@cache = external dso_local local_unnamed_addr global %struct.cache_def, align 8
@.str.33 = external hidden unnamed_addr constant [4 x i8], align 1
@__const.test_valid_giggle_index_many.files = external hidden unnamed_addr constant [21 x ptr], align 16

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

declare void @uint64_t_ll_giggle_set_data_handler(...) #1

declare i32 @giggle_insert(i32 noundef, ptr noundef, i32 noundef, i32 noundef, i64 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

declare void @giggle_index_destroy(ptr noundef) local_unnamed_addr #1

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

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

declare ptr @input_file_init(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #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

declare void @input_file_destroy(ptr noundef) local_unnamed_addr #1

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

declare i32 @rmrf(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_valid_giggle_index_many() local_unnamed_addr #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca %struct.__kstring_t, align 8
  store i32 100, ptr @ORDER, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %9 = tail call ptr @giggle_init(i32 noundef 24, ptr noundef nonnull @.str.33, i32 noundef 1, ptr noundef nonnull @uint64_t_ll_giggle_set_data_handler) #6
  store ptr %9, ptr %1, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %8, i64 16
  br label %11

11:                                               ; preds = %0, %67
  %12 = phi ptr [ %9, %0 ], [ %58, %67 ]
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %67 ]
  %13 = getelementptr inbounds [21 x ptr], ptr @__const.test_valid_giggle_index_many.files, i64 0, i64 %indvars.iv
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %15 = call ptr @input_file_init(ptr noundef %14) #6
  store ptr %15, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  store i32 10, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %16 = call noalias dereferenceable_or_null(10) ptr @malloc(i64 noundef 10) #7
  store ptr %16, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %8, i8 0, i64 24, i1 false)
  %17 = getelementptr inbounds i8, ptr %12, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = call i32 @file_index_add(ptr noundef %18, ptr noundef %14) #6
  %20 = load ptr, ptr %17, align 8, !tbaa !11
  %21 = call ptr @file_index_get(ptr noundef %20, i32 noundef %19) #6
  %22 = load ptr, ptr %2, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %22, i64 64
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = call i32 %24(ptr noundef %22, ptr noundef nonnull %4, ptr noundef nonnull %3, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8) #6
  %26 = icmp sgt i32 %25, -1
  br i1 %26, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %11
  %27 = getelementptr inbounds i8, ptr %21, i64 16
  %28 = getelementptr inbounds i8, ptr %21, i64 8
  br label %29

29:                                               ; preds = %.lr.ph, %29
  %30 = phi ptr [ %12, %.lr.ph ], [ %37, %29 ]
  %31 = getelementptr inbounds i8, ptr %30, i64 32
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = load i64, ptr %7, align 8, !tbaa !17
  %34 = call i64 @offset_index_add(ptr noundef %32, i64 noundef %33, ptr noundef nonnull %8, i32 noundef %19) #6
  %35 = load ptr, ptr %4, align 8, !tbaa !9
  %36 = call i32 @giggle_get_chrm_id(ptr noundef nonnull %30, ptr noundef %35) #6
  %37 = load ptr, ptr %1, align 8, !tbaa !9
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = zext i32 %36 to i64
  %40 = getelementptr inbounds i32, ptr %38, i64 %39
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = and i64 %34, 4294967295
  %44 = call i32 @giggle_insert(i32 noundef %36, ptr noundef %40, i32 noundef %41, i32 noundef %42, i64 noundef %43) #6
  call void @valid_giggle_index(ptr noundef nonnull %37)
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sub i32 %45, %46
  %48 = uitofp i32 %47 to double
  %49 = load double, ptr %27, align 8, !tbaa !19
  %50 = fadd double %49, %48
  store double %50, ptr %27, align 8, !tbaa !19
  %51 = load i32, ptr %28, align 8, !tbaa !22
  %52 = add i32 %51, 1
  store i32 %52, ptr %28, align 8, !tbaa !22
  %53 = load ptr, ptr %2, align 8, !tbaa !9
  %54 = getelementptr inbounds i8, ptr %53, i64 64
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  %56 = call i32 %55(ptr noundef %53, ptr noundef nonnull %4, ptr noundef nonnull %3, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8) #6
  %57 = icmp sgt i32 %56, -1
  br i1 %57, label %29, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %29, %11
  %58 = phi ptr [ %12, %11 ], [ %37, %29 ]
  %59 = getelementptr inbounds i8, ptr %21, i64 16
  %60 = load double, ptr %59, align 8, !tbaa !19
  %61 = getelementptr inbounds i8, ptr %21, i64 8
  %62 = load i32, ptr %61, align 8, !tbaa !22
  %63 = uitofp i32 %62 to double
  %64 = fdiv double %60, %63
  store double %64, ptr %59, align 8, !tbaa !19
  call void @input_file_destroy(ptr noundef nonnull %2) #6
  %65 = load ptr, ptr %10, align 8, !tbaa !25
  %.not = icmp eq ptr %65, null
  br i1 %.not, label %67, label %66

66:                                               ; preds = %._crit_edge
  call void @free(ptr noundef nonnull %65) #6
  br label %67

67:                                               ; preds = %66, %._crit_edge
  %68 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %68) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 21
  br i1 %exitcond.not, label %69, label %11, !llvm.loop !27

69:                                               ; preds = %67
  call void @giggle_index_destroy(ptr noundef nonnull %1) #6
  %70 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !28
  call void (...) %70() #6
  %71 = call i32 @rmrf(ptr noundef nonnull @.str.33) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret void
}

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

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

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

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

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


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