; 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_seek_to_pcm_frame = external hidden unnamed_addr constant [106 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

; 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) #3

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

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

13:                                               ; preds = %2
  br label %16

14:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.157, ptr noundef @.str.6, i32 noundef 66119, ptr noundef @__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_seek_to_pcm_frame) #5
  unreachable

15:                                               ; No predecessors!
  br label %16

16:                                               ; preds = %15, %13
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = call noundef i32 @_ZL57ma_resource_manager_data_buffer_node_get_data_supply_typeP36ma_resource_manager_data_buffer_node(ptr noundef %19)
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %28

22:                                               ; preds = %16
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %24, i32 0, i32 6
  store i64 %23, ptr %25, align 8, !tbaa !16
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %26, i32 0, i32 7
  store i32 1, ptr %27, align 8, !tbaa !17
  store i32 -19, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %42

28:                                               ; preds = %16
  %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 i64, ptr %5, align 8, !tbaa !9
  %32 = call i32 @ma_data_source_seek_to_pcm_frame(ptr noundef %30, i64 noundef %31)
  store i32 %32, ptr %6, align 4, !tbaa !18
  %33 = load i32, ptr %6, align 4, !tbaa !18
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %28
  %36 = load i32, ptr %6, align 4, !tbaa !18
  store i32 %36, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %42

37:                                               ; preds = %28
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %38, i32 0, i32 6
  store i64 -1, ptr %39, align 8, !tbaa !16
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ma_resource_manager_data_buffer, ptr %40, i32 0, i32 7
  store i32 0, ptr %41, align 8, !tbaa !17
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %42

42:                                               ; preds = %37, %35, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %43 = load i32, ptr %3, align 4
  ret i32 %43
}

attributes #0 = { 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 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 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 = { 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, !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 long", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"_ZTS31ma_resource_manager_data_buffer", !13, i64 0, !6, i64 72, !6, i64 80, !14, i64 88, !14, i64 92, !14, i64 96, !10, i64 104, !14, i64 112, !15, i64 116, !14, i64 120, !14, i64 124, !7, i64 128}
!13 = !{!"_ZTS19ma_data_source_base", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !14, i64 64}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTS9ma_result", !7, i64 0}
!16 = !{!12, !10, i64 104}
!17 = !{!12, !14, i64 112}
!18 = !{!15, !15, 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_seek_to_pcm_frame = external hidden unnamed_addr constant [106 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_seek_to_pcm_frame(ptr noundef, i64 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_seek_to_pcm_frame(ptr noundef %0, i64 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 66119, ptr noundef nonnull @__PRETTY_FUNCTION__.ma_resource_manager_data_buffer_seek_to_pcm_frame) #3
  unreachable

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

11:                                               ; preds = %7
  %12 = tail call noundef ptr @_ZL45ma_resource_manager_data_buffer_get_connectorP31ma_resource_manager_data_buffer(ptr noundef nonnull %0)
  %13 = tail call i32 @ma_data_source_seek_to_pcm_frame(ptr noundef %12, i64 noundef %1)
  %.not12 = icmp eq i32 %13, 0
  br i1 %.not12, label %.sink.split, label %16

.sink.split:                                      ; preds = %11, %7
  %.sink14 = phi i64 [ %1, %7 ], [ -1, %11 ]
  %.sink = phi i32 [ 1, %7 ], [ 0, %11 ]
  %.0.ph = phi i32 [ -19, %7 ], [ 0, %11 ]
  %14 = getelementptr inbounds i8, ptr %0, i64 104
  store i64 %.sink14, ptr %14, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %0, i64 112
  store i32 %.sink, ptr %15, align 8, !tbaa !15
  br label %16

16:                                               ; preds = %.sink.split, %11
  %.0 = phi i32 [ %13, %11 ], [ %.0.ph, %.sink.split ]
  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}
!14 = !{!6, !11, i64 104}
!15 = !{!6, !12, i64 112}


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