; LLVM IR from humz2k/sugaryc :: ext/bdwgc/tests (gctest)

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

@n_tests = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@print_stats = external hidden global i32, align 4
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [59 x i8], align 1
@stdout = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 0, ptr @n_tests, align 4, !tbaa !5
  call void @GC_clear_exclusion_table()
  call void @GC_set_handle_fork(i32 noundef -1)
  call void @GC_set_manual_vdb_allowed(i32 noundef 0)
  %3 = call i32 @GC_get_version()
  %4 = icmp ne i32 %3, 525056
  br i1 %4, label %5, label %6

5:                                                ; preds = %0
  call void (ptr, ...) @GC_printf(ptr noundef @.str)
  call void @exit(i32 noundef 1) #5
  unreachable

6:                                                ; preds = %0
  %7 = call ptr @getenv(ptr noundef @.str.1) #6
  %8 = icmp ne ptr null, %7
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  store i32 2, ptr @print_stats, align 4, !tbaa !5
  br label %15

10:                                               ; preds = %6
  %11 = call ptr @getenv(ptr noundef @.str.2) #6
  %12 = icmp ne ptr null, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  store i32 1, ptr @print_stats, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %13, %10
  br label %15

15:                                               ; preds = %14, %9
  %16 = call i32 @GC_get_find_leak()
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void (ptr, ...) @GC_printf(ptr noundef @.str.3)
  br label %20

20:                                               ; preds = %19, %18
  call void @GC_start_performance_measurement()
  call void @GC_set_warn_proc(ptr noundef @warn_proc)
  call void @enable_incremental_mode()
  call void @set_print_procs()
  call void @GC_start_incremental_collection()
  call void @run_one_test()
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %25, %20
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 5
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  call void @run_one_test()
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !9

28:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @run_single_threaded_test()
  call void @check_heap_stats()
  %29 = load ptr, ptr @stdout, align 8, !tbaa !11
  %30 = call i32 @fflush(ptr noundef %29)
  call void @GC_set_log_fd(i32 noundef 2)
  ret i32 0
}

declare void @GC_clear_exclusion_table() #1

declare void @GC_set_handle_fork(i32 noundef) #1

declare void @GC_set_manual_vdb_allowed(i32 noundef) #1

declare i32 @GC_get_version() #1

declare void @GC_printf(ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nounwind
declare ptr @getenv(ptr noundef) #3

declare i32 @GC_get_find_leak() #1

declare void @GC_start_performance_measurement() #1

declare void @GC_set_warn_proc(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @warn_proc(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @enable_incremental_mode() #0

; Function Attrs: nounwind uwtable
declare hidden void @set_print_procs() #0

declare void @GC_start_incremental_collection() #1

; Function Attrs: nounwind uwtable
declare hidden void @run_one_test() #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #4

; Function Attrs: nounwind uwtable
declare hidden void @run_single_threaded_test() #0

; Function Attrs: nounwind uwtable
declare hidden void @check_heap_stats() #0

declare i32 @fflush(ptr noundef) #1

declare void @GC_set_log_fd(i32 noundef) #1

attributes #0 = { 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 #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 = { noreturn 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 "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


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

@n_tests = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@print_stats = external hidden local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [59 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  store i32 0, ptr @n_tests, align 4, !tbaa !5
  tail call void @GC_clear_exclusion_table() #5
  tail call void @GC_set_handle_fork(i32 noundef -1) #5
  tail call void @GC_set_manual_vdb_allowed(i32 noundef 0) #5
  %1 = tail call i32 @GC_get_version() #5
  %.not = icmp eq i32 %1, 525056
  br i1 %.not, label %3, label %2

2:                                                ; preds = %0
  tail call void (ptr, ...) @GC_printf(ptr noundef nonnull @.str) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

3:                                                ; preds = %0
  %4 = tail call ptr @getenv(ptr noundef nonnull @.str.1) #5
  %.not2 = icmp eq ptr %4, null
  br i1 %.not2, label %5, label %.sink.split

5:                                                ; preds = %3
  %6 = tail call ptr @getenv(ptr noundef nonnull @.str.2) #5
  %.not3 = icmp eq ptr %6, null
  br i1 %.not3, label %7, label %.sink.split

.sink.split:                                      ; preds = %5, %3
  %.sink = phi i32 [ 2, %3 ], [ 1, %5 ]
  store i32 %.sink, ptr @print_stats, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %.sink.split, %5
  %8 = tail call i32 @GC_get_find_leak() #5
  %.not4 = icmp eq i32 %8, 0
  br i1 %.not4, label %10, label %9

9:                                                ; preds = %7
  tail call void (ptr, ...) @GC_printf(ptr noundef nonnull @.str.3) #5
  br label %10

10:                                               ; preds = %7, %9
  tail call void @GC_start_performance_measurement() #5
  tail call void @GC_set_warn_proc(ptr noundef nonnull @warn_proc) #5
  tail call void @enable_incremental_mode()
  tail call void @set_print_procs()
  tail call void @GC_start_incremental_collection() #5
  tail call void @run_one_test()
  tail call void @run_one_test()
  tail call void @run_one_test()
  tail call void @run_one_test()
  tail call void @run_one_test()
  tail call void @run_one_test()
  tail call void @run_single_threaded_test()
  tail call void @check_heap_stats()
  %11 = load ptr, ptr @stdout, align 8, !tbaa !9
  %12 = tail call i32 @fflush(ptr noundef %11)
  tail call void @GC_set_log_fd(i32 noundef 2) #5
  ret i32 0
}

declare void @GC_clear_exclusion_table() local_unnamed_addr #1

declare void @GC_set_handle_fork(i32 noundef) local_unnamed_addr #1

declare void @GC_set_manual_vdb_allowed(i32 noundef) local_unnamed_addr #1

declare i32 @GC_get_version() local_unnamed_addr #1

declare void @GC_printf(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind memory(read)
declare noundef ptr @getenv(ptr nocapture noundef) local_unnamed_addr #3

declare i32 @GC_get_find_leak() local_unnamed_addr #1

declare void @GC_start_performance_measurement() local_unnamed_addr #1

declare void @GC_set_warn_proc(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @warn_proc(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @enable_incremental_mode() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @set_print_procs() local_unnamed_addr #0

declare void @GC_start_incremental_collection() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @run_one_test() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @run_single_threaded_test() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @check_heap_stats() local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #4

declare void @GC_set_log_fd(i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { noreturn 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 = { nofree nounwind memory(read) "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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass