; LLVM IR from SelfishOlex/MiniAudioO3DE :: MiniAudio/Code/Source/Clients (MiniAudioImplementation)

; 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.ma_job_queue = type { i32, i32, i64, i64, %struct.ma_semaphore, %struct.ma_slot_allocator, ptr, i32, ptr, i32 }
%struct.ma_semaphore = type { i32, %union.pthread_mutex_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 }
%struct.ma_slot_allocator = type { ptr, ptr, i32, i32, i32, ptr }
%struct.ma_job = type { %union.anon.0, i64, i32, %union.anon.2 }
%union.anon.0 = type { i64 }
%union.anon.2 = type { %union.anon.4 }
%union.anon.4 = type { %struct.anon.8 }
%struct.anon.8 = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i32 }
%struct.anon.1 = type { i16, i16, i32 }

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 x i8], align 1
@__PRETTY_FUNCTION__.ma_job_queue_post = external hidden unnamed_addr constant [60 x i8], align 1

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

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

; Function Attrs: 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) #1

; Function Attrs: mustprogress uwtable
declare dso_local i32 @ma_spinlock_lock(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @ma_spinlock_unlock(ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z20ma_semaphore_releaseP12ma_semaphore(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @ma_slot_allocator_alloc(ptr noundef, ptr noundef) #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_job_queue_post(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %19, label %16

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %16, %2
  store i32 -2, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %153

20:                                               ; preds = %16
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ma_job_queue, ptr %21, i32 0, i32 5
  %23 = call i32 @ma_slot_allocator_alloc(ptr noundef %22, ptr noundef %7)
  store i32 %23, ptr %6, align 4, !tbaa !9
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %20
  %27 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %153

28:                                               ; preds = %20
  %29 = load i64, ptr %7, align 8, !tbaa !11
  %30 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %29)
  %31 = zext i16 %30 to i32
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ma_job_queue, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = icmp ult i32 %31, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %28
  br label %39

37:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.6, i32 noundef 16904, ptr noundef @__PRETTY_FUNCTION__.ma_job_queue_post) #8
  unreachable

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %36
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ma_job_queue, ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 8, !tbaa !18
  %44 = load i64, ptr %7, align 8, !tbaa !11
  %45 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %44)
  %46 = zext i16 %45 to i64
  %47 = getelementptr inbounds %struct.ma_job, ptr %43, i64 %46
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %47, ptr align 8 %40, i64 104, i1 false), !tbaa.struct !19
  %48 = load i64, ptr %7, align 8, !tbaa !11
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ma_job_queue, ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = load i64, ptr %7, align 8, !tbaa !11
  %53 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %52)
  %54 = zext i16 %53 to i64
  %55 = getelementptr inbounds %struct.ma_job, ptr %51, i64 %54
  %56 = getelementptr inbounds %struct.ma_job, ptr %55, i32 0, i32 0
  store i64 %48, ptr %56, align 8, !tbaa !20
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ma_job, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.anon.1, ptr %58, i32 0, i32 0
  %60 = load i16, ptr %59, align 8, !tbaa !20
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ma_job_queue, ptr %61, i32 0, i32 6
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = load i64, ptr %7, align 8, !tbaa !11
  %65 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %64)
  %66 = zext i16 %65 to i64
  %67 = getelementptr inbounds %struct.ma_job, ptr %63, i64 %66
  %68 = getelementptr inbounds %struct.ma_job, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds %struct.anon.1, ptr %68, i32 0, i32 0
  store i16 %60, ptr %69, align 8, !tbaa !20
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ma_job_queue, ptr %70, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !18
  %73 = load i64, ptr %7, align 8, !tbaa !11
  %74 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %73)
  %75 = zext i16 %74 to i64
  %76 = getelementptr inbounds %struct.ma_job, ptr %72, i64 %75
  %77 = getelementptr inbounds %struct.ma_job, ptr %76, i32 0, i32 1
  store i64 -1, ptr %77, align 8, !tbaa !22
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ma_job_queue, ptr %78, i32 0, i32 7
  %80 = call i32 @ma_spinlock_lock(ptr noundef %79)
  br label %81

81:                                               ; preds = %133, %39
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ma_job_queue, ptr %82, i32 0, i32 3
  %84 = load atomic i64, ptr %83 seq_cst, align 8
  store i64 %84, ptr %11, align 8
  %85 = load i64, ptr %11, align 8, !tbaa !11
  store i64 %85, ptr %8, align 8, !tbaa !11
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.ma_job_queue, ptr %86, i32 0, i32 6
  %88 = load ptr, ptr %87, align 8, !tbaa !18
  %89 = load i64, ptr %8, align 8, !tbaa !11
  %90 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %89)
  %91 = zext i16 %90 to i64
  %92 = getelementptr inbounds %struct.ma_job, ptr %88, i64 %91
  %93 = getelementptr inbounds %struct.ma_job, ptr %92, i32 0, i32 1
  %94 = load atomic i64, ptr %93 seq_cst, align 8
  store i64 %94, ptr %12, align 8
  %95 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %95, ptr %9, align 8, !tbaa !11
  %96 = load i64, ptr %8, align 8, !tbaa !11
  %97 = call noundef i64 @_ZL24ma_job_toc_to_allocationy(i64 noundef %96)
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.ma_job_queue, ptr %98, i32 0, i32 3
  %100 = load atomic i64, ptr %99 seq_cst, align 8
  store i64 %100, ptr %13, align 8
  %101 = load i64, ptr %13, align 8, !tbaa !11
  %102 = call noundef i64 @_ZL24ma_job_toc_to_allocationy(i64 noundef %101)
  %103 = icmp eq i64 %97, %102
  br i1 %103, label %104, label %133

104:                                              ; preds = %81
  %105 = load i64, ptr %9, align 8, !tbaa !11
  %106 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %105)
  %107 = zext i16 %106 to i32
  %108 = icmp eq i32 %107, 65535
  br i1 %108, label %109, label %124

109:                                              ; preds = %104
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.ma_job_queue, ptr %110, i32 0, i32 6
  %112 = load ptr, ptr %111, align 8, !tbaa !18
  %113 = load i64, ptr %8, align 8, !tbaa !11
  %114 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %113)
  %115 = zext i16 %114 to i64
  %116 = getelementptr inbounds %struct.ma_job, ptr %112, i64 %115
  %117 = getelementptr inbounds %struct.ma_job, ptr %116, i32 0, i32 1
  %118 = load i64, ptr %9, align 8, !tbaa !11
  %119 = load i64, ptr %7, align 8, !tbaa !11
  %120 = call noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef %117, i64 noundef %118, i64 noundef %119)
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %123

122:                                              ; preds = %109
  br label %134

123:                                              ; preds = %109
  br label %132

124:                                              ; preds = %104
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.ma_job_queue, ptr %125, i32 0, i32 3
  %127 = load i64, ptr %8, align 8, !tbaa !11
  %128 = load i64, ptr %9, align 8, !tbaa !11
  %129 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %128)
  %130 = zext i16 %129 to i64
  %131 = call noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef %126, i64 noundef %127, i64 noundef %130)
  br label %132

132:                                              ; preds = %124, %123
  br label %133

133:                                              ; preds = %132, %81
  br label %81, !llvm.loop !24

134:                                              ; preds = %122
  %135 = load ptr, ptr %4, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.ma_job_queue, ptr %135, i32 0, i32 3
  %137 = load i64, ptr %8, align 8, !tbaa !11
  %138 = load i64, ptr %7, align 8, !tbaa !11
  %139 = call noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef %136, i64 noundef %137, i64 noundef %138)
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.ma_job_queue, ptr %140, i32 0, i32 7
  %142 = call i32 @ma_spinlock_unlock(ptr noundef %141)
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.ma_job_queue, ptr %143, i32 0, i32 0
  %145 = load i32, ptr %144, align 8, !tbaa !26
  %146 = and i32 %145, 1
  %147 = icmp eq i32 %146, 0
  br i1 %147, label %148, label %152

148:                                              ; preds = %134
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.ma_job_queue, ptr %149, i32 0, i32 4
  %151 = call noundef i32 @_Z20ma_semaphore_releaseP12ma_semaphore(ptr noundef %150)
  br label %152

152:                                              ; preds = %148, %134
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %153

153:                                              ; preds = %152, %26, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %154 = load i32, ptr %3, align 4
  ret i32 %154
}

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef i64 @_ZL24ma_job_toc_to_allocationy(i64 noundef) #6

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef, i64 noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #5 = { alwaysinline 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 #6 = { alwaysinline 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 #7 = { nounwind }
attributes #8 = { noreturn 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 = !{!"_ZTS9ma_result", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !15, i64 4}
!14 = !{!"_ZTS12ma_job_queue", !15, i64 0, !15, i64 4, !12, i64 8, !12, i64 16, !16, i64 24, !17, i64 120, !6, i64 160, !15, i64 168, !6, i64 176, !15, i64 184}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS12ma_semaphore", !15, i64 0, !7, i64 8, !7, i64 48}
!17 = !{!"_ZTS17ma_slot_allocator", !6, i64 0, !6, i64 8, !15, i64 16, !15, i64 20, !15, i64 24, !6, i64 32}
!18 = !{!14, !6, i64 160}
!19 = !{i64 0, i64 8, !20, i64 8, i64 8, !11, i64 16, i64 4, !21, i64 24, i64 80, !20}
!20 = !{!7, !7, i64 0}
!21 = !{!15, !15, i64 0}
!22 = !{!23, !12, i64 8}
!23 = !{!"_ZTS6ma_job", !7, i64 0, !12, i64 8, !15, i64 16, !7, i64 24}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!14, !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.ma_job = type { %union.anon.0, i64, i32, %union.anon.2 }
%union.anon.0 = type { i64 }
%union.anon.2 = type { %union.anon.4 }
%union.anon.4 = type { %struct.anon.8 }
%struct.anon.8 = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i32 }

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 x i8], align 1
@__PRETTY_FUNCTION__.ma_job_queue_post = external hidden unnamed_addr constant [60 x i8], align 1

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

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

; Function Attrs: mustprogress 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) #1

; Function Attrs: mustprogress uwtable
declare dso_local i32 @ma_spinlock_lock(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @ma_spinlock_unlock(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z20ma_semaphore_releaseP12ma_semaphore(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @ma_slot_allocator_alloc(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_job_queue_post(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #2 {
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %78, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = call i32 @ma_slot_allocator_alloc(ptr noundef nonnull %7, ptr noundef nonnull %3)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %78

9:                                                ; preds = %6
  %10 = load i64, ptr %3, align 8, !tbaa !5
  %11 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %10)
  %12 = zext i16 %11 to i32
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = icmp ugt i32 %14, %12
  br i1 %15, label %17, label %16

16:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.6, i32 noundef 16904, ptr noundef nonnull @__PRETTY_FUNCTION__.ma_job_queue_post) #8
  unreachable

17:                                               ; preds = %9
  %18 = getelementptr inbounds i8, ptr %0, i64 160
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %20)
  %22 = zext i16 %21 to i64
  %23 = getelementptr inbounds %struct.ma_job, ptr %19, i64 %22
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %23, ptr noundef nonnull align 8 dereferenceable(104) %1, i64 104, i1 false), !tbaa.struct !16
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = load ptr, ptr %18, align 8, !tbaa !15
  %26 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %24)
  %27 = zext i16 %26 to i64
  %28 = getelementptr inbounds %struct.ma_job, ptr %25, i64 %27
  store i64 %24, ptr %28, align 8, !tbaa !17
  %29 = load i16, ptr %1, align 8, !tbaa !17
  %30 = load ptr, ptr %18, align 8, !tbaa !15
  %31 = load i64, ptr %3, align 8, !tbaa !5
  %32 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %31)
  %33 = zext i16 %32 to i64
  %34 = getelementptr inbounds %struct.ma_job, ptr %30, i64 %33
  store i16 %29, ptr %34, align 8, !tbaa !17
  %35 = load ptr, ptr %18, align 8, !tbaa !15
  %36 = load i64, ptr %3, align 8, !tbaa !5
  %37 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %36)
  %38 = zext i16 %37 to i64
  %39 = getelementptr inbounds %struct.ma_job, ptr %35, i64 %38, i32 1
  store i64 -1, ptr %39, align 8, !tbaa !19
  %40 = getelementptr inbounds i8, ptr %0, i64 168
  %41 = call i32 @ma_spinlock_lock(ptr noundef nonnull %40)
  %42 = getelementptr inbounds i8, ptr %0, i64 16
  br label %43

43:                                               ; preds = %.backedge, %17
  %44 = load atomic i64, ptr %42 seq_cst, align 8
  %45 = load ptr, ptr %18, align 8, !tbaa !15
  %46 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %44)
  %47 = zext i16 %46 to i64
  %48 = getelementptr inbounds %struct.ma_job, ptr %45, i64 %47, i32 1
  %49 = load atomic i64, ptr %48 seq_cst, align 8
  %50 = call noundef i64 @_ZL24ma_job_toc_to_allocationy(i64 noundef %44)
  %51 = load atomic i64, ptr %42 seq_cst, align 8
  %52 = call noundef i64 @_ZL24ma_job_toc_to_allocationy(i64 noundef %51)
  %53 = icmp eq i64 %50, %52
  br i1 %53, label %54, label %.backedge

54:                                               ; preds = %43
  %55 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %49)
  %56 = icmp eq i16 %55, -1
  br i1 %56, label %57, label %64

57:                                               ; preds = %54
  %58 = load ptr, ptr %18, align 8, !tbaa !15
  %59 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %44)
  %60 = zext i16 %59 to i64
  %61 = getelementptr inbounds %struct.ma_job, ptr %58, i64 %60, i32 1
  %62 = load i64, ptr %3, align 8, !tbaa !5
  %63 = call noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef nonnull %61, i64 noundef %49, i64 noundef %62)
  %.not37 = icmp eq i32 %63, 0
  br i1 %.not37, label %.backedge, label %68

64:                                               ; preds = %54
  %65 = call noundef zeroext i16 @_ZL19ma_job_extract_sloty(i64 noundef %49)
  %66 = zext i16 %65 to i64
  %67 = call noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef nonnull %42, i64 noundef %44, i64 noundef %66)
  br label %.backedge

.backedge:                                        ; preds = %64, %57, %43
  br label %43, !llvm.loop !21

68:                                               ; preds = %57
  %69 = load i64, ptr %3, align 8, !tbaa !5
  %70 = call noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef nonnull %42, i64 noundef %44, i64 noundef %69)
  %71 = call i32 @ma_spinlock_unlock(ptr noundef nonnull %40)
  %72 = load i32, ptr %0, align 8, !tbaa !23
  %73 = and i32 %72, 1
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %78

75:                                               ; preds = %68
  %76 = getelementptr inbounds i8, ptr %0, i64 24
  %77 = call noundef i32 @_Z20ma_semaphore_releaseP12ma_semaphore(ptr noundef nonnull %76)
  br label %78

78:                                               ; preds = %68, %75, %6, %2
  %.0 = phi i32 [ -2, %2 ], [ %8, %6 ], [ 0, %75 ], [ 0, %68 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  ret i32 %.0
}

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef i64 @_ZL24ma_job_toc_to_allocationy(i64 noundef) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL16ma_job_queue_casPVyyy(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #5 = { alwaysinline 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 #6 = { alwaysinline 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 #7 = { nounwind }
attributes #8 = { noreturn 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"_ZTS12ma_job_queue", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !12, i64 24, !13, i64 120, !14, i64 160, !11, i64 168, !14, i64 176, !11, i64 184}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS12ma_semaphore", !11, i64 0, !7, i64 8, !7, i64 48}
!13 = !{!"_ZTS17ma_slot_allocator", !14, i64 0, !14, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !14, i64 32}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!10, !14, i64 160}
!16 = !{i64 0, i64 8, !17, i64 8, i64 8, !5, i64 16, i64 4, !18, i64 24, i64 80, !17}
!17 = !{!7, !7, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !6, i64 8}
!20 = !{!"_ZTS6ma_job", !7, i64 0, !6, i64 8, !11, i64 16, !7, i64 24}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!10, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass