; 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.giggle_def = type { %struct.cache_handler, %struct.cache_handler, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cache_handler = type { ptr, ptr, ptr }
%struct.cache_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.bpt_node = type { ptr }

@giggle_data_handler = external dso_local global %struct.giggle_def, align 8
@cache = external dso_local global %struct.cache_def, align 8
@bpt_node_cache_handler = external dso_local global %struct.cache_handler, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @giggle_insert(i32 noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i64 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca i32, align 4
  %28 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i64 %4, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = add i32 %32, 1
  %34 = call i32 @bpt_find(i32 noundef %29, i32 noundef %31, ptr noundef %11, ptr noundef %12, i32 noundef %33)
  store i32 %34, ptr %13, align 4, !tbaa !5
  %35 = load i32, ptr %13, align 4, !tbaa !5
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %52

37:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %38 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 2), align 8, !tbaa !13
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = call ptr %38(i32 noundef %39)
  store ptr %40, ptr %14, align 8, !tbaa !9
  %41 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 5), align 8, !tbaa !16
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = load ptr, ptr %14, align 8, !tbaa !9
  call void %41(i32 noundef %42, ptr noundef %43, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = add i32 %47, 1
  %49 = load ptr, ptr %14, align 8, !tbaa !9
  %50 = call i32 @bpt_insert_new_value(i32 noundef %44, i32 noundef %46, i32 noundef %48, ptr noundef %49, ptr noundef @giggle_data_handler, ptr noundef %15, ptr noundef %11, ptr noundef %12)
  %51 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 %50, ptr %51, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %61

52:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %53 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !17
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = load i32, ptr %13, align 4, !tbaa !5
  %56 = sub i32 %55, 1
  %57 = call ptr %53(i32 noundef %54, i32 noundef %56, ptr noundef @giggle_data_handler)
  store ptr %57, ptr %17, align 8, !tbaa !9
  %58 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 5), align 8, !tbaa !16
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = load ptr, ptr %17, align 8, !tbaa !9
  call void %58(i32 noundef %59, ptr noundef %60, ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %61

61:                                               ; preds = %52, %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !9
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = load i32, ptr %8, align 4, !tbaa !5
  %66 = call i32 @bpt_find(i32 noundef %62, i32 noundef %64, ptr noundef %18, ptr noundef %19, i32 noundef %65)
  store i32 %66, ptr %20, align 4, !tbaa !5
  %67 = load i32, ptr %20, align 4, !tbaa !5
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %83

69:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  %70 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 2), align 8, !tbaa !13
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = call ptr %70(i32 noundef %71)
  store ptr %72, ptr %21, align 8, !tbaa !9
  %73 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 4), align 8, !tbaa !19
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = load ptr, ptr %21, align 8, !tbaa !9
  call void %73(i32 noundef %74, ptr noundef %75, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = load ptr, ptr %7, align 8, !tbaa !9
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = load ptr, ptr %21, align 8, !tbaa !9
  %81 = call i32 @bpt_insert_new_value(i32 noundef %76, i32 noundef %78, i32 noundef %79, ptr noundef %80, ptr noundef @giggle_data_handler, ptr noundef %22, ptr noundef %18, ptr noundef %19)
  %82 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 %81, ptr %82, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  br label %92

83:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  %84 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !17
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr %20, align 4, !tbaa !5
  %87 = sub i32 %86, 1
  %88 = call ptr %84(i32 noundef %85, i32 noundef %87, ptr noundef @giggle_data_handler)
  store ptr %88, ptr %24, align 8, !tbaa !9
  %89 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 4), align 8, !tbaa !19
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = load ptr, ptr %24, align 8, !tbaa !9
  call void %89(i32 noundef %90, ptr noundef %91, ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  br label %92

92:                                               ; preds = %83, %69
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = load ptr, ptr %7, align 8, !tbaa !9
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = call i32 @bpt_find_leaf(i32 noundef %93, i32 noundef %95, i32 noundef %96)
  store i32 %97, ptr %18, align 4, !tbaa !5
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = load ptr, ptr %7, align 8, !tbaa !9
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = load i32, ptr %9, align 4, !tbaa !5
  %102 = add i32 %101, 1
  %103 = call i32 @bpt_find_leaf(i32 noundef %98, i32 noundef %100, i32 noundef %102)
  store i32 %103, ptr %11, align 4, !tbaa !5
  %104 = load i32, ptr %18, align 4, !tbaa !5
  %105 = load i32, ptr %11, align 4, !tbaa !5
  %106 = icmp ne i32 %104, %105
  br i1 %106, label %107, label %173

107:                                              ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #3
  %108 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !17
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = load i32, ptr %18, align 4, !tbaa !5
  %111 = sub i32 %110, 1
  %112 = call ptr %108(i32 noundef %109, i32 noundef %111, ptr noundef @bpt_node_cache_handler)
  store ptr %112, ptr %25, align 8, !tbaa !9
  br label %113

113:                                              ; preds = %164, %107
  %114 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !17
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = load ptr, ptr %25, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct.bpt_node, ptr %116, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !20
  %119 = getelementptr inbounds i32, ptr %118, i64 4
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = sub i32 %120, 1
  %122 = call ptr %114(i32 noundef %115, i32 noundef %121, ptr noundef @bpt_node_cache_handler)
  store ptr %122, ptr %25, align 8, !tbaa !9
  %123 = load ptr, ptr %25, align 8, !tbaa !9
  %124 = getelementptr inbounds %struct.bpt_node, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !20
  %126 = getelementptr inbounds i32, ptr %125, i64 3
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = icmp eq i32 %127, 0
  br i1 %128, label %129, label %150

129:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #3
  %130 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 3), align 8, !tbaa !22
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = call ptr %130(i32 noundef %131)
  store ptr %132, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #3
  %133 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 1), align 8, !tbaa !23
  %134 = load i32, ptr %6, align 4, !tbaa !5
  %135 = call i32 %133(i32 noundef %134)
  %136 = add i32 %135, 1
  store i32 %136, ptr %27, align 4, !tbaa !5
  %137 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 2), align 8, !tbaa !24
  %138 = load i32, ptr %6, align 4, !tbaa !5
  %139 = load i32, ptr %27, align 4, !tbaa !5
  %140 = sub i32 %139, 1
  %141 = load ptr, ptr %26, align 8, !tbaa !9
  call void %137(i32 noundef %138, i32 noundef %140, ptr noundef %141, i64 noundef 8, ptr noundef getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 1))
  %142 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 6), align 8, !tbaa !25
  %143 = load i32, ptr %6, align 4, !tbaa !5
  %144 = load ptr, ptr %26, align 8, !tbaa !9
  call void %142(i32 noundef %143, ptr noundef %144, ptr noundef %10)
  %145 = load i32, ptr %27, align 4, !tbaa !5
  %146 = load ptr, ptr %25, align 8, !tbaa !9
  %147 = getelementptr inbounds %struct.bpt_node, ptr %146, i32 0, i32 0
  %148 = load ptr, ptr %147, align 8, !tbaa !20
  %149 = getelementptr inbounds i32, ptr %148, i64 3
  store i32 %145, ptr %149, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #3
  br label %163

150:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #3
  %151 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !17
  %152 = load i32, ptr %6, align 4, !tbaa !5
  %153 = load ptr, ptr %25, align 8, !tbaa !9
  %154 = getelementptr inbounds %struct.bpt_node, ptr %153, i32 0, i32 0
  %155 = load ptr, ptr %154, align 8, !tbaa !20
  %156 = getelementptr inbounds i32, ptr %155, i64 3
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = sub i32 %157, 1
  %159 = call ptr %151(i32 noundef %152, i32 noundef %158, ptr noundef getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 1))
  store ptr %159, ptr %28, align 8, !tbaa !9
  %160 = load ptr, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 6), align 8, !tbaa !25
  %161 = load i32, ptr %6, align 4, !tbaa !5
  %162 = load ptr, ptr %28, align 8, !tbaa !9
  call void %160(i32 noundef %161, ptr noundef %162, ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #3
  br label %163

163:                                              ; preds = %150, %129
  br label %164

164:                                              ; preds = %163
  %165 = load ptr, ptr %25, align 8, !tbaa !9
  %166 = getelementptr inbounds %struct.bpt_node, ptr %165, i32 0, i32 0
  %167 = load ptr, ptr %166, align 8, !tbaa !20
  %168 = getelementptr inbounds i32, ptr %167, i64 0
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = load i32, ptr %11, align 4, !tbaa !5
  %171 = icmp ne i32 %169, %170
  br i1 %171, label %113, label %172, !llvm.loop !26

172:                                              ; preds = %164
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #3
  br label %173

173:                                              ; preds = %172, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 0
}

declare i32 @bpt_find(i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @bpt_insert_new_value(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @bpt_find_leaf(i32 noundef, i32 noundef, i32 noundef) #2

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

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 48}
!14 = !{!"giggle_def", !15, i64 0, !15, i64 24, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128}
!15 = !{!"cache_handler", !10, i64 0, !10, i64 8, !10, i64 16}
!16 = !{!14, !10, i64 72}
!17 = !{!18, !10, i64 24}
!18 = !{!"cache_def", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!19 = !{!14, !10, i64 64}
!20 = !{!21, !10, i64 0}
!21 = !{!"bpt_node", !10, i64 0}
!22 = !{!14, !10, i64 56}
!23 = !{!18, !10, i64 8}
!24 = !{!18, !10, i64 16}
!25 = !{!14, !10, i64 80}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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

@giggle_data_handler = external dso_local global %struct.giggle_def, align 8
@cache = external dso_local local_unnamed_addr global %struct.cache_def, align 8
@bpt_node_cache_handler = external dso_local global %struct.cache_handler, 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @giggle_insert(i32 noundef %0, ptr nocapture noundef %1, i32 noundef %2, i32 noundef %3, i64 noundef %4) local_unnamed_addr #1 {
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i64 %4, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %14 = add i32 %3, 1
  %15 = call i32 @bpt_find(i32 noundef %0, i32 noundef %13, ptr noundef nonnull %7, ptr noundef nonnull %8, i32 noundef %14) #3
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %23

17:                                               ; preds = %5
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 48), align 8, !tbaa !11
  %19 = call ptr %18(i32 noundef %0) #3
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 72), align 8, !tbaa !15
  call void %20(i32 noundef %0, ptr noundef %19, ptr noundef nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %21 = load i32, ptr %1, align 4, !tbaa !9
  %22 = call i32 @bpt_insert_new_value(i32 noundef %0, i32 noundef %21, i32 noundef %14, ptr noundef %19, ptr noundef nonnull @giggle_data_handler, ptr noundef nonnull %9, ptr noundef nonnull %7, ptr noundef nonnull %8) #3
  store i32 %22, ptr %1, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  br label %28

23:                                               ; preds = %5
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !16
  %25 = add i32 %15, -1
  %26 = call ptr %24(i32 noundef %0, i32 noundef %25, ptr noundef nonnull @giggle_data_handler) #3
  %27 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 72), align 8, !tbaa !15
  call void %27(i32 noundef %0, ptr noundef %26, ptr noundef nonnull %6) #3
  %.pre = load i32, ptr %1, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %23, %17
  %29 = phi i32 [ %.pre, %23 ], [ %22, %17 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #3
  %30 = call i32 @bpt_find(i32 noundef %0, i32 noundef %29, ptr noundef nonnull %10, ptr noundef nonnull %11, i32 noundef %2) #3
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %38

32:                                               ; preds = %28
  %33 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 48), align 8, !tbaa !11
  %34 = call ptr %33(i32 noundef %0) #3
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 64), align 8, !tbaa !18
  call void %35(i32 noundef %0, ptr noundef %34, ptr noundef nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  %36 = load i32, ptr %1, align 4, !tbaa !9
  %37 = call i32 @bpt_insert_new_value(i32 noundef %0, i32 noundef %36, i32 noundef %2, ptr noundef %34, ptr noundef nonnull @giggle_data_handler, ptr noundef nonnull %12, ptr noundef nonnull %10, ptr noundef nonnull %11) #3
  store i32 %37, ptr %1, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  br label %43

38:                                               ; preds = %28
  %39 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !16
  %40 = add i32 %30, -1
  %41 = call ptr %39(i32 noundef %0, i32 noundef %40, ptr noundef nonnull @giggle_data_handler) #3
  %42 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 64), align 8, !tbaa !18
  call void %42(i32 noundef %0, ptr noundef %41, ptr noundef nonnull %6) #3
  %.pre60 = load i32, ptr %1, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %38, %32
  %44 = phi i32 [ %.pre60, %38 ], [ %37, %32 ]
  %45 = call i32 @bpt_find_leaf(i32 noundef %0, i32 noundef %44, i32 noundef %2) #3
  store i32 %45, ptr %10, align 4, !tbaa !9
  %46 = load i32, ptr %1, align 4, !tbaa !9
  %47 = call i32 @bpt_find_leaf(i32 noundef %0, i32 noundef %46, i32 noundef %14) #3
  store i32 %47, ptr %7, align 4, !tbaa !9
  %48 = load i32, ptr %10, align 4, !tbaa !9
  %.not = icmp eq i32 %48, %47
  br i1 %.not, label %.loopexit, label %49

49:                                               ; preds = %43
  %50 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !16
  %51 = add i32 %48, -1
  %52 = call ptr %50(i32 noundef %0, i32 noundef %51, ptr noundef nonnull @bpt_node_cache_handler) #3
  %.pre61 = load ptr, ptr %52, align 8, !tbaa !19
  br label %53

53:                                               ; preds = %79, %49
  %54 = phi ptr [ %.pre61, %49 ], [ %80, %79 ]
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !16
  %56 = getelementptr inbounds i8, ptr %54, i64 16
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = add i32 %57, -1
  %59 = call ptr %55(i32 noundef %0, i32 noundef %58, ptr noundef nonnull @bpt_node_cache_handler) #3
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = getelementptr inbounds i8, ptr %60, i64 12
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %74

64:                                               ; preds = %53
  %65 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 56), align 8, !tbaa !21
  %66 = call ptr %65(i32 noundef %0) #3
  %67 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 8), align 8, !tbaa !22
  %68 = call i32 %67(i32 noundef %0) #3
  %69 = add i32 %68, 1
  %70 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 16), align 8, !tbaa !23
  call void %70(i32 noundef %0, i32 noundef %68, ptr noundef %66, i64 noundef 8, ptr noundef nonnull getelementptr inbounds (i8, ptr @giggle_data_handler, i64 24)) #3
  %71 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 80), align 8, !tbaa !24
  call void %71(i32 noundef %0, ptr noundef %66, ptr noundef nonnull %6) #3
  %72 = load ptr, ptr %59, align 8, !tbaa !19
  %73 = getelementptr inbounds i8, ptr %72, i64 12
  store i32 %69, ptr %73, align 4, !tbaa !9
  br label %79

74:                                               ; preds = %53
  %75 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !16
  %76 = add i32 %62, -1
  %77 = call ptr %75(i32 noundef %0, i32 noundef %76, ptr noundef nonnull getelementptr inbounds (i8, ptr @giggle_data_handler, i64 24)) #3
  %78 = load ptr, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 80), align 8, !tbaa !24
  call void %78(i32 noundef %0, ptr noundef %77, ptr noundef nonnull %6) #3
  %.pre62 = load ptr, ptr %59, align 8, !tbaa !19
  br label %79

79:                                               ; preds = %64, %74
  %80 = phi ptr [ %72, %64 ], [ %.pre62, %74 ]
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %.not59 = icmp eq i32 %81, %82
  br i1 %.not59, label %.loopexit, label %53, !llvm.loop !25

.loopexit:                                        ; preds = %79, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  ret i32 0
}

declare i32 @bpt_find(i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @bpt_insert_new_value(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @bpt_find_leaf(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

!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 = !{!"long", !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, !14, i64 48}
!12 = !{!"giggle_def", !13, i64 0, !13, i64 24, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !14, i64 128}
!13 = !{!"cache_handler", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!12, !14, i64 72}
!16 = !{!17, !14, i64 24}
!17 = !{!"cache_def", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48}
!18 = !{!12, !14, i64 64}
!19 = !{!20, !14, i64 0}
!20 = !{!"bpt_node", !14, i64 0}
!21 = !{!12, !14, i64 56}
!22 = !{!17, !14, i64 8}
!23 = !{!17, !14, i64 16}
!24 = !{!12, !14, i64 80}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass