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

@ORDER = external dso_local global i32, align 4
@cache = external dso_local global %struct.cache_def, align 8
@.str.1 = external hidden unnamed_addr constant [21 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.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [21 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 ptr @simple_cache_init(i32 noundef, i32 noundef, ptr noundef) #1

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 ptr @giggle_init_index(i32 noundef, ptr noundef) #1

declare void @giggle_index_destroy(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @remove(ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_index_directory() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store i32 10, ptr @ORDER, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %6 = call ptr @simple_cache_init(i32 noundef 1000, i32 noundef 30, ptr noundef null)
  store ptr %6, ptr %1, align 8, !tbaa !9
  call void (...) @uint64_t_ll_giggle_set_data_handler()
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %7 = call ptr @giggle_init_index(i32 noundef 30, ptr noundef @.str.1)
  store ptr %7, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store ptr @.str.32, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %8 = load ptr, ptr %2, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !9
  %10 = call i32 @giggle_index_directory(ptr noundef %8, ptr noundef %9, i32 noundef 0)
  store i32 %10, ptr %4, align 4, !tbaa !5
  %11 = load ptr, ptr %2, align 8, !tbaa !9
  call void @valid_giggle_index(ptr noundef %11)
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = zext i32 %12 to i64
  call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %13, ptr noundef null, i64 noundef 1187, i32 noundef 148)
  %14 = load ptr, ptr %2, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.giggle_index, ptr %14, i32 0, i32 4
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = getelementptr inbounds %struct.file_index, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.unordered_list, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !15
  %21 = zext i32 %20 to i64
  call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %21, ptr noundef null, i64 noundef 1188, i32 noundef 148)
  %22 = load ptr, ptr %2, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.giggle_index, ptr %22, i32 0, i32 5
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = getelementptr inbounds %struct.offset_index, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = getelementptr inbounds %struct.file_id_offset_pairs, ptr %26, i32 0, i32 0
  %28 = load i64, ptr %27, align 8, !tbaa !20
  call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %28, ptr noundef null, i64 noundef 1189, i32 noundef 148)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %29 = load ptr, ptr %2, align 8, !tbaa !9
  %30 = call ptr @giggle_query_region(ptr noundef %29, ptr noundef @.str.11, i32 noundef 1000, i32 noundef 3000000)
  store ptr %30, ptr %5, align 8, !tbaa !9
  call void @uint64_t_ll_free(ptr noundef %5)
  %31 = load ptr, ptr %2, align 8, !tbaa !9
  %32 = call ptr @giggle_query_region(ptr noundef %31, ptr noundef @.str.9, i32 noundef 1000, i32 noundef 3000000)
  store ptr %32, ptr %5, align 8, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.uint64_t_ll, ptr %33, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !23
  call void @UnityAssertEqualNumber(i64 noundef 71, i64 noundef %35, ptr noundef null, i64 noundef 1200, i32 noundef 148)
  call void @uint64_t_ll_free(ptr noundef %5)
  %36 = load ptr, ptr %2, align 8, !tbaa !9
  %37 = call ptr @giggle_query_region(ptr noundef %36, ptr noundef @.str.9, i32 noundef 249250622, i32 noundef 249250625)
  store ptr %37, ptr %5, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !9
  %39 = ptrtoint ptr %38 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %39, ptr noundef null, i64 noundef 1207, i32 noundef 148)
  %40 = load ptr, ptr %2, align 8, !tbaa !9
  %41 = call ptr @giggle_query_region(ptr noundef %40, ptr noundef @.str.12, i32 noundef 52463173, i32 noundef 52464215)
  store ptr %41, ptr %5, align 8, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.uint64_t_ll, ptr %42, i32 0, i32 0
  %44 = load i64, ptr %43, align 8, !tbaa !23
  call void @UnityAssertEqualNumber(i64 noundef 4, i64 noundef %44, ptr noundef null, i64 noundef 1214, i32 noundef 148)
  call void @uint64_t_ll_free(ptr noundef %5)
  call void @giggle_index_destroy(ptr noundef %2)
  %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 @remove(ptr noundef @.str.1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

declare i32 @giggle_index_directory(ptr 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 = { 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, !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 8}
!14 = !{!"file_index", !10, i64 0, !10, i64 8}
!15 = !{!16, !6, i64 8}
!16 = !{!"unordered_list", !10, i64 0, !6, i64 8, !6, i64 12}
!17 = !{!12, !10, i64 32}
!18 = !{!19, !10, i64 0}
!19 = !{!"offset_index", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !6, i64 32}
!20 = !{!21, !22, i64 0}
!21 = !{!"file_id_offset_pairs", !22, i64 0, !22, i64 8, !10, i64 16}
!22 = !{!"long", !7, i64 0}
!23 = !{!24, !22, i64 0}
!24 = !{!"uint64_t_ll", !22, i64 0, !10, i64 8, !10, i64 16}
!25 = !{!26, !10, i64 48}
!26 = !{!"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 }

@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.1 = external hidden unnamed_addr constant [21 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.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [21 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 ptr @simple_cache_init(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @uint64_t_ll_giggle_set_data_handler(...) local_unnamed_addr #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 ptr @giggle_init_index(i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @giggle_index_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @remove(ptr nocapture noundef readonly) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_giggle_index_directory() local_unnamed_addr #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  store i32 10, ptr @ORDER, align 4, !tbaa !5
  %3 = tail call ptr @simple_cache_init(i32 noundef 1000, i32 noundef 30, ptr noundef null) #4
  tail call void (...) @uint64_t_ll_giggle_set_data_handler() #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %4 = tail call ptr @giggle_init_index(i32 noundef 30, ptr noundef nonnull @.str.1) #4
  store ptr %4, ptr %1, align 8, !tbaa !9
  %5 = tail call i32 @giggle_index_directory(ptr noundef %4, ptr noundef nonnull @.str.32, i32 noundef 0) #4
  tail call void @valid_giggle_index(ptr noundef %4)
  %6 = zext i32 %5 to i64
  tail call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %6, ptr noundef null, i64 noundef 1187, i32 noundef 148) #4
  %7 = getelementptr inbounds i8, ptr %4, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %13 = zext i32 %12 to i64
  tail call void @UnityAssertEqualNumber(i64 noundef 22, i64 noundef %13, ptr noundef null, i64 noundef 1188, i32 noundef 148) #4
  %14 = getelementptr inbounds i8, ptr %4, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  %16 = load ptr, ptr %15, align 8, !tbaa !18
  %17 = load i64, ptr %16, align 8, !tbaa !20
  tail call void @UnityAssertEqualNumber(i64 noundef 21024, i64 noundef %17, ptr noundef null, i64 noundef 1189, i32 noundef 148) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %18 = tail call ptr @giggle_query_region(ptr noundef %4, ptr noundef nonnull @.str.11, i32 noundef 1000, i32 noundef 3000000) #4
  store ptr %18, ptr %2, align 8, !tbaa !9
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #4
  %19 = call ptr @giggle_query_region(ptr noundef %4, ptr noundef nonnull @.str.9, i32 noundef 1000, i32 noundef 3000000) #4
  store ptr %19, ptr %2, align 8, !tbaa !9
  %20 = load i64, ptr %19, align 8, !tbaa !23
  call void @UnityAssertEqualNumber(i64 noundef 71, i64 noundef %20, ptr noundef null, i64 noundef 1200, i32 noundef 148) #4
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #4
  %21 = call ptr @giggle_query_region(ptr noundef %4, ptr noundef nonnull @.str.9, i32 noundef 249250622, i32 noundef 249250625) #4
  store ptr %21, ptr %2, align 8, !tbaa !9
  %22 = ptrtoint ptr %21 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %22, ptr noundef null, i64 noundef 1207, i32 noundef 148) #4
  %23 = call ptr @giggle_query_region(ptr noundef %4, ptr noundef nonnull @.str.12, i32 noundef 52463173, i32 noundef 52464215) #4
  store ptr %23, ptr %2, align 8, !tbaa !9
  %24 = load i64, ptr %23, align 8, !tbaa !23
  call void @UnityAssertEqualNumber(i64 noundef 4, i64 noundef %24, ptr noundef null, i64 noundef 1214, i32 noundef 148) #4
  call void @uint64_t_ll_free(ptr noundef nonnull %2) #4
  call void @giggle_index_destroy(ptr noundef nonnull %1) #4
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 48), align 8, !tbaa !25
  call void (...) %25() #4
  %26 = call i32 @remove(ptr noundef nonnull @.str.1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret void
}

declare i32 @giggle_index_directory(ptr 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 = { nofree 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 = { 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, !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 8}
!14 = !{!"file_index", !10, i64 0, !10, i64 8}
!15 = !{!16, !6, i64 8}
!16 = !{!"unordered_list", !10, i64 0, !6, i64 8, !6, i64 12}
!17 = !{!12, !10, i64 32}
!18 = !{!19, !10, i64 0}
!19 = !{!"offset_index", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !6, i64 32}
!20 = !{!21, !22, i64 0}
!21 = !{!"file_id_offset_pairs", !22, i64 0, !22, i64 8, !10, i64 16}
!22 = !{!"long", !7, i64 0}
!23 = !{!24, !22, i64 0}
!24 = !{!"uint64_t_ll", !22, i64 0, !10, i64 8, !10, i64 16}
!25 = !{!26, !10, i64 48}
!26 = !{!"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: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass