; LLVM IR from gulrak/filesystem :: test/filesystem_test.ll (ZN5Catch21FatalConditionHandler15engage_platformEv)

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

@_ZN5CatchL11altStackMemE = external hidden global ptr, align 8
@_ZN5CatchL12altStackSizeE = external hidden global i64, align 8
@_ZN5CatchL11oldSigStackE = external hidden global %struct.stack_t, align 8
@_ZN5CatchL10signalDefsE = external hidden global [6 x %"struct.Catch::SignalDefs"], align 16
@_ZN5CatchL13oldSigActionsE = external hidden global [6 x %struct.sigaction], align 16

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5Catch21FatalConditionHandler15engage_platformEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.stack_t, align 8
  %4 = alloca %struct.sigaction, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #5
  %7 = load ptr, ptr @_ZN5CatchL11altStackMemE, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.stack_t, ptr %3, i32 0, i32 0
  store ptr %7, ptr %8, align 8, !tbaa !9
  %9 = load i64, ptr @_ZN5CatchL12altStackSizeE, align 8, !tbaa !13
  %10 = getelementptr inbounds %struct.stack_t, ptr %3, i32 0, i32 2
  store i64 %9, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds %struct.stack_t, ptr %3, i32 0, i32 1
  store i32 0, ptr %11, align 8, !tbaa !15
  %12 = call i32 @sigaltstack(ptr noundef %3, ptr noundef @_ZN5CatchL11oldSigStackE) #5
  call void @llvm.lifetime.start.p0(i64 152, ptr %4) #5
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 152, i1 false)
  %13 = getelementptr inbounds %struct.sigaction, ptr %4, i32 0, i32 0
  store ptr @_ZN5CatchL12handleSignalEi, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds %struct.sigaction, ptr %4, i32 0, i32 2
  store i32 134217728, ptr %14, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !13
  br label %15

15:                                               ; preds = %27, %1
  %16 = load i64, ptr %5, align 8, !tbaa !13
  %17 = icmp ult i64 %16, 6
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %30

19:                                               ; preds = %15
  %20 = load i64, ptr %5, align 8, !tbaa !13
  %21 = getelementptr inbounds [6 x %"struct.Catch::SignalDefs"], ptr @_ZN5CatchL10signalDefsE, i64 0, i64 %20
  %22 = getelementptr inbounds %"struct.Catch::SignalDefs", ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 16, !tbaa !20
  %24 = load i64, ptr %5, align 8, !tbaa !13
  %25 = getelementptr inbounds [6 x %struct.sigaction], ptr @_ZN5CatchL13oldSigActionsE, i64 0, i64 %24
  %26 = call i32 @sigaction(i32 noundef %23, ptr noundef %4, ptr noundef %25) #5
  br label %27

27:                                               ; preds = %19
  %28 = load i64, ptr %5, align 8, !tbaa !13
  %29 = add i64 %28, 1
  store i64 %29, ptr %5, align 8, !tbaa !13
  br label %15, !llvm.loop !22

30:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 152, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #5
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5CatchL12handleSignalEi(i32 noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = { 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 #5 = { 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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS7stack_t", !6, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 16}
!15 = !{!10, !11, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !11, i64 136}
!18 = !{!"_ZTS9sigaction", !7, i64 0, !19, i64 8, !11, i64 136, !6, i64 144}
!19 = !{!"_ZTS10__sigset_t", !7, i64 0}
!20 = !{!21, !11, i64 0}
!21 = !{!"_ZTSN5Catch10SignalDefsE", !11, i64 0, !6, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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

@_ZN5CatchL11altStackMemE = external hidden local_unnamed_addr global ptr, align 8
@_ZN5CatchL12altStackSizeE = external hidden local_unnamed_addr global i64, align 8
@_ZN5CatchL11oldSigStackE = external hidden global %struct.stack_t, align 8
@_ZN5CatchL10signalDefsE = external hidden local_unnamed_addr global [6 x %"struct.Catch::SignalDefs"], align 16
@_ZN5CatchL13oldSigActionsE = external hidden global [6 x %struct.sigaction], align 16

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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 nounwind uwtable
define dso_local void @_ZN5Catch21FatalConditionHandler15engage_platformEv(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca %struct.stack_t, align 8
  %3 = alloca %struct.sigaction, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  %4 = load ptr, ptr @_ZN5CatchL11altStackMemE, align 8, !tbaa !5
  store ptr %4, ptr %2, align 8, !tbaa !9
  %5 = load i64, ptr @_ZN5CatchL12altStackSizeE, align 8, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  store i64 %5, ptr %6, align 8, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 0, ptr %7, align 8, !tbaa !15
  %8 = call i32 @sigaltstack(ptr noundef nonnull %2, ptr noundef nonnull @_ZN5CatchL11oldSigStackE) #5
  call void @llvm.lifetime.start.p0(i64 152, ptr nonnull %3) #5
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(152) %9, i8 0, i64 144, i1 false)
  store ptr @_ZN5CatchL12handleSignalEi, ptr %3, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %3, i64 136
  store i32 134217728, ptr %10, align 8, !tbaa !17
  %11 = load i32, ptr @_ZN5CatchL10signalDefsE, align 16, !tbaa !20
  %12 = call i32 @sigaction(i32 noundef %11, ptr noundef nonnull %3, ptr noundef nonnull @_ZN5CatchL13oldSigActionsE) #5
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @_ZN5CatchL10signalDefsE, i64 16), align 16, !tbaa !20
  %14 = call i32 @sigaction(i32 noundef %13, ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZN5CatchL13oldSigActionsE, i64 152)) #5
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @_ZN5CatchL10signalDefsE, i64 32), align 16, !tbaa !20
  %16 = call i32 @sigaction(i32 noundef %15, ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZN5CatchL13oldSigActionsE, i64 304)) #5
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @_ZN5CatchL10signalDefsE, i64 48), align 16, !tbaa !20
  %18 = call i32 @sigaction(i32 noundef %17, ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZN5CatchL13oldSigActionsE, i64 456)) #5
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @_ZN5CatchL10signalDefsE, i64 64), align 16, !tbaa !20
  %20 = call i32 @sigaction(i32 noundef %19, ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZN5CatchL13oldSigActionsE, i64 608)) #5
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @_ZN5CatchL10signalDefsE, i64 80), align 16, !tbaa !20
  %22 = call i32 @sigaction(i32 noundef %21, ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZN5CatchL13oldSigActionsE, i64 760)) #5
  call void @llvm.lifetime.end.p0(i64 152, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5CatchL12handleSignalEi(i32 noundef) #4

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = { 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 #5 = { 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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS7stack_t", !6, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 16}
!15 = !{!10, !11, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !11, i64 136}
!18 = !{!"_ZTS9sigaction", !7, i64 0, !19, i64 8, !11, i64 136, !6, i64 144}
!19 = !{!"_ZTS10__sigset_t", !7, i64 0}
!20 = !{!21, !11, i64 0}
!21 = !{!"_ZTSN5Catch10SignalDefsE", !11, i64 0, !6, i64 8}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass