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

; 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._GC_arrays = type { i64, i64, i64, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i64, i64, i64, ptr, ptr, i64, i32, i64, i64, i64, %struct.dl_hashtbl_s, %struct.dl_hashtbl_s, %struct.fnlz_roots_s, i32, ptr, i64, i64, i32, i64, i64, i64, ptr, [64 x ptr], [8 x i8], [64 x ptr], [129 x ptr], [129 x ptr], [129 x ptr], [2049 x i64], [129 x ptr], [4096 x i8], [4096 x i64], [4096 x i64], ptr, [2048 x %struct.roots], [512 x %struct.exclusion], [2048 x ptr] }
%struct.dl_hashtbl_s = type { ptr, i64, i32 }
%struct.fnlz_roots_s = type { ptr, ptr }
%struct.roots = type { ptr, ptr, ptr, i32 }
%struct.exclusion = type { ptr, ptr }

@GC_black_list_spacing = external dso_local global i64, align 8
@GC_incomplete_normal_bl = external hidden global ptr, align 8
@GC_old_normal_bl = external hidden global ptr, align 8
@GC_all_interior_pointers = external global i32, align 4
@GC_old_stack_bl = external hidden global ptr, align 8
@GC_incomplete_stack_bl = external hidden global ptr, align 8
@GC_total_stack_black_listed = external hidden global i64, align 8
@GC_print_stats = external global i32, align 4
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1
@GC_arrays = external global %struct._GC_arrays, align 8

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

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

; Function Attrs: nounwind uwtable
declare hidden void @GC_clear_bl(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @GC_promote_black_lists() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %3 = load ptr, ptr @GC_old_normal_bl, align 8, !tbaa !5
  store ptr %3, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %4 = load ptr, ptr @GC_old_stack_bl, align 8, !tbaa !5
  store ptr %4, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr @GC_incomplete_normal_bl, align 8, !tbaa !5
  store ptr %5, ptr @GC_old_normal_bl, align 8, !tbaa !5
  %6 = load ptr, ptr @GC_incomplete_stack_bl, align 8, !tbaa !5
  store ptr %6, ptr @GC_old_stack_bl, align 8, !tbaa !5
  %7 = load i32, ptr @GC_all_interior_pointers, align 4, !tbaa !9
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %11, label %9

9:                                                ; preds = %0
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  call void @GC_clear_bl(ptr noundef %10)
  br label %11

11:                                               ; preds = %9, %0
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  call void @GC_clear_bl(ptr noundef %12)
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  store ptr %13, ptr @GC_incomplete_normal_bl, align 8, !tbaa !5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %14, ptr @GC_incomplete_stack_bl, align 8, !tbaa !5
  %15 = call i64 @total_stack_black_listed()
  store i64 %15, ptr @GC_total_stack_black_listed, align 8, !tbaa !11
  %16 = load i32, ptr @GC_print_stats, align 4, !tbaa !9
  %17 = icmp ne i32 %16, 2
  %18 = zext i1 %17 to i32
  %19 = sext i32 %18 to i64
  %20 = call i64 @llvm.expect.i64(i64 %19, i64 1)
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %11
  br label %25

23:                                               ; preds = %11
  %24 = load i64, ptr @GC_total_stack_black_listed, align 8, !tbaa !11
  call void (ptr, ...) @GC_log_printf(ptr noundef @.str.5, i64 noundef %24)
  br label %25

25:                                               ; preds = %23, %22
  %26 = load i64, ptr @GC_total_stack_black_listed, align 8, !tbaa !11
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = load i64, ptr @GC_arrays, align 8, !tbaa !13
  %30 = load i64, ptr @GC_total_stack_black_listed, align 8, !tbaa !11
  %31 = udiv i64 %29, %30
  %32 = mul i64 4096, %31
  store i64 %32, ptr @GC_black_list_spacing, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %28, %25
  %34 = load i64, ptr @GC_black_list_spacing, align 8, !tbaa !11
  %35 = icmp ult i64 %34, 12288
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  store i64 12288, ptr @GC_black_list_spacing, align 8, !tbaa !11
  br label %37

37:                                               ; preds = %36, %33
  %38 = load i64, ptr @GC_black_list_spacing, align 8, !tbaa !11
  %39 = icmp ugt i64 %38, 8388608
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  store i64 8388608, ptr @GC_black_list_spacing, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %40, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i64 @total_stack_black_listed() #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #2

declare void @GC_log_printf(ptr noundef, ...) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #3 = { "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 = !{!"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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_GC_arrays", !12, i64 0, !12, i64 8, !12, i64 16, !6, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !10, i64 176, !10, i64 180, !10, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !6, i64 216, !6, i64 224, !12, i64 232, !10, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !15, i64 272, !15, i64 296, !16, i64 320, !10, i64 336, !6, i64 344, !12, i64 352, !12, i64 360, !10, i64 368, !12, i64 376, !12, i64 384, !12, i64 392, !6, i64 400, !7, i64 408, !7, i64 920, !7, i64 928, !7, i64 1440, !7, i64 2472, !7, i64 3504, !7, i64 4536, !7, i64 20928, !7, i64 21960, !7, i64 26056, !7, i64 58824, !6, i64 91592, !7, i64 91600, !7, i64 157136, !7, i64 165328}
!15 = !{!"dl_hashtbl_s", !6, i64 0, !12, i64 8, !10, i64 16}
!16 = !{!"fnlz_roots_s", !6, i64 0, !6, i64 8}


; 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._GC_arrays = type { i64, i64, i64, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i64, i64, i64, ptr, ptr, i64, i32, i64, i64, i64, %struct.dl_hashtbl_s, %struct.dl_hashtbl_s, %struct.fnlz_roots_s, i32, ptr, i64, i64, i32, i64, i64, i64, ptr, [64 x ptr], [8 x i8], [64 x ptr], [129 x ptr], [129 x ptr], [129 x ptr], [2049 x i64], [129 x ptr], [4096 x i8], [4096 x i64], [4096 x i64], ptr, [2048 x %struct.roots], [512 x %struct.exclusion], [2048 x ptr] }
%struct.dl_hashtbl_s = type { ptr, i64, i32 }
%struct.fnlz_roots_s = type { ptr, ptr }
%struct.roots = type { ptr, ptr, ptr, i32 }
%struct.exclusion = type { ptr, ptr }

@GC_black_list_spacing = external dso_local local_unnamed_addr global i64, align 8
@GC_incomplete_normal_bl = external hidden local_unnamed_addr global ptr, align 8
@GC_old_normal_bl = external hidden local_unnamed_addr global ptr, align 8
@GC_all_interior_pointers = external local_unnamed_addr global i32, align 4
@GC_old_stack_bl = external hidden local_unnamed_addr global ptr, align 8
@GC_incomplete_stack_bl = external hidden local_unnamed_addr global ptr, align 8
@GC_total_stack_black_listed = external hidden local_unnamed_addr global i64, align 8
@GC_print_stats = external local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1
@GC_arrays = external local_unnamed_addr global %struct._GC_arrays, align 8

; Function Attrs: nounwind uwtable
declare hidden void @GC_clear_bl(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @GC_promote_black_lists() local_unnamed_addr #0 {
  %1 = load ptr, ptr @GC_old_normal_bl, align 8, !tbaa !5
  %2 = load ptr, ptr @GC_old_stack_bl, align 8, !tbaa !5
  %3 = load ptr, ptr @GC_incomplete_normal_bl, align 8, !tbaa !5
  store ptr %3, ptr @GC_old_normal_bl, align 8, !tbaa !5
  %4 = load ptr, ptr @GC_incomplete_stack_bl, align 8, !tbaa !5
  store ptr %4, ptr @GC_old_stack_bl, align 8, !tbaa !5
  %5 = load i32, ptr @GC_all_interior_pointers, align 4, !tbaa !9
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %7

6:                                                ; preds = %0
  tail call void @GC_clear_bl(ptr noundef %1)
  br label %7

7:                                                ; preds = %6, %0
  tail call void @GC_clear_bl(ptr noundef %2)
  store ptr %1, ptr @GC_incomplete_normal_bl, align 8, !tbaa !5
  store ptr %2, ptr @GC_incomplete_stack_bl, align 8, !tbaa !5
  %8 = tail call i64 @total_stack_black_listed()
  store i64 %8, ptr @GC_total_stack_black_listed, align 8, !tbaa !11
  %9 = load i32, ptr @GC_print_stats, align 4, !tbaa !9
  %.not4 = icmp eq i32 %9, 2
  br i1 %.not4, label %10, label %11, !prof !13

10:                                               ; preds = %7
  tail call void (ptr, ...) @GC_log_printf(ptr noundef nonnull @.str.5, i64 noundef %8) #2
  %.pr = load i64, ptr @GC_total_stack_black_listed, align 8, !tbaa !11
  br label %11

11:                                               ; preds = %7, %10
  %12 = phi i64 [ %8, %7 ], [ %.pr, %10 ]
  %.not5 = icmp eq i64 %12, 0
  br i1 %.not5, label %thread-pre-split, label %13

13:                                               ; preds = %11
  %14 = load i64, ptr @GC_arrays, align 8, !tbaa !14
  %15 = udiv i64 %14, %12
  %16 = shl i64 %15, 12
  store i64 %16, ptr @GC_black_list_spacing, align 8, !tbaa !11
  br label %17

thread-pre-split:                                 ; preds = %11
  %.pr6 = load i64, ptr @GC_black_list_spacing, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %thread-pre-split, %13
  %.pr8 = phi i64 [ %.pr6, %thread-pre-split ], [ %16, %13 ]
  %18 = icmp ult i64 %.pr8, 12288
  br i1 %18, label %.sink.split, label %19

19:                                               ; preds = %17
  %20 = icmp ugt i64 %.pr8, 8388608
  br i1 %20, label %.sink.split, label %21

.sink.split:                                      ; preds = %19, %17
  %.sink = phi i64 [ 12288, %17 ], [ 8388608, %19 ]
  store i64 %.sink, ptr @GC_black_list_spacing, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %.sink.split, %19
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i64 @total_stack_black_listed() local_unnamed_addr #0

declare void @GC_log_printf(ptr 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 = { 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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!14 = !{!15, !12, i64 0}
!15 = !{!"_GC_arrays", !12, i64 0, !12, i64 8, !12, i64 16, !6, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !10, i64 176, !10, i64 180, !10, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !6, i64 216, !6, i64 224, !12, i64 232, !10, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !16, i64 272, !16, i64 296, !17, i64 320, !10, i64 336, !6, i64 344, !12, i64 352, !12, i64 360, !10, i64 368, !12, i64 376, !12, i64 384, !12, i64 392, !6, i64 400, !7, i64 408, !7, i64 920, !7, i64 928, !7, i64 1440, !7, i64 2472, !7, i64 3504, !7, i64 4536, !7, i64 20928, !7, i64 21960, !7, i64 26056, !7, i64 58824, !6, i64 91592, !7, i64 91600, !7, i64 157136, !7, i64 165328}
!16 = !{!"dl_hashtbl_s", !6, i64 0, !12, i64 8, !10, i64 16}
!17 = !{!"fnlz_roots_s", !6, i64 0, !6, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass