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

; 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.std::thread" = type { %"class.std::thread::id" }
%"class.std::thread::id" = type { i64 }
%"struct.enki::ThreadArgs" = type { i32, 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.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i32 }
%"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
@_ZN12_GLOBAL__N_17gc_FileE = external hidden global ptr, align 8
@_ZN4enkiL26gc_MaxNumInitialPartitionsE = external hidden constant 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 nounwind uwtable
declare dso_local noundef i32 @_ZN4enki21GetNumHardwareThreadsEv() #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv() #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler12StartThreadsEv(ptr noundef nonnull align 8 dereferenceable(220) %0) #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"class.std::thread", align 8
  %9 = alloca %"struct.enki::ThreadArgs", align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %15 = load ptr, ptr %2, align 8
  %16 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 18
  %17 = load i8, ptr %16, align 4, !tbaa !9, !range !20, !noundef !21
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %20

19:                                               ; preds = %1
  br label %213

20:                                               ; preds = %1
  %21 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 20
  %22 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !22
  %24 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 20
  %25 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !23
  %27 = add i32 %23, %26
  %28 = add i32 %27, 1
  %29 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  store i32 %28, ptr %29, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !25
  br label %30

30:                                               ; preds = %53, %20
  %31 = load i32, ptr %3, align 4, !tbaa !25
  %32 = icmp slt i32 %31, 3
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %56

34:                                               ; preds = %30
  %35 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %36 = load i32, ptr %35, align 8, !tbaa !24
  %37 = zext i32 %36 to i64
  %38 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !5
  %39 = call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_8TaskPipeEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %15, i64 noundef %37, ptr noundef %38, i32 noundef 0)
  %40 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 0
  %41 = load i32, ptr %3, align 4, !tbaa !25
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [3 x ptr], ptr %40, i64 0, i64 %42
  store ptr %39, ptr %43, align 8, !tbaa !5
  %44 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %45 = load i32, ptr %44, align 8, !tbaa !24
  %46 = zext i32 %45 to i64
  %47 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !5
  %48 = call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_14PinnedTaskListEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %15, i64 noundef %46, ptr noundef %47, i32 noundef 0)
  %49 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 1
  %50 = load i32, ptr %3, align 4, !tbaa !25
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [3 x ptr], ptr %49, i64 0, i64 %51
  store ptr %48, ptr %52, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %34
  %54 = load i32, ptr %3, align 4, !tbaa !25
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !25
  br label %30, !llvm.loop !26

56:                                               ; preds = %33
  %57 = call noundef ptr @_ZN4enki13TaskScheduler12SemaphoreNewEv(ptr noundef nonnull align 8 dereferenceable(220) %15)
  %58 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 15
  store ptr %57, ptr %58, align 8, !tbaa !28
  %59 = call noundef ptr @_ZN4enki13TaskScheduler12SemaphoreNewEv(ptr noundef nonnull align 8 dereferenceable(220) %15)
  %60 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 16
  store ptr %59, ptr %60, align 8, !tbaa !29
  %61 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !24
  %63 = zext i32 %62 to i64
  %64 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !5
  %65 = call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_15ThreadDataStoreEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %15, i64 noundef %63, ptr noundef %64, i32 noundef 0)
  %66 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 4
  store ptr %65, ptr %66, align 8, !tbaa !30
  %67 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !24
  %69 = zext i32 %68 to i64
  %70 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !5
  %71 = call noundef ptr @_ZN4enki13TaskScheduler8NewArrayISt6threadEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %15, i64 noundef %69, ptr noundef %70, i32 noundef 0)
  %72 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 5
  store ptr %71, ptr %72, align 8, !tbaa !31
  %73 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 6
  %74 = call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %73, i1 noundef zeroext true) #5
  %75 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 8
  %76 = call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %75, i1 noundef zeroext false) #5
  %77 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 7
  %78 = call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %77, i1 noundef zeroext false) #5
  %79 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 4
  %80 = load ptr, ptr %79, align 8, !tbaa !30
  %81 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %80, i64 0
  %82 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %81, i32 0, i32 1
  %83 = call noundef i32 @_ZNSt6atomicIN4enki11ThreadStateEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) %82, i32 noundef 3) #5
  %84 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  store i32 0, ptr %84, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %85 = call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  store i32 %85, ptr %4, align 4, !tbaa !25
  br label %86

86:                                               ; preds = %103, %56
  %87 = load i32, ptr %4, align 4, !tbaa !25
  %88 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 20
  %89 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !23
  %91 = call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %92 = add i32 %90, %91
  %93 = icmp ult i32 %87, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %106

95:                                               ; preds = %86
  %96 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 4
  %97 = load ptr, ptr %96, align 8, !tbaa !30
  %98 = load i32, ptr %4, align 4, !tbaa !25
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %97, i64 %99
  %101 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %100, i32 0, i32 1
  %102 = call noundef i32 @_ZNSt6atomicIN4enki11ThreadStateEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) %101, i32 noundef 5) #5
  br label %103

103:                                              ; preds = %95
  %104 = load i32, ptr %4, align 4, !tbaa !25
  %105 = add i32 %104, 1
  store i32 %105, ptr %4, align 4, !tbaa !25
  br label %86, !llvm.loop !32

106:                                              ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %107 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 20
  %108 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !23
  %110 = call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %111 = add i32 %109, %110
  store i32 %111, ptr %5, align 4, !tbaa !25
  br label %112

112:                                              ; preds = %126, %106
  %113 = load i32, ptr %5, align 4, !tbaa !25
  %114 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %115 = load i32, ptr %114, align 8, !tbaa !24
  %116 = icmp ult i32 %113, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %112
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %129

118:                                              ; preds = %112
  %119 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 4
  %120 = load ptr, ptr %119, align 8, !tbaa !30
  %121 = load i32, ptr %5, align 4, !tbaa !25
  %122 = zext i32 %121 to i64
  %123 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %120, i64 %122
  %124 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %123, i32 0, i32 1
  %125 = call noundef i32 @_ZNSt6atomicIN4enki11ThreadStateEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) %124, i32 noundef 1) #5
  br label %126

126:                                              ; preds = %118
  %127 = load i32, ptr %5, align 4, !tbaa !25
  %128 = add i32 %127, 1
  store i32 %128, ptr %5, align 4, !tbaa !25
  br label %112, !llvm.loop !33

129:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !25
  br label %130

130:                                              ; preds = %151, %129
  %131 = load i32, ptr %6, align 4, !tbaa !25
  %132 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %133 = load i32, ptr %132, align 8, !tbaa !24
  %134 = icmp ult i32 %131, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %154

136:                                              ; preds = %130
  %137 = call noundef ptr @_ZN4enki13TaskScheduler12SemaphoreNewEv(ptr noundef nonnull align 8 dereferenceable(220) %15)
  %138 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 4
  %139 = load ptr, ptr %138, align 8, !tbaa !30
  %140 = load i32, ptr %6, align 4, !tbaa !25
  %141 = zext i32 %140 to i64
  %142 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %139, i64 %141
  %143 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %142, i32 0, i32 0
  store ptr %137, ptr %143, align 64, !tbaa !34
  %144 = load i32, ptr %6, align 4, !tbaa !25
  %145 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 4
  %146 = load ptr, ptr %145, align 8, !tbaa !30
  %147 = load i32, ptr %6, align 4, !tbaa !25
  %148 = zext i32 %147 to i64
  %149 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %146, i64 %148
  %150 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %149, i32 0, i32 2
  store i32 %144, ptr %150, align 4, !tbaa !38
  br label %151

151:                                              ; preds = %136
  %152 = load i32, ptr %6, align 4, !tbaa !25
  %153 = add i32 %152, 1
  store i32 %153, ptr %6, align 4, !tbaa !25
  br label %130, !llvm.loop !39

154:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %155 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 20
  %156 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %155, i32 0, i32 1
  %157 = load i32, ptr %156, align 4, !tbaa !23
  %158 = call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %159 = add i32 %157, %158
  store i32 %159, ptr %7, align 4, !tbaa !25
  br label %160

160:                                              ; preds = %178, %154
  %161 = load i32, ptr %7, align 4, !tbaa !25
  %162 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %163 = load i32, ptr %162, align 8, !tbaa !24
  %164 = icmp ult i32 %161, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %160
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %181

166:                                              ; preds = %160
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  %167 = getelementptr inbounds %"struct.enki::ThreadArgs", ptr %9, i32 0, i32 0
  %168 = load i32, ptr %7, align 4, !tbaa !25
  store i32 %168, ptr %167, align 8, !tbaa !40
  %169 = getelementptr inbounds %"struct.enki::ThreadArgs", ptr %9, i32 0, i32 1
  store ptr %15, ptr %169, align 8, !tbaa !42
  call void @_ZNSt6threadC2IRFvRKN4enki10ThreadArgsEEJS2_EvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull @_ZN4enki13TaskScheduler21TaskingThreadFunctionERKNS_10ThreadArgsE, ptr noundef nonnull align 8 dereferenceable(16) %9)
  %170 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 5
  %171 = load ptr, ptr %170, align 8, !tbaa !31
  %172 = load i32, ptr %7, align 4, !tbaa !25
  %173 = zext i32 %172 to i64
  %174 = getelementptr inbounds %"class.std::thread", ptr %171, i64 %173
  %175 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6threadaSEOS_(ptr noundef nonnull align 8 dereferenceable(8) %174, ptr noundef nonnull align 8 dereferenceable(8) %8) #5
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %176 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 10
  %177 = call noundef i32 @_ZNSt13__atomic_baseIiEppEv(ptr noundef nonnull align 4 dereferenceable(4) %176) #5
  br label %178

178:                                              ; preds = %166
  %179 = load i32, ptr %7, align 4, !tbaa !25
  %180 = add i32 %179, 1
  store i32 %180, ptr %7, align 4, !tbaa !25
  br label %160, !llvm.loop !43

181:                                              ; preds = %165
  %182 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  %183 = load i32, ptr %182, align 8, !tbaa !24
  %184 = icmp eq i32 1, %183
  br i1 %184, label %185, label %188

185:                                              ; preds = %181
  %186 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 13
  store i32 1, ptr %186, align 8, !tbaa !44
  %187 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 17
  store i32 1, ptr %187, align 8, !tbaa !45
  br label %211

188:                                              ; preds = %181
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %189 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %190 = call noundef i32 @_ZN4enki21GetNumHardwareThreadsEv()
  store i32 %190, ptr %11, align 4, !tbaa !25
  %191 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %189, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %192 = load i32, ptr %191, align 4, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  store i32 %192, ptr %10, align 4, !tbaa !25
  %193 = load i32, ptr %10, align 4, !tbaa !25
  %194 = load i32, ptr %10, align 4, !tbaa !25
  %195 = sub i32 %194, 1
  %196 = mul i32 %193, %195
  %197 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 13
  store i32 %196, ptr %197, align 8, !tbaa !44
  %198 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 1, ptr %12, align 4, !tbaa !25
  %199 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %198, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %200 = load i32, ptr %199, align 4, !tbaa !25
  %201 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 13
  store i32 %200, ptr %201, align 8, !tbaa !44
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %202 = load i32, ptr %10, align 4, !tbaa !25
  %203 = sub i32 %202, 1
  store i32 %203, ptr %13, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 1, ptr %14, align 4, !tbaa !25
  %204 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %205 = load i32, ptr %204, align 4, !tbaa !25
  %206 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 17
  store i32 %205, ptr %206, align 8, !tbaa !45
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %207 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 17
  %208 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %207, ptr noundef nonnull align 4 dereferenceable(4) @_ZN4enkiL26gc_MaxNumInitialPartitionsE)
  %209 = load i32, ptr %208, align 4, !tbaa !25
  %210 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 17
  store i32 %209, ptr %210, align 8, !tbaa !45
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %211

211:                                              ; preds = %188, %185
  %212 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %15, i32 0, i32 18
  store i8 1, ptr %212, align 4, !tbaa !9
  br label %213

213:                                              ; preds = %211, %19
  ret void
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4enki13TaskScheduler12SemaphoreNewEv(ptr noundef nonnull align 8 dereferenceable(220)) #4 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6threadC2IRFvRKN4enki10ThreadArgsEEJS2_EvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull, ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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, !14, i64 116}
!10 = !{!"_ZTSN4enki13TaskSchedulerE", !7, i64 0, !7, i64 24, !11, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 73, !12, i64 74, !15, i64 76, !15, i64 80, !15, i64 84, !11, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !14, i64 116, !17, i64 120, !15, i64 216}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSSt6atomicIbE", !13, i64 0}
!13 = !{!"_ZTSSt13__atomic_baseIbE", !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSSt6atomicIiE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIiE", !11, i64 0}
!17 = !{!"_ZTSN4enki19TaskSchedulerConfigE", !11, i64 0, !11, i64 4, !18, i64 8, !19, i64 72}
!18 = !{!"_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}
!19 = !{!"_ZTSN4enki15CustomAllocatorE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!10, !11, i64 120}
!23 = !{!10, !11, i64 124}
!24 = !{!10, !11, i64 48}
!25 = !{!11, !11, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!10, !6, i64 96}
!29 = !{!10, !6, i64 104}
!30 = !{!10, !6, i64 56}
!31 = !{!10, !6, i64 64}
!32 = distinct !{!32, !27}
!33 = distinct !{!33, !27}
!34 = !{!35, !6, i64 0}
!35 = !{!"_ZTSN4enki15ThreadDataStoreE", !6, i64 0, !36, i64 8, !11, i64 12, !7, i64 16}
!36 = !{!"_ZTSSt6atomicIN4enki11ThreadStateEE", !37, i64 0}
!37 = !{!"_ZTSN4enki11ThreadStateE", !7, i64 0}
!38 = !{!35, !11, i64 12}
!39 = distinct !{!39, !27}
!40 = !{!41, !11, i64 0}
!41 = !{!"_ZTSN4enki10ThreadArgsE", !11, i64 0, !6, i64 8}
!42 = !{!41, !6, i64 8}
!43 = distinct !{!43, !27}
!44 = !{!10, !11, i64 88}
!45 = !{!10, !11, i64 112}


; 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.std::thread" = type { %"class.std::thread::id" }
%"class.std::thread::id" = type { i64 }
%"struct.enki::ThreadArgs" = type { i32, 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
@_ZN12_GLOBAL__N_17gc_FileE = external hidden local_unnamed_addr global ptr, align 8
@_ZN4enkiL26gc_MaxNumInitialPartitionsE = external hidden constant i32, align 4

; 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 nounwind uwtable
declare dso_local noundef i32 @_ZN4enki21GetNumHardwareThreadsEv() local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv() local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler12StartThreadsEv(ptr noundef nonnull align 8 dereferenceable(220) %0) local_unnamed_addr #4 align 2 {
  %2 = alloca %"class.std::thread", align 8
  %3 = alloca %"struct.enki::ThreadArgs", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = getelementptr inbounds i8, ptr %0, i64 116
  %9 = load i8, ptr %8, align 4, !tbaa !5, !range !19, !noundef !20
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %142, label %11

11:                                               ; preds = %1
  %12 = getelementptr inbounds i8, ptr %0, i64 120
  %13 = load i32, ptr %12, align 8, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %0, i64 124
  %15 = load i32, ptr %14, align 4, !tbaa !22
  %16 = add i32 %13, 1
  %17 = add i32 %16, %15
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %17, ptr %18, align 8, !tbaa !23
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = zext i32 %17 to i64
  %21 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %22 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_8TaskPipeEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %20, ptr noundef %21, i32 noundef 0)
  store ptr %22, ptr %0, align 8, !tbaa !24
  %23 = load i32, ptr %18, align 8, !tbaa !23
  %24 = zext i32 %23 to i64
  %25 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %26 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_14PinnedTaskListEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %24, ptr noundef %25, i32 noundef 0)
  store ptr %26, ptr %19, align 8, !tbaa !24
  %27 = load i32, ptr %18, align 8, !tbaa !23
  %28 = zext i32 %27 to i64
  %29 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %30 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_8TaskPipeEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %28, ptr noundef %29, i32 noundef 0)
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %30, ptr %31, align 8, !tbaa !24
  %32 = load i32, ptr %18, align 8, !tbaa !23
  %33 = zext i32 %32 to i64
  %34 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %35 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_14PinnedTaskListEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %33, ptr noundef %34, i32 noundef 0)
  %36 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %35, ptr %36, align 8, !tbaa !24
  %37 = load i32, ptr %18, align 8, !tbaa !23
  %38 = zext i32 %37 to i64
  %39 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %40 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_8TaskPipeEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %38, ptr noundef %39, i32 noundef 0)
  %41 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %40, ptr %41, align 8, !tbaa !24
  %42 = load i32, ptr %18, align 8, !tbaa !23
  %43 = zext i32 %42 to i64
  %44 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %45 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_14PinnedTaskListEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %43, ptr noundef %44, i32 noundef 0)
  %46 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %45, ptr %46, align 8, !tbaa !24
  %47 = tail call noundef ptr @_ZN4enki13TaskScheduler12SemaphoreNewEv(ptr noundef nonnull align 8 dereferenceable(220) %0)
  %48 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr %47, ptr %48, align 8, !tbaa !25
  %49 = tail call noundef ptr @_ZN4enki13TaskScheduler12SemaphoreNewEv(ptr noundef nonnull align 8 dereferenceable(220) %0)
  %50 = getelementptr inbounds i8, ptr %0, i64 104
  store ptr %49, ptr %50, align 8, !tbaa !26
  %51 = load i32, ptr %18, align 8, !tbaa !23
  %52 = zext i32 %51 to i64
  %53 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %54 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayINS_15ThreadDataStoreEEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %52, ptr noundef %53, i32 noundef 0)
  %55 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %54, ptr %55, align 8, !tbaa !27
  %56 = load i32, ptr %18, align 8, !tbaa !23
  %57 = zext i32 %56 to i64
  %58 = load ptr, ptr @_ZN12_GLOBAL__N_17gc_FileE, align 8, !tbaa !24
  %59 = tail call noundef ptr @_ZN4enki13TaskScheduler8NewArrayISt6threadEEPT_mPKci(ptr noundef nonnull align 8 dereferenceable(220) %0, i64 noundef %57, ptr noundef %58, i32 noundef 0)
  %60 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %59, ptr %60, align 8, !tbaa !28
  %61 = getelementptr inbounds i8, ptr %0, i64 72
  %62 = tail call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %61, i1 noundef zeroext true) #5
  %63 = getelementptr inbounds i8, ptr %0, i64 74
  %64 = tail call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %63, i1 noundef zeroext false) #5
  %65 = getelementptr inbounds i8, ptr %0, i64 73
  %66 = tail call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %65, i1 noundef zeroext false) #5
  %67 = load ptr, ptr %55, align 8, !tbaa !27
  %68 = getelementptr inbounds i8, ptr %67, i64 8
  %69 = tail call noundef i32 @_ZNSt6atomicIN4enki11ThreadStateEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) %68, i32 noundef 3) #5
  %70 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  store i32 0, ptr %70, align 4, !tbaa !29
  %71 = tail call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %72 = load i32, ptr %14, align 4, !tbaa !22
  %73 = tail call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %74 = add i32 %73, %72
  %75 = icmp ult i32 %71, %74
  br i1 %75, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %11
  %76 = zext i32 %71 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %11
  %77 = load i32, ptr %14, align 4, !tbaa !22
  %78 = tail call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %79 = add i32 %78, %77
  %80 = load i32, ptr %18, align 8, !tbaa !23
  %81 = icmp ult i32 %79, %80
  br i1 %81, label %.lr.ph31.preheader, label %.preheader

.lr.ph31.preheader:                               ; preds = %._crit_edge
  %82 = zext i32 %79 to i64
  br label %.lr.ph31

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %76, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %83 = load ptr, ptr %55, align 8, !tbaa !27
  %84 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %83, i64 %indvars.iv, i32 1
  %85 = tail call noundef i32 @_ZNSt6atomicIN4enki11ThreadStateEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) %84, i32 noundef 5) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %86 = load i32, ptr %14, align 4, !tbaa !22
  %87 = tail call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %88 = add i32 %87, %86
  %89 = zext i32 %88 to i64
  %90 = icmp ult i64 %indvars.iv.next, %89
  br i1 %90, label %.lr.ph, label %._crit_edge, !llvm.loop !30

.preheader:                                       ; preds = %.lr.ph31, %._crit_edge
  %91 = phi i32 [ %80, %._crit_edge ], [ %95, %.lr.ph31 ]
  %.not = icmp eq i32 %91, 0
  br i1 %.not, label %._crit_edge34, label %.lr.ph33

.lr.ph31:                                         ; preds = %.lr.ph31.preheader, %.lr.ph31
  %indvars.iv42 = phi i64 [ %82, %.lr.ph31.preheader ], [ %indvars.iv.next43, %.lr.ph31 ]
  %92 = load ptr, ptr %55, align 8, !tbaa !27
  %93 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %92, i64 %indvars.iv42, i32 1
  %94 = tail call noundef i32 @_ZNSt6atomicIN4enki11ThreadStateEEaSES1_(ptr noundef nonnull align 4 dereferenceable(4) %93, i32 noundef 1) #5
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %95 = load i32, ptr %18, align 8, !tbaa !23
  %96 = zext i32 %95 to i64
  %97 = icmp ult i64 %indvars.iv.next43, %96
  br i1 %97, label %.lr.ph31, label %.preheader, !llvm.loop !32

._crit_edge34:                                    ; preds = %.lr.ph33, %.preheader
  %98 = load i32, ptr %14, align 4, !tbaa !22
  %99 = tail call noundef i32 @_ZN4enki13TaskScheduler29GetNumFirstExternalTaskThreadEv()
  %100 = add i32 %99, %98
  %101 = load i32, ptr %18, align 8, !tbaa !23
  %102 = icmp ult i32 %100, %101
  br i1 %102, label %.lr.ph37, label %._crit_edge38

.lr.ph37:                                         ; preds = %._crit_edge34
  %103 = getelementptr inbounds i8, ptr %3, i64 8
  %104 = getelementptr inbounds i8, ptr %0, i64 76
  %105 = zext i32 %100 to i64
  br label %115

.lr.ph33:                                         ; preds = %.preheader, %.lr.ph33
  %indvars.iv45 = phi i64 [ %indvars.iv.next46, %.lr.ph33 ], [ 0, %.preheader ]
  %106 = tail call noundef ptr @_ZN4enki13TaskScheduler12SemaphoreNewEv(ptr noundef nonnull align 8 dereferenceable(220) %0)
  %107 = load ptr, ptr %55, align 8, !tbaa !27
  %108 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %107, i64 %indvars.iv45
  store ptr %106, ptr %108, align 64, !tbaa !33
  %109 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %107, i64 %indvars.iv45, i32 2
  %110 = trunc nuw i64 %indvars.iv45 to i32
  store i32 %110, ptr %109, align 4, !tbaa !37
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %111 = load i32, ptr %18, align 8, !tbaa !23
  %112 = zext i32 %111 to i64
  %113 = icmp ult i64 %indvars.iv.next46, %112
  br i1 %113, label %.lr.ph33, label %._crit_edge34, !llvm.loop !38

._crit_edge38:                                    ; preds = %115, %._crit_edge34
  %.lcssa = phi i32 [ %101, %._crit_edge34 ], [ %121, %115 ]
  %114 = icmp eq i32 %.lcssa, 1
  br i1 %114, label %124, label %127

115:                                              ; preds = %.lr.ph37, %115
  %indvars.iv48 = phi i64 [ %105, %.lr.ph37 ], [ %indvars.iv.next49, %115 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %116 = trunc nuw i64 %indvars.iv48 to i32
  store i32 %116, ptr %3, align 8, !tbaa !39
  store ptr %0, ptr %103, align 8, !tbaa !41
  call void @_ZNSt6threadC2IRFvRKN4enki10ThreadArgsEEJS2_EvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull @_ZN4enki13TaskScheduler21TaskingThreadFunctionERKNS_10ThreadArgsE, ptr noundef nonnull align 8 dereferenceable(16) %3)
  %117 = load ptr, ptr %60, align 8, !tbaa !28
  %118 = getelementptr inbounds %"class.std::thread", ptr %117, i64 %indvars.iv48
  %119 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6threadaSEOS_(ptr noundef nonnull align 8 dereferenceable(8) %118, ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  %120 = call noundef i32 @_ZNSt13__atomic_baseIiEppEv(ptr noundef nonnull align 4 dereferenceable(4) %104) #5
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %121 = load i32, ptr %18, align 8, !tbaa !23
  %122 = zext i32 %121 to i64
  %123 = icmp ult i64 %indvars.iv.next49, %122
  br i1 %123, label %115, label %._crit_edge38, !llvm.loop !42

124:                                              ; preds = %._crit_edge38
  %125 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 1, ptr %125, align 8, !tbaa !43
  %126 = getelementptr inbounds i8, ptr %0, i64 112
  store i32 1, ptr %126, align 8, !tbaa !44
  br label %141

127:                                              ; preds = %._crit_edge38
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %128 = call noundef i32 @_ZN4enki21GetNumHardwareThreadsEv()
  store i32 %128, ptr %4, align 4, !tbaa !29
  %129 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %130 = load i32, ptr %129, align 4, !tbaa !29
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  %131 = add i32 %130, -1
  %132 = mul i32 %131, %130
  %133 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 %132, ptr %133, align 8, !tbaa !43
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store i32 1, ptr %5, align 4, !tbaa !29
  %134 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %133, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %135 = load i32, ptr %134, align 4, !tbaa !29
  store i32 %135, ptr %133, align 8, !tbaa !43
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  store i32 %131, ptr %6, align 4, !tbaa !29
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  store i32 1, ptr %7, align 4, !tbaa !29
  %136 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %137 = load i32, ptr %136, align 4, !tbaa !29
  %138 = getelementptr inbounds i8, ptr %0, i64 112
  store i32 %137, ptr %138, align 8, !tbaa !44
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  %139 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %138, ptr noundef nonnull align 4 dereferenceable(4) @_ZN4enkiL26gc_MaxNumInitialPartitionsE)
  %140 = load i32, ptr %139, align 4, !tbaa !29
  store i32 %140, ptr %138, align 8, !tbaa !44
  br label %141

141:                                              ; preds = %127, %124
  store i8 1, ptr %8, align 4, !tbaa !5
  br label %142

142:                                              ; preds = %1, %141
  ret void
}

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6threadC2IRFvRKN4enki10ThreadArgsEEJS2_EvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull, ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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, !13, i64 116}
!6 = !{!"_ZTSN4enki13TaskSchedulerE", !7, i64 0, !7, i64 24, !9, i64 48, !10, i64 56, !10, i64 64, !11, i64 72, !11, i64 73, !11, i64 74, !14, i64 76, !14, i64 80, !14, i64 84, !9, i64 88, !10, i64 96, !10, i64 104, !9, i64 112, !13, i64 116, !16, i64 120, !14, i64 216}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"_ZTSSt6atomicIbE", !12, i64 0}
!12 = !{!"_ZTSSt13__atomic_baseIbE", !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSSt6atomicIiE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIiE", !9, i64 0}
!16 = !{!"_ZTSN4enki19TaskSchedulerConfigE", !9, i64 0, !9, i64 4, !17, i64 8, !18, i64 72}
!17 = !{!"_ZTSN4enki17ProfilerCallbacksE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!18 = !{!"_ZTSN4enki15CustomAllocatorE", !10, i64 0, !10, i64 8, !10, i64 16}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!6, !9, i64 120}
!22 = !{!6, !9, i64 124}
!23 = !{!6, !9, i64 48}
!24 = !{!10, !10, i64 0}
!25 = !{!6, !10, i64 96}
!26 = !{!6, !10, i64 104}
!27 = !{!6, !10, i64 56}
!28 = !{!6, !10, i64 64}
!29 = !{!9, !9, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}
!33 = !{!34, !10, i64 0}
!34 = !{!"_ZTSN4enki15ThreadDataStoreE", !10, i64 0, !35, i64 8, !9, i64 12, !7, i64 16}
!35 = !{!"_ZTSSt6atomicIN4enki11ThreadStateEE", !36, i64 0}
!36 = !{!"_ZTSN4enki11ThreadStateE", !7, i64 0}
!37 = !{!34, !9, i64 12}
!38 = distinct !{!38, !31}
!39 = !{!40, !9, i64 0}
!40 = !{!"_ZTSN4enki10ThreadArgsE", !9, i64 0, !10, i64 8}
!41 = !{!40, !10, i64 8}
!42 = distinct !{!42, !31}
!43 = !{!6, !9, i64 88}
!44 = !{!6, !9, i64 112}


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