; 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_index = type { ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.file_index = type { ptr, ptr }
%struct.unordered_list = type { ptr, i32, i32 }
%struct.offset_index = type { ptr, ptr, i32, ptr, i32 }
%struct.file_id_offset_pairs = type { i64, i64, ptr }
%struct.uint64_t_ll = type { i64, 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.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 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

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_init_store_load() #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
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = zext i32 %9 to i64
  call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %10, ptr noundef null, i64 noundef 1234, i32 noundef 148)
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.giggle_index, ptr %11, i32 0, i32 4
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.file_index, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = getelementptr inbounds %struct.unordered_list, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !15
  %18 = zext i32 %17 to i64
  call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %18, ptr noundef null, i64 noundef 1235, i32 noundef 148)
  %19 = load ptr, ptr %1, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.giggle_index, ptr %19, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = getelementptr inbounds %struct.offset_index, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  %24 = getelementptr inbounds %struct.file_id_offset_pairs, ptr %23, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !20
  call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %25, ptr noundef null, i64 noundef 1236, i32 noundef 148)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = call ptr @giggle_query_region(ptr noundef %26, ptr noundef @.str.11, i32 noundef 1000, i32 noundef 3000000)
  store ptr %27, ptr %4, align 8, !tbaa !5
  call void @uint64_t_ll_free(ptr noundef %4)
  %28 = load ptr, ptr %1, align 8, !tbaa !5
  %29 = call ptr @giggle_query_region(ptr noundef %28, ptr noundef @.str.9, i32 noundef 1000, i32 noundef 3000000)
  store ptr %29, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.uint64_t_ll, ptr %30, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !23
  call void @UnityAssertEqualNumber(i64 noundef 71, i64 noundef %32, ptr noundef null, i64 noundef 1251, i32 noundef 148)
  call void @uint64_t_ll_free(ptr noundef %4)
  %33 = load ptr, ptr %1, align 8, !tbaa !5
  %34 = call i32 @giggle_store(ptr noundef %33)
  %35 = zext i32 %34 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %35, ptr noundef null, i64 noundef 1254, i32 noundef 148)
  call void @giggle_index_destroy(ptr noundef %1)
  %36 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 6), align 8, !tbaa !25
  call void (...) %36()
  %37 = call ptr @giggle_load(ptr noundef @.str.33, ptr noundef @uint64_t_ll_giggle_set_data_handler)
  store ptr %37, ptr %1, align 8, !tbaa !5
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  %39 = call ptr @giggle_query_region(ptr noundef %38, ptr noundef @.str.9, i32 noundef 1000, i32 noundef 1000000)
  store ptr %39, ptr %4, align 8, !tbaa !5
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.uint64_t_ll, ptr %40, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !23
  call void @UnityAssertEqualNumber(i64 noundef 16, i64 noundef %42, ptr noundef null, i64 noundef 1265, i32 noundef 148)
  call void @uint64_t_ll_free(ptr noundef %4)
  %43 = load ptr, ptr %1, align 8, !tbaa !5
  %44 = call ptr @giggle_query_region(ptr noundef %43, ptr noundef @.str.5, i32 noundef 112989628, i32 noundef 112989630)
  store ptr %44, ptr %4, align 8, !tbaa !5
  call void @uint64_t_ll_free(ptr noundef %4)
  call void @giggle_index_destroy(ptr noundef %1)
  %45 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 6), align 8, !tbaa !25
  call void (...) %45()
  %46 = 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
}

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

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 24}
!12 = !{!"giggle_index", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!14, !6, i64 8}
!14 = !{!"file_index", !6, i64 0, !6, i64 8}
!15 = !{!16, !10, i64 8}
!16 = !{!"unordered_list", !6, i64 0, !10, i64 8, !10, i64 12}
!17 = !{!12, !6, i64 32}
!18 = !{!19, !6, i64 0}
!19 = !{!"offset_index", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32}
!20 = !{!21, !22, i64 0}
!21 = !{!"file_id_offset_pairs", !22, i64 0, !22, i64 8, !6, i64 16}
!22 = !{!"long", !7, i64 0}
!23 = !{!24, !22, i64 0}
!24 = !{!"uint64_t_ll", !22, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!26, !6, i64 48}
!26 = !{!"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.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 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

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_init_store_load() 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
  %5 = zext i32 %4 to i64
  tail call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %5, ptr noundef null, i64 noundef 1234, i32 noundef 148) #3
  %6 = getelementptr inbounds i8, ptr %3, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = zext i32 %11 to i64
  tail call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %12, ptr noundef null, i64 noundef 1235, i32 noundef 148) #3
  %13 = getelementptr inbounds i8, ptr %3, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  %16 = load i64, ptr %15, align 8, !tbaa !19
  tail call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %16, ptr noundef null, i64 noundef 1236, i32 noundef 148) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %17 = tail call ptr @giggle_query_region(ptr noundef %3, ptr noundef nonnull @.str.11, i32 noundef 1000, i32 noundef 3000000) #3
  store ptr %17, ptr %2, align 8, !tbaa !5
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #3
  %18 = call ptr @giggle_query_region(ptr noundef %3, ptr noundef nonnull @.str.9, i32 noundef 1000, i32 noundef 3000000) #3
  store ptr %18, ptr %2, align 8, !tbaa !5
  %19 = load i64, ptr %18, align 8, !tbaa !22
  call void @UnityAssertEqualNumber(i64 noundef 71, i64 noundef %19, ptr noundef null, i64 noundef 1251, i32 noundef 148) #3
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #3
  %20 = call i32 @giggle_store(ptr noundef %3) #3
  %21 = zext i32 %20 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %21, ptr noundef null, i64 noundef 1254, i32 noundef 148) #3
  call void @giggle_index_destroy(ptr noundef nonnull %1) #3
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !24
  call void (...) %22() #3
  %23 = call ptr @giggle_load(ptr noundef nonnull @.str.33, ptr noundef nonnull @uint64_t_ll_giggle_set_data_handler) #3
  store ptr %23, ptr %1, align 8, !tbaa !5
  %24 = call ptr @giggle_query_region(ptr noundef %23, ptr noundef nonnull @.str.9, i32 noundef 1000, i32 noundef 1000000) #3
  store ptr %24, ptr %2, align 8, !tbaa !5
  %25 = load i64, ptr %24, align 8, !tbaa !22
  call void @UnityAssertEqualNumber(i64 noundef 16, i64 noundef %25, ptr noundef null, i64 noundef 1265, i32 noundef 148) #3
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #3
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = call ptr @giggle_query_region(ptr noundef %26, ptr noundef nonnull @.str.5, i32 noundef 112989628, i32 noundef 112989630) #3
  store ptr %27, 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
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !24
  call void (...) %28() #3
  %29 = 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
}

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

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 24}
!10 = !{!"giggle_index", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 8}
!13 = !{!"file_index", !6, i64 0, !6, i64 8}
!14 = !{!15, !11, i64 8}
!15 = !{!"unordered_list", !6, i64 0, !11, i64 8, !11, i64 12}
!16 = !{!10, !6, i64 32}
!17 = !{!18, !6, i64 0}
!18 = !{!"offset_index", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !11, i64 32}
!19 = !{!20, !21, i64 0}
!20 = !{!"file_id_offset_pairs", !21, i64 0, !21, i64 8, !6, i64 16}
!21 = !{!"long", !7, i64 0}
!22 = !{!23, !21, i64 0}
!23 = !{!"uint64_t_ll", !21, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!25, !6, i64 48}
!25 = !{!"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