; 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 = 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.ma_resource_manager_inline_notification = type { %union.anon.76, ptr }
%union.anon.76 = type { %struct.ma_async_notification_event }
%struct.ma_async_notification_event = type { %struct.ma_async_notification_callbacks, %struct.ma_event }
%struct.ma_async_notification_callbacks = type { ptr }
%struct.ma_event = 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_resource_manager_data_stream = type { %struct.ma_data_source_base, ptr, i32, %struct.ma_decoder, i32, i64, i32, i64, i32, i32, i32, i32, ptr, [2 x i32], i32, i32, [2 x i32], i32 }
%struct.ma_data_source_base = type { ptr, i64, i64, i64, i64, ptr, ptr, ptr, i32 }
%struct.ma_decoder = type { %struct.ma_data_source_base, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i32, i32, i32, %struct.ma_data_converter, ptr, i64, i64, i64, %struct.ma_allocation_callbacks, %union.anon.61 }
%struct.ma_data_converter = type { i32, i32, i32, i32, i32, i32, i32, i32, %struct.ma_channel_converter, %struct.ma_resampler, i8, i8, i8, i8, i8, i8, ptr }
%struct.ma_channel_converter = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, %union.anon.27, ptr, i32 }
%union.anon.27 = type { ptr }
%struct.ma_resampler = type { ptr, ptr, ptr, i32, i32, i32, i32, %union.anon.28, ptr, i32 }
%union.anon.28 = type { %struct.ma_linear_resampler }
%struct.ma_linear_resampler = type { %struct.ma_linear_resampler_config, i32, i32, i32, i32, %union.anon.29, %union.anon.30, %struct.ma_lpf, ptr, i32 }
%struct.ma_linear_resampler_config = type { i32, i32, i32, i32, i32, double }
%union.anon.29 = type { ptr }
%union.anon.30 = type { ptr }
%struct.ma_lpf = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, i32 }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%union.anon.61 = type { %struct.anon.63 }
%struct.anon.63 = type { ptr, i64, i64 }
%struct.anon.11 = type { ptr, 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: 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 nounwind uwtable
declare dso_local void @ma_job_init(ptr dead_on_unwind noalias writable sret(%struct.ma_job) align 8, i16 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL44ma_resource_manager_inline_notification_initP19ma_resource_managerP39ma_resource_manager_inline_notification(ptr noundef, ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL55ma_resource_manager_inline_notification_wait_and_uninitP39ma_resource_manager_inline_notification(ptr noundef) #3

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

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

12:                                               ; preds = %1
  store i32 -2, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %37

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ma_resource_manager_data_stream, ptr %14, i32 0, i32 14
  store i32 -22, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %7, align 4
  %17 = atomicrmw xchg ptr %15, i32 %16 seq_cst, align 8
  store i32 %17, ptr %8, align 4
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ma_resource_manager_data_stream, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = call noundef i32 @_ZL44ma_resource_manager_inline_notification_initP19ma_resource_managerP39ma_resource_manager_inline_notification(ptr noundef %21, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 104, ptr %9) #4
  call void @ma_job_init(ptr dead_on_unwind writable sret(%struct.ma_job) align 8 %9, i16 noundef zeroext 8)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %9, i64 104, i1 false), !tbaa.struct !26
  call void @llvm.lifetime.end.p0(i64 104, ptr %9) #4
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call noundef i32 @_ZL52ma_resource_manager_data_stream_next_execution_orderP31ma_resource_manager_data_stream(ptr noundef %23)
  %25 = getelementptr inbounds %struct.ma_job, ptr %5, i32 0, i32 2
  store i32 %24, ptr %25, align 8, !tbaa !29
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ma_job, ptr %5, i32 0, i32 3
  %28 = getelementptr inbounds %struct.anon.11, ptr %27, i32 0, i32 0
  store ptr %26, ptr %28, align 8, !tbaa !27
  %29 = getelementptr inbounds %struct.ma_job, ptr %5, i32 0, i32 3
  %30 = getelementptr inbounds %struct.anon.11, ptr %29, i32 0, i32 1
  store ptr %4, ptr %30, align 8, !tbaa !27
  %31 = getelementptr inbounds %struct.ma_job, ptr %5, i32 0, i32 3
  %32 = getelementptr inbounds %struct.anon.11, ptr %31, i32 0, i32 2
  store ptr null, ptr %32, align 8, !tbaa !27
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ma_resource_manager_data_stream, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = call i32 @ma_resource_manager_post_job(ptr noundef %35, ptr noundef %5)
  call void @_ZL55ma_resource_manager_inline_notification_wait_and_uninitP39ma_resource_manager_inline_notification(ptr noundef %4)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %37

37:                                               ; preds = %13, %12
  call void @llvm.lifetime.end.p0(i64 104, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr %4) #4
  %38 = load i32, ptr %2, align 4
  ret i32 %38
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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, !6, i64 72}
!12 = !{!"_ZTS31ma_resource_manager_data_stream", !13, i64 0, !6, i64 72, !10, i64 80, !15, i64 88, !10, i64 640, !14, i64 648, !10, i64 656, !14, i64 664, !10, i64 672, !10, i64 676, !10, i64 680, !10, i64 684, !6, i64 688, !7, i64 696, !25, i64 704, !10, i64 708, !7, i64 712, !10, i64 720}
!13 = !{!"_ZTS19ma_data_source_base", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"_ZTS10ma_decoder", !13, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !14, i64 128, !16, i64 136, !10, i64 140, !10, i64 144, !17, i64 152, !6, i64 464, !14, i64 472, !14, i64 480, !14, i64 488, !24, i64 496, !7, i64 528}
!16 = !{!"_ZTS9ma_format", !7, i64 0}
!17 = !{!"_ZTS17ma_data_converter", !16, i64 0, !16, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !18, i64 24, !19, i64 28, !20, i64 32, !23, i64 104, !7, i64 296, !7, i64 297, !7, i64 298, !7, i64 299, !7, i64 300, !7, i64 301, !6, i64 304}
!18 = !{!"_ZTS14ma_dither_mode", !7, i64 0}
!19 = !{!"_ZTS32ma_data_converter_execution_path", !7, i64 0}
!20 = !{!"_ZTS20ma_channel_converter", !16, i64 0, !10, i64 4, !10, i64 8, !21, i64 12, !22, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !6, i64 56, !10, i64 64}
!21 = !{!"_ZTS19ma_channel_mix_mode", !7, i64 0}
!22 = !{!"_ZTS26ma_channel_conversion_path", !7, i64 0}
!23 = !{!"_ZTS12ma_resampler", !6, i64 0, !6, i64 8, !6, i64 16, !16, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !6, i64 176, !10, i64 184}
!24 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!25 = !{!"_ZTS9ma_result", !7, i64 0}
!26 = !{i64 0, i64 8, !27, i64 8, i64 8, !28, i64 16, i64 4, !9, i64 24, i64 80, !27}
!27 = !{!7, !7, i64 0}
!28 = !{!14, !14, i64 0}
!29 = !{!30, !10, i64 16}
!30 = !{!"_ZTS6ma_job", !7, i64 0, !14, i64 8, !10, i64 16, !7, i64 24}


; 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 }
%struct.ma_resource_manager_inline_notification = type { %union.anon.76, ptr }
%union.anon.76 = type { %struct.ma_async_notification_event }
%struct.ma_async_notification_event = type { %struct.ma_async_notification_callbacks, %struct.ma_event }
%struct.ma_async_notification_callbacks = type { ptr }
%struct.ma_event = 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 }

; 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 void @ma_job_init(ptr dead_on_unwind noalias writable sret(%struct.ma_job) align 8, i16 noundef zeroext) local_unnamed_addr #1

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -2, 1) i32 @ma_resource_manager_data_stream_uninit(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.ma_resource_manager_inline_notification, align 8
  %3 = alloca %struct.ma_job, align 8
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %3) #3
  %4 = icmp eq ptr %0, null
  br i1 %4, label %18, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 704
  %7 = atomicrmw xchg ptr %6, i32 -22 seq_cst, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 72
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = call noundef i32 @_ZL44ma_resource_manager_inline_notification_initP19ma_resource_managerP39ma_resource_manager_inline_notification(ptr noundef %9, ptr noundef nonnull %2)
  call void @ma_job_init(ptr dead_on_unwind nonnull writable sret(%struct.ma_job) align 8 %3, i16 noundef zeroext 8)
  %11 = call noundef i32 @_ZL52ma_resource_manager_data_stream_next_execution_orderP31ma_resource_manager_data_stream(ptr noundef nonnull %0)
  %12 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 %11, ptr %12, align 8, !tbaa !24
  %13 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %0, ptr %13, align 8, !tbaa !26
  %14 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr %2, ptr %14, align 8, !tbaa !26
  %15 = getelementptr inbounds i8, ptr %3, i64 40
  store ptr null, ptr %15, align 8, !tbaa !26
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = call i32 @ma_resource_manager_post_job(ptr noundef %16, ptr noundef nonnull %3)
  call void @_ZL55ma_resource_manager_inline_notification_wait_and_uninitP39ma_resource_manager_inline_notification(ptr noundef nonnull %2)
  br label %18

18:                                               ; preds = %1, %5
  %.0 = phi i32 [ 0, %5 ], [ -2, %1 ]
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %2) #3
  ret i32 %.0
}

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 = { 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 = { 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, !8, i64 72}
!6 = !{!"_ZTS31ma_resource_manager_data_stream", !7, i64 0, !8, i64 72, !12, i64 80, !13, i64 88, !12, i64 640, !11, i64 648, !12, i64 656, !11, i64 664, !12, i64 672, !12, i64 676, !12, i64 680, !12, i64 684, !8, i64 688, !9, i64 696, !23, i64 704, !12, i64 708, !9, i64 712, !12, i64 720}
!7 = !{!"_ZTS19ma_data_source_base", !8, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !12, i64 64}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long long", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"_ZTS10ma_decoder", !7, i64 0, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !8, i64 120, !11, i64 128, !14, i64 136, !12, i64 140, !12, i64 144, !15, i64 152, !8, i64 464, !11, i64 472, !11, i64 480, !11, i64 488, !22, i64 496, !9, i64 528}
!14 = !{!"_ZTS9ma_format", !9, i64 0}
!15 = !{!"_ZTS17ma_data_converter", !14, i64 0, !14, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !16, i64 24, !17, i64 28, !18, i64 32, !21, i64 104, !9, i64 296, !9, i64 297, !9, i64 298, !9, i64 299, !9, i64 300, !9, i64 301, !8, i64 304}
!16 = !{!"_ZTS14ma_dither_mode", !9, i64 0}
!17 = !{!"_ZTS32ma_data_converter_execution_path", !9, i64 0}
!18 = !{!"_ZTS20ma_channel_converter", !14, i64 0, !12, i64 4, !12, i64 8, !19, i64 12, !20, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !9, i64 48, !8, i64 56, !12, i64 64}
!19 = !{!"_ZTS19ma_channel_mix_mode", !9, i64 0}
!20 = !{!"_ZTS26ma_channel_conversion_path", !9, i64 0}
!21 = !{!"_ZTS12ma_resampler", !8, i64 0, !8, i64 8, !8, i64 16, !14, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !9, i64 40, !8, i64 176, !12, i64 184}
!22 = !{!"_ZTS23ma_allocation_callbacks", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!23 = !{!"_ZTS9ma_result", !9, i64 0}
!24 = !{!25, !12, i64 16}
!25 = !{!"_ZTS6ma_job", !9, i64 0, !11, i64 8, !12, i64 16, !9, i64 24}
!26 = !{!9, !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass