; 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_resource_manager = type { %struct.ma_resource_manager_config, ptr, %union.pthread_mutex_t, [64 x i64], %struct.ma_job_queue, %struct.ma_default_vfs, %struct.ma_log }
%struct.ma_resource_manager_config = type { %struct.ma_allocation_callbacks, ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, i32, ptr }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%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 }
%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_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_default_vfs = type { %struct.ma_vfs_callbacks, %struct.ma_allocation_callbacks }
%struct.ma_vfs_callbacks = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.ma_log = type { [4 x %struct.ma_log_callback], i32, %struct.ma_allocation_callbacks, %union.pthread_mutex_t }
%struct.ma_log_callback = type { ptr, ptr }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_free(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_log_uninit(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_mutex_uninit(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_job_queue_uninit(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL14ma_thread_waitPm(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL40ma_resource_manager_is_threading_enabledPK19ma_resource_manager(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @ma_resource_manager_uninit(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %62

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = call i32 @ma_resource_manager_post_job_quit(ptr noundef %8)
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call noundef i32 @_ZL40ma_resource_manager_is_threading_enabledPK19ma_resource_manager(ptr noundef %10)
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %31

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

14:                                               ; preds = %27, %13
  %15 = load i32, ptr %3, align 4, !tbaa !9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ma_resource_manager, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.ma_resource_manager_config, ptr %17, i32 0, i32 5
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = icmp ult i32 %15, %19
  br i1 %20, label %21, label %30

21:                                               ; preds = %14
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ma_resource_manager, ptr %22, i32 0, i32 3
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [64 x i64], ptr %23, i64 0, i64 %25
  call void @_ZL14ma_thread_waitPm(ptr noundef %26)
  br label %27

27:                                               ; preds = %21
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = add i32 %28, 1
  store i32 %29, ptr %3, align 4, !tbaa !9
  br label %14, !llvm.loop !23

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

31:                                               ; preds = %30, %7
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZL48ma_resource_manager_delete_all_data_buffer_nodesP19ma_resource_manager(ptr noundef %32)
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ma_resource_manager, ptr %33, i32 0, i32 4
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ma_resource_manager, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.ma_resource_manager_config, ptr %36, i32 0, i32 0
  call void @ma_job_queue_uninit(ptr noundef %34, ptr noundef %37)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = call noundef i32 @_ZL40ma_resource_manager_is_threading_enabledPK19ma_resource_manager(ptr noundef %38)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %44

41:                                               ; preds = %31
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ma_resource_manager, ptr %42, i32 0, i32 2
  call void @ma_mutex_uninit(ptr noundef %43)
  br label %44

44:                                               ; preds = %41, %31
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ma_resource_manager, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct.ma_resource_manager_config, ptr %46, i32 0, i32 9
  %48 = load ptr, ptr %47, align 8, !tbaa !25
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ma_resource_manager, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %struct.ma_resource_manager_config, ptr %50, i32 0, i32 0
  call void @ma_free(ptr noundef %48, ptr noundef %51)
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ma_resource_manager, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.ma_resource_manager_config, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !26
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ma_resource_manager, ptr %56, i32 0, i32 6
  %58 = icmp eq ptr %55, %57
  br i1 %58, label %59, label %62

59:                                               ; preds = %44
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ma_resource_manager, ptr %60, i32 0, i32 6
  call void @ma_log_uninit(ptr noundef %61)
  br label %62

62:                                               ; preds = %59, %44, %6
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local i32 @ma_resource_manager_post_job_quit(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL48ma_resource_manager_delete_all_data_buffer_nodesP19ma_resource_manager(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 52}
!12 = !{!"_ZTS19ma_resource_manager", !13, i64 0, !6, i64 96, !7, i64 104, !7, i64 144, !16, i64 656, !20, i64 848, !22, i64 944}
!13 = !{!"_ZTS26ma_resource_manager_config", !14, i64 0, !6, i64 32, !15, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !10, i64 80, !6, i64 88}
!14 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!"_ZTS9ma_format", !7, i64 0}
!16 = !{!"_ZTS12ma_job_queue", !10, i64 0, !10, i64 4, !17, i64 8, !17, i64 16, !18, i64 24, !19, i64 120, !6, i64 160, !10, i64 168, !6, i64 176, !10, i64 184}
!17 = !{!"long long", !7, i64 0}
!18 = !{!"_ZTS12ma_semaphore", !10, i64 0, !7, i64 8, !7, i64 48}
!19 = !{!"_ZTS17ma_slot_allocator", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32}
!20 = !{!"_ZTS14ma_default_vfs", !21, i64 0, !14, i64 64}
!21 = !{!"_ZTS16ma_vfs_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!22 = !{!"_ZTS6ma_log", !7, i64 0, !10, i64 64, !14, i64 72, !7, i64 104}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!12, !6, i64 72}
!26 = !{!12, !6, i64 32}


; 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"

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_free(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_log_uninit(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_mutex_uninit(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_job_queue_uninit(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL14ma_thread_waitPm(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL40ma_resource_manager_is_threading_enabledPK19ma_resource_manager(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @ma_resource_manager_uninit(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %26, label %3

3:                                                ; preds = %1
  %4 = tail call i32 @ma_resource_manager_post_job_quit(ptr noundef nonnull %0)
  %5 = tail call noundef i32 @_ZL40ma_resource_manager_is_threading_enabledPK19ma_resource_manager(ptr noundef nonnull %0)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 52
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %.not21 = icmp eq i32 %7, 0
  br i1 %.not21, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %8 = getelementptr inbounds i8, ptr %0, i64 144
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %10 = getelementptr inbounds [64 x i64], ptr %8, i64 0, i64 %indvars.iv
  tail call void @_ZL14ma_thread_waitPm(ptr noundef nonnull %10)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = load i32, ptr %6, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = icmp ult i64 %indvars.iv.next, %12
  br i1 %13, label %9, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %9, %.preheader, %3
  tail call void @_ZL48ma_resource_manager_delete_all_data_buffer_nodesP19ma_resource_manager(ptr noundef nonnull %0)
  %14 = getelementptr inbounds i8, ptr %0, i64 656
  tail call void @ma_job_queue_uninit(ptr noundef nonnull %14, ptr noundef nonnull %0)
  %15 = tail call noundef i32 @_ZL40ma_resource_manager_is_threading_enabledPK19ma_resource_manager(ptr noundef nonnull %0)
  %.not19 = icmp eq i32 %15, 0
  br i1 %.not19, label %18, label %16

16:                                               ; preds = %.loopexit
  %17 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @ma_mutex_uninit(ptr noundef nonnull %17)
  br label %18

18:                                               ; preds = %16, %.loopexit
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = load ptr, ptr %19, align 8, !tbaa !23
  tail call void @ma_free(ptr noundef %20, ptr noundef nonnull %0)
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load ptr, ptr %21, align 8, !tbaa !24
  %23 = getelementptr inbounds i8, ptr %0, i64 944
  %24 = icmp eq ptr %22, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %18
  tail call void @ma_log_uninit(ptr noundef nonnull %23)
  br label %26

26:                                               ; preds = %1, %25, %18
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL48ma_resource_manager_delete_all_data_buffer_nodesP19ma_resource_manager(ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #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" }

!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 52}
!6 = !{!"_ZTS19ma_resource_manager", !7, i64 0, !9, i64 96, !10, i64 104, !10, i64 144, !14, i64 656, !18, i64 848, !20, i64 944}
!7 = !{!"_ZTS26ma_resource_manager_config", !8, i64 0, !9, i64 32, !12, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !9, i64 64, !9, i64 72, !13, i64 80, !9, i64 88}
!8 = !{!"_ZTS23ma_allocation_callbacks", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTS9ma_format", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"_ZTS12ma_job_queue", !13, i64 0, !13, i64 4, !15, i64 8, !15, i64 16, !16, i64 24, !17, i64 120, !9, i64 160, !13, i64 168, !9, i64 176, !13, i64 184}
!15 = !{!"long long", !10, i64 0}
!16 = !{!"_ZTS12ma_semaphore", !13, i64 0, !10, i64 8, !10, i64 48}
!17 = !{!"_ZTS17ma_slot_allocator", !9, i64 0, !9, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !9, i64 32}
!18 = !{!"_ZTS14ma_default_vfs", !19, i64 0, !8, i64 64}
!19 = !{!"_ZTS16ma_vfs_callbacks", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40, !9, i64 48, !9, i64 56}
!20 = !{!"_ZTS6ma_log", !10, i64 0, !13, i64 64, !8, i64 72, !10, i64 104}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!6, !9, i64 72}
!24 = !{!6, !9, i64 32}


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