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

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

declare void @uint64_t_ll_free(ptr noundef) #1

declare void @giggle_index_destroy(ptr noundef) #1

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

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() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  %5 = 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 %5, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  store ptr @.str.32, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = call i32 @giggle_index_directory(ptr noundef %6, ptr noundef %7, i32 noundef 0)
  store i32 %8, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = call ptr @giggle_query_region(ptr noundef %9, ptr noundef @.str.5, i32 noundef 112989628, i32 noundef 112989630)
  store ptr %10, ptr %4, align 8, !tbaa !5
  call void @uint64_t_ll_free(ptr noundef %4)
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = call i32 @giggle_store(ptr noundef %11)
  %13 = zext i32 %12 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %13, ptr noundef null, i64 noundef 1589, i32 noundef 148)
  call void @giggle_index_destroy(ptr noundef %1)
  %14 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 6), align 8, !tbaa !11
  call void (...) %14()
  %15 = call ptr @giggle_load(ptr noundef @.str.33, ptr noundef @uint64_t_ll_giggle_set_data_handler)
  store ptr %15, ptr %1, align 8, !tbaa !5
  %16 = load ptr, ptr %1, align 8, !tbaa !5
  %17 = call ptr @giggle_query_region(ptr noundef %16, ptr noundef @.str.5, i32 noundef 112989628, i32 noundef 112989630)
  store ptr %17, ptr %4, align 8, !tbaa !5
  call void @uint64_t_ll_free(ptr noundef %4)
  call void @giggle_index_destroy(ptr noundef %1)
  %18 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 6), align 8, !tbaa !11
  call void (...) %18()
  %19 = call i32 @rmrf(ptr noundef @.str.33)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

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 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 48}
!12 = !{!"cache_def", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, 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 }

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

declare void @uint64_t_ll_free(ptr noundef) local_unnamed_addr #1

declare void @giggle_index_destroy(ptr noundef) local_unnamed_addr #1

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

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() local_unnamed_addr #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %3 = 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) #3
  store ptr %3, ptr %1, align 8, !tbaa !5
  %4 = tail call i32 @giggle_index_directory(ptr noundef %3, ptr noundef nonnull @.str.32, i32 noundef 0) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %5 = tail call ptr @giggle_query_region(ptr noundef %3, ptr noundef nonnull @.str.5, i32 noundef 112989628, i32 noundef 112989630) #3
  store ptr %5, ptr %2, align 8, !tbaa !5
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #3
  %6 = call i32 @giggle_store(ptr noundef %3) #3
  %7 = zext i32 %6 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %7, ptr noundef null, i64 noundef 1589, i32 noundef 148) #3
  call void @giggle_index_destroy(ptr noundef nonnull %1) #3
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !9
  call void (...) %8() #3
  %9 = call ptr @giggle_load(ptr noundef nonnull @.str.33, ptr noundef nonnull @uint64_t_ll_giggle_set_data_handler) #3
  store ptr %9, ptr %1, align 8, !tbaa !5
  %10 = call ptr @giggle_query_region(ptr noundef %9, ptr noundef nonnull @.str.5, i32 noundef 112989628, i32 noundef 112989630) #3
  store ptr %10, ptr %2, align 8, !tbaa !5
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #3
  call void @giggle_index_destroy(ptr noundef nonnull %1) #3
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !9
  call void (...) %11() #3
  %12 = call i32 @rmrf(ptr noundef nonnull @.str.33) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret void
}

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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 48}
!10 = !{!"cache_def", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass