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

; 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.sigaction = type { %union.anon, %struct.__sigset_t, i32, ptr }
%union.anon = type { ptr }
%struct.__sigset_t = type { [16 x i64] }

@GC_on_abort = external global ptr, align 8
@GC_page_size = external dso_local global i64, align 8
@GC_print_stats = external global i32, align 4
@.str.12 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [17 x i8], align 1
@GC_old_segv_handler = external hidden global ptr, align 8
@GC_old_segv_handler_used_si = external hidden global i32, align 4
@GC_current_warn_proc = external global ptr, align 8
@.str.16 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 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 @GC_log_printf(ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @abort() #2

; 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 i32 @GC_dirty_init() #3 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.sigaction, align 8
  %3 = alloca %struct.sigaction, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 152, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 152, ptr %3) #6
  %6 = getelementptr inbounds %struct.sigaction, ptr %2, i32 0, i32 2
  store i32 268435460, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.sigaction, ptr %2, i32 0, i32 0
  store ptr @GC_write_fault_handler, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds %struct.sigaction, ptr %2, i32 0, i32 1
  %9 = call i32 @sigemptyset(ptr noundef %8) #6
  %10 = load i32, ptr @GC_print_stats, align 4, !tbaa !13
  %11 = icmp ne i32 %10, 2
  %12 = zext i1 %11 to i32
  %13 = sext i32 %12 to i64
  %14 = call i64 @llvm.expect.i64(i64 %13, i64 1)
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %0
  br label %18

17:                                               ; preds = %0
  call void (ptr, ...) @GC_log_printf(ptr noundef @.str.12)
  br label %18

18:                                               ; preds = %17, %16
  %19 = load i64, ptr @GC_page_size, align 8, !tbaa !14
  %20 = urem i64 %19, 4096
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %18
  %23 = load ptr, ptr @GC_on_abort, align 8, !tbaa !16
  call void %23(ptr noundef @.str.13)
  call void @abort() #7
  unreachable

24:                                               ; preds = %18
  %25 = call i32 @soft_dirty_init()
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %38

27:                                               ; preds = %24
  %28 = load i32, ptr @GC_print_stats, align 4, !tbaa !13
  %29 = icmp ne i32 %28, 0
  %30 = xor i1 %29, true
  %31 = zext i1 %30 to i32
  %32 = sext i32 %31 to i64
  %33 = call i64 @llvm.expect.i64(i64 %32, i64 1)
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %27
  br label %37

36:                                               ; preds = %27
  call void (ptr, ...) @GC_log_printf(ptr noundef @.str.14)
  br label %37

37:                                               ; preds = %36, %35
  store i32 1, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %78

38:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %39 = call i32 @sigaction(i32 noundef 11, ptr noundef %2, ptr noundef %3) #6
  store i32 %39, ptr %5, align 4, !tbaa !13
  %40 = load i32, ptr %5, align 4, !tbaa !13
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %38
  %43 = load ptr, ptr @GC_on_abort, align 8, !tbaa !16
  call void %43(ptr noundef @.str.15)
  call void @abort() #7
  unreachable

44:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  %45 = getelementptr inbounds %struct.sigaction, ptr %3, i32 0, i32 2
  %46 = load i32, ptr %45, align 8, !tbaa !5
  %47 = and i32 %46, 4
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %44
  %50 = getelementptr inbounds %struct.sigaction, ptr %3, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !12
  store ptr %51, ptr @GC_old_segv_handler, align 8, !tbaa !16
  store i32 1, ptr @GC_old_segv_handler_used_si, align 4, !tbaa !13
  br label %57

52:                                               ; preds = %44
  %53 = getelementptr inbounds %struct.sigaction, ptr %3, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !12
  %55 = ptrtoint ptr %54 to i64
  %56 = inttoptr i64 %55 to ptr
  store ptr %56, ptr @GC_old_segv_handler, align 8, !tbaa !16
  store i32 0, ptr @GC_old_segv_handler_used_si, align 4, !tbaa !13
  br label %57

57:                                               ; preds = %52, %49
  %58 = load ptr, ptr @GC_old_segv_handler, align 8, !tbaa !16
  %59 = ptrtoint ptr %58 to i64
  %60 = icmp eq i64 %59, 1
  br i1 %60, label %61, label %63

61:                                               ; preds = %57
  %62 = load ptr, ptr @GC_current_warn_proc, align 8, !tbaa !16
  call void %62(ptr noundef @.str.16, i64 noundef 0)
  store ptr null, ptr @GC_old_segv_handler, align 8, !tbaa !16
  br label %63

63:                                               ; preds = %61, %57
  %64 = load ptr, ptr @GC_old_segv_handler, align 8, !tbaa !16
  %65 = ptrtoint ptr %64 to i64
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %67, label %77

67:                                               ; preds = %63
  %68 = load i32, ptr @GC_print_stats, align 4, !tbaa !13
  %69 = icmp ne i32 %68, 2
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = call i64 @llvm.expect.i64(i64 %71, i64 1)
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %67
  br label %76

75:                                               ; preds = %67
  call void (ptr, ...) @GC_log_printf(ptr noundef @.str.17)
  br label %76

76:                                               ; preds = %75, %74
  br label %77

77:                                               ; preds = %76, %63
  store i32 1, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %78

78:                                               ; preds = %77, %37
  call void @llvm.lifetime.end.p0(i64 152, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 152, ptr %2) #6
  %79 = load i32, ptr %1, align 4
  ret i32 %79
}

; Function Attrs: nounwind uwtable
declare hidden void @GC_write_fault_handler(i32 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @sigemptyset(ptr noundef) #4

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

; Function Attrs: nounwind uwtable
declare hidden i32 @soft_dirty_init() #3

; Function Attrs: nounwind
declare i32 @sigaction(i32 noundef, ptr noundef, ptr noundef) #4

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 = { 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 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 "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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { 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, !10, i64 136}
!6 = !{!"sigaction", !7, i64 0, !9, i64 8, !10, i64 136, !11, i64 144}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!11, !11, 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.sigaction = type { %union.anon, %struct.__sigset_t, i32, ptr }
%union.anon = type { ptr }
%struct.__sigset_t = type { [16 x i64] }

@GC_on_abort = external local_unnamed_addr global ptr, align 8
@GC_page_size = external dso_local local_unnamed_addr global i64, align 8
@GC_print_stats = external local_unnamed_addr global i32, align 4
@.str.12 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [17 x i8], align 1
@GC_old_segv_handler = external hidden local_unnamed_addr global ptr, align 8
@GC_old_segv_handler_used_si = external hidden local_unnamed_addr global i32, align 4
@GC_current_warn_proc = external local_unnamed_addr global ptr, align 8
@.str.16 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 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 @GC_log_printf(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #2

; Function Attrs: mustprogress 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 noundef i32 @GC_dirty_init() local_unnamed_addr #3 {
  %1 = alloca %struct.sigaction, align 8
  %2 = alloca %struct.sigaction, align 8
  call void @llvm.lifetime.start.p0(i64 152, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 152, ptr nonnull %2) #5
  %3 = getelementptr inbounds i8, ptr %1, i64 136
  store i32 268435460, ptr %3, align 8, !tbaa !5
  store ptr @GC_write_fault_handler, ptr %1, align 8, !tbaa !12
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = call i32 @sigemptyset(ptr noundef nonnull %4) #5
  %6 = load i32, ptr @GC_print_stats, align 4, !tbaa !13
  %.not = icmp eq i32 %6, 2
  br i1 %.not, label %7, label %8, !prof !14

7:                                                ; preds = %0
  call void (ptr, ...) @GC_log_printf(ptr noundef nonnull @.str.12) #5
  br label %8

8:                                                ; preds = %0, %7
  %9 = load i64, ptr @GC_page_size, align 8, !tbaa !15
  %10 = and i64 %9, 4095
  %.not2 = icmp eq i64 %10, 0
  br i1 %.not2, label %13, label %11

11:                                               ; preds = %8
  %12 = load ptr, ptr @GC_on_abort, align 8, !tbaa !17
  call void %12(ptr noundef nonnull @.str.13) #5
  call void @abort() #6
  unreachable

13:                                               ; preds = %8
  %14 = call i32 @soft_dirty_init()
  %.not3 = icmp eq i32 %14, 0
  br i1 %.not3, label %18, label %15

15:                                               ; preds = %13
  %16 = load i32, ptr @GC_print_stats, align 4, !tbaa !13
  %.not9 = icmp eq i32 %16, 0
  br i1 %.not9, label %31, label %17, !prof !18

17:                                               ; preds = %15
  call void (ptr, ...) @GC_log_printf(ptr noundef nonnull @.str.14) #5
  br label %31

18:                                               ; preds = %13
  %19 = call i32 @sigaction(i32 noundef 11, ptr noundef nonnull %1, ptr noundef nonnull %2) #5
  %.not4 = icmp eq i32 %19, 0
  br i1 %.not4, label %22, label %20

20:                                               ; preds = %18
  %21 = load ptr, ptr @GC_on_abort, align 8, !tbaa !17
  call void %21(ptr noundef nonnull @.str.15) #5
  call void @abort() #6
  unreachable

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %2, i64 136
  %24 = load i32, ptr %23, align 8, !tbaa !5
  %25 = lshr i32 %24, 2
  %.lobit = and i32 %25, 1
  %storemerge6 = load ptr, ptr %2, align 8, !tbaa !12
  store ptr %storemerge6, ptr @GC_old_segv_handler, align 8, !tbaa !17
  store i32 %.lobit, ptr @GC_old_segv_handler_used_si, align 4, !tbaa !13
  %26 = icmp eq ptr %storemerge6, inttoptr (i64 1 to ptr)
  br i1 %26, label %.thread, label %28

.thread:                                          ; preds = %22
  %27 = load ptr, ptr @GC_current_warn_proc, align 8, !tbaa !17
  call void %27(ptr noundef nonnull @.str.16, i64 noundef 0) #5
  store ptr null, ptr @GC_old_segv_handler, align 8, !tbaa !17
  br label %31

28:                                               ; preds = %22
  %.not7 = icmp ne ptr %storemerge6, null
  %29 = load i32, ptr @GC_print_stats, align 4
  %.not8 = icmp eq i32 %29, 2
  %or.cond = select i1 %.not7, i1 %.not8, i1 false
  br i1 %or.cond, label %30, label %31, !prof !19

30:                                               ; preds = %28
  call void (ptr, ...) @GC_log_printf(ptr noundef nonnull @.str.17) #5
  br label %31

31:                                               ; preds = %.thread, %28, %30, %17, %15
  call void @llvm.lifetime.end.p0(i64 152, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 152, ptr nonnull %1) #5
  ret i32 1
}

; Function Attrs: nounwind uwtable
declare hidden void @GC_write_fault_handler(i32 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @sigemptyset(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @soft_dirty_init() local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @sigaction(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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 = { 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 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 "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, !10, i64 136}
!6 = !{!"sigaction", !7, i64 0, !9, i64 8, !10, i64 136, !11, i64 144}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!11, !11, i64 0}
!18 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!19 = !{!"branch_weights", i32 858565, i32 2146625083}


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