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

; 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"

@_ZL9MinThread = external hidden global i32, align 4
@_ZL9MaxThread = external hidden global i32, align 4

; 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
define dso_local noundef i32 @_Z8TestMainv() #1 {
  %1 = alloca i32, align 4
  call void @_Z23TestUnconstructibleTaskILm1EEvv()
  call void @_Z23TestUnconstructibleTaskILm10000EEvv()
  call void @_Z13TestAlignmentv()
  call void @_Z23TestNoteAffinityContextv()
  call void @_Z30TestDispatchLoopResponsivenessv()
  call void @_Z41TestWaitDiscriminativenessWithoutStealingv()
  call void @_Z38TestWaitDiscriminativenessWithStealingv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  %2 = load i32, ptr @_ZL9MinThread, align 4, !tbaa !5
  store i32 %2, ptr %1, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %19, %0
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %6 = icmp sle i32 %4, %5
  br i1 %6, label %8, label %7

7:                                                ; preds = %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %22

8:                                                ; preds = %3
  %9 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z17TestSpawnChildreni(i32 noundef %9)
  %10 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z17TestSpawnRootListi(i32 noundef %10)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z20TestSafeContinuationi(i32 noundef %11)
  %12 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z17TestLeftRecursioni(i32 noundef %12)
  %13 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z7TestDagi(i32 noundef %13)
  %14 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z12TestAffinityi(i32 noundef %14)
  %15 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z14TestUserThreadi(i32 noundef %15)
  %16 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z14TestStealLimiti(i32 noundef %16)
  %17 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z20TestRelaxedOwnershipi(i32 noundef %17)
  %18 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z20TestMastersIsolationi(i32 noundef %18)
  br label %19

19:                                               ; preds = %8
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %1, align 4, !tbaa !5
  br label %3, !llvm.loop !9

22:                                               ; preds = %7
  call void @_Z16TestWaitableTaskv()
  ret i32 0
}

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestNoteAffinityContextv() #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13TestAlignmentv() #1

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z30TestDispatchLoopResponsivenessv() #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z41TestWaitDiscriminativenessWithoutStealingv() #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z38TestWaitDiscriminativenessWithStealingv() #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z16TestWaitableTaskv() #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestUnconstructibleTaskILm1EEvv() #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestUnconstructibleTaskILm10000EEvv() #1

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 = { 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 = distinct !{!9, !10}
!10 = !{!"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"

@_ZL9MinThread = external hidden local_unnamed_addr global i32, align 4
@_ZL9MaxThread = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z8TestMainv() local_unnamed_addr #0 {
  tail call void @_Z23TestUnconstructibleTaskILm1EEvv()
  tail call void @_Z23TestUnconstructibleTaskILm10000EEvv()
  tail call void @_Z13TestAlignmentv()
  tail call void @_Z23TestNoteAffinityContextv()
  tail call void @_Z30TestDispatchLoopResponsivenessv()
  tail call void @_Z41TestWaitDiscriminativenessWithoutStealingv()
  tail call void @_Z38TestWaitDiscriminativenessWithStealingv()
  %1 = load i32, ptr @_ZL9MinThread, align 4, !tbaa !5
  %2 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %.not12 = icmp sgt i32 %1, %2
  br i1 %.not12, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  tail call void @_Z16TestWaitableTaskv()
  ret i32 0

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.013 = phi i32 [ %3, %.lr.ph ], [ %1, %0 ]
  tail call void @_Z17TestSpawnChildreni(i32 noundef %.013)
  tail call void @_Z17TestSpawnRootListi(i32 noundef %.013)
  tail call void @_Z20TestSafeContinuationi(i32 noundef %.013)
  tail call void @_Z17TestLeftRecursioni(i32 noundef %.013)
  tail call void @_Z7TestDagi(i32 noundef %.013)
  tail call void @_Z12TestAffinityi(i32 noundef %.013)
  tail call void @_Z14TestUserThreadi(i32 noundef %.013)
  tail call void @_Z14TestStealLimiti(i32 noundef %.013)
  tail call void @_Z20TestRelaxedOwnershipi(i32 noundef %.013)
  tail call void @_Z20TestMastersIsolationi(i32 noundef %.013)
  %3 = add nsw i32 %.013, 1
  %4 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.013, %4
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14TestStealLimiti(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17TestSpawnChildreni(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17TestSpawnRootListi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z20TestSafeContinuationi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12TestAffinityi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestNoteAffinityContextv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13TestAlignmentv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17TestLeftRecursioni(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7TestDagi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z20TestRelaxedOwnershipi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14TestUserThreadi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z30TestDispatchLoopResponsivenessv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z41TestWaitDiscriminativenessWithoutStealingv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z38TestWaitDiscriminativenessWithStealingv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z20TestMastersIsolationi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z16TestWaitableTaskv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestUnconstructibleTaskILm1EEvv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestUnconstructibleTaskILm10000EEvv() local_unnamed_addr #0

attributes #0 = { 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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