; 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_source = type { %union.anon.77, i32, i32, i32 }
%union.anon.77 = type { %struct.ma_resource_manager_data_stream }
%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 }

; 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_resource_manager_data_source_config_init(ptr dead_on_unwind noalias writable sret(%struct.ma_resource_manager_data_source_config) align 8) #2

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

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

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

14:                                               ; preds = %3
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %41

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 72, ptr %11) #4
  call void @ma_resource_manager_data_source_config_init(ptr dead_on_unwind writable sret(%struct.ma_resource_manager_data_source_config) align 8 %11)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %11, i64 72, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 72, ptr %11) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ma_resource_manager_data_source, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = getelementptr inbounds %struct.ma_resource_manager_data_source_config, ptr %9, i32 0, i32 9
  store i32 %18, ptr %19, align 4, !tbaa !16
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = call noundef i32 @_ZL39ma_resource_manager_data_source_preinitP19ma_resource_managerPK38ma_resource_manager_data_source_configP31ma_resource_manager_data_source(ptr noundef %20, ptr noundef %9, ptr noundef %21)
  store i32 %22, ptr %8, align 4, !tbaa !18
  %23 = load i32, ptr %8, align 4, !tbaa !18
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %15
  %26 = load i32, ptr %8, align 4, !tbaa !18
  store i32 %26, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %41

27:                                               ; preds = %15
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ma_resource_manager_data_source, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !14
  %31 = and i32 %30, 1
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  store i32 -3, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %41

34:                                               ; preds = %27
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ma_resource_manager_data_source, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ma_resource_manager_data_source, ptr %38, i32 0, i32 0
  %40 = call i32 @ma_resource_manager_data_buffer_init_copy(ptr noundef %35, ptr noundef %37, ptr noundef %39)
  store i32 %40, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %41

41:                                               ; preds = %34, %33, %25, %14
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %42 = load i32, ptr %4, align 4
  ret i32 %42
}

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 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !10, i64 32, i64 8, !10, i64 40, i64 8, !10, i64 48, i64 8, !10, i64 56, i64 8, !10, i64 64, i64 4, !12, i64 68, i64 4, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"long long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 728}
!15 = !{!"_ZTS31ma_resource_manager_data_source", !7, i64 0, !13, i64 728, !13, i64 732, !13, i64 736}
!16 = !{!17, !13, i64 68}
!17 = !{!"_ZTS38ma_resource_manager_data_source_config", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !13, i64 64, !13, i64 68}
!18 = !{!19, !19, i64 0}
!19 = !{!"_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_resource_manager_data_source_config = type { ptr, ptr, ptr, i64, i64, i64, i64, i64, i32, i32 }

; 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_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 #1

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

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

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

6:                                                ; preds = %3
  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)
  %7 = getelementptr inbounds i8, ptr %1, i64 728
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %4, i64 68
  store i32 %8, ptr %9, align 4, !tbaa !10
  %10 = call noundef i32 @_ZL39ma_resource_manager_data_source_preinitP19ma_resource_managerPK38ma_resource_manager_data_source_configP31ma_resource_manager_data_source(ptr noundef %0, ptr noundef nonnull %4, ptr noundef %2)
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %16

11:                                               ; preds = %6
  %12 = load i32, ptr %7, align 8, !tbaa !5
  %13 = and i32 %12, 1
  %.not12 = icmp eq i32 %13, 0
  br i1 %.not12, label %14, label %16

14:                                               ; preds = %11
  %15 = call i32 @ma_resource_manager_data_buffer_init_copy(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2)
  br label %16

16:                                               ; preds = %11, %6, %3, %14
  %.0 = phi i32 [ %15, %14 ], [ -2, %3 ], [ %10, %6 ], [ -3, %11 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %4) #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, !9, i64 728}
!6 = !{!"_ZTS31ma_resource_manager_data_source", !7, i64 0, !9, i64 728, !9, i64 732, !9, i64 736}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!11, !9, i64 68}
!11 = !{!"_ZTS38ma_resource_manager_data_source_config", !12, i64 0, !12, i64 8, !12, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !9, i64 64, !9, i64 68}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"long long", !7, i64 0}


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