; 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_decoder_config = type { i32, i32, i32, ptr, i32, i32, %struct.ma_resampler_config, %struct.ma_allocation_callbacks, i32, i32, ptr, i32, ptr }
%struct.ma_resampler_config = type { i32, i32, i32, i32, i32, ptr, ptr, %struct.anon.48 }
%struct.anon.48 = type { i32 }
%struct.ma_allocation_callbacks = type { ptr, 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 @_Z27ma_decoder_config_init_copyPK17ma_decoder_config(ptr dead_on_unwind noalias writable sret(%struct.ma_decoder_config) align 8, ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_decoder_init_memory(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.ma_decoder_config, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.ma_decoder_config, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 144, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 144, ptr %12) #4
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_Z27ma_decoder_config_init_copyPK17ma_decoder_config(ptr dead_on_unwind writable sret(%struct.ma_decoder_config) align 8 %12, ptr noundef %14)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %12, i64 144, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 144, ptr %12) #4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = call noundef i32 @_ZL26ma_decoder__preinit_memoryPKvmPK17ma_decoder_configP10ma_decoder(ptr noundef %15, i64 noundef %16, ptr noundef %10, ptr noundef %17)
  store i32 %18, ptr %11, align 4, !tbaa !24
  %19 = load i32, ptr %11, align 4, !tbaa !24
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %4
  %22 = load i32, ptr %11, align 4, !tbaa !24
  store i32 %22, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %26

23:                                               ; preds = %4
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = call noundef i32 @_ZL25ma_decoder_init__internalPF9ma_resultP10ma_decoderPvmPmEPFS_S1_x14ma_seek_originES2_PK17ma_decoder_configS1_(ptr noundef @_ZL26ma_decoder__on_read_memoryP10ma_decoderPvmPm, ptr noundef @_ZL26ma_decoder__on_seek_memoryP10ma_decoderx14ma_seek_origin, ptr noundef null, ptr noundef %10, ptr noundef %24)
  store i32 %25, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %26

26:                                               ; preds = %23, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 144, ptr %10) #4
  %27 = load i32, ptr %5, align 4
  ret i32 %27
}

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

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

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

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 = !{!"long", !7, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 4, !14, i64 8, i64 4, !14, i64 16, i64 8, !5, i64 24, i64 4, !16, i64 28, i64 4, !18, i64 32, i64 4, !12, i64 36, i64 4, !14, i64 40, i64 4, !14, i64 44, i64 4, !14, i64 48, i64 4, !20, i64 56, i64 8, !5, i64 64, i64 8, !5, i64 72, i64 4, !14, i64 80, i64 8, !5, i64 88, i64 8, !5, i64 96, i64 8, !5, i64 104, i64 8, !5, i64 112, i64 4, !22, i64 116, i64 4, !14, i64 120, i64 8, !5, i64 128, i64 4, !14, i64 136, i64 8, !5}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS9ma_format", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"_ZTS19ma_channel_mix_mode", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"_ZTS14ma_dither_mode", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"_ZTS21ma_resample_algorithm", !7, i64 0}
!22 = !{!23, !23, i64 0}
!23 = !{!"_ZTS18ma_encoding_format", !7, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"_ZTS9ma_result", !7, 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_decoder_config = type { i32, i32, i32, ptr, i32, i32, %struct.ma_resampler_config, %struct.ma_allocation_callbacks, i32, i32, ptr, i32, ptr }
%struct.ma_resampler_config = type { i32, i32, i32, i32, i32, ptr, ptr, %struct.anon.48 }
%struct.anon.48 = type { i32 }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }

; 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 @_Z27ma_decoder_config_init_copyPK17ma_decoder_config(ptr dead_on_unwind noalias writable sret(%struct.ma_decoder_config) align 8, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @ma_decoder_init_memory(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.ma_decoder_config, align 8
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %5) #3
  call void @_Z27ma_decoder_config_init_copyPK17ma_decoder_config(ptr dead_on_unwind nonnull writable sret(%struct.ma_decoder_config) align 8 %5, ptr noundef %2)
  %6 = call noundef i32 @_ZL26ma_decoder__preinit_memoryPKvmPK17ma_decoder_configP10ma_decoder(ptr noundef %0, i64 noundef %1, ptr noundef nonnull %5, ptr noundef %3)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %9

7:                                                ; preds = %4
  %8 = call noundef i32 @_ZL25ma_decoder_init__internalPF9ma_resultP10ma_decoderPvmPmEPFS_S1_x14ma_seek_originES2_PK17ma_decoder_configS1_(ptr noundef nonnull @_ZL26ma_decoder__on_read_memoryP10ma_decoderPvmPm, ptr noundef nonnull @_ZL26ma_decoder__on_seek_memoryP10ma_decoderx14ma_seek_origin, ptr noundef null, ptr noundef nonnull %5, ptr noundef %3)
  br label %9

9:                                                ; preds = %4, %7
  %.0 = phi i32 [ %8, %7 ], [ %6, %4 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %5) #3
  ret i32 %.0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL26ma_decoder__on_read_memoryP10ma_decoderPvmPm(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL26ma_decoder__on_seek_memoryP10ma_decoderx14ma_seek_origin(ptr noundef, i64 noundef, i32 noundef) #1

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)"}


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