; LLVM IR from AdaptiveCpp/AdaptiveCpp :: tests/pcuda/pcuda_test_suite.ll (ZN5boost6detail13signal_actionC2EibbPc)

; 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.boost::system_error" = type { i64, ptr }
%"class.boost::detail::signal_action" = type { i32, i8, %struct.sigaction, %struct.sigaction }
%struct.sigaction = type { %union.anon.210, %struct.__sigset_t, i32, ptr }
%union.anon.210 = type { ptr }
%struct.__sigset_t = type { [16 x i64] }

@.str.175 = external hidden unnamed_addr constant [4 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5boost6detail13signal_actionC2EibbPc(ptr noundef nonnull align 8 dereferenceable(312) %0, i32 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, ptr noundef %4) unnamed_addr #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca %"class.boost::system_error", align 8
  %12 = alloca %"class.boost::system_error", align 8
  %13 = alloca %"class.boost::system_error", align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  %14 = zext i1 %2 to i8
  store i8 %14, ptr %8, align 1, !tbaa !11
  %15 = zext i1 %3 to i8
  store i8 %15, ptr %9, align 1, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8
  %17 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %18, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 1
  %20 = load i8, ptr %8, align 1, !tbaa !11, !range !17, !noundef !18
  %21 = trunc i8 %20 to i1
  %22 = zext i1 %21 to i8
  store i8 %22, ptr %19, align 4, !tbaa !19
  %23 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %24 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 3
  %25 = load i8, ptr %8, align 1, !tbaa !11, !range !17, !noundef !18
  %26 = trunc i8 %25 to i1
  br i1 %26, label %28, label %27

27:                                               ; preds = %5
  br label %83

28:                                               ; preds = %5
  %29 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  call void @llvm.memset.p0.i64(ptr align 8 %29, i8 0, i64 152, i1 false)
  %30 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %33 = call i32 @sigaction(i32 noundef %31, ptr noundef null, ptr noundef %32) #5
  %34 = icmp ne i32 %33, -1
  br i1 %34, label %35, label %36

35:                                               ; preds = %28
  br label %37

36:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  call void @_ZN5boost12system_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef @.str.175)
  call void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16) %11) #6
  unreachable

37:                                               ; preds = %35
  %38 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %39 = getelementptr inbounds %struct.sigaction, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !20
  %41 = icmp ne ptr %40, null
  br i1 %41, label %47, label %42

42:                                               ; preds = %37
  %43 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %44 = getelementptr inbounds %struct.sigaction, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %49

47:                                               ; preds = %42, %37
  %48 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 1
  store i8 0, ptr %48, align 4, !tbaa !19
  br label %83

49:                                               ; preds = %42
  %50 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %51 = getelementptr inbounds %struct.sigaction, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 8, !tbaa !21
  %53 = or i32 %52, 4
  store i32 %53, ptr %51, align 8, !tbaa !21
  %54 = load i8, ptr %9, align 1, !tbaa !11, !range !17, !noundef !18
  %55 = trunc i8 %54 to i1
  %56 = zext i1 %55 to i64
  %57 = select i1 %55, ptr @_ZN5boost6detailL48boost_execution_monitor_attaching_signal_handlerEiP9siginfo_tPv, ptr @_ZN5boost6detailL46boost_execution_monitor_jumping_signal_handlerEiP9siginfo_tPv
  %58 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %59 = getelementptr inbounds %struct.sigaction, ptr %58, i32 0, i32 0
  store ptr %57, ptr %59, align 8, !tbaa !20
  %60 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %61 = getelementptr inbounds %struct.sigaction, ptr %60, i32 0, i32 1
  %62 = call i32 @sigemptyset(ptr noundef %61) #5
  %63 = icmp ne i32 %62, -1
  br i1 %63, label %64, label %65

64:                                               ; preds = %49
  br label %66

65:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  call void @_ZN5boost12system_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef @.str.175)
  call void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16) %12) #6
  unreachable

66:                                               ; preds = %64
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %74

69:                                               ; preds = %66
  %70 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %71 = getelementptr inbounds %struct.sigaction, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 8, !tbaa !21
  %73 = or i32 %72, 134217728
  store i32 %73, ptr %71, align 8, !tbaa !21
  br label %74

74:                                               ; preds = %69, %66
  %75 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 0
  %76 = load i32, ptr %75, align 8, !tbaa !13
  %77 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 2
  %78 = getelementptr inbounds %"class.boost::detail::signal_action", ptr %16, i32 0, i32 3
  %79 = call i32 @sigaction(i32 noundef %76, ptr noundef %77, ptr noundef %78) #5
  %80 = icmp ne i32 %79, -1
  br i1 %80, label %81, label %82

81:                                               ; preds = %74
  br label %83

82:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  call void @_ZN5boost12system_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef @.str.175)
  call void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16) %13) #6
  unreachable

83:                                               ; preds = %81, %47, %27
  ret void
}

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

; Function Attrs: inlinehint mustprogress noreturn uwtable
declare dso_local void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16)) #4

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5boost6detailL48boost_execution_monitor_attaching_signal_handlerEiP9siginfo_tPv(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5boost6detailL46boost_execution_monitor_jumping_signal_handlerEiP9siginfo_tPv(i32 noundef, ptr noundef, ptr noundef) #2

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

declare void @_ZN5boost12system_errorC1EPKc(ptr, ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = { inlinehint mustprogress noreturn 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 = { noreturn }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN5boost6detail13signal_actionE", !10, i64 0, !12, i64 4, !15, i64 8, !15, i64 160}
!15 = !{!"_ZTS9sigaction", !7, i64 0, !16, i64 8, !10, i64 136, !6, i64 144}
!16 = !{!"_ZTS10__sigset_t", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!14, !12, i64 4}
!20 = !{!7, !7, i64 0}
!21 = !{!14, !10, i64 144}


; 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.boost::system_error" = type { i64, ptr }

@.str.175 = external hidden unnamed_addr constant [4 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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5boost6detail13signal_actionC2EibbPc(ptr noundef nonnull align 8 dereferenceable(312) %0, i32 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, ptr noundef readnone %4) unnamed_addr #2 align 2 {
  %6 = alloca %"class.boost::system_error", align 8
  %7 = alloca %"class.boost::system_error", align 8
  %8 = alloca %"class.boost::system_error", align 8
  %9 = zext i1 %2 to i8
  store i32 %1, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 %9, ptr %10, align 4, !tbaa !14
  br i1 %2, label %11, label %35

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(152) %12, i8 0, i64 152, i1 false)
  %13 = tail call i32 @sigaction(i32 noundef %1, ptr noundef null, ptr noundef nonnull %12) #5
  %.not = icmp eq i32 %13, -1
  br i1 %.not, label %14, label %15

14:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  call void @_ZN5boost12system_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull @.str.175)
  call void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16) %6) #6
  unreachable

15:                                               ; preds = %11
  %16 = load ptr, ptr %12, align 8, !tbaa !15
  %.not5 = icmp eq ptr %16, null
  br i1 %.not5, label %18, label %17

17:                                               ; preds = %15
  store i8 0, ptr %10, align 4, !tbaa !14
  br label %35

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %0, i64 144
  %20 = load i32, ptr %19, align 8, !tbaa !16
  %21 = or i32 %20, 4
  store i32 %21, ptr %19, align 8, !tbaa !16
  %22 = select i1 %3, ptr @_ZN5boost6detailL48boost_execution_monitor_attaching_signal_handlerEiP9siginfo_tPv, ptr @_ZN5boost6detailL46boost_execution_monitor_jumping_signal_handlerEiP9siginfo_tPv
  store ptr %22, ptr %12, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = tail call i32 @sigemptyset(ptr noundef nonnull %23) #5
  %.not6 = icmp eq i32 %24, -1
  br i1 %.not6, label %25, label %26

25:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  call void @_ZN5boost12system_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull @.str.175)
  call void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16) %7) #6
  unreachable

26:                                               ; preds = %18
  %.not7 = icmp eq ptr %4, null
  br i1 %.not7, label %30, label %27

27:                                               ; preds = %26
  %28 = load i32, ptr %19, align 8, !tbaa !16
  %29 = or i32 %28, 134217728
  store i32 %29, ptr %19, align 8, !tbaa !16
  br label %30

30:                                               ; preds = %27, %26
  %31 = load i32, ptr %0, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 160
  %33 = tail call i32 @sigaction(i32 noundef %31, ptr noundef nonnull %12, ptr noundef nonnull %32) #5
  %.not8 = icmp eq i32 %33, -1
  br i1 %.not8, label %34, label %35

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #5
  call void @_ZN5boost12system_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull @.str.175)
  call void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16) %8) #6
  unreachable

35:                                               ; preds = %30, %5, %17
  ret void
}

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

; Function Attrs: inlinehint mustprogress noreturn uwtable
declare dso_local void @_ZN5boost9unit_test9ut_detail15throw_exceptionINS_12system_errorEEEvRKT_(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5boost6detailL48boost_execution_monitor_attaching_signal_handlerEiP9siginfo_tPv(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5boost6detailL46boost_execution_monitor_jumping_signal_handlerEiP9siginfo_tPv(i32 noundef, ptr noundef, ptr noundef) #2

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

declare void @_ZN5boost12system_errorC1EPKc(ptr, ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = { inlinehint mustprogress noreturn 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 = { noreturn }

!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, !7, i64 0}
!6 = !{!"_ZTSN5boost6detail13signal_actionE", !7, i64 0, !10, i64 4, !11, i64 8, !11, i64 160}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS9sigaction", !8, i64 0, !12, i64 8, !7, i64 136, !13, i64 144}
!12 = !{!"_ZTS10__sigset_t", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!6, !10, i64 4}
!15 = !{!8, !8, i64 0}
!16 = !{!6, !7, i64 144}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass