; LLVM IR from tsotchke/quantum_geometric_tensor :: src/quantum_geometric/distributed (workload_distribution)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.WorkItem = type { ptr, i64, i32, i32, double }
%struct.WorkloadManager = type { ptr, i32, i32, i8, i64, i8, ptr, i64, %struct.WorkMetrics }
%struct.WorkMetrics = type { i64, i64, i64, i64, i64, double }
%struct.WorkQueue = type { ptr, i64, i64, i64, i64, %union.pthread_mutex_t, %union.pthread_cond_t, %union.pthread_cond_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

; 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @submit_work(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.WorkItem, align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !11
  store i32 %4, ptr %11, align 4, !tbaa !11
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %19, %5
  store i32 -1, ptr %6, align 4
  br label %198

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #6
  %24 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 0
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = call noalias ptr @malloc(i64 noundef %25) #7
  store ptr %26, ptr %24, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 1
  %28 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %28, ptr %27, align 8, !tbaa !16
  %29 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 2
  %30 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %30, ptr %29, align 8, !tbaa !17
  %31 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 3
  %32 = load i32, ptr %11, align 4, !tbaa !11
  store i32 %32, ptr %31, align 4, !tbaa !18
  %33 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 4
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = load i32, ptr %10, align 4, !tbaa !11
  %37 = call double @estimate_work_cost(ptr noundef %34, i64 noundef %35, i32 noundef %36)
  store double %37, ptr %33, align 8, !tbaa !19
  %38 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %23
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %197

42:                                               ; preds = %23
  %43 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i64, ptr %9, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %44, ptr align 1 %45, i64 %46, i1 false)
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.WorkloadManager, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !20
  %50 = getelementptr inbounds %struct.WorkQueue, ptr %49, i32 0, i32 5
  %51 = call i32 @pthread_mutex_lock(ptr noundef %50) #6
  br label %52

52:                                               ; preds = %64, %42
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.WorkloadManager, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = getelementptr inbounds %struct.WorkQueue, ptr %55, i32 0, i32 2
  %57 = load i64, ptr %56, align 8, !tbaa !24
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.WorkloadManager, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !20
  %61 = getelementptr inbounds %struct.WorkQueue, ptr %60, i32 0, i32 1
  %62 = load i64, ptr %61, align 8, !tbaa !26
  %63 = icmp uge i64 %57, %62
  br i1 %63, label %64, label %74

64:                                               ; preds = %52
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.WorkloadManager, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !20
  %68 = getelementptr inbounds %struct.WorkQueue, ptr %67, i32 0, i32 7
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.WorkloadManager, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  %72 = getelementptr inbounds %struct.WorkQueue, ptr %71, i32 0, i32 5
  %73 = call i32 @pthread_cond_wait(ptr noundef %68, ptr noundef %72)
  br label %52, !llvm.loop !27

74:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.WorkloadManager, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !20
  %78 = getelementptr inbounds %struct.WorkQueue, ptr %77, i32 0, i32 4
  %79 = load i64, ptr %78, align 8, !tbaa !29
  store i64 %79, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 0, ptr %15, align 8, !tbaa !9
  br label %80

80:                                               ; preds = %121, %74
  %81 = load i64, ptr %15, align 8, !tbaa !9
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.WorkloadManager, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !20
  %85 = getelementptr inbounds %struct.WorkQueue, ptr %84, i32 0, i32 2
  %86 = load i64, ptr %85, align 8, !tbaa !24
  %87 = icmp ult i64 %81, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %80
  store i32 4, ptr %13, align 4
  br label %124

89:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.WorkloadManager, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !20
  %93 = getelementptr inbounds %struct.WorkQueue, ptr %92, i32 0, i32 3
  %94 = load i64, ptr %93, align 8, !tbaa !30
  %95 = load i64, ptr %15, align 8, !tbaa !9
  %96 = add i64 %94, %95
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.WorkloadManager, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !20
  %100 = getelementptr inbounds %struct.WorkQueue, ptr %99, i32 0, i32 1
  %101 = load i64, ptr %100, align 8, !tbaa !26
  %102 = urem i64 %96, %101
  store i64 %102, ptr %16, align 8, !tbaa !9
  %103 = getelementptr inbounds %struct.WorkItem, ptr %12, i32 0, i32 3
  %104 = load i32, ptr %103, align 4, !tbaa !18
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.WorkloadManager, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !20
  %108 = getelementptr inbounds %struct.WorkQueue, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !31
  %110 = load i64, ptr %16, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.WorkItem, ptr %109, i64 %110
  %112 = getelementptr inbounds %struct.WorkItem, ptr %111, i32 0, i32 3
  %113 = load i32, ptr %112, align 4, !tbaa !18
  %114 = icmp sgt i32 %104, %113
  br i1 %114, label %115, label %117

115:                                              ; preds = %89
  %116 = load i64, ptr %16, align 8, !tbaa !9
  store i64 %116, ptr %14, align 8, !tbaa !9
  store i32 4, ptr %13, align 4
  br label %118

117:                                              ; preds = %89
  store i32 0, ptr %13, align 4
  br label %118

118:                                              ; preds = %117, %115
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  %119 = load i32, ptr %13, align 4
  switch i32 %119, label %124 [
    i32 0, label %120
  ]

120:                                              ; preds = %118
  br label %121

121:                                              ; preds = %120
  %122 = load i64, ptr %15, align 8, !tbaa !9
  %123 = add i64 %122, 1
  store i64 %123, ptr %15, align 8, !tbaa !9
  br label %80, !llvm.loop !32

124:                                              ; preds = %118, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %125

125:                                              ; preds = %124
  %126 = load i64, ptr %14, align 8, !tbaa !9
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.WorkloadManager, ptr %127, i32 0, i32 0
  %129 = load ptr, ptr %128, align 8, !tbaa !20
  %130 = getelementptr inbounds %struct.WorkQueue, ptr %129, i32 0, i32 4
  %131 = load i64, ptr %130, align 8, !tbaa !29
  %132 = icmp ne i64 %126, %131
  br i1 %132, label %133, label %157

133:                                              ; preds = %125
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.WorkloadManager, ptr %134, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !20
  %137 = getelementptr inbounds %struct.WorkQueue, ptr %136, i32 0, i32 0
  %138 = load ptr, ptr %137, align 8, !tbaa !31
  %139 = load i64, ptr %14, align 8, !tbaa !9
  %140 = add i64 %139, 1
  %141 = getelementptr inbounds %struct.WorkItem, ptr %138, i64 %140
  %142 = load ptr, ptr %7, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.WorkloadManager, ptr %142, i32 0, i32 0
  %144 = load ptr, ptr %143, align 8, !tbaa !20
  %145 = getelementptr inbounds %struct.WorkQueue, ptr %144, i32 0, i32 0
  %146 = load ptr, ptr %145, align 8, !tbaa !31
  %147 = load i64, ptr %14, align 8, !tbaa !9
  %148 = getelementptr inbounds %struct.WorkItem, ptr %146, i64 %147
  %149 = load ptr, ptr %7, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.WorkloadManager, ptr %149, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !20
  %152 = getelementptr inbounds %struct.WorkQueue, ptr %151, i32 0, i32 2
  %153 = load i64, ptr %152, align 8, !tbaa !24
  %154 = load i64, ptr %14, align 8, !tbaa !9
  %155 = sub i64 %153, %154
  %156 = mul i64 %155, 32
  call void @llvm.memmove.p0.p0.i64(ptr align 8 %141, ptr align 8 %148, i64 %156, i1 false)
  br label %157

157:                                              ; preds = %133, %125
  %158 = load ptr, ptr %7, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.WorkloadManager, ptr %158, i32 0, i32 0
  %160 = load ptr, ptr %159, align 8, !tbaa !20
  %161 = getelementptr inbounds %struct.WorkQueue, ptr %160, i32 0, i32 0
  %162 = load ptr, ptr %161, align 8, !tbaa !31
  %163 = load i64, ptr %14, align 8, !tbaa !9
  %164 = getelementptr inbounds %struct.WorkItem, ptr %162, i64 %163
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %164, ptr align 8 %12, i64 32, i1 false), !tbaa.struct !33
  %165 = load ptr, ptr %7, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.WorkloadManager, ptr %165, i32 0, i32 0
  %167 = load ptr, ptr %166, align 8, !tbaa !20
  %168 = getelementptr inbounds %struct.WorkQueue, ptr %167, i32 0, i32 2
  %169 = load i64, ptr %168, align 8, !tbaa !24
  %170 = add i64 %169, 1
  store i64 %170, ptr %168, align 8, !tbaa !24
  %171 = load ptr, ptr %7, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.WorkloadManager, ptr %171, i32 0, i32 0
  %173 = load ptr, ptr %172, align 8, !tbaa !20
  %174 = getelementptr inbounds %struct.WorkQueue, ptr %173, i32 0, i32 4
  %175 = load i64, ptr %174, align 8, !tbaa !29
  %176 = add i64 %175, 1
  %177 = load ptr, ptr %7, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.WorkloadManager, ptr %177, i32 0, i32 0
  %179 = load ptr, ptr %178, align 8, !tbaa !20
  %180 = getelementptr inbounds %struct.WorkQueue, ptr %179, i32 0, i32 1
  %181 = load i64, ptr %180, align 8, !tbaa !26
  %182 = urem i64 %176, %181
  %183 = load ptr, ptr %7, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.WorkloadManager, ptr %183, i32 0, i32 0
  %185 = load ptr, ptr %184, align 8, !tbaa !20
  %186 = getelementptr inbounds %struct.WorkQueue, ptr %185, i32 0, i32 4
  store i64 %182, ptr %186, align 8, !tbaa !29
  %187 = load ptr, ptr %7, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.WorkloadManager, ptr %187, i32 0, i32 0
  %189 = load ptr, ptr %188, align 8, !tbaa !20
  %190 = getelementptr inbounds %struct.WorkQueue, ptr %189, i32 0, i32 6
  %191 = call i32 @pthread_cond_signal(ptr noundef %190) #6
  %192 = load ptr, ptr %7, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.WorkloadManager, ptr %192, i32 0, i32 0
  %194 = load ptr, ptr %193, align 8, !tbaa !20
  %195 = getelementptr inbounds %struct.WorkQueue, ptr %194, i32 0, i32 5
  %196 = call i32 @pthread_mutex_unlock(ptr noundef %195) #6
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %197

197:                                              ; preds = %157, %41
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #6
  br label %198

198:                                              ; preds = %197, %22
  %199 = load i32, ptr %6, align 4
  ret i32 %199
}

; Function Attrs: nounwind uwtable
declare hidden double @estimate_work_cost(ptr noundef, i64 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) #4

declare i32 @pthread_cond_wait(ptr noundef, ptr noundef) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) #4

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind 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 nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !10, i64 8, !12, i64 16, !12, i64 20, !15, i64 24}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !10, i64 8}
!17 = !{!14, !12, i64 16}
!18 = !{!14, !12, i64 20}
!19 = !{!14, !15, i64 24}
!20 = !{!21, !6, i64 0}
!21 = !{!"", !6, i64 0, !12, i64 8, !12, i64 12, !22, i64 16, !10, i64 24, !22, i64 32, !6, i64 40, !10, i64 48, !23, i64 56}
!22 = !{!"_Bool", !7, i64 0}
!23 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !15, i64 40}
!24 = !{!25, !10, i64 16}
!25 = !{!"", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !7, i64 80, !7, i64 128}
!26 = !{!25, !10, i64 8}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!25, !10, i64 32}
!30 = !{!25, !10, i64 24}
!31 = !{!25, !6, i64 0}
!32 = distinct !{!32, !28}
!33 = !{i64 0, i64 8, !5, i64 8, i64 8, !9, i64 16, i64 4, !11, i64 20, i64 4, !11, i64 24, i64 8, !34}
!34 = !{!15, !15, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.WorkItem = type { ptr, i64, i32, i32, double }

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @submit_work(ptr noundef readonly %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = icmp ne ptr %0, null
  %7 = icmp ne ptr %1, null
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %8, label %65

8:                                                ; preds = %5
  %9 = tail call noalias ptr @malloc(i64 noundef %2) #5
  %10 = tail call double @estimate_work_cost(ptr noundef nonnull %1, i64 noundef %2, i32 noundef %3)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %65, label %11

11:                                               ; preds = %8
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %9, ptr nonnull align 1 %1, i64 %2, i1 false)
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 40
  %14 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %13) #6
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %15, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !17
  %.not5257 = icmp ult i64 %17, %19
  br i1 %.not5257, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %.lr.ph
  %20 = phi ptr [ %24, %.lr.ph ], [ %15, %11 ]
  %21 = getelementptr inbounds i8, ptr %20, i64 128
  %22 = getelementptr inbounds i8, ptr %20, i64 40
  %23 = tail call i32 @pthread_cond_wait(ptr noundef nonnull %21, ptr noundef nonnull %22) #6
  %24 = load ptr, ptr %0, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %26 = load i64, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %24, i64 8
  %28 = load i64, ptr %27, align 8, !tbaa !17
  %.not52 = icmp ult i64 %26, %28
  br i1 %.not52, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %11
  %.lcssa56 = phi ptr [ %15, %11 ], [ %24, %.lr.ph ]
  %.lcssa55 = phi i64 [ %17, %11 ], [ %26, %.lr.ph ]
  %.lcssa = phi i64 [ %19, %11 ], [ %28, %.lr.ph ]
  %29 = getelementptr inbounds i8, ptr %.lcssa56, i64 32
  %30 = load i64, ptr %29, align 8, !tbaa !20
  %.not67 = icmp eq i64 %.lcssa55, 0
  br i1 %.not67, label %._crit_edge63.thread, label %.lr.ph62

.lr.ph62:                                         ; preds = %._crit_edge
  %31 = getelementptr inbounds i8, ptr %.lcssa56, i64 24
  %32 = load i64, ptr %31, align 8, !tbaa !21
  %33 = load ptr, ptr %.lcssa56, align 8, !tbaa !22
  br label %36

34:                                               ; preds = %36
  %35 = add nuw i64 %.04560, 1
  %exitcond.not = icmp eq i64 %35, %.lcssa55
  br i1 %exitcond.not, label %._crit_edge63.thread, label %36, !llvm.loop !23

36:                                               ; preds = %.lr.ph62, %34
  %.04560 = phi i64 [ 0, %.lr.ph62 ], [ %35, %34 ]
  %37 = add i64 %32, %.04560
  %38 = urem i64 %37, %.lcssa
  %39 = getelementptr inbounds %struct.WorkItem, ptr %33, i64 %38, i32 3
  %40 = load i32, ptr %39, align 4, !tbaa !24
  %.not53 = icmp slt i32 %40, %4
  br i1 %.not53, label %._crit_edge63, label %34

._crit_edge63:                                    ; preds = %36
  %.not54 = icmp eq i64 %38, %30
  br i1 %.not54, label %._crit_edge63.thread, label %41

41:                                               ; preds = %._crit_edge63
  %42 = load ptr, ptr %.lcssa56, align 8, !tbaa !22
  %43 = getelementptr %struct.WorkItem, ptr %42, i64 %38
  %44 = getelementptr i8, ptr %43, i64 32
  %45 = sub i64 %.lcssa55, %38
  %46 = shl i64 %45, 5
  tail call void @llvm.memmove.p0.p0.i64(ptr align 8 %44, ptr align 8 %43, i64 %46, i1 false)
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %._crit_edge63.thread

._crit_edge63.thread:                             ; preds = %34, %._crit_edge, %41, %._crit_edge63
  %.273 = phi i64 [ %38, %41 ], [ %38, %._crit_edge63 ], [ %30, %._crit_edge ], [ %30, %34 ]
  %47 = phi ptr [ %.pre, %41 ], [ %.lcssa56, %._crit_edge63 ], [ %.lcssa56, %._crit_edge ], [ %.lcssa56, %34 ]
  %48 = load ptr, ptr %47, align 8, !tbaa !22
  %49 = getelementptr inbounds %struct.WorkItem, ptr %48, i64 %.273
  store ptr %9, ptr %49, align 8, !tbaa !26
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %49, i64 8
  store i64 %2, ptr %.sroa.6.0..sroa_idx, align 8, !tbaa !27
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %49, i64 16
  store i32 %3, ptr %.sroa.7.0..sroa_idx, align 8, !tbaa !28
  %.sroa.8.0..sroa_idx = getelementptr inbounds i8, ptr %49, i64 20
  store i32 %4, ptr %.sroa.8.0..sroa_idx, align 4, !tbaa !28
  %.sroa.10.0..sroa_idx = getelementptr inbounds i8, ptr %49, i64 24
  store double %10, ptr %.sroa.10.0..sroa_idx, align 8, !tbaa !29
  %50 = load ptr, ptr %0, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 16
  %52 = load i64, ptr %51, align 8, !tbaa !15
  %53 = add i64 %52, 1
  store i64 %53, ptr %51, align 8, !tbaa !15
  %54 = getelementptr inbounds i8, ptr %50, i64 32
  %55 = load i64, ptr %54, align 8, !tbaa !20
  %56 = add i64 %55, 1
  %57 = getelementptr inbounds i8, ptr %50, i64 8
  %58 = load i64, ptr %57, align 8, !tbaa !17
  %59 = urem i64 %56, %58
  store i64 %59, ptr %54, align 8, !tbaa !20
  %60 = getelementptr inbounds i8, ptr %50, i64 80
  %61 = tail call i32 @pthread_cond_signal(ptr noundef nonnull %60) #6
  %62 = load ptr, ptr %0, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 40
  %64 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %63) #6
  br label %65

65:                                               ; preds = %._crit_edge63.thread, %8, %5
  %.1 = phi i32 [ -1, %5 ], [ 0, %._crit_edge63.thread ], [ -1, %8 ]
  ret i32 %.1
}

; Function Attrs: nounwind uwtable
declare hidden double @estimate_work_cost(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #3

declare i32 @pthread_cond_wait(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "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 allocsize(0) }
attributes #6 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !12, i64 24, !11, i64 32, !7, i64 40, !12, i64 48, !13, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !14, i64 40}
!14 = !{!"double", !8, i64 0}
!15 = !{!16, !12, i64 16}
!16 = !{!"", !7, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !8, i64 40, !8, i64 80, !8, i64 128}
!17 = !{!16, !12, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!16, !12, i64 32}
!21 = !{!16, !12, i64 24}
!22 = !{!16, !7, i64 0}
!23 = distinct !{!23, !19}
!24 = !{!25, !10, i64 20}
!25 = !{!"", !7, i64 0, !12, i64 8, !10, i64 16, !10, i64 20, !14, i64 24}
!26 = !{!7, !7, i64 0}
!27 = !{!12, !12, i64 0}
!28 = !{!10, !10, i64 0}
!29 = !{!14, !14, i64 0}


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