; 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_incomplete_normal_bl = external hidden global ptr, align 8
@GC_old_normal_bl = external hidden global ptr, align 8
@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

declare ptr @GC_find_header(ptr noundef) #1

; 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
define dso_local void @GC_add_to_black_list_normal(i64 noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  store i64 %0, ptr %2, align 8, !tbaa !5
  %4 = load i64, ptr %2, align 8, !tbaa !5
  %5 = and i64 %4, 7
  %6 = getelementptr inbounds [8 x i8], ptr getelementptr inbounds (%struct._GC_arrays, ptr @GC_arrays, i32 0, i32 48), i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !9
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %9, label %39

9:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %11 = lshr i64 %10, 12
  %12 = and i64 %11, 262143
  store i64 %12, ptr %3, align 8, !tbaa !5
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = inttoptr i64 %13 to ptr
  %15 = call ptr @GC_find_header(ptr noundef %14)
  %16 = icmp eq ptr %15, null
  br i1 %16, label %28, label %17

17:                                               ; preds = %9
  %18 = load ptr, ptr @GC_old_normal_bl, align 8, !tbaa !10
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = lshr i64 %19, 6
  %21 = getelementptr inbounds i64, ptr %18, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = load i64, ptr %3, align 8, !tbaa !5
  %24 = and i64 %23, 63
  %25 = lshr i64 %22, %24
  %26 = and i64 %25, 1
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %38

28:                                               ; preds = %17, %9
  %29 = load i64, ptr %3, align 8, !tbaa !5
  %30 = and i64 %29, 63
  %31 = shl i64 1, %30
  %32 = load ptr, ptr @GC_incomplete_normal_bl, align 8, !tbaa !10
  %33 = load i64, ptr %3, align 8, !tbaa !5
  %34 = lshr i64 %33, 6
  %35 = getelementptr inbounds i64, ptr %32, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = or i64 %36, %31
  store i64 %37, ptr %35, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %28, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %39

39:                                               ; preds = %38, %1
  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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"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"

%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_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_arrays = external local_unnamed_addr global %struct._GC_arrays, align 8

declare ptr @GC_find_header(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @GC_add_to_black_list_normal(i64 noundef %0) local_unnamed_addr #1 {
  %2 = and i64 %0, 7
  %3 = getelementptr inbounds [8 x i8], ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 920), i64 0, i64 %2
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %24, label %5

5:                                                ; preds = %1
  %6 = lshr i64 %0, 12
  %7 = and i64 %6, 262143
  %8 = inttoptr i64 %0 to ptr
  %9 = tail call ptr @GC_find_header(ptr noundef %8) #2
  %10 = icmp eq ptr %9, null
  br i1 %10, label %._crit_edge, label %11

._crit_edge:                                      ; preds = %5
  %.pre = and i64 %6, 63
  %.pre8 = shl nuw i64 1, %.pre
  %.pre10 = lshr i64 %7, 6
  br label %19

11:                                               ; preds = %5
  %12 = load ptr, ptr @GC_old_normal_bl, align 8, !tbaa !8
  %13 = lshr i64 %7, 6
  %14 = getelementptr inbounds i64, ptr %12, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !10
  %16 = and i64 %6, 63
  %17 = shl nuw i64 1, %16
  %18 = and i64 %15, %17
  %.not7 = icmp eq i64 %18, 0
  br i1 %.not7, label %24, label %19

19:                                               ; preds = %._crit_edge, %11
  %.pre-phi11 = phi i64 [ %.pre10, %._crit_edge ], [ %13, %11 ]
  %.pre-phi9 = phi i64 [ %.pre8, %._crit_edge ], [ %17, %11 ]
  %20 = load ptr, ptr @GC_incomplete_normal_bl, align 8, !tbaa !8
  %21 = getelementptr inbounds i64, ptr %20, i64 %.pre-phi11
  %22 = load i64, ptr %21, align 8, !tbaa !10
  %23 = or i64 %22, %.pre-phi9
  store i64 %23, ptr %21, align 8, !tbaa !10
  br label %24

24:                                               ; preds = %11, %19, %1
  ret void
}

attributes #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 = { 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !6, i64 0}


; Effective O3 passes: BDCEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass