; LLVM IR from aras-p/ToyPathTracer :: Cpp/Source/enkiTS/TaskScheduler.ll (ZN4enki13TaskScheduler10WaitforAllEv)

; 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.TaskSchedulerWaitTask = type { %"class.enki::IPinnedTask" }
%"class.enki::IPinnedTask" = type { %"class.enki::ICompletable", i32, %"struct.std::atomic.5" }
%"class.enki::ICompletable" = type { ptr, i32, %"struct.std::atomic.0", %"struct.std::atomic.0", i32, %"struct.std::atomic.0", ptr }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i32 }
%"struct.std::atomic.5" = type { %"struct.std::__atomic_base.6" }
%"struct.std::__atomic_base.6" = type { ptr }
%"class.enki::TaskScheduler" = type <{ [3 x ptr], [3 x ptr], i32, [4 x i8], ptr, ptr, %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", i8, %"struct.std::atomic.0", %"struct.std::atomic.0", %"struct.std::atomic.0", i32, [4 x i8], ptr, ptr, i32, i8, [3 x i8], %"struct.enki::TaskSchedulerConfig", %"struct.std::atomic.0", [4 x i8] }>
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i8 }
%"struct.enki::TaskSchedulerConfig" = type { i32, i32, %"struct.enki::ProfilerCallbacks", %"struct.enki::CustomAllocator" }
%"struct.enki::ProfilerCallbacks" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.enki::CustomAllocator" = type { ptr, ptr, ptr }
%"struct.enki::ThreadDataStore" = type { ptr, %"struct.std::atomic.2", i32, [48 x i8] }
%"struct.std::atomic.2" = type { i32 }

@_ZL13gtl_threadNum = external hidden thread_local global i32, align 4
@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv = external hidden unnamed_addr constant [39 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [6 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4enki13TaskScheduler15GetIsRunningIntEv(ptr noundef nonnull align 8 dereferenceable(220)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4enki13TaskScheduler10TryRunTaskEjRj(ptr noundef nonnull align 8 dereferenceable(220), i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_18SpinWaitEj(i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext, i32 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4enki13TaskScheduler9HaveTasksEj(ptr noundef nonnull align 8 dereferenceable(220), i32 noundef) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4enki13TaskScheduler13AddPinnedTaskEPNS_11IPinnedTaskE(ptr noundef nonnull align 8 dereferenceable(220), ptr noundef) #5 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler10WaitforAllEv(ptr noundef nonnull align 8 dereferenceable(220) %0) #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca %class.TaskSchedulerWaitTask, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %18 = load ptr, ptr %2, align 8
  %19 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp ne i32 %20, -1
  br i1 %21, label %22, label %23

22:                                               ; preds = %1
  br label %25

23:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.3, i32 noundef 1039, ptr noundef @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv) #6
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  %26 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 8
  call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %26, i1 noundef zeroext true, i32 noundef 3) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #7
  store i8 1, ptr %3, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %27 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  %28 = load i32, ptr %27, align 4, !tbaa !9
  store i32 %28, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = add i32 %29, 1
  store i32 %30, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #7
  store i8 0, ptr %6, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 56, ptr %8) #7
  call void @_ZN21TaskSchedulerWaitTaskC2Ev(ptr noundef nonnull align 8 dereferenceable(56) %8) #7
  %31 = getelementptr inbounds %"class.enki::IPinnedTask", ptr %8, i32 0, i32 1
  store i32 0, ptr %31, align 8, !tbaa !13
  br label %32

32:                                               ; preds = %218, %25
  %33 = invoke noundef zeroext i1 @_ZNK4enki13TaskScheduler15GetIsRunningIntEv(ptr noundef nonnull align 8 dereferenceable(220) %18)
          to label %34 unwind label %55

34:                                               ; preds = %32
  br i1 %33, label %35, label %43

35:                                               ; preds = %34
  %36 = load i8, ptr %3, align 1, !tbaa !11, !range !21, !noundef !22
  %37 = trunc i8 %36 to i1
  br i1 %37, label %41, label %38

38:                                               ; preds = %35
  %39 = load i8, ptr %6, align 1, !tbaa !11, !range !21, !noundef !22
  %40 = trunc i8 %39 to i1
  br label %41

41:                                               ; preds = %38, %35
  %42 = phi i1 [ true, %35 ], [ %40, %38 ]
  br label %43

43:                                               ; preds = %41, %34
  %44 = phi i1 [ false, %34 ], [ %42, %41 ]
  br i1 %44, label %45, label %219

45:                                               ; preds = %43
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = invoke noundef zeroext i1 @_ZN4enki13TaskScheduler10TryRunTaskEjRj(ptr noundef nonnull align 8 dereferenceable(220) %18, i32 noundef %46, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %48 unwind label %55

48:                                               ; preds = %45
  %49 = zext i1 %47 to i8
  store i8 %49, ptr %3, align 1, !tbaa !11
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %7, align 4, !tbaa !9
  %52 = load i8, ptr %3, align 1, !tbaa !11, !range !21, !noundef !22
  %53 = trunc i8 %52 to i1
  br i1 %53, label %54, label %59

54:                                               ; preds = %48
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %59

55:                                               ; preds = %45, %32
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %9, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %10, align 4
  br label %221

59:                                               ; preds = %54, %48
  %60 = load i32, ptr %7, align 4, !tbaa !9
  %61 = icmp ugt i32 %60, 10
  br i1 %61, label %62, label %129

62:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %63 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 2
  %64 = load i32, ptr %63, align 8, !tbaa !23
  %65 = sub i32 %64, 1
  store i32 %65, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #7
  store i8 0, ptr %12, align 1, !tbaa !11
  br label %66

66:                                               ; preds = %107, %62
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = add nsw i32 %67, -1
  store i32 %68, ptr %11, align 4, !tbaa !9
  %69 = getelementptr inbounds %"class.enki::IPinnedTask", ptr %8, i32 0, i32 1
  %70 = load i32, ptr %69, align 8, !tbaa !13
  %71 = add i32 %70, 1
  %72 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 2
  %73 = load i32, ptr %72, align 8, !tbaa !23
  %74 = urem i32 %71, %73
  %75 = getelementptr inbounds %"class.enki::IPinnedTask", ptr %8, i32 0, i32 1
  store i32 %74, ptr %75, align 8, !tbaa !13
  %76 = getelementptr inbounds %"class.enki::IPinnedTask", ptr %8, i32 0, i32 1
  %77 = load i32, ptr %76, align 8, !tbaa !13
  %78 = load i32, ptr %4, align 4, !tbaa !9
  %79 = icmp ne i32 %77, %78
  br i1 %79, label %80, label %106

80:                                               ; preds = %66
  %81 = getelementptr inbounds %"class.enki::IPinnedTask", ptr %8, i32 0, i32 1
  %82 = load i32, ptr %81, align 8, !tbaa !13
  %83 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 20
  %84 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !30
  %86 = icmp ugt i32 %82, %85
  br i1 %86, label %87, label %106

87:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %88 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 4
  %89 = load ptr, ptr %88, align 8, !tbaa !31
  %90 = getelementptr inbounds %"class.enki::IPinnedTask", ptr %8, i32 0, i32 1
  %91 = load i32, ptr %90, align 8, !tbaa !13
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %89, i64 %92
  %94 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %93, i32 0, i32 1
  %95 = call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %94, i32 noundef 2) #7
  store i32 %95, ptr %13, align 4, !tbaa !32
  %96 = load i32, ptr %13, align 4, !tbaa !32
  %97 = icmp eq i32 %96, 2
  br i1 %97, label %101, label %98

98:                                               ; preds = %87
  %99 = load i32, ptr %13, align 4, !tbaa !32
  %100 = icmp eq i32 %99, 6
  br i1 %100, label %101, label %102

101:                                              ; preds = %98, %87
  store i8 1, ptr %12, align 1, !tbaa !11
  store i32 4, ptr %14, align 4
  br label %103

102:                                              ; preds = %98
  store i32 0, ptr %14, align 4
  br label %103

103:                                              ; preds = %102, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  %104 = load i32, ptr %14, align 4
  switch i32 %104, label %227 [
    i32 0, label %105
    i32 4, label %110
  ]

105:                                              ; preds = %103
  br label %106

106:                                              ; preds = %105, %80, %66
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %11, align 4, !tbaa !9
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %66, label %110, !llvm.loop !34

110:                                              ; preds = %107, %103
  %111 = load i8, ptr %12, align 1, !tbaa !11, !range !21, !noundef !22
  %112 = trunc i8 %111 to i1
  br i1 %112, label %113, label %128

113:                                              ; preds = %110
  %114 = getelementptr inbounds %"class.enki::IPinnedTask", ptr %8, i32 0, i32 1
  %115 = load i32, ptr %114, align 8, !tbaa !13
  %116 = load i32, ptr %4, align 4, !tbaa !9
  %117 = icmp ne i32 %115, %116
  br i1 %117, label %118, label %119

118:                                              ; preds = %113
  br label %121

119:                                              ; preds = %113
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.3, i32 noundef 1082, ptr noundef @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv) #6
  unreachable

120:                                              ; No predecessors!
  br label %121

121:                                              ; preds = %120, %118
  invoke void @_ZN4enki13TaskScheduler13AddPinnedTaskEPNS_11IPinnedTaskE(ptr noundef nonnull align 8 dereferenceable(220) %18, ptr noundef %8)
          to label %122 unwind label %124

122:                                              ; preds = %121
  invoke void @_ZN4enki13TaskScheduler11WaitforTaskEPKNS_12ICompletableENS_12TaskPriorityE(ptr noundef nonnull align 8 dereferenceable(220) %18, ptr noundef %8, i32 noundef 2)
          to label %123 unwind label %124

123:                                              ; preds = %122
  br label %128

124:                                              ; preds = %122, %121
  %125 = landingpad { ptr, i32 }
          cleanup
  %126 = extractvalue { ptr, i32 } %125, 0
  store ptr %126, ptr %9, align 8
  %127 = extractvalue { ptr, i32 } %125, 1
  store i32 %127, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %221

128:                                              ; preds = %123, %110
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %138

129:                                              ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %130 = load i32, ptr %7, align 4, !tbaa !9
  %131 = mul i32 %130, 100
  store i32 %131, ptr %15, align 4, !tbaa !9
  %132 = load i32, ptr %15, align 4, !tbaa !9
  invoke void @_ZN12_GLOBAL__N_18SpinWaitEj(i32 noundef %132)
          to label %133 unwind label %134

133:                                              ; preds = %129
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %138

134:                                              ; preds = %129
  %135 = landingpad { ptr, i32 }
          cleanup
  %136 = extractvalue { ptr, i32 } %135, 0
  store ptr %136, ptr %9, align 8
  %137 = extractvalue { ptr, i32 } %135, 1
  store i32 %137, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %221

138:                                              ; preds = %133, %128
  store i8 0, ptr %6, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %139

139:                                              ; preds = %181, %138
  %140 = load i32, ptr %16, align 4, !tbaa !9
  %141 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 2
  %142 = load i32, ptr %141, align 8, !tbaa !23
  %143 = icmp ult i32 %140, %142
  br i1 %143, label %144, label %148

144:                                              ; preds = %139
  %145 = load i8, ptr %6, align 1, !tbaa !11, !range !21, !noundef !22
  %146 = trunc i8 %145 to i1
  %147 = xor i1 %146, true
  br label %148

148:                                              ; preds = %144, %139
  %149 = phi i1 [ false, %139 ], [ %147, %144 ]
  br i1 %149, label %151, label %150

150:                                              ; preds = %148
  store i32 6, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %184

151:                                              ; preds = %148
  %152 = load i32, ptr %16, align 4, !tbaa !9
  %153 = load i32, ptr %4, align 4, !tbaa !9
  %154 = icmp ne i32 %152, %153
  br i1 %154, label %155, label %180

155:                                              ; preds = %151
  %156 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 4
  %157 = load ptr, ptr %156, align 8, !tbaa !31
  %158 = load i32, ptr %16, align 4, !tbaa !9
  %159 = zext i32 %158 to i64
  %160 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %157, i64 %159
  %161 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %160, i32 0, i32 1
  %162 = call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %161, i32 noundef 2) #7
  switch i32 %162, label %179 [
    i32 0, label %163
    i32 1, label %164
    i32 2, label %164
    i32 6, label %164
    i32 8, label %165
    i32 3, label %178
    i32 4, label %178
    i32 5, label %178
    i32 7, label %178
    i32 9, label %178
  ]

163:                                              ; preds = %155
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.3, i32 noundef 1104, ptr noundef @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv) #6
  unreachable

164:                                              ; preds = %155, %155, %155
  store i8 1, ptr %6, align 1, !tbaa !11
  br label %179

165:                                              ; preds = %155
  store i8 1, ptr %6, align 1, !tbaa !11
  %166 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 4
  %167 = load ptr, ptr %166, align 8, !tbaa !31
  %168 = load i32, ptr %16, align 4, !tbaa !9
  %169 = zext i32 %168 to i64
  %170 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %167, i64 %169
  %171 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %170, i32 0, i32 0
  %172 = load ptr, ptr %171, align 64, !tbaa !36
  invoke void @_ZN4enki15SemaphoreSignalERNS_13semaphoreid_tEi(ptr noundef nonnull align 1 %172, i32 noundef 1)
          to label %173 unwind label %174

173:                                              ; preds = %165
  br label %179

174:                                              ; preds = %165
  %175 = landingpad { ptr, i32 }
          cleanup
  %176 = extractvalue { ptr, i32 } %175, 0
  store ptr %176, ptr %9, align 8
  %177 = extractvalue { ptr, i32 } %175, 1
  store i32 %177, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %221

178:                                              ; preds = %155, %155, %155, %155, %155
  br label %179

179:                                              ; preds = %178, %173, %164, %155
  br label %180

180:                                              ; preds = %179, %151
  br label %181

181:                                              ; preds = %180
  %182 = load i32, ptr %16, align 4, !tbaa !9
  %183 = add i32 %182, 1
  store i32 %183, ptr %16, align 4, !tbaa !9
  br label %139, !llvm.loop !39

184:                                              ; preds = %150
  %185 = load i8, ptr %6, align 1, !tbaa !11, !range !21, !noundef !22
  %186 = trunc i8 %185 to i1
  br i1 %186, label %218, label %187

187:                                              ; preds = %184
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %188

188:                                              ; preds = %214, %187
  %189 = load i32, ptr %17, align 4, !tbaa !9
  %190 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 2
  %191 = load i32, ptr %190, align 8, !tbaa !23
  %192 = icmp ult i32 %189, %191
  br i1 %192, label %193, label %197

193:                                              ; preds = %188
  %194 = load i8, ptr %6, align 1, !tbaa !11, !range !21, !noundef !22
  %195 = trunc i8 %194 to i1
  %196 = xor i1 %195, true
  br label %197

197:                                              ; preds = %193, %188
  %198 = phi i1 [ false, %188 ], [ %196, %193 ]
  br i1 %198, label %200, label %199

199:                                              ; preds = %197
  store i32 10, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %217

200:                                              ; preds = %197
  %201 = load i32, ptr %17, align 4, !tbaa !9
  %202 = load i32, ptr %4, align 4, !tbaa !9
  %203 = icmp ne i32 %201, %202
  br i1 %203, label %204, label %213

204:                                              ; preds = %200
  %205 = load i32, ptr %17, align 4, !tbaa !9
  %206 = invoke noundef zeroext i1 @_ZN4enki13TaskScheduler9HaveTasksEj(ptr noundef nonnull align 8 dereferenceable(220) %18, i32 noundef %205)
          to label %207 unwind label %209

207:                                              ; preds = %204
  %208 = zext i1 %206 to i8
  store i8 %208, ptr %6, align 1, !tbaa !11
  br label %213

209:                                              ; preds = %204
  %210 = landingpad { ptr, i32 }
          cleanup
  %211 = extractvalue { ptr, i32 } %210, 0
  store ptr %211, ptr %9, align 8
  %212 = extractvalue { ptr, i32 } %210, 1
  store i32 %212, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %221

213:                                              ; preds = %207, %200
  br label %214

214:                                              ; preds = %213
  %215 = load i32, ptr %17, align 4, !tbaa !9
  %216 = add i32 %215, 1
  store i32 %216, ptr %17, align 4, !tbaa !9
  br label %188, !llvm.loop !40

217:                                              ; preds = %199
  br label %218

218:                                              ; preds = %217, %184
  br label %32, !llvm.loop !41

219:                                              ; preds = %43
  %220 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %18, i32 0, i32 8
  call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %220, i1 noundef zeroext false, i32 noundef 3) #7
  call void @_ZN4enki12ICompletableD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %8) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #7
  ret void

221:                                              ; preds = %209, %174, %134, %124, %55
  call void @_ZN4enki12ICompletableD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %8) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #7
  br label %222

222:                                              ; preds = %221
  %223 = load ptr, ptr %9, align 8
  %224 = load i32, ptr %10, align 4
  %225 = insertvalue { ptr, i32 } poison, ptr %223, 0
  %226 = insertvalue { ptr, i32 } %225, i32 %224, 1
  resume { ptr, i32 } %226

227:                                              ; preds = %103
  unreachable
}

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

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

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = { 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 #6 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 40}
!14 = !{!"_ZTSN4enki11IPinnedTaskE", !15, i64 0, !10, i64 40, !19, i64 48}
!15 = !{!"_ZTSN4enki12ICompletableE", !16, i64 8, !17, i64 12, !17, i64 16, !10, i64 20, !17, i64 24, !6, i64 32}
!16 = !{!"_ZTSN4enki12TaskPriorityE", !7, i64 0}
!17 = !{!"_ZTSSt6atomicIiE", !18, i64 0}
!18 = !{!"_ZTSSt13__atomic_baseIiE", !10, i64 0}
!19 = !{!"_ZTSSt6atomicIPN4enki11IPinnedTaskEE", !20, i64 0}
!20 = !{!"_ZTSSt13__atomic_baseIPN4enki11IPinnedTaskEE", !6, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!24, !10, i64 48}
!24 = !{!"_ZTSN4enki13TaskSchedulerE", !7, i64 0, !7, i64 24, !10, i64 48, !6, i64 56, !6, i64 64, !25, i64 72, !25, i64 73, !25, i64 74, !17, i64 76, !17, i64 80, !17, i64 84, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !12, i64 116, !27, i64 120, !17, i64 216}
!25 = !{!"_ZTSSt6atomicIbE", !26, i64 0}
!26 = !{!"_ZTSSt13__atomic_baseIbE", !12, i64 0}
!27 = !{!"_ZTSN4enki19TaskSchedulerConfigE", !10, i64 0, !10, i64 4, !28, i64 8, !29, i64 72}
!28 = !{!"_ZTSN4enki17ProfilerCallbacksE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!29 = !{!"_ZTSN4enki15CustomAllocatorE", !6, i64 0, !6, i64 8, !6, i64 16}
!30 = !{!24, !10, i64 124}
!31 = !{!24, !6, i64 56}
!32 = !{!33, !33, i64 0}
!33 = !{!"_ZTSN4enki11ThreadStateE", !7, i64 0}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = !{!37, !6, i64 0}
!37 = !{!"_ZTSN4enki15ThreadDataStoreE", !6, i64 0, !38, i64 8, !10, i64 12, !7, i64 16}
!38 = !{!"_ZTSSt6atomicIN4enki11ThreadStateEE", !33, i64 0}
!39 = distinct !{!39, !35}
!40 = distinct !{!40, !35}
!41 = distinct !{!41, !35}


; 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.TaskSchedulerWaitTask = type { %"class.enki::IPinnedTask" }
%"class.enki::IPinnedTask" = type { %"class.enki::ICompletable", i32, %"struct.std::atomic.5" }
%"class.enki::ICompletable" = type { ptr, i32, %"struct.std::atomic.0", %"struct.std::atomic.0", i32, %"struct.std::atomic.0", ptr }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i32 }
%"struct.std::atomic.5" = type { %"struct.std::__atomic_base.6" }
%"struct.std::__atomic_base.6" = type { ptr }
%"struct.enki::ThreadDataStore" = type { ptr, %"struct.std::atomic.2", i32, [48 x i8] }
%"struct.std::atomic.2" = type { i32 }

@_ZL13gtl_threadNum = external hidden thread_local local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv = external hidden unnamed_addr constant [39 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [6 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4enki13TaskScheduler15GetIsRunningIntEv(ptr noundef nonnull align 8 dereferenceable(220)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4enki13TaskScheduler10TryRunTaskEjRj(ptr noundef nonnull align 8 dereferenceable(220), i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_18SpinWaitEj(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext, i32 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4enki13TaskScheduler9HaveTasksEj(ptr noundef nonnull align 8 dereferenceable(220), i32 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4enki13TaskScheduler13AddPinnedTaskEPNS_11IPinnedTaskE(ptr noundef nonnull align 8 dereferenceable(220), ptr noundef) local_unnamed_addr #5 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler10WaitforAllEv(ptr noundef nonnull align 8 dereferenceable(220) %0) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca %class.TaskSchedulerWaitTask, align 8
  %4 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, -1
  br i1 %.not, label %6, label %7

6:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.3, i32 noundef 1039, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv) #6
  unreachable

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 74
  tail call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %8, i1 noundef zeroext true, i32 noundef 3) #7
  %9 = load i32, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %10 = add i32 %9, 1
  store i32 %10, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %3) #7
  call void @_ZN21TaskSchedulerWaitTaskC2Ev(ptr noundef nonnull align 8 dereferenceable(56) %3) #7
  %11 = getelementptr inbounds i8, ptr %3, i64 40
  store i32 0, ptr %11, align 8, !tbaa !9
  %12 = call noundef zeroext i1 @_ZNK4enki13TaskScheduler15GetIsRunningIntEv(ptr noundef nonnull align 8 dereferenceable(220) %0)
  br i1 %12, label %.lr.ph82, label %.critedge

.lr.ph82:                                         ; preds = %7
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = getelementptr inbounds i8, ptr %0, i64 124
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  %16 = zext i32 %9 to i64
  br label %17

17:                                               ; preds = %.lr.ph82, %.loopexit
  %.04580 = phi i32 [ 0, %.lr.ph82 ], [ %.146, %.loopexit ]
  %18 = invoke noundef zeroext i1 @_ZN4enki13TaskScheduler10TryRunTaskEjRj(ptr noundef nonnull align 8 dereferenceable(220) %0, i32 noundef %9, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %19 unwind label %22

19:                                               ; preds = %17
  %20 = add i32 %.04580, 1
  %spec.store.select = select i1 %18, i32 0, i32 %20
  %21 = icmp ugt i32 %spec.store.select, 10
  br i1 %21, label %24, label %48

22:                                               ; preds = %17
  %23 = landingpad { ptr, i32 }
          cleanup
  br label %79

24:                                               ; preds = %19
  %25 = load i32, ptr %13, align 8, !tbaa !18
  %26 = add i32 %25, -1
  br label %27

27:                                               ; preds = %41, %24
  %.042 = phi i32 [ %26, %24 ], [ %28, %41 ]
  %28 = add nsw i32 %.042, -1
  %29 = load i32, ptr %11, align 8, !tbaa !9
  %30 = add i32 %29, 1
  %31 = load i32, ptr %13, align 8, !tbaa !18
  %32 = urem i32 %30, %31
  store i32 %32, ptr %11, align 8, !tbaa !9
  %.not49 = icmp ne i32 %32, %9
  %33 = load i32, ptr %14, align 4
  %34 = icmp ugt i32 %32, %33
  %or.cond63 = select i1 %.not49, i1 %34, i1 false
  br i1 %or.cond63, label %35, label %41

35:                                               ; preds = %27
  %36 = load ptr, ptr %15, align 8, !tbaa !26
  %37 = zext i32 %32 to i64
  %38 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %36, i64 %37, i32 1
  %39 = call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %38, i32 noundef 2) #7
  %40 = and i32 %39, -5
  %or.cond = icmp eq i32 %40, 2
  br i1 %or.cond, label %.critedge65, label %41

41:                                               ; preds = %35, %27
  %.not50 = icmp eq i32 %28, 0
  br i1 %.not50, label %.loopexit66, label %27, !llvm.loop !27

.critedge65:                                      ; preds = %35
  %42 = load i32, ptr %11, align 8, !tbaa !9
  %.not51 = icmp eq i32 %42, %9
  br i1 %.not51, label %43, label %44

43:                                               ; preds = %.critedge65
  call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.3, i32 noundef 1082, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv) #6
  unreachable

44:                                               ; preds = %.critedge65
  invoke void @_ZN4enki13TaskScheduler13AddPinnedTaskEPNS_11IPinnedTaskE(ptr noundef nonnull align 8 dereferenceable(220) %0, ptr noundef nonnull %3)
          to label %45 unwind label %46

45:                                               ; preds = %44
  invoke void @_ZN4enki13TaskScheduler11WaitforTaskEPKNS_12ICompletableENS_12TaskPriorityE(ptr noundef nonnull align 8 dereferenceable(220) %0, ptr noundef nonnull %3, i32 noundef 2)
          to label %.loopexit66 unwind label %46

46:                                               ; preds = %45, %44
  %47 = landingpad { ptr, i32 }
          cleanup
  br label %79

48:                                               ; preds = %19
  %49 = mul nuw nsw i32 %spec.store.select, 100
  call void @_ZN12_GLOBAL__N_18SpinWaitEj(i32 noundef %49)
  br label %.loopexit66

.loopexit66:                                      ; preds = %41, %45, %48
  %.146 = phi i32 [ %spec.store.select, %48 ], [ 0, %45 ], [ 0, %41 ]
  %50 = load i32, ptr %13, align 8, !tbaa !18
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %.loopexit, label %.lr.ph

.preheader:                                       ; preds = %62
  %52 = icmp eq i32 %63, 0
  br i1 %52, label %.loopexit, label %.lr.ph78

.lr.ph:                                           ; preds = %.loopexit66, %62
  %indvars.iv = phi i64 [ %indvars.iv.next, %62 ], [ 0, %.loopexit66 ]
  %.not58 = icmp eq i64 %indvars.iv, %16
  br i1 %.not58, label %62, label %53

53:                                               ; preds = %.lr.ph
  %54 = load ptr, ptr %15, align 8, !tbaa !26
  %55 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %54, i64 %indvars.iv, i32 1
  %56 = call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %55, i32 noundef 2) #7
  switch i32 %56, label %62 [
    i32 0, label %57
    i32 1, label %.loopexit
    i32 2, label %.loopexit
    i32 6, label %.loopexit
    i32 8, label %58
  ]

57:                                               ; preds = %53
  call void @__assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.3, i32 noundef 1104, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler10WaitforAllEv) #6
  unreachable

58:                                               ; preds = %53
  %59 = load ptr, ptr %15, align 8, !tbaa !26
  %60 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %59, i64 %indvars.iv
  %61 = load ptr, ptr %60, align 64, !tbaa !29
  call void @_ZN4enki15SemaphoreSignalERNS_13semaphoreid_tEi(ptr noundef nonnull align 1 %61, i32 noundef 1)
  br label %.loopexit

62:                                               ; preds = %.lr.ph, %53
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %63 = load i32, ptr %13, align 8, !tbaa !18
  %64 = zext i32 %63 to i64
  %.not102 = icmp ult i64 %indvars.iv.next, %64
  br i1 %.not102, label %.lr.ph, label %.preheader, !llvm.loop !33

.lr.ph78:                                         ; preds = %.preheader, %72
  %65 = phi i32 [ %73, %72 ], [ %63, %.preheader ]
  %.077 = phi i32 [ %74, %72 ], [ 0, %.preheader ]
  %.376 = phi i8 [ %.4, %72 ], [ 0, %.preheader ]
  %.not56 = icmp eq i32 %.077, %9
  br i1 %.not56, label %72, label %66

66:                                               ; preds = %.lr.ph78
  %67 = invoke noundef zeroext i1 @_ZN4enki13TaskScheduler9HaveTasksEj(ptr noundef nonnull align 8 dereferenceable(220) %0, i32 noundef %.077)
          to label %68 unwind label %70

68:                                               ; preds = %66
  %69 = zext i1 %67 to i8
  %.pre = load i32, ptr %13, align 8, !tbaa !18
  br label %72

70:                                               ; preds = %66
  %71 = landingpad { ptr, i32 }
          cleanup
  br label %79

72:                                               ; preds = %.lr.ph78, %68
  %73 = phi i32 [ %.pre, %68 ], [ %65, %.lr.ph78 ]
  %.4 = phi i8 [ %69, %68 ], [ %.376, %.lr.ph78 ]
  %74 = add nuw i32 %.077, 1
  %75 = icmp uge i32 %74, %73
  %76 = trunc nuw i8 %.4 to i1
  %.not55 = select i1 %75, i1 true, i1 %76
  br i1 %.not55, label %.loopexit, label %.lr.ph78, !llvm.loop !34

.loopexit:                                        ; preds = %53, %53, %53, %72, %58, %.loopexit66, %.preheader
  %.pre-phi = phi i1 [ false, %.preheader ], [ false, %.loopexit66 ], [ true, %58 ], [ %76, %72 ], [ true, %53 ], [ true, %53 ], [ true, %53 ]
  %77 = call noundef zeroext i1 @_ZNK4enki13TaskScheduler15GetIsRunningIntEv(ptr noundef nonnull align 8 dereferenceable(220) %0)
  %78 = select i1 %18, i1 true, i1 %.pre-phi
  %or.cond60 = select i1 %77, i1 %78, i1 false
  br i1 %or.cond60, label %17, label %.critedge, !llvm.loop !35

.critedge:                                        ; preds = %.loopexit, %7
  call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %8, i1 noundef zeroext false, i32 noundef 3) #7
  call void @_ZN4enki12ICompletableD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %3) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  ret void

79:                                               ; preds = %70, %46, %22
  %.pn = phi { ptr, i32 } [ %71, %70 ], [ %47, %46 ], [ %23, %22 ]
  call void @_ZN4enki12ICompletableD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %3) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  resume { ptr, i32 } %.pn
}

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

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

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = { 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 #6 = { noreturn nounwind }
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, !6, i64 40}
!10 = !{!"_ZTSN4enki11IPinnedTaskE", !11, i64 0, !6, i64 40, !16, i64 48}
!11 = !{!"_ZTSN4enki12ICompletableE", !12, i64 8, !13, i64 12, !13, i64 16, !6, i64 20, !13, i64 24, !15, i64 32}
!12 = !{!"_ZTSN4enki12TaskPriorityE", !7, i64 0}
!13 = !{!"_ZTSSt6atomicIiE", !14, i64 0}
!14 = !{!"_ZTSSt13__atomic_baseIiE", !6, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!"_ZTSSt6atomicIPN4enki11IPinnedTaskEE", !17, i64 0}
!17 = !{!"_ZTSSt13__atomic_baseIPN4enki11IPinnedTaskEE", !15, i64 0}
!18 = !{!19, !6, i64 48}
!19 = !{!"_ZTSN4enki13TaskSchedulerE", !7, i64 0, !7, i64 24, !6, i64 48, !15, i64 56, !15, i64 64, !20, i64 72, !20, i64 73, !20, i64 74, !13, i64 76, !13, i64 80, !13, i64 84, !6, i64 88, !15, i64 96, !15, i64 104, !6, i64 112, !22, i64 116, !23, i64 120, !13, i64 216}
!20 = !{!"_ZTSSt6atomicIbE", !21, i64 0}
!21 = !{!"_ZTSSt13__atomic_baseIbE", !22, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{!"_ZTSN4enki19TaskSchedulerConfigE", !6, i64 0, !6, i64 4, !24, i64 8, !25, i64 72}
!24 = !{!"_ZTSN4enki17ProfilerCallbacksE", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56}
!25 = !{!"_ZTSN4enki15CustomAllocatorE", !15, i64 0, !15, i64 8, !15, i64 16}
!26 = !{!19, !15, i64 56}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!30, !15, i64 0}
!30 = !{!"_ZTSN4enki15ThreadDataStoreE", !15, i64 0, !31, i64 8, !6, i64 12, !7, i64 16}
!31 = !{!"_ZTSSt6atomicIN4enki11ThreadStateEE", !32, i64 0}
!32 = !{!"_ZTSN4enki11ThreadStateE", !7, i64 0}
!33 = distinct !{!33, !28}
!34 = distinct !{!34, !28}
!35 = distinct !{!35, !28}


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