; LLVM IR from stan-dev/math :: lib/tbb_2020.3/src/old/test_concurrent_queue_v2.ll (Z13TestFullQueuev)

; 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.tbb::atomic" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic" }
%"struct.tbb::internal::atomic_impl_with_arithmetic" = type { %"struct.tbb::internal::atomic_impl" }
%"struct.tbb::internal::atomic_impl" = type { %"struct.tbb::internal::aligned_storage" }
%"struct.tbb::internal::aligned_storage" = type { i64 }
%"class.tbb::concurrent_queue" = type { %"class.tbb::internal::concurrent_queue_base" }
%"class.tbb::internal::concurrent_queue_base" = type { ptr, ptr, i64, i64, i64 }
%class.Foo = type { i32, i32, i32 }

@.str.17 = external hidden unnamed_addr constant [99 x i8], align 1
@_ZL14FooConstructed = external hidden global %"struct.tbb::atomic", align 8
@_ZL12FooDestroyed = external hidden global %"struct.tbb::atomic", align 8
@.str.27 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [23 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11ReportErrorPKciS0_S0_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3tbb6atomicIlEaSEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb16concurrent_queueI3FooEC2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb16concurrent_queueI3FooE12set_capacityEl(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3FooC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNVK3tbb8internal11atomic_implIlEcvlEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13TestFullQueuev() #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"class.tbb::concurrent_queue", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %class.Foo, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca %class.Foo, align 4
  %11 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %118, %0
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 10
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %122

16:                                               ; preds = %12
  %17 = call noundef i64 @_ZN3tbb6atomicIlEaSEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZL14FooConstructed, i64 noundef 0)
  %18 = call noundef i64 @_ZN3tbb6atomicIlEaSEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZL12FooDestroyed, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 40, ptr %3) #3
  call void @_ZN3tbb16concurrent_queueI3FooEC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %3)
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  invoke void @_ZN3tbb16concurrent_queueI3FooE12set_capacityEl(ptr noundef nonnull align 8 dereferenceable(40) %3, i64 noundef %20)
          to label %21 unwind label %27

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %50, %21
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = icmp sle i32 %23, %24
  br i1 %25, label %31, label %26

26:                                               ; preds = %22
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %62

27:                                               ; preds = %115, %110, %108, %16
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %4, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %5, align 4
  br label %121

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #3
  invoke void @_ZN3FooC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %32 unwind label %53

32:                                               ; preds = %31
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = getelementptr inbounds %class.Foo, ptr %7, i32 0, i32 2
  store i32 %33, ptr %34, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %35 = invoke noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE16push_if_not_fullERKS1_(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %36 unwind label %57

36:                                               ; preds = %32
  %37 = zext i1 %35 to i8
  store i8 %37, ptr %8, align 1, !tbaa !12
  %38 = load i8, ptr %8, align 1, !tbaa !12, !range !14, !noundef !15
  %39 = trunc i8 %38 to i1
  %40 = zext i1 %39 to i32
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = load i32, ptr %1, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  %44 = zext i1 %43 to i32
  %45 = icmp eq i32 %40, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %36
  br label %49

47:                                               ; preds = %36
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.17, i32 noundef 279, ptr noundef @.str.35, ptr noundef null)
          to label %48 unwind label %57

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48, %46
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #3
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %6, align 4, !tbaa !5
  br label %22, !llvm.loop !16

53:                                               ; preds = %31
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %4, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %5, align 4
  br label %61

57:                                               ; preds = %47, %32
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %4, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #3
  br label %61

61:                                               ; preds = %57, %53
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %121

62:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %96, %62
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = load i32, ptr %1, align 4, !tbaa !5
  %66 = icmp sle i32 %64, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %108

68:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #3
  invoke void @_ZN3FooC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10)
          to label %69 unwind label %99

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  %70 = invoke noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE14pop_if_presentERS1_(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull align 4 dereferenceable(12) %10)
          to label %71 unwind label %103

71:                                               ; preds = %69
  %72 = zext i1 %70 to i8
  store i8 %72, ptr %11, align 1, !tbaa !12
  %73 = load i8, ptr %11, align 1, !tbaa !12, !range !14, !noundef !15
  %74 = trunc i8 %73 to i1
  %75 = zext i1 %74 to i32
  %76 = load i32, ptr %9, align 4, !tbaa !5
  %77 = load i32, ptr %1, align 4, !tbaa !5
  %78 = icmp slt i32 %76, %77
  %79 = zext i1 %78 to i32
  %80 = icmp eq i32 %75, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %71
  br label %84

82:                                               ; preds = %71
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.17, i32 noundef 284, ptr noundef @.str.35, ptr noundef null)
          to label %83 unwind label %103

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83, %81
  %85 = load i8, ptr %11, align 1, !tbaa !12, !range !14, !noundef !15
  %86 = trunc i8 %85 to i1
  br i1 %86, label %87, label %92

87:                                               ; preds = %84
  %88 = getelementptr inbounds %class.Foo, ptr %10, i32 0, i32 2
  %89 = load i32, ptr %88, align 4, !tbaa !9
  %90 = load i32, ptr %9, align 4, !tbaa !5
  %91 = icmp eq i32 %89, %90
  br i1 %91, label %92, label %93

92:                                               ; preds = %87, %84
  br label %95

93:                                               ; preds = %87
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.17, i32 noundef 285, ptr noundef @.str.36, ptr noundef null)
          to label %94 unwind label %103

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94, %92
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #3
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %9, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %9, align 4, !tbaa !5
  br label %63, !llvm.loop !18

99:                                               ; preds = %68
  %100 = landingpad { ptr, i32 }
          cleanup
  %101 = extractvalue { ptr, i32 } %100, 0
  store ptr %101, ptr %4, align 8
  %102 = extractvalue { ptr, i32 } %100, 1
  store i32 %102, ptr %5, align 4
  br label %107

103:                                              ; preds = %93, %82, %69
  %104 = landingpad { ptr, i32 }
          cleanup
  %105 = extractvalue { ptr, i32 } %104, 0
  store ptr %105, ptr %4, align 8
  %106 = extractvalue { ptr, i32 } %104, 1
  store i32 %106, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10) #3
  br label %107

107:                                              ; preds = %103, %99
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %121

108:                                              ; preds = %67
  %109 = invoke noundef i64 @_ZNVK3tbb8internal11atomic_implIlEcvlEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZL14FooConstructed)
          to label %110 unwind label %27

110:                                              ; preds = %108
  %111 = invoke noundef i64 @_ZNVK3tbb8internal11atomic_implIlEcvlEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZL12FooDestroyed)
          to label %112 unwind label %27

112:                                              ; preds = %110
  %113 = icmp eq i64 %109, %111
  br i1 %113, label %114, label %115

114:                                              ; preds = %112
  br label %117

115:                                              ; preds = %112
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.17, i32 noundef 287, ptr noundef @.str.27, ptr noundef null)
          to label %116 unwind label %27

116:                                              ; preds = %115
  br label %117

117:                                              ; preds = %116, %114
  call void @_ZN3tbb16concurrent_queueI3FooED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %3) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #3
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %1, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %1, align 4, !tbaa !5
  br label %12, !llvm.loop !19

121:                                              ; preds = %107, %61, %27
  call void @_ZN3tbb16concurrent_queueI3FooED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %3) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %123

122:                                              ; preds = %15
  ret void

123:                                              ; preds = %121
  %124 = load ptr, ptr %4, align 8
  %125 = load i32, ptr %5, align 4
  %126 = insertvalue { ptr, i32 } poison, ptr %124, 0
  %127 = insertvalue { ptr, i32 } %126, i32 %125, 1
  resume { ptr, i32 } %127
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE16push_if_not_fullERKS1_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE14pop_if_presentERS1_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS3Foo", !11, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!"_ZTS7state_t", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


; 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.tbb::atomic" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic" }
%"struct.tbb::internal::atomic_impl_with_arithmetic" = type { %"struct.tbb::internal::atomic_impl" }
%"struct.tbb::internal::atomic_impl" = type { %"struct.tbb::internal::aligned_storage" }
%"struct.tbb::internal::aligned_storage" = type { i64 }
%"class.tbb::concurrent_queue" = type { %"class.tbb::internal::concurrent_queue_base" }
%"class.tbb::internal::concurrent_queue_base" = type { ptr, ptr, i64, i64, i64 }
%class.Foo = type { i32, i32, i32 }

@.str.17 = external hidden unnamed_addr constant [99 x i8], align 1
@_ZL14FooConstructed = external hidden global %"struct.tbb::atomic", align 8
@_ZL12FooDestroyed = external hidden global %"struct.tbb::atomic", align 8
@.str.27 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [23 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11ReportErrorPKciS0_S0_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3tbb6atomicIlEaSEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb16concurrent_queueI3FooEC2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb16concurrent_queueI3FooE12set_capacityEl(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3FooC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNVK3tbb8internal11atomic_implIlEcvlEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13TestFullQueuev() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.tbb::concurrent_queue", align 8
  %2 = alloca %class.Foo, align 4
  %3 = alloca %class.Foo, align 4
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  br label %7

6:                                                ; preds = %51
  ret void

7:                                                ; preds = %0, %51
  %indvars.iv39 = phi i64 [ 0, %0 ], [ %indvars.iv.next40, %51 ]
  %indvars.iv = phi i32 [ 1, %0 ], [ %indvars.iv.next, %51 ]
  %8 = call noundef i64 @_ZN3tbb6atomicIlEaSEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZL14FooConstructed, i64 noundef 0)
  %9 = call noundef i64 @_ZN3tbb6atomicIlEaSEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZL12FooDestroyed, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #3
  call void @_ZN3tbb16concurrent_queueI3FooEC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %1)
  invoke void @_ZN3tbb16concurrent_queueI3FooE12set_capacityEl(ptr noundef nonnull align 8 dereferenceable(40) %1, i64 noundef %indvars.iv39)
          to label %.preheader34 unwind label %10

10:                                               ; preds = %50, %46, %26, %7
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %52

.preheader34:                                     ; preds = %7, %19
  %.02035 = phi i32 [ %20, %19 ], [ 0, %7 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #3
  invoke void @_ZN3FooC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %2)
          to label %12 unwind label %21

12:                                               ; preds = %.preheader34
  store i32 %.02035, ptr %4, align 4, !tbaa !5
  %13 = invoke noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE16push_if_not_fullERKS1_(ptr noundef nonnull align 8 dereferenceable(40) %1, ptr noundef nonnull align 4 dereferenceable(12) %2)
          to label %14 unwind label %23

14:                                               ; preds = %12
  %15 = zext nneg i32 %.02035 to i64
  %16 = icmp ule i64 %indvars.iv39, %15
  %17 = xor i1 %16, %13
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.17, i32 noundef 279, ptr noundef nonnull @.str.35, ptr noundef null)
          to label %19 unwind label %23

19:                                               ; preds = %18, %14
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %2) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #3
  %20 = add nuw nsw i32 %.02035, 1
  %exitcond.not = icmp eq i32 %20, %indvars.iv
  br i1 %exitcond.not, label %.preheader, label %.preheader34, !llvm.loop !11

21:                                               ; preds = %.preheader34
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %25

23:                                               ; preds = %18, %12
  %24 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %2) #3
  br label %25

25:                                               ; preds = %23, %21
  %.pn27 = phi { ptr, i32 } [ %24, %23 ], [ %22, %21 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #3
  br label %52

26:                                               ; preds = %39
  %27 = invoke noundef i64 @_ZNVK3tbb8internal11atomic_implIlEcvlEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZL14FooConstructed)
          to label %46 unwind label %10

.preheader:                                       ; preds = %19, %39
  %.01936 = phi i32 [ %40, %39 ], [ 0, %19 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  invoke void @_ZN3FooC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %3)
          to label %28 unwind label %41

28:                                               ; preds = %.preheader
  %29 = invoke noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE14pop_if_presentERS1_(ptr noundef nonnull align 8 dereferenceable(40) %1, ptr noundef nonnull align 4 dereferenceable(12) %3)
          to label %30 unwind label %43

30:                                               ; preds = %28
  %31 = zext nneg i32 %.01936 to i64
  %32 = icmp ule i64 %indvars.iv39, %31
  %33 = xor i1 %32, %29
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.17, i32 noundef 284, ptr noundef nonnull @.str.35, ptr noundef null)
          to label %35 unwind label %43

35:                                               ; preds = %34, %30
  %36 = load i32, ptr %5, align 4
  %37 = icmp ne i32 %36, %.01936
  %or.cond.not = select i1 %29, i1 %37, i1 false
  br i1 %or.cond.not, label %38, label %39

38:                                               ; preds = %35
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.17, i32 noundef 285, ptr noundef nonnull @.str.36, ptr noundef null)
          to label %39 unwind label %43

39:                                               ; preds = %38, %35
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %3) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #3
  %40 = add nuw nsw i32 %.01936, 1
  %exitcond38.not = icmp eq i32 %40, %indvars.iv
  br i1 %exitcond38.not, label %26, label %.preheader, !llvm.loop !13

41:                                               ; preds = %.preheader
  %42 = landingpad { ptr, i32 }
          cleanup
  br label %45

43:                                               ; preds = %38, %34, %28
  %44 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3FooD2Ev(ptr noundef nonnull align 4 dereferenceable(12) %3) #3
  br label %45

45:                                               ; preds = %43, %41
  %.pn = phi { ptr, i32 } [ %44, %43 ], [ %42, %41 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #3
  br label %52

46:                                               ; preds = %26
  %47 = invoke noundef i64 @_ZNVK3tbb8internal11atomic_implIlEcvlEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZL12FooDestroyed)
          to label %48 unwind label %10

48:                                               ; preds = %46
  %49 = icmp eq i64 %27, %47
  br i1 %49, label %51, label %50

50:                                               ; preds = %48
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.17, i32 noundef 287, ptr noundef nonnull @.str.27, ptr noundef null)
          to label %51 unwind label %10

51:                                               ; preds = %50, %48
  call void @_ZN3tbb16concurrent_queueI3FooED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %1) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #3
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
  %exitcond42.not = icmp eq i64 %indvars.iv.next40, 10
  br i1 %exitcond42.not, label %6, label %7, !llvm.loop !14

52:                                               ; preds = %45, %25, %10
  %.pn27.pn = phi { ptr, i32 } [ %.pn27, %25 ], [ %.pn, %45 ], [ %11, %10 ]
  call void @_ZN3tbb16concurrent_queueI3FooED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %1) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #3
  resume { ptr, i32 } %.pn27.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE16push_if_not_fullERKS1_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb16concurrent_queueI3FooE14pop_if_presentERS1_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

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

!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 8}
!6 = !{!"_ZTS3Foo", !7, i64 0, !10, i64 4, !10, i64 8}
!7 = !{!"_ZTS7state_t", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass