; LLVM IR from wichue/nethello :: src/base/SignalCatch.ll (ZN3chw11SignalCatch8InstanceEv)

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

%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZZN3chw11SignalCatch8InstanceEvE10s_instance = external hidden global %"class.std::shared_ptr", align 8
@_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance = external hidden global i64, align 8
@__dso_handle = external hidden global i8
@_ZZN3chw11SignalCatch8InstanceEvE14s_instance_ref = external hidden global ptr, align 8
@_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref = external hidden global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN3chw11SignalCatch8InstanceEv() #0 align 2 personality ptr @__gxx_personality_v0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = load atomic i8, ptr @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance acquire, align 8
  %4 = icmp eq i8 %3, 0
  br i1 %4, label %5, label %14, !prof !5

5:                                                ; preds = %0
  %6 = call i32 @__cxa_guard_acquire(ptr @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance) #1
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %14

8:                                                ; preds = %5
  %9 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 1) #5
          to label %10 unwind label %24

10:                                               ; preds = %8
  invoke void @_ZN3chw11SignalCatchC1Ev(ptr noundef nonnull align 1 dereferenceable(1) %9)
          to label %11 unwind label %28

11:                                               ; preds = %10
  invoke void @_ZNSt10shared_ptrIN3chw11SignalCatchEEC2IS1_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16) @_ZZN3chw11SignalCatch8InstanceEvE10s_instance, ptr noundef %9)
          to label %12 unwind label %24

12:                                               ; preds = %11
  %13 = call i32 @__cxa_atexit(ptr @_ZNSt12__shared_ptrIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2EED2Ev, ptr @_ZZN3chw11SignalCatch8InstanceEvE10s_instance, ptr @__dso_handle) #1
  call void @__cxa_guard_release(ptr @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance) #1
  br label %14

14:                                               ; preds = %12, %5, %0
  %15 = load atomic i8, ptr @_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref acquire, align 8
  %16 = icmp eq i8 %15, 0
  br i1 %16, label %17, label %22, !prof !5

17:                                               ; preds = %14
  %18 = call i32 @__cxa_guard_acquire(ptr @_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref) #1
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt19__shared_ptr_accessIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEdeEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZZN3chw11SignalCatch8InstanceEvE10s_instance) #1
  store ptr %21, ptr @_ZZN3chw11SignalCatch8InstanceEvE14s_instance_ref, align 8, !tbaa !6
  call void @__cxa_guard_release(ptr @_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref) #1
  br label %22

22:                                               ; preds = %20, %17, %14
  %23 = load ptr, ptr @_ZZN3chw11SignalCatch8InstanceEvE14s_instance_ref, align 8, !tbaa !6
  ret ptr %23

24:                                               ; preds = %11, %8
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %1, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %2, align 4
  br label %32

28:                                               ; preds = %10
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %1, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %9, i64 noundef 1) #6
  br label %32

32:                                               ; preds = %28, %24
  call void @__cxa_guard_abort(ptr @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance) #1
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %1, align 8
  %35 = load i32, ptr %2, align 4
  %36 = insertvalue { ptr, i32 } poison, ptr %34, 0
  %37 = insertvalue { ptr, i32 } %36, i32 %35, 1
  resume { ptr, i32 } %37
}

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10shared_ptrIN3chw11SignalCatchEEC2IS1_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

; Function Attrs: nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) #1

; Function Attrs: nounwind
declare void @__cxa_guard_abort(ptr) #1

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt19__shared_ptr_accessIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEdeEv(ptr noundef nonnull align 1 dereferenceable(1)) #4 align 2

declare void @_ZN3chw11SignalCatchC1Ev(ptr)

attributes #0 = { mustprogress 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 = { nounwind }
attributes #2 = { nobuiltin allocsize(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 = { nobuiltin 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 = { mustprogress 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 #5 = { builtin allocsize(0) }
attributes #6 = { builtin 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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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

%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZZN3chw11SignalCatch8InstanceEvE10s_instance = external hidden global %"class.std::shared_ptr", align 8
@_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance = external hidden global i64, align 8
@__dso_handle = external hidden global i8
@_ZZN3chw11SignalCatch8InstanceEvE14s_instance_ref = external hidden local_unnamed_addr global ptr, align 8
@_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref = external hidden global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN3chw11SignalCatch8InstanceEv() local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %1 = load atomic i8, ptr @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance acquire, align 8
  %2 = icmp eq i8 %1, 0
  br i1 %2, label %3, label %11, !prof !5

3:                                                ; preds = %0
  %4 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance) #5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %11, label %5

5:                                                ; preds = %3
  %6 = invoke noalias noundef nonnull dereferenceable(1) ptr @_Znwm(i64 noundef 1) #6
          to label %7 unwind label %20

7:                                                ; preds = %5
  invoke void @_ZN3chw11SignalCatchC1Ev(ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %8 unwind label %22

8:                                                ; preds = %7
  invoke void @_ZNSt10shared_ptrIN3chw11SignalCatchEEC2IS1_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16) @_ZZN3chw11SignalCatch8InstanceEvE10s_instance, ptr noundef nonnull %6)
          to label %9 unwind label %20

9:                                                ; preds = %8
  %10 = tail call i32 @__cxa_atexit(ptr nonnull @_ZNSt12__shared_ptrIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2EED2Ev, ptr nonnull @_ZZN3chw11SignalCatch8InstanceEvE10s_instance, ptr nonnull @__dso_handle) #5
  tail call void @__cxa_guard_release(ptr nonnull @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance) #5
  br label %11

11:                                               ; preds = %9, %3, %0
  %12 = load atomic i8, ptr @_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref acquire, align 8
  %13 = icmp eq i8 %12, 0
  br i1 %13, label %14, label %18, !prof !5

14:                                               ; preds = %11
  %15 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref) #5
  %.not3 = icmp eq i32 %15, 0
  br i1 %.not3, label %18, label %16

16:                                               ; preds = %14
  %17 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt19__shared_ptr_accessIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEdeEv(ptr noundef nonnull align 1 dereferenceable(1) @_ZZN3chw11SignalCatch8InstanceEvE10s_instance) #5
  store ptr %17, ptr @_ZZN3chw11SignalCatch8InstanceEvE14s_instance_ref, align 8, !tbaa !6
  tail call void @__cxa_guard_release(ptr nonnull @_ZGVZN3chw11SignalCatch8InstanceEvE14s_instance_ref) #5
  br label %18

18:                                               ; preds = %16, %14, %11
  %19 = load ptr, ptr @_ZZN3chw11SignalCatch8InstanceEvE14s_instance_ref, align 8, !tbaa !6
  ret ptr %19

20:                                               ; preds = %8, %5
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %24

22:                                               ; preds = %7
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %6, i64 noundef 1) #7
  br label %24

24:                                               ; preds = %22, %20
  %.pn = phi { ptr, i32 } [ %21, %20 ], [ %23, %22 ]
  tail call void @__cxa_guard_abort(ptr nonnull @_ZGVZN3chw11SignalCatch8InstanceEvE10s_instance) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10shared_ptrIN3chw11SignalCatchEEC2IS1_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

; Function Attrs: nofree nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare void @__cxa_guard_abort(ptr) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt19__shared_ptr_accessIN3chw11SignalCatchELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEdeEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #4 align 2

declare void @_ZN3chw11SignalCatchC1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress 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 = { nofree nounwind }
attributes #2 = { nobuiltin allocsize(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 = { nobuiltin 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 = { mustprogress 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass