; LLVM IR from stan-dev/math :: lib/tbb_2020.3/src/test/test_task_priority.ll (Z16TestEnqueueOrderv)

; 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.Harness::internal::Tracer" = type <{ i32, [4 x i8], ptr, ptr, i64, [8 x i8] }>
%"struct.tbb::atomic" = type { %"struct.tbb::internal::atomic_impl" }
%"struct.tbb::internal::atomic_impl" = type { %"struct.tbb::internal::aligned_storage" }
%"struct.tbb::internal::aligned_storage" = type { i32 }
%"struct.tbb::atomic.0" = type { %"struct.tbb::internal::atomic_impl.1" }
%"struct.tbb::internal::atomic_impl.1" = type { %"struct.tbb::internal::aligned_storage.2" }
%"struct.tbb::internal::aligned_storage.2" = type { i8 }
%"struct.tbb::atomic.3" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic" }
%"struct.tbb::internal::atomic_impl_with_arithmetic" = type { %"struct.tbb::internal::atomic_impl.4" }
%"struct.tbb::internal::atomic_impl.4" = type { %"struct.tbb::internal::aligned_storage.5" }
%"struct.tbb::internal::aligned_storage.5" = type { i32 }
%"class.tbb::task_scheduler_init" = type { ptr }

@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@.str.21 = external hidden unnamed_addr constant [94 x i8], align 1
@_ZL7Verbose = external hidden global i8, align 1
@g_order = external dso_local global %"struct.tbb::atomic", align 4
@g_order_established = external dso_local global %"struct.tbb::atomic.0", align 1
@g_num_tasks = external dso_local global %"struct.tbb::atomic.3", align 4
@g_all_tasks_enqueued = external dso_local global %"struct.tbb::atomic.0", align 1
@g_failures = external dso_local global i32, align 4
@__FUNCTION__._Z16TestEnqueueOrderv = external hidden unnamed_addr constant [17 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [18 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: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef, ptr noundef, i64 noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, ...) #2 align 2

; 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) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb19task_scheduler_initC2Eim(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i64 noundef) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare i32 @sched_yield() #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16TestEnqueueOrderv() #2 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.tbb::task_scheduler_init", align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %7 = trunc i8 %6 to i1
  br i1 %7, label %9, label %8

8:                                                ; preds = %0
  br label %11

9:                                                ; preds = %0
  %10 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef @.str.21, i64 noundef 464, ptr noundef @__FUNCTION__._Z16TestEnqueueOrderv)
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %10, ptr noundef @.str.38)
  br label %11

11:                                               ; preds = %9, %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @_ZN3tbb19task_scheduler_initC2Eim(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef 1, i64 noundef 0)
  %12 = invoke noundef i32 @_ZN3tbb6atomicINS_10priority_tEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) @g_order, i32 noundef 536870911)
          to label %13 unwind label %22

13:                                               ; preds = %11
  %14 = invoke noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) @g_order_established, i1 noundef zeroext false)
          to label %15 unwind label %22

15:                                               ; preds = %13
  %16 = invoke noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) @g_all_tasks_enqueued, i1 noundef zeroext false)
          to label %17 unwind label %22

17:                                               ; preds = %15
  store i32 0, ptr @g_failures, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %29, %17
  %19 = load i32, ptr %4, align 4, !tbaa !11
  %20 = icmp slt i32 %19, 1000
  br i1 %20, label %26, label %21

21:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %36

22:                                               ; preds = %86, %74, %70, %61, %57, %54, %15, %13, %11
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %2, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %3, align 4
  br label %89

26:                                               ; preds = %18
  %27 = load i32, ptr %4, align 4, !tbaa !11
  invoke void @_ZN11OrderedTask5startEi(i32 noundef %27)
          to label %28 unwind label %32

28:                                               ; preds = %26
  br label %29

29:                                               ; preds = %28
  %30 = load i32, ptr %4, align 4, !tbaa !11
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %4, align 4, !tbaa !11
  br label %18, !llvm.loop !13

32:                                               ; preds = %26
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %2, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %89

36:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %37 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %38 unwind label %49

38:                                               ; preds = %36
  store i32 %37, ptr %5, align 4, !tbaa !11
  %39 = load i32, ptr %5, align 4, !tbaa !11
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %54

41:                                               ; preds = %38
  br label %42

42:                                               ; preds = %47, %41
  %43 = load i32, ptr %5, align 4, !tbaa !11
  %44 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %45 unwind label %49

45:                                               ; preds = %42
  %46 = icmp eq i32 %43, %44
  br i1 %46, label %47, label %53

47:                                               ; preds = %45
  %48 = call i32 @sched_yield() #4
  br label %42, !llvm.loop !15

49:                                               ; preds = %42, %36
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %2, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %89

53:                                               ; preds = %45
  br label %54

54:                                               ; preds = %53, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %55 = invoke noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) @g_all_tasks_enqueued, i1 noundef zeroext true)
          to label %56 unwind label %22

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %67, %56
  %58 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implINS_10priority_tEEcvS2_Ev(ptr noundef nonnull align 4 dereferenceable(4) @g_order)
          to label %59 unwind label %22

59:                                               ; preds = %57
  %60 = icmp eq i32 %58, 536870911
  br i1 %60, label %61, label %65

61:                                               ; preds = %59
  %62 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %63 unwind label %22

63:                                               ; preds = %61
  %64 = icmp sgt i32 %62, 0
  br label %65

65:                                               ; preds = %63, %59
  %66 = phi i1 [ false, %59 ], [ %64, %63 ]
  br i1 %66, label %67, label %69

67:                                               ; preds = %65
  %68 = call i32 @sched_yield() #4
  br label %57, !llvm.loop !16

69:                                               ; preds = %65
  br label %70

70:                                               ; preds = %80, %69
  %71 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implINS_10priority_tEEcvS2_Ev(ptr noundef nonnull align 4 dereferenceable(4) @g_order)
          to label %72 unwind label %22

72:                                               ; preds = %70
  %73 = icmp ne i32 %71, 536870911
  br i1 %73, label %74, label %78

74:                                               ; preds = %72
  %75 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %76 unwind label %22

76:                                               ; preds = %74
  %77 = icmp sgt i32 %75, 0
  br label %78

78:                                               ; preds = %76, %72
  %79 = phi i1 [ false, %72 ], [ %77, %76 ]
  br i1 %79, label %80, label %82

80:                                               ; preds = %78
  %81 = call i32 @sched_yield() #4
  br label %70, !llvm.loop !17

82:                                               ; preds = %78
  %83 = load i32, ptr @g_failures, align 4, !tbaa !11
  %84 = icmp slt i32 %83, 5
  br i1 %84, label %85, label %86

85:                                               ; preds = %82
  br label %88

86:                                               ; preds = %82
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.21, i32 noundef 482, ptr noundef @.str.39, ptr noundef @.str.40)
          to label %87 unwind label %22

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87, %85
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void

89:                                               ; preds = %49, %32, %22
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %2, align 8
  %92 = load i32, ptr %3, align 4
  %93 = insertvalue { ptr, i32 } poison, ptr %91, 0
  %94 = insertvalue { ptr, i32 } %93, i32 %92, 1
  resume { ptr, i32 } %94
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3tbb6atomicINS_10priority_tEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11OrderedTask5startEi(i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNVK3tbb8internal11atomic_implINS_10priority_tEEcvS2_Ev(ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


; 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.Harness::internal::Tracer" = type <{ i32, [4 x i8], ptr, ptr, i64, [8 x i8] }>
%"struct.tbb::atomic" = type { %"struct.tbb::internal::atomic_impl" }
%"struct.tbb::internal::atomic_impl" = type { %"struct.tbb::internal::aligned_storage" }
%"struct.tbb::internal::aligned_storage" = type { i32 }
%"struct.tbb::atomic.0" = type { %"struct.tbb::internal::atomic_impl.1" }
%"struct.tbb::internal::atomic_impl.1" = type { %"struct.tbb::internal::aligned_storage.2" }
%"struct.tbb::internal::aligned_storage.2" = type { i8 }
%"struct.tbb::atomic.3" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic" }
%"struct.tbb::internal::atomic_impl_with_arithmetic" = type { %"struct.tbb::internal::atomic_impl.4" }
%"struct.tbb::internal::atomic_impl.4" = type { %"struct.tbb::internal::aligned_storage.5" }
%"struct.tbb::internal::aligned_storage.5" = type { i32 }
%"class.tbb::task_scheduler_init" = type { ptr }

@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@.str.21 = external hidden unnamed_addr constant [94 x i8], align 1
@_ZL7Verbose = external hidden local_unnamed_addr global i8, align 1
@g_order = external dso_local global %"struct.tbb::atomic", align 4
@g_order_established = external dso_local global %"struct.tbb::atomic.0", align 1
@g_num_tasks = external dso_local global %"struct.tbb::atomic.3", align 4
@g_all_tasks_enqueued = external dso_local global %"struct.tbb::atomic.0", align 1
@g_failures = external dso_local local_unnamed_addr global i32, align 4
@__FUNCTION__._Z16TestEnqueueOrderv = external hidden unnamed_addr constant [17 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [18 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 nounwind uwtable
declare dso_local noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, ...) local_unnamed_addr #2 align 2

; 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 #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb19task_scheduler_initC2Eim(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i64 noundef) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare i32 @sched_yield() local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16TestEnqueueOrderv() local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.tbb::task_scheduler_init", align 8
  %2 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %3 = trunc nuw i8 %2 to i1
  br i1 %3, label %4, label %6

4:                                                ; preds = %0
  %5 = tail call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef nonnull @.str.21, i64 noundef 464, ptr noundef nonnull @__FUNCTION__._Z16TestEnqueueOrderv)
  tail call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %5, ptr noundef nonnull @.str.38)
  br label %6

6:                                                ; preds = %0, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @_ZN3tbb19task_scheduler_initC2Eim(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef 1, i64 noundef 0)
  %7 = invoke noundef i32 @_ZN3tbb6atomicINS_10priority_tEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) @g_order, i32 noundef 536870911)
          to label %8 unwind label %.loopexit.split-lp.loopexit.split-lp

8:                                                ; preds = %6
  %9 = invoke noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) @g_order_established, i1 noundef zeroext false)
          to label %10 unwind label %.loopexit.split-lp.loopexit.split-lp

10:                                               ; preds = %8
  %11 = invoke noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) @g_all_tasks_enqueued, i1 noundef zeroext false)
          to label %12 unwind label %.loopexit.split-lp.loopexit.split-lp

12:                                               ; preds = %10
  store i32 0, ptr @g_failures, align 4, !tbaa !11
  br label %15

13:                                               ; preds = %16
  %14 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %20 unwind label %.loopexit.split-lp17

.loopexit:                                        ; preds = %.critedge, %38
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit:                      ; preds = %30, %.preheader
  %lpad.loopexit12 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp:             ; preds = %46, %.loopexit20, %10, %8, %6
  %lpad.loopexit.split-lp13 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

15:                                               ; preds = %12, %16
  %.0821 = phi i32 [ 0, %12 ], [ %17, %16 ]
  invoke void @_ZN11OrderedTask5startEi(i32 noundef %.0821)
          to label %16 unwind label %18

16:                                               ; preds = %15
  %17 = add nuw nsw i32 %.0821, 1
  %exitcond.not = icmp eq i32 %17, 1000
  br i1 %exitcond.not, label %13, label %15, !llvm.loop !13

18:                                               ; preds = %15
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

20:                                               ; preds = %13
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %.loopexit20, label %.preheader15

.preheader15:                                     ; preds = %20, %24
  %21 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %22 unwind label %.loopexit16

22:                                               ; preds = %.preheader15
  %23 = icmp eq i32 %14, %21
  br i1 %23, label %24, label %.loopexit20

24:                                               ; preds = %22
  %25 = call i32 @sched_yield() #4
  br label %.preheader15, !llvm.loop !15

.loopexit16:                                      ; preds = %.preheader15
  %lpad.loopexit18 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp17:                             ; preds = %13
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit20:                                      ; preds = %22, %20
  %26 = invoke noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) @g_all_tasks_enqueued, i1 noundef zeroext true)
          to label %.preheader unwind label %.loopexit.split-lp.loopexit.split-lp

.preheader:                                       ; preds = %.loopexit20, %34
  %27 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implINS_10priority_tEEcvS2_Ev(ptr noundef nonnull align 4 dereferenceable(4) @g_order)
          to label %28 unwind label %.loopexit.split-lp.loopexit

28:                                               ; preds = %.preheader
  %29 = icmp eq i32 %27, 536870911
  br i1 %29, label %30, label %.critedge.preheader

30:                                               ; preds = %28
  %31 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %32 unwind label %.loopexit.split-lp.loopexit

32:                                               ; preds = %30
  %33 = icmp sgt i32 %31, 0
  br i1 %33, label %34, label %.critedge.preheader

.critedge.preheader:                              ; preds = %28, %32
  br label %.critedge

34:                                               ; preds = %32
  %35 = call i32 @sched_yield() #4
  br label %.preheader, !llvm.loop !16

.critedge:                                        ; preds = %.critedge.preheader, %42
  %36 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implINS_10priority_tEEcvS2_Ev(ptr noundef nonnull align 4 dereferenceable(4) @g_order)
          to label %37 unwind label %.loopexit

37:                                               ; preds = %.critedge
  %.not10 = icmp eq i32 %36, 536870911
  br i1 %.not10, label %.critedge2, label %38

38:                                               ; preds = %37
  %39 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @g_num_tasks)
          to label %40 unwind label %.loopexit

40:                                               ; preds = %38
  %41 = icmp sgt i32 %39, 0
  br i1 %41, label %42, label %.critedge2

42:                                               ; preds = %40
  %43 = call i32 @sched_yield() #4
  br label %.critedge, !llvm.loop !17

.critedge2:                                       ; preds = %37, %40
  %44 = load i32, ptr @g_failures, align 4, !tbaa !11
  %45 = icmp slt i32 %44, 5
  br i1 %45, label %47, label %46

46:                                               ; preds = %.critedge2
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.21, i32 noundef 482, ptr noundef nonnull @.str.39, ptr noundef nonnull @.str.40)
          to label %47 unwind label %.loopexit.split-lp.loopexit.split-lp

47:                                               ; preds = %46, %.critedge2
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret void

.loopexit.split-lp:                               ; preds = %.loopexit16, %.loopexit.split-lp17, %.loopexit, %.loopexit.split-lp.loopexit.split-lp, %.loopexit.split-lp.loopexit, %18
  %.pn = phi { ptr, i32 } [ %19, %18 ], [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit12, %.loopexit.split-lp.loopexit ], [ %lpad.loopexit.split-lp13, %.loopexit.split-lp.loopexit.split-lp ], [ %lpad.loopexit18, %.loopexit16 ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp17 ]
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3tbb6atomicINS_10priority_tEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11OrderedTask5startEi(i32 noundef) local_unnamed_addr #2 align 2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass