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

; 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 { i32 }
%"class.tbb::task_scheduler_init" = type { ptr }
%"class.tbb::internal::allocate_root_proxy" = type { i8 }

@.str.17 = external hidden unnamed_addr constant [85 x i8], align 1
@TotalCount = external dso_local global %"struct.tbb::atomic", align 4
@.str.23 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [5 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 nounwind uwtable
declare dso_local noundef ptr @_Z10GetTaskPtrRi(ptr noundef nonnull align 4 dereferenceable(4)) #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 #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3tbb4task13allocate_rootEv() #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZnwmRKN3tbb8internal19allocate_root_proxyE(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZdlPvRKN3tbb8internal19allocate_root_proxyE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #4

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12TestAffinityi(i32 noundef %0) #1 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.tbb::task_scheduler_init", align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.tbb::internal::allocate_root_proxy", align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.tbb::internal::allocate_root_proxy", align 1
  %10 = alloca i16, align 2
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %13 = call noundef i32 @_ZN3tbb6atomicIiEaSEi(ptr noundef nonnull align 4 dereferenceable(4) @TotalCount, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %14 = call noundef i32 @_ZN3tbb19task_scheduler_init19default_num_threadsEv()
  store i32 %14, ptr %3, align 4, !tbaa !5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = icmp sgt i32 %15, %16
  br i1 %17, label %18, label %20

18:                                               ; preds = %1
  %19 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %19, ptr %3, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %18, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %21 = load i32, ptr %3, align 4, !tbaa !5
  call void @_ZN3tbb19task_scheduler_initC2Eim(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %21, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #7
  invoke void @_ZN3tbb4task13allocate_rootEv()
          to label %22 unwind label %44

22:                                               ; preds = %20
  %23 = invoke noundef ptr @_ZnwmRKN3tbb8internal19allocate_root_proxyE(i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %24 unwind label %44

24:                                               ; preds = %22
  invoke void @_ZN3tbb10empty_taskC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %23)
          to label %25 unwind label %48

25:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  store ptr %23, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #7
  %26 = load ptr, ptr %5, align 8, !tbaa !9
  %27 = invoke noundef zeroext i16 @_ZNK3tbb4task8affinityEv(ptr noundef nonnull align 8 dereferenceable(8) %26)
          to label %28 unwind label %53

28:                                               ; preds = %25
  store i16 %27, ptr %10, align 2, !tbaa !11
  %29 = load i16, ptr %10, align 2, !tbaa !11
  %30 = zext i16 %29 to i32
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  br label %35

33:                                               ; preds = %28
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.17, i32 noundef 212, ptr noundef @.str.23, ptr noundef null)
          to label %34 unwind label %53

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34, %32
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = load i32, ptr %3, align 4, !tbaa !5
  invoke void @_ZN3tbb4task13set_ref_countEi(ptr noundef nonnull align 8 dereferenceable(8) %36, i32 noundef %37)
          to label %38 unwind label %53

38:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %66, %38
  %40 = load i32, ptr %11, align 4, !tbaa !5
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %57, label %43

43:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %78

44:                                               ; preds = %22, %20
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %7, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %8, align 4
  br label %52

48:                                               ; preds = %24
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %7, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %8, align 4
  call void @_ZdlPvRKN3tbb8internal19allocate_root_proxyE(ptr noundef %23, ptr noundef nonnull align 1 dereferenceable(1) %6) #7
  br label %52

52:                                               ; preds = %48, %44
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  br label %108

53:                                               ; preds = %91, %82, %35, %33, %25
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %7, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %8, align 4
  br label %107

57:                                               ; preds = %39
  %58 = load ptr, ptr %5, align 8, !tbaa !9
  %59 = invoke noundef nonnull align 1 dereferenceable(1) ptr @_ZN3tbb4task14allocate_childEv(ptr noundef nonnull align 8 dereferenceable(8) %58)
          to label %60 unwind label %69

60:                                               ; preds = %57
  %61 = invoke noundef ptr @_ZnwmRKN3tbb8internal20allocate_child_proxyE(i64 noundef 16, ptr noundef nonnull align 1 dereferenceable(1) %59)
          to label %62 unwind label %69

62:                                               ; preds = %60
  %63 = load i32, ptr %11, align 4, !tbaa !5
  invoke void @_ZN12AffinityTaskC2Ei(ptr noundef nonnull align 8 dereferenceable(11) %61, i32 noundef %63)
          to label %64 unwind label %73

64:                                               ; preds = %62
  invoke void @_ZN3tbb10interface58internal9task_base5spawnERNS_4taskE(ptr noundef nonnull align 8 dereferenceable(8) %61)
          to label %65 unwind label %69

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %11, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %11, align 4, !tbaa !5
  br label %39, !llvm.loop !13

69:                                               ; preds = %64, %60, %57
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %7, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %8, align 4
  br label %77

73:                                               ; preds = %62
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %7, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %8, align 4
  call void @_ZdlPvRKN3tbb8internal20allocate_child_proxyE(ptr noundef %61, ptr noundef nonnull align 1 dereferenceable(1) %59) #7
  br label %77

77:                                               ; preds = %73, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %107

78:                                               ; preds = %43
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = icmp sgt i32 %79, 1
  br i1 %80, label %81, label %91

81:                                               ; preds = %78
  br label %82

82:                                               ; preds = %88, %81
  %83 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @TotalCount)
          to label %84 unwind label %53

84:                                               ; preds = %82
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = sub nsw i32 %85, 1
  %87 = icmp ne i32 %83, %86
  br i1 %87, label %88, label %90

88:                                               ; preds = %84
  %89 = call i32 @sched_yield() #7
  br label %82, !llvm.loop !15

90:                                               ; preds = %84
  br label %91

91:                                               ; preds = %90, %78
  %92 = load ptr, ptr %5, align 8, !tbaa !9
  invoke void @_ZN3tbb4task12wait_for_allEv(ptr noundef nonnull align 8 dereferenceable(8) %92)
          to label %93 unwind label %53

93:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  %94 = call noundef ptr @_Z10GetTaskPtrRi(ptr noundef nonnull align 4 dereferenceable(4) %12)
  %95 = load ptr, ptr %5, align 8, !tbaa !9
  invoke void @_ZN3tbb10interface58internal9task_base7destroyERNS_4taskE(ptr noundef nonnull align 8 dereferenceable(8) %95)
          to label %96 unwind label %103

96:                                               ; preds = %93
  %97 = load i32, ptr %12, align 4, !tbaa !5
  %98 = icmp eq i32 %97, 1
  br i1 %98, label %99, label %100

99:                                               ; preds = %96
  br label %102

100:                                              ; preds = %96
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str.17, i32 noundef 227, ptr noundef @.str.24, ptr noundef null)
          to label %101 unwind label %103

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101, %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  ret void

103:                                              ; preds = %100, %93
  %104 = landingpad { ptr, i32 }
          cleanup
  %105 = extractvalue { ptr, i32 } %104, 0
  store ptr %105, ptr %7, align 8
  %106 = extractvalue { ptr, i32 } %104, 1
  store i32 %106, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %107

107:                                              ; preds = %103, %77, %53
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #7
  br label %108

108:                                              ; preds = %107, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %109

109:                                              ; preds = %108
  %110 = load ptr, ptr %7, align 8
  %111 = load i32, ptr %8, align 4
  %112 = insertvalue { ptr, i32 } poison, ptr %110, 0
  %113 = insertvalue { ptr, i32 } %112, i32 %111, 1
  resume { ptr, i32 } %113
}

declare noundef i32 @_ZN3tbb19task_scheduler_init19default_num_threadsEv() #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb10empty_taskC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3tbb4task8affinityEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZnwmRKN3tbb8internal20allocate_child_proxyE(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZdlPvRKN3tbb8internal20allocate_child_proxyE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #4

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

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

declare void @_ZN3tbb10interface58internal9task_base7destroyERNS_4taskE(ptr noundef nonnull align 8 dereferenceable(8)) #5

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 = { 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 #4 = { inlinehint 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 #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 "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 #7 = { 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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"

%"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 { i32 }
%"class.tbb::task_scheduler_init" = type { ptr }
%"class.tbb::internal::allocate_root_proxy" = type { i8 }

@.str.17 = external hidden unnamed_addr constant [85 x i8], align 1
@TotalCount = external dso_local global %"struct.tbb::atomic", align 4
@.str.23 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [5 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 nounwind uwtable
declare dso_local noundef ptr @_Z10GetTaskPtrRi(ptr noundef nonnull align 4 dereferenceable(4)) 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 #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3tbb4task13allocate_rootEv() local_unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZnwmRKN3tbb8internal19allocate_root_proxyE(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZdlPvRKN3tbb8internal19allocate_root_proxyE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #4

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12TestAffinityi(i32 noundef %0) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.tbb::task_scheduler_init", align 8
  %3 = alloca %"class.tbb::internal::allocate_root_proxy", align 1
  %4 = alloca i32, align 4
  %5 = tail call noundef i32 @_ZN3tbb6atomicIiEaSEi(ptr noundef nonnull align 4 dereferenceable(4) @TotalCount, i32 noundef 0)
  %6 = tail call noundef i32 @_ZN3tbb19task_scheduler_init19default_num_threadsEv()
  %spec.select = tail call i32 @llvm.smin.i32(i32 %6, i32 %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  call void @_ZN3tbb19task_scheduler_initC2Eim(ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %spec.select, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #8
  call void @_ZN3tbb4task13allocate_rootEv()
  %7 = invoke noundef ptr @_ZnwmRKN3tbb8internal19allocate_root_proxyE(i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %8 unwind label %16

8:                                                ; preds = %1
  invoke void @_ZN3tbb10empty_taskC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %9 unwind label %18

9:                                                ; preds = %8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  %10 = call noundef zeroext i16 @_ZNK3tbb4task8affinityEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %11 = icmp eq i16 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.17, i32 noundef 212, ptr noundef nonnull @.str.23, ptr noundef null)
          to label %13 unwind label %.loopexit.split-lp

13:                                               ; preds = %12, %9
  call void @_ZN3tbb4task13set_ref_countEi(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef %spec.select)
  %14 = icmp sgt i32 %spec.select, 1
  br i1 %14, label %.lr.ph, label %.loopexit31

._crit_edge:                                      ; preds = %25
  br i1 %14, label %.preheader, label %.loopexit31

.preheader:                                       ; preds = %._crit_edge
  %15 = add nsw i32 %spec.select, -1
  br label %31

16:                                               ; preds = %1
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %20

18:                                               ; preds = %8
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvRKN3tbb8internal19allocate_root_proxyE(ptr noundef %7, ptr noundef nonnull align 1 dereferenceable(1) %3) #8
  br label %20

20:                                               ; preds = %18, %16
  %.pn = phi { ptr, i32 } [ %19, %18 ], [ %17, %16 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  br label %45

.loopexit:                                        ; preds = %31
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %45

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

.lr.ph:                                           ; preds = %13, %25
  %.034 = phi i32 [ %26, %25 ], [ 1, %13 ]
  %21 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN3tbb4task14allocate_childEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %22 = invoke noundef ptr @_ZnwmRKN3tbb8internal20allocate_child_proxyE(i64 noundef 16, ptr noundef nonnull align 1 dereferenceable(1) %21)
          to label %23 unwind label %27

23:                                               ; preds = %.lr.ph
  invoke void @_ZN12AffinityTaskC2Ei(ptr noundef nonnull align 8 dereferenceable(11) %22, i32 noundef %.034)
          to label %24 unwind label %29

24:                                               ; preds = %23
  invoke void @_ZN3tbb10interface58internal9task_base5spawnERNS_4taskE(ptr noundef nonnull align 8 dereferenceable(8) %22)
          to label %25 unwind label %27

25:                                               ; preds = %24
  %26 = add nuw nsw i32 %.034, 1
  %exitcond.not = icmp eq i32 %26, %spec.select
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

27:                                               ; preds = %24, %.lr.ph
  %28 = landingpad { ptr, i32 }
          cleanup
  br label %45

29:                                               ; preds = %23
  %30 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvRKN3tbb8internal20allocate_child_proxyE(ptr noundef %22, ptr noundef nonnull align 1 dereferenceable(1) %21) #8
  br label %45

31:                                               ; preds = %.preheader, %34
  %32 = invoke noundef i32 @_ZNVK3tbb8internal11atomic_implIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) @TotalCount)
          to label %33 unwind label %.loopexit

33:                                               ; preds = %31
  %.not = icmp eq i32 %32, %15
  br i1 %.not, label %.loopexit31, label %34

34:                                               ; preds = %33
  %35 = call i32 @sched_yield() #8
  br label %31, !llvm.loop !7

.loopexit31:                                      ; preds = %33, %13, %._crit_edge
  invoke void @_ZN3tbb4task12wait_for_allEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %36 unwind label %.loopexit.split-lp

36:                                               ; preds = %.loopexit31
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  store i32 0, ptr %4, align 4, !tbaa !8
  %37 = call noundef ptr @_Z10GetTaskPtrRi(ptr noundef nonnull align 4 dereferenceable(4) %4)
  invoke void @_ZN3tbb10interface58internal9task_base7destroyERNS_4taskE(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %38 unwind label %43

38:                                               ; preds = %36
  %39 = load i32, ptr %4, align 4, !tbaa !8
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  invoke void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str.17, i32 noundef 227, ptr noundef nonnull @.str.24, ptr noundef null)
          to label %42 unwind label %43

42:                                               ; preds = %41, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  ret void

43:                                               ; preds = %41, %36
  %44 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  br label %45

45:                                               ; preds = %.loopexit, %.loopexit.split-lp, %43, %29, %27, %20
  %.pn27.pn.pn = phi { ptr, i32 } [ %.pn, %20 ], [ %44, %43 ], [ %28, %27 ], [ %30, %29 ], [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @_ZN3tbb19task_scheduler_initD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  resume { ptr, i32 } %.pn27.pn.pn
}

declare noundef i32 @_ZN3tbb19task_scheduler_init19default_num_threadsEv() local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb10empty_taskC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3tbb4task8affinityEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZnwmRKN3tbb8internal20allocate_child_proxyE(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZdlPvRKN3tbb8internal20allocate_child_proxyE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #4

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

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

declare void @_ZN3tbb10interface58internal9task_base7destroyERNS_4taskE(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #7

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 = { 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 #4 = { inlinehint 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 #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 "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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass