; 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_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 }

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.157 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_get_length_in_pcm_frames = external hidden unnamed_addr constant [115 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_resource_manager_data_buffer_get_length_in_pcm_frames(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %6, i32 0, i32 2
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = call noundef i32 @_ZL43ma_resource_manager_data_buffer_node_resultPK36ma_resource_manager_data_buffer_node(ptr noundef %8)
  %10 = icmp ne i32 %9, -22
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %14

12:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.157, ptr noundef @.str.6, i32 noundef 66225, ptr noundef @__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_get_length_in_pcm_frames) #3
  unreachable

13:                                               ; No predecessors!
  br label %14

14:                                               ; preds = %13, %11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %20, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %14
  store i32 -2, ptr %3, align 4
  br label %33

21:                                               ; preds = %17
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = call noundef i32 @_ZL57ma_resource_manager_data_buffer_node_get_data_supply_typeP36ma_resource_manager_data_buffer_node(ptr noundef %24)
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %21
  store i32 -19, ptr %3, align 4
  br label %33

28:                                               ; preds = %21
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call noundef ptr @_ZL45ma_resource_manager_data_buffer_get_connectorP31ma_resource_manager_data_buffer(ptr noundef %29)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call i32 @ma_data_source_get_length_in_pcm_frames(ptr noundef %30, ptr noundef %31)
  store i32 %32, ptr %3, align 4
  br label %33

33:                                               ; preds = %28, %27, %20
  %34 = load i32, ptr %3, align 4
  ret i32 %34
}

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


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

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.157 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_get_length_in_pcm_frames = external hidden unnamed_addr constant [115 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_resource_manager_data_buffer_get_length_in_pcm_frames(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 80
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call noundef i32 @_ZL43ma_resource_manager_data_buffer_node_resultPK36ma_resource_manager_data_buffer_node(ptr noundef %4)
  %.not = icmp eq i32 %5, -22
  br i1 %.not, label %6, label %7

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.157, ptr noundef nonnull @.str.6, i32 noundef 66225, ptr noundef nonnull @__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_get_length_in_pcm_frames) #3
  unreachable

7:                                                ; preds = %2
  %8 = icmp eq ptr %1, null
  br i1 %8, label %16, label %9

9:                                                ; preds = %7
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = tail call noundef i32 @_ZL57ma_resource_manager_data_buffer_node_get_data_supply_typeP36ma_resource_manager_data_buffer_node(ptr noundef %10)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %16, label %13

13:                                               ; preds = %9
  %14 = tail call noundef ptr @_ZL45ma_resource_manager_data_buffer_get_connectorP31ma_resource_manager_data_buffer(ptr noundef nonnull %0)
  %15 = tail call i32 @ma_data_source_get_length_in_pcm_frames(ptr noundef %14, ptr noundef nonnull %1)
  br label %16

16:                                               ; preds = %9, %7, %13
  %.0 = phi i32 [ %15, %13 ], [ -2, %7 ], [ -19, %9 ]
  ret i32 %.0
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass