; LLVM IR from pictools/pica :: test/gtest/fused-src/gtest/gtest-all.ll (ZN7testing8internal16ForkingDeathTest4WaitEv)

; 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.testing::internal::String" = type { ptr, i64 }
%"class.testing::internal::ForkingDeathTest" = type { %"class.testing::internal::DeathTestImpl.base", i32 }
%"class.testing::internal::DeathTestImpl.base" = type <{ %"class.testing::internal::DeathTest", ptr, ptr, i8, [3 x i8], i32, i32, i32, i32 }>
%"class.testing::internal::DeathTest" = type { ptr }

@.str.28 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.243 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.257 = external hidden unnamed_addr constant [38 x i8], align 1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7testing8internal6String6FormatEPKcz(ptr dead_on_unwind noalias writable sret(%"class.testing::internal::String") align 8, ptr noundef, ...) #2 align 2

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7testing8internal13DeathTestImpl26ReadAndInterpretStatusByteEv(ptr noundef nonnull align 8 dereferenceable(44)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7testing8internal11AlwaysFalseEv() #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7testing8internal13DeathTestImpl7spawnedEv(ptr noundef nonnull align 8 dereferenceable(44)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7testing8internal16ForkingDeathTest4WaitEv(ptr noundef nonnull align 8 dereferenceable(48) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"class.testing::internal::String", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = call noundef zeroext i1 @_ZNK7testing8internal13DeathTestImpl7spawnedEv(ptr noundef nonnull align 8 dereferenceable(44) %9)
  br i1 %10, label %12, label %11

11:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  br label %42

12:                                               ; preds = %1
  call void @_ZN7testing8internal13DeathTestImpl26ReadAndInterpretStatusByteEv(ptr noundef nonnull align 8 dereferenceable(44) %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  br label %13

13:                                               ; preds = %37, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  br label %14

14:                                               ; preds = %25, %13
  %15 = getelementptr inbounds %"class.testing::internal::ForkingDeathTest", ptr %9, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = call i32 @waitpid(i32 noundef %16, ptr noundef %4, i32 noundef 0)
  store i32 %17, ptr %5, align 4, !tbaa !16
  br label %18

18:                                               ; preds = %14
  %19 = load i32, ptr %5, align 4, !tbaa !16
  %20 = icmp eq i32 %19, -1
  br i1 %20, label %21, label %25

21:                                               ; preds = %18
  %22 = call ptr @__errno_location() #7
  %23 = load i32, ptr %22, align 4, !tbaa !16
  %24 = icmp eq i32 %23, 4
  br label %25

25:                                               ; preds = %21, %18
  %26 = phi i1 [ false, %18 ], [ %24, %21 ]
  br i1 %26, label %14, label %27, !llvm.loop !17

27:                                               ; preds = %25
  %28 = load i32, ptr %5, align 4, !tbaa !16
  %29 = icmp eq i32 %28, -1
  br i1 %29, label %30, label %36

30:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  call void (ptr, ptr, ...) @_ZN7testing8internal6String6FormatEPKcz(ptr dead_on_unwind writable sret(%"class.testing::internal::String") align 8 %6, ptr noundef @.str.243, ptr noundef @.str.28, i32 noundef 6967, ptr noundef @.str.257)
  invoke void @_ZN7testing8internal14DeathTestAbortERKNS0_6StringE(ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %31 unwind label %32

31:                                               ; preds = %30
  call void @_ZN7testing8internal6StringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  br label %36

32:                                               ; preds = %30
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %7, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %8, align 4
  call void @_ZN7testing8internal6StringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %44

36:                                               ; preds = %31, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %37

37:                                               ; preds = %36
  %38 = call noundef zeroext i1 @_ZN7testing8internal11AlwaysFalseEv()
  br i1 %38, label %13, label %39, !llvm.loop !19

39:                                               ; preds = %37
  %40 = load i32, ptr %4, align 4, !tbaa !16
  call void @_ZN7testing8internal13DeathTestImpl10set_statusEi(ptr noundef nonnull align 8 dereferenceable(44) %9, i32 noundef %40)
  %41 = load i32, ptr %4, align 4, !tbaa !16
  store i32 %41, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %42

42:                                               ; preds = %39, %11
  %43 = load i32, ptr %2, align 4
  ret i32 %43

44:                                               ; preds = %32
  %45 = load ptr, ptr %7, align 8
  %46 = load i32, ptr %8, align 4
  %47 = insertvalue { ptr, i32 } poison, ptr %45, 0
  %48 = insertvalue { ptr, i32 } %47, i32 %46, 1
  resume { ptr, i32 } %48
}

declare i32 @waitpid(i32 noundef, ptr noundef, i32 noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7testing8internal13DeathTestImpl10set_statusEi(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef) #0 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 willreturn memory(none) "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 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 = { "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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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, !14, i64 44}
!10 = !{!"_ZTSN7testing8internal16ForkingDeathTestE", !11, i64 0, !14, i64 44}
!11 = !{!"_ZTSN7testing8internal13DeathTestImplE", !12, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 28, !15, i64 32, !14, i64 36, !14, i64 40}
!12 = !{!"_ZTSN7testing8internal9DeathTestE"}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSN7testing8internal16DeathTestOutcomeE", !7, i64 0}
!16 = !{!14, !14, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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.testing::internal::String" = type { ptr, i64 }

@.str.28 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.243 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.257 = external hidden unnamed_addr constant [38 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7testing8internal6String6FormatEPKcz(ptr dead_on_unwind noalias writable sret(%"class.testing::internal::String") align 8, ptr noundef, ...) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7testing8internal14DeathTestAbortERKNS0_6StringE(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7testing8internal13DeathTestImpl26ReadAndInterpretStatusByteEv(ptr noundef nonnull align 8 dereferenceable(44)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7testing8internal11AlwaysFalseEv() local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7testing8internal13DeathTestImpl7spawnedEv(ptr noundef nonnull align 8 dereferenceable(44)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7testing8internal16ForkingDeathTest4WaitEv(ptr noundef nonnull align 8 dereferenceable(48) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca %"class.testing::internal::String", align 8
  %4 = tail call noundef zeroext i1 @_ZNK7testing8internal13DeathTestImpl7spawnedEv(ptr noundef nonnull align 8 dereferenceable(44) %0)
  br i1 %4, label %5, label %22

5:                                                ; preds = %1
  tail call void @_ZN7testing8internal13DeathTestImpl26ReadAndInterpretStatusByteEv(ptr noundef nonnull align 8 dereferenceable(44) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %6 = getelementptr inbounds i8, ptr %0, i64 44
  br label %7

7:                                                ; preds = %.backedge, %5
  %8 = load i32, ptr %6, align 4, !tbaa !5
  %9 = call i32 @waitpid(i32 noundef %8, ptr noundef nonnull %2, i32 noundef 0)
  %10 = icmp eq i32 %9, -1
  br i1 %10, label %11, label %.critedge5

11:                                               ; preds = %7
  %12 = tail call ptr @__errno_location() #7
  %13 = load i32, ptr %12, align 4, !tbaa !15
  %14 = icmp eq i32 %13, 4
  br i1 %14, label %.backedge, label %.critedge

.backedge:                                        ; preds = %11, %.critedge5
  br label %7, !llvm.loop !16

.critedge:                                        ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void (ptr, ptr, ...) @_ZN7testing8internal6String6FormatEPKcz(ptr dead_on_unwind nonnull writable sret(%"class.testing::internal::String") align 8 %3, ptr noundef nonnull @.str.243, ptr noundef nonnull @.str.28, i32 noundef 6967, ptr noundef nonnull @.str.257)
  invoke void @_ZN7testing8internal14DeathTestAbortERKNS0_6StringE(ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %15 unwind label %16

15:                                               ; preds = %.critedge
  call void @_ZN7testing8internal6StringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  br label %.critedge5

16:                                               ; preds = %.critedge
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7testing8internal6StringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  resume { ptr, i32 } %17

.critedge5:                                       ; preds = %7, %15
  %18 = call noundef zeroext i1 @_ZN7testing8internal11AlwaysFalseEv()
  br i1 %18, label %.backedge, label %19

19:                                               ; preds = %.critedge5
  %20 = load i32, ptr %2, align 4, !tbaa !15
  call void @_ZN7testing8internal13DeathTestImpl10set_statusEi(ptr noundef nonnull align 8 dereferenceable(44) %0, i32 noundef %20)
  %21 = load i32, ptr %2, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  br label %22

22:                                               ; preds = %1, %19
  %.0 = phi i32 [ %21, %19 ], [ 0, %1 ]
  ret i32 %.0
}

declare i32 @waitpid(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7testing8internal13DeathTestImpl10set_statusEi(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 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 = { "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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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, !13, i64 44}
!6 = !{!"_ZTSN7testing8internal16ForkingDeathTestE", !7, i64 0, !13, i64 44}
!7 = !{!"_ZTSN7testing8internal13DeathTestImplE", !8, i64 0, !9, i64 8, !9, i64 16, !12, i64 24, !13, i64 28, !14, i64 32, !13, i64 36, !13, i64 40}
!8 = !{!"_ZTSN7testing8internal9DeathTestE"}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"bool", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"_ZTSN7testing8internal16DeathTestOutcomeE", !10, i64 0}
!15 = !{!13, !13, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass