; 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.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.giggle_query_result = type { ptr, i32, ptr, i32 }

@cache = external dso_local global %struct.cache_def, align 8
@giggle_data_handler = external dso_local global %struct.giggle_def, align 8
@.str.32 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [3 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

declare void @uint64_t_ll_giggle_set_data_handler(...) #1

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 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 void @giggle_index_destroy(ptr noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

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

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

declare i32 @giggle_store(ptr noundef) #1

declare ptr @giggle_load(ptr noundef, ptr noundef) #1

declare i32 @rmrf(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_index_search_store_search_block() #4 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %16 = 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 %16, ptr %1, align 8, !tbaa !5
  store ptr @giggle_write_tree_leaf_data, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 10), align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store ptr @.str.32, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = call i32 @giggle_index_directory(ptr noundef %17, ptr noundef %18, i32 noundef 0)
  store i32 %19, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 10000, ptr %4, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %20 = load i32, ptr %4, align 4, !tbaa !12
  %21 = zext i32 %20 to i64
  %22 = mul i64 %21, 4
  %23 = call noalias ptr @malloc(i64 noundef %22) #6
  store ptr %23, ptr %5, align 8, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !12
  %25 = zext i32 %24 to i64
  %26 = mul i64 %25, 4
  %27 = call noalias ptr @malloc(i64 noundef %26) #6
  store ptr %27, ptr %6, align 8, !tbaa !5
  %28 = load i32, ptr %4, align 4, !tbaa !12
  %29 = zext i32 %28 to i64
  %30 = mul i64 %29, 4
  %31 = call noalias ptr @malloc(i64 noundef %30) #6
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %4, align 4, !tbaa !12
  %33 = zext i32 %32 to i64
  %34 = mul i64 %33, 4
  %35 = call noalias ptr @malloc(i64 noundef %34) #6
  store ptr %35, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !12
  br label %36

36:                                               ; preds = %109, %0
  %37 = load i32, ptr %11, align 4, !tbaa !12
  %38 = load i32, ptr %4, align 4, !tbaa !12
  %39 = icmp ult i32 %37, %38
  br i1 %39, label %40, label %112

40:                                               ; preds = %36
  %41 = call i32 @rand() #5
  %42 = srem i32 %41, 20
  %43 = add nsw i32 %42, 1
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %11, align 4, !tbaa !12
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds i32, ptr %44, i64 %46
  store i32 %43, ptr %47, align 4, !tbaa !12
  %48 = call i32 @rand() #5
  %49 = srem i32 %48, 10000000
  %50 = add nsw i32 %49, 1
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !12
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  store i32 %50, ptr %54, align 4, !tbaa !12
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load i32, ptr %11, align 4, !tbaa !12
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !12
  %60 = call i32 @rand() #5
  %61 = srem i32 %60, 10000000
  %62 = add i32 %59, %61
  %63 = add i32 %62, 1
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i32, ptr %11, align 4, !tbaa !12
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds i32, ptr %64, i64 %66
  store i32 %63, ptr %67, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load i32, ptr %11, align 4, !tbaa !12
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i32, ptr %68, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !12
  %73 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %12, ptr noundef @.str.55, i32 noundef %72) #5
  %74 = load ptr, ptr %1, align 8, !tbaa !5
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = load i32, ptr %11, align 4, !tbaa !12
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds i32, ptr %76, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !12
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = load i32, ptr %11, align 4, !tbaa !12
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds i32, ptr %81, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !12
  %86 = call ptr @giggle_query(ptr noundef %74, ptr noundef %75, i32 noundef %80, i32 noundef %85, ptr noundef null)
  store ptr %86, ptr %9, align 8, !tbaa !5
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %87) #5
  store i32 0, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !12
  br label %88

88:                                               ; preds = %100, %40
  %89 = load i32, ptr %13, align 4, !tbaa !12
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.giggle_query_result, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 8, !tbaa !14
  %93 = icmp ult i32 %89, %92
  br i1 %93, label %94, label %103

94:                                               ; preds = %88
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = load i32, ptr %13, align 4, !tbaa !12
  %97 = call i32 @giggle_get_query_len(ptr noundef %95, i32 noundef %96)
  %98 = load i32, ptr %10, align 4, !tbaa !12
  %99 = add i32 %98, %97
  store i32 %99, ptr %10, align 4, !tbaa !12
  br label %100

100:                                              ; preds = %94
  %101 = load i32, ptr %13, align 4, !tbaa !12
  %102 = add i32 %101, 1
  store i32 %102, ptr %13, align 4, !tbaa !12
  br label %88, !llvm.loop !16

103:                                              ; preds = %88
  %104 = load i32, ptr %10, align 4, !tbaa !12
  %105 = load ptr, ptr %8, align 8, !tbaa !5
  %106 = load i32, ptr %11, align 4, !tbaa !12
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds i32, ptr %105, i64 %107
  store i32 %104, ptr %108, align 4, !tbaa !12
  call void @giggle_query_result_destroy(ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %109

109:                                              ; preds = %103
  %110 = load i32, ptr %11, align 4, !tbaa !12
  %111 = add i32 %110, 1
  store i32 %111, ptr %11, align 4, !tbaa !12
  br label %36, !llvm.loop !18

112:                                              ; preds = %36
  %113 = load ptr, ptr %1, align 8, !tbaa !5
  %114 = call i32 @giggle_store(ptr noundef %113)
  %115 = zext i32 %114 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %115, ptr noundef null, i64 noundef 1655, i32 noundef 148)
  call void @giggle_index_destroy(ptr noundef %1)
  %116 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 6), align 8, !tbaa !19
  call void (...) %116()
  %117 = call ptr @giggle_load(ptr noundef @.str.33, ptr noundef @uint64_t_ll_giggle_set_data_handler)
  store ptr %117, ptr %1, align 8, !tbaa !5
  store ptr @giggle_collect_intersection_data_in_block, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 11), align 8, !tbaa !21
  store ptr @leaf_data_map_intersection_to_offset_list, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 12), align 8, !tbaa !22
  store i32 0, ptr %11, align 4, !tbaa !12
  br label %118

118:                                              ; preds = %167, %112
  %119 = load i32, ptr %11, align 4, !tbaa !12
  %120 = load i32, ptr %4, align 4, !tbaa !12
  %121 = icmp ult i32 %119, %120
  br i1 %121, label %122, label %170

122:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = load i32, ptr %11, align 4, !tbaa !12
  %125 = zext i32 %124 to i64
  %126 = getelementptr inbounds i32, ptr %123, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !12
  %128 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %14, ptr noundef @.str.55, i32 noundef %127) #5
  %129 = load ptr, ptr %1, align 8, !tbaa !5
  %130 = load ptr, ptr %14, align 8, !tbaa !5
  %131 = load ptr, ptr %6, align 8, !tbaa !5
  %132 = load i32, ptr %11, align 4, !tbaa !12
  %133 = zext i32 %132 to i64
  %134 = getelementptr inbounds i32, ptr %131, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !12
  %136 = load ptr, ptr %7, align 8, !tbaa !5
  %137 = load i32, ptr %11, align 4, !tbaa !12
  %138 = zext i32 %137 to i64
  %139 = getelementptr inbounds i32, ptr %136, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !12
  %141 = call ptr @giggle_query(ptr noundef %129, ptr noundef %130, i32 noundef %135, i32 noundef %140, ptr noundef null)
  store ptr %141, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !12
  br label %142

142:                                              ; preds = %154, %122
  %143 = load i32, ptr %15, align 4, !tbaa !12
  %144 = load ptr, ptr %9, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.giggle_query_result, ptr %144, i32 0, i32 1
  %146 = load i32, ptr %145, align 8, !tbaa !14
  %147 = icmp ult i32 %143, %146
  br i1 %147, label %148, label %157

148:                                              ; preds = %142
  %149 = load ptr, ptr %9, align 8, !tbaa !5
  %150 = load i32, ptr %15, align 4, !tbaa !12
  %151 = call i32 @giggle_get_query_len(ptr noundef %149, i32 noundef %150)
  %152 = load i32, ptr %10, align 4, !tbaa !12
  %153 = add i32 %152, %151
  store i32 %153, ptr %10, align 4, !tbaa !12
  br label %154

154:                                              ; preds = %148
  %155 = load i32, ptr %15, align 4, !tbaa !12
  %156 = add i32 %155, 1
  store i32 %156, ptr %15, align 4, !tbaa !12
  br label %142, !llvm.loop !23

157:                                              ; preds = %142
  %158 = load ptr, ptr %8, align 8, !tbaa !5
  %159 = load i32, ptr %11, align 4, !tbaa !12
  %160 = zext i32 %159 to i64
  %161 = getelementptr inbounds i32, ptr %158, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !12
  %163 = zext i32 %162 to i64
  %164 = load i32, ptr %10, align 4, !tbaa !12
  %165 = zext i32 %164 to i64
  call void @UnityAssertEqualNumber(i64 noundef %163, i64 noundef %165, ptr noundef null, i64 noundef 1683, i32 noundef 148)
  call void @giggle_query_result_destroy(ptr noundef %9)
  %166 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %166) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %167

167:                                              ; preds = %157
  %168 = load i32, ptr %11, align 4, !tbaa !12
  %169 = add i32 %168, 1
  store i32 %169, ptr %11, align 4, !tbaa !12
  br label %118, !llvm.loop !24

170:                                              ; preds = %118
  %171 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %171) #5
  %172 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %172) #5
  %173 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %173) #5
  %174 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %174) #5
  call void @giggle_index_destroy(ptr noundef %1)
  %175 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 6), align 8, !tbaa !19
  call void (...) %175()
  %176 = call i32 @rmrf(ptr noundef @.str.33)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret void
}

declare void @giggle_write_tree_leaf_data(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @rand() #2

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

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

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

declare void @giggle_query_result_destroy(ptr noundef) #1

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

declare void @leaf_data_map_intersection_to_offset_list(ptr noundef, ptr noundef, ptr 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 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 #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 = { nounwind }
attributes #6 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 112}
!10 = !{!"giggle_def", !11, i64 0, !11, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!11 = !{!"cache_handler", !6, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 8}
!15 = !{!"giggle_query_result", !6, i64 0, !13, i64 8, !6, i64 16, !13, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!20, !6, i64 48}
!20 = !{!"cache_def", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!21 = !{!10, !6, i64 120}
!22 = !{!10, !6, i64 128}
!23 = distinct !{!23, !17}
!24 = distinct !{!24, !17}


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

@cache = external dso_local local_unnamed_addr global %struct.cache_def, align 8
@giggle_data_handler = external dso_local local_unnamed_addr global %struct.giggle_def, align 8
@.str.32 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [3 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

declare void @uint64_t_ll_giggle_set_data_handler(...) #1

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 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 void @giggle_index_destroy(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 #3

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

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

declare i32 @giggle_store(ptr noundef) local_unnamed_addr #1

declare ptr @giggle_load(ptr 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_giggle_index_search_store_search_block() local_unnamed_addr #4 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %5 = 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 %5, ptr %1, align 8, !tbaa !5
  store ptr @giggle_write_tree_leaf_data, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 112), align 8, !tbaa !9
  %6 = tail call i32 @giggle_index_directory(ptr noundef %5, ptr noundef nonnull @.str.32, i32 noundef 0) #6
  %7 = tail call noalias dereferenceable_or_null(40000) ptr @malloc(i64 noundef 40000) #7
  %8 = tail call noalias dereferenceable_or_null(40000) ptr @malloc(i64 noundef 40000) #7
  %9 = tail call noalias dereferenceable_or_null(40000) ptr @malloc(i64 noundef 40000) #7
  %10 = tail call noalias dereferenceable_or_null(40000) ptr @malloc(i64 noundef 40000) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  br label %11

11:                                               ; preds = %0, %._crit_edge
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %._crit_edge ]
  %12 = call i32 @rand() #6
  %13 = srem i32 %12, 20
  %14 = add nsw i32 %13, 1
  %15 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv
  store i32 %14, ptr %15, align 4, !tbaa !12
  %16 = call i32 @rand() #6
  %17 = srem i32 %16, 10000000
  %18 = add nsw i32 %17, 1
  %19 = getelementptr inbounds i32, ptr %8, i64 %indvars.iv
  store i32 %18, ptr %19, align 4, !tbaa !12
  %20 = call i32 @rand() #6
  %21 = srem i32 %20, 10000000
  %22 = add nsw i32 %17, 2
  %23 = add nsw i32 %22, %21
  %24 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  store i32 %23, ptr %24, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %25 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.55, i32 noundef %14) #6
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call ptr @giggle_query(ptr noundef %5, ptr noundef %26, i32 noundef %18, i32 noundef %23, ptr noundef null) #6
  store ptr %27, ptr %2, align 8, !tbaa !5
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %28) #6
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  %31 = load i32, ptr %30, align 8, !tbaa !14
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %.lr.ph
  %32 = phi ptr [ %36, %.lr.ph ], [ %29, %11 ]
  %.04853 = phi i32 [ %35, %.lr.ph ], [ 0, %11 ]
  %.05052 = phi i32 [ %34, %.lr.ph ], [ 0, %11 ]
  %33 = call i32 @giggle_get_query_len(ptr noundef nonnull %32, i32 noundef %.04853) #6
  %34 = add i32 %33, %.05052
  %35 = add nuw i32 %.04853, 1
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 8
  %38 = load i32, ptr %37, align 8, !tbaa !14
  %39 = icmp ult i32 %35, %38
  br i1 %39, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %11
  %.050.lcssa = phi i32 [ 0, %11 ], [ %34, %.lr.ph ]
  %40 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv
  store i32 %.050.lcssa, ptr %40, align 4, !tbaa !12
  call void @giggle_query_result_destroy(ptr noundef nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10000
  br i1 %exitcond.not, label %41, label %11, !llvm.loop !18

41:                                               ; preds = %._crit_edge
  %42 = call i32 @giggle_store(ptr noundef %5) #6
  %43 = zext i32 %42 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %43, ptr noundef null, i64 noundef 1655, i32 noundef 148) #6
  call void @giggle_index_destroy(ptr noundef nonnull %1) #6
  %44 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !19
  call void (...) %44() #6
  %45 = call ptr @giggle_load(ptr noundef nonnull @.str.33, ptr noundef nonnull @uint64_t_ll_giggle_set_data_handler) #6
  store ptr %45, ptr %1, align 8, !tbaa !5
  store ptr @giggle_collect_intersection_data_in_block, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 120), align 8, !tbaa !21
  store ptr @leaf_data_map_intersection_to_offset_list, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 128), align 8, !tbaa !22
  br label %46

46:                                               ; preds = %41, %._crit_edge59
  %indvars.iv65 = phi i64 [ 0, %41 ], [ %indvars.iv.next66, %._crit_edge59 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %47 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv65
  %48 = load i32, ptr %47, align 4, !tbaa !12
  %49 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.55, i32 noundef %48) #6
  %50 = load ptr, ptr %1, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %8, i64 %indvars.iv65
  %53 = load i32, ptr %52, align 4, !tbaa !12
  %54 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv65
  %55 = load i32, ptr %54, align 4, !tbaa !12
  %56 = call ptr @giggle_query(ptr noundef %50, ptr noundef %51, i32 noundef %53, i32 noundef %55, ptr noundef null) #6
  store ptr %56, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 8
  %58 = load i32, ptr %57, align 8, !tbaa !14
  %.not62 = icmp eq i32 %58, 0
  br i1 %.not62, label %._crit_edge59, label %.lr.ph58

.lr.ph58:                                         ; preds = %46, %.lr.ph58
  %59 = phi ptr [ %63, %.lr.ph58 ], [ %56, %46 ]
  %.056 = phi i32 [ %62, %.lr.ph58 ], [ 0, %46 ]
  %.15155 = phi i32 [ %61, %.lr.ph58 ], [ 0, %46 ]
  %60 = call i32 @giggle_get_query_len(ptr noundef nonnull %59, i32 noundef %.056) #6
  %61 = add i32 %60, %.15155
  %62 = add nuw i32 %.056, 1
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 8
  %65 = load i32, ptr %64, align 8, !tbaa !14
  %66 = icmp ult i32 %62, %65
  br i1 %66, label %.lr.ph58, label %._crit_edge59, !llvm.loop !23

._crit_edge59:                                    ; preds = %.lr.ph58, %46
  %.151.lcssa = phi i32 [ 0, %46 ], [ %61, %.lr.ph58 ]
  %67 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv65
  %68 = load i32, ptr %67, align 4, !tbaa !12
  %69 = zext i32 %68 to i64
  %70 = zext i32 %.151.lcssa to i64
  call void @UnityAssertEqualNumber(i64 noundef %69, i64 noundef %70, ptr noundef null, i64 noundef 1683, i32 noundef 148) #6
  call void @giggle_query_result_destroy(ptr noundef nonnull %2) #6
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %71) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %exitcond68.not = icmp eq i64 %indvars.iv.next66, 10000
  br i1 %exitcond68.not, label %72, label %46, !llvm.loop !24

72:                                               ; preds = %._crit_edge59
  call void @free(ptr noundef %7) #6
  call void @free(ptr noundef %8) #6
  call void @free(ptr noundef %9) #6
  call void @free(ptr noundef nonnull %10) #6
  call void @giggle_index_destroy(ptr noundef nonnull %1) #6
  %73 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !19
  call void (...) %73() #6
  %74 = call i32 @rmrf(ptr noundef nonnull @.str.33) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret void
}

declare void @giggle_write_tree_leaf_data(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #5

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

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

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

declare void @giggle_query_result_destroy(ptr noundef) local_unnamed_addr #1

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

declare void @leaf_data_map_intersection_to_offset_list(ptr noundef, ptr noundef, ptr noundef) #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 = { 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 #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 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 112}
!10 = !{!"giggle_def", !11, i64 0, !11, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!11 = !{!"cache_handler", !6, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 8}
!15 = !{!"giggle_query_result", !6, i64 0, !13, i64 8, !6, i64 16, !13, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!20, !6, i64 48}
!20 = !{!"cache_def", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!21 = !{!10, !6, i64 120}
!22 = !{!10, !6, i64 128}
!23 = distinct !{!23, !17}
!24 = distinct !{!24, !17}


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