; 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_data_source_config = type { ptr, ptr, ptr, i64, i64, i64, i64, i64, i32, i32 }
%struct.ma_resource_manager_data_buffer = type { %struct.ma_data_source_base, ptr, ptr, i32, i32, i32, i64, i32, i32, i32, i32, %union.anon.71 }
%struct.ma_data_source_base = type { ptr, i64, i64, i64, i64, ptr, ptr, ptr, i32 }
%union.anon.71 = type { %struct.ma_decoder }
%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.ma_resource_manager_data_buffer_node = type { i32, i32, i32, i32, i32, i32, %struct.ma_resource_manager_data_supply, ptr, ptr, ptr }
%struct.ma_resource_manager_data_supply = type { i32, %union.anon.72 }
%union.anon.72 = type { %struct.anon.75 }
%struct.anon.75 = type { %struct.ma_paged_audio_buffer_data, i64, i32 }
%struct.ma_paged_audio_buffer_data = type { i32, i32, %struct.ma_paged_audio_buffer_page, ptr }
%struct.ma_paged_audio_buffer_page = type { ptr, i64, [1 x i8] }

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.156 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_init_copy = external hidden unnamed_addr constant [151 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ma_resource_manager_data_source_config_init(ptr dead_on_unwind noalias writable sret(%struct.ma_resource_manager_data_source_config) align 8) #3

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

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

13:                                               ; preds = %3
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %35

14:                                               ; preds = %3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  br label %22

20:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.156, ptr noundef @.str.6, i32 noundef 65946, ptr noundef @__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_init_copy) #6
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  call void @llvm.lifetime.start.p0(i64 72, ptr %10) #5
  call void @ma_resource_manager_data_source_config_init(ptr dead_on_unwind writable sret(%struct.ma_resource_manager_data_source_config) align 8 %10)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %10, i64 72, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 72, ptr %10) #5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %23, i32 0, i32 3
  %25 = load i32, ptr %24, align 8, !tbaa !18
  %26 = getelementptr inbounds %struct.ma_resource_manager_data_source_config, ptr %8, i32 0, i32 9
  store i32 %25, ptr %26, align 4, !tbaa !19
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.ma_resource_manager_data_buffer_node, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !21
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = call noundef i32 @_ZL48ma_resource_manager_data_buffer_init_ex_internalP19ma_resource_managerPK38ma_resource_manager_data_source_configjP31ma_resource_manager_data_buffer(ptr noundef %27, ptr noundef %8, i32 noundef %32, ptr noundef %33)
  store i32 %34, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %35

35:                                               ; preds = %22, %13
  call void @llvm.lifetime.end.p0(i64 72, ptr %8) #5
  %36 = load i32, ptr %4, align 4
  ret i32 %36
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #5 = { nounwind }
attributes #6 = { 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, !6, i64 80}
!10 = !{!"_ZTS31ma_resource_manager_data_buffer", !11, i64 0, !6, i64 72, !6, i64 80, !13, i64 88, !13, i64 92, !13, i64 96, !12, i64 104, !13, i64 112, !14, i64 116, !13, i64 120, !13, i64 124, !7, i64 128}
!11 = !{!"_ZTS19ma_data_source_base", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !13, i64 64}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS9ma_result", !7, i64 0}
!15 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !16, i64 32, i64 8, !16, i64 40, i64 8, !16, i64 48, i64 8, !16, i64 56, i64 8, !16, i64 64, i64 4, !17, i64 68, i64 4, !17}
!16 = !{!12, !12, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!10, !13, i64 88}
!19 = !{!20, !13, i64 68}
!20 = !{!"_ZTS38ma_resource_manager_data_source_config", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !13, i64 64, !13, i64 68}
!21 = !{!22, !13, i64 0}
!22 = !{!"_ZTS36ma_resource_manager_data_buffer_node", !13, i64 0, !13, i64 4, !14, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !23, i64 24, !6, i64 88, !6, i64 96, !6, i64 104}
!23 = !{!"_ZTS31ma_resource_manager_data_supply", !24, i64 0, !7, i64 8}
!24 = !{!"_ZTS36ma_resource_manager_data_supply_type", !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_resource_manager_data_source_config = type { ptr, ptr, ptr, i64, i64, i64, i64, i64, i32, i32 }

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.156 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_init_copy = external hidden unnamed_addr constant [151 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ma_resource_manager_data_source_config_init(ptr dead_on_unwind noalias writable sret(%struct.ma_resource_manager_data_source_config) align 8) local_unnamed_addr #2

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

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

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 80
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.156, ptr noundef nonnull @.str.6, i32 noundef 65946, ptr noundef nonnull @__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_init_copy) #5
  unreachable

10:                                               ; preds = %6
  call void @ma_resource_manager_data_source_config_init(ptr dead_on_unwind nonnull writable sret(%struct.ma_resource_manager_data_source_config) align 8 %4)
  %11 = getelementptr inbounds i8, ptr %1, i64 88
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %4, i64 68
  store i32 %12, ptr %13, align 4, !tbaa !15
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = load i32, ptr %14, align 8, !tbaa !17
  %16 = call noundef i32 @_ZL48ma_resource_manager_data_buffer_init_ex_internalP19ma_resource_managerPK38ma_resource_manager_data_source_configjP31ma_resource_manager_data_buffer(ptr noundef %0, ptr noundef nonnull %4, i32 noundef %15, ptr noundef %2)
  br label %17

17:                                               ; preds = %3, %10
  %.0 = phi i32 [ %16, %10 ], [ -2, %3 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %4) #4
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }
attributes #5 = { 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, !8, i64 80}
!6 = !{!"_ZTS31ma_resource_manager_data_buffer", !7, i64 0, !8, i64 72, !8, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !11, i64 104, !12, i64 112, !13, i64 116, !12, i64 120, !12, i64 124, !9, i64 128}
!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 = !{!"_ZTS9ma_result", !9, i64 0}
!14 = !{!6, !12, i64 88}
!15 = !{!16, !12, i64 68}
!16 = !{!"_ZTS38ma_resource_manager_data_source_config", !8, i64 0, !8, i64 8, !8, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !12, i64 64, !12, i64 68}
!17 = !{!18, !12, i64 0}
!18 = !{!"_ZTS36ma_resource_manager_data_buffer_node", !12, i64 0, !12, i64 4, !13, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !19, i64 24, !8, i64 88, !8, i64 96, !8, i64 104}
!19 = !{!"_ZTS31ma_resource_manager_data_supply", !20, i64 0, !9, i64 8}
!20 = !{!"_ZTS36ma_resource_manager_data_supply_type", !9, i64 0}


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