; 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_mp3 = type { %struct.ma_data_source_base, ptr, ptr, ptr, ptr, i32, %struct.drmp3, i32, ptr }
%struct.ma_data_source_base = type { ptr, i64, i64, i64, i64, ptr, ptr, ptr, i32 }
%struct.drmp3 = type { %struct.drmp3dec, %struct.drmp3dec_frame_info, i32, i32, ptr, ptr, ptr, %struct.drmp3_allocation_callbacks, i32, i32, i32, i32, [9216 x i8], i64, i64, ptr, i32, i64, i64, i64, ptr, i8, %struct.anon.59 }
%struct.drmp3dec = type { [2 x [288 x float]], [960 x float], i32, i32, [4 x i8], [511 x i8] }
%struct.drmp3dec_frame_info = type { i32, i32, i32, i32, i32 }
%struct.drmp3_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.anon.59 = type { ptr, i64, i64 }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z22ma_mp3_get_data_formatP6ma_mp3P9ma_formatPjS3_Phm(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !9
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %6
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %16, %6
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %22, align 4, !tbaa !13
  br label %23

23:                                               ; preds = %21, %18
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 0, ptr %27, align 4, !tbaa !13
  br label %28

28:                                               ; preds = %26, %23
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %35

31:                                               ; preds = %28
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = load i64, ptr %13, align 8, !tbaa !9
  %34 = mul i64 1, %33
  call void @llvm.memset.p0.i64(ptr align 1 %32, i8 0, i64 %34, i1 false)
  br label %35

35:                                               ; preds = %31, %28
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  store i32 -3, ptr %7, align 4
  br label %76

39:                                               ; preds = %35
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %47

42:                                               ; preds = %39
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ma_mp3, ptr %43, i32 0, i32 5
  %45 = load i32, ptr %44, align 8, !tbaa !15
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %45, ptr %46, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %42, %39
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %56

50:                                               ; preds = %47
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ma_mp3, ptr %51, i32 0, i32 6
  %53 = getelementptr inbounds %struct.drmp3, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !24
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %54, ptr %55, align 4, !tbaa !13
  br label %56

56:                                               ; preds = %50, %47
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %65

59:                                               ; preds = %56
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ma_mp3, ptr %60, i32 0, i32 6
  %62 = getelementptr inbounds %struct.drmp3, ptr %61, i32 0, i32 3
  %63 = load i32, ptr %62, align 4, !tbaa !25
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %63, ptr %64, align 4, !tbaa !13
  br label %65

65:                                               ; preds = %59, %56
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %75

68:                                               ; preds = %65
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = load i64, ptr %13, align 8, !tbaa !9
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.ma_mp3, ptr %71, i32 0, i32 6
  %73 = getelementptr inbounds %struct.drmp3, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 8, !tbaa !24
  call void @ma_channel_map_init_standard(i32 noundef 0, ptr noundef %69, i64 noundef %70, i32 noundef %74)
  br label %75

75:                                               ; preds = %68, %65
  store i32 0, ptr %7, align 4
  br label %76

76:                                               ; preds = %75, %38
  %77 = load i32, ptr %7, align 4
  ret i32 %77
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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" }

!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 = !{!12, !12, i64 0}
!12 = !{!"_ZTS9ma_format", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !12, i64 104}
!16 = !{!"_ZTS6ma_mp3", !17, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !12, i64 104, !19, i64 112, !14, i64 16192, !6, i64 16200}
!17 = !{!"_ZTS19ma_data_source_base", !6, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !18, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !14, i64 64}
!18 = !{!"long long", !7, i64 0}
!19 = !{!"_ZTS5drmp3", !20, i64 0, !21, i64 6668, !14, i64 6688, !14, i64 6692, !6, i64 6696, !6, i64 6704, !6, i64 6712, !22, i64 6720, !14, i64 6752, !14, i64 6756, !14, i64 6760, !14, i64 6764, !7, i64 6768, !18, i64 15984, !18, i64 15992, !6, i64 16000, !14, i64 16008, !10, i64 16016, !10, i64 16024, !10, i64 16032, !6, i64 16040, !14, i64 16048, !23, i64 16056}
!20 = !{!"_ZTS8drmp3dec", !7, i64 0, !7, i64 2304, !14, i64 6144, !14, i64 6148, !7, i64 6152, !7, i64 6156}
!21 = !{!"_ZTS19drmp3dec_frame_info", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16}
!22 = !{!"_ZTS26drmp3_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!23 = !{!"_ZTSN5drmp3Ut_E", !6, i64 0, !10, i64 8, !10, i64 16}
!24 = !{!16, !14, i64 6800}
!25 = !{!16, !14, i64 6804}


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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -3, 1) i32 @_Z22ma_mp3_get_data_formatP6ma_mp3P9ma_formatPjS3_Phm(ptr noundef readonly %0, ptr noundef writeonly %1, ptr noundef writeonly %2, ptr noundef writeonly %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %8, label %7

7:                                                ; preds = %6
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %7, %6
  %.not31 = icmp eq ptr %2, null
  br i1 %.not31, label %10, label %9

9:                                                ; preds = %8
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %9, %8
  %.not32 = icmp eq ptr %3, null
  br i1 %.not32, label %12, label %11

11:                                               ; preds = %10
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %11, %10
  %.not33 = icmp eq ptr %4, null
  br i1 %.not33, label %14, label %13

13:                                               ; preds = %12
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %4, i8 0, i64 %5, i1 false)
  br label %14

14:                                               ; preds = %13, %12
  %15 = icmp eq ptr %0, null
  br i1 %15, label %32, label %16

16:                                               ; preds = %14
  br i1 %.not, label %20, label %17

17:                                               ; preds = %16
  %18 = getelementptr inbounds i8, ptr %0, i64 104
  %19 = load i32, ptr %18, align 8, !tbaa !11
  store i32 %19, ptr %1, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %17, %16
  br i1 %.not31, label %24, label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds i8, ptr %0, i64 6800
  %23 = load i32, ptr %22, align 8, !tbaa !22
  store i32 %23, ptr %2, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %21, %20
  br i1 %.not32, label %28, label %25

25:                                               ; preds = %24
  %26 = getelementptr inbounds i8, ptr %0, i64 6804
  %27 = load i32, ptr %26, align 4, !tbaa !23
  store i32 %27, ptr %3, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %25, %24
  br i1 %.not33, label %32, label %29

29:                                               ; preds = %28
  %30 = getelementptr inbounds i8, ptr %0, i64 6800
  %31 = load i32, ptr %30, align 8, !tbaa !22
  tail call void @ma_channel_map_init_standard(i32 noundef 0, ptr noundef nonnull %4, i64 noundef %5, i32 noundef %31)
  br label %32

32:                                               ; preds = %28, %29, %14
  %.0 = phi i32 [ -3, %14 ], [ 0, %29 ], [ 0, %28 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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" }

!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 = !{!"_ZTS9ma_format", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 104}
!12 = !{!"_ZTS6ma_mp3", !13, i64 0, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !6, i64 104, !16, i64 112, !10, i64 16192, !14, i64 16200}
!13 = !{!"_ZTS19ma_data_source_base", !14, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !10, i64 64}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"_ZTS5drmp3", !17, i64 0, !18, i64 6668, !10, i64 6688, !10, i64 6692, !14, i64 6696, !14, i64 6704, !14, i64 6712, !19, i64 6720, !10, i64 6752, !10, i64 6756, !10, i64 6760, !10, i64 6764, !7, i64 6768, !15, i64 15984, !15, i64 15992, !14, i64 16000, !10, i64 16008, !20, i64 16016, !20, i64 16024, !20, i64 16032, !14, i64 16040, !10, i64 16048, !21, i64 16056}
!17 = !{!"_ZTS8drmp3dec", !7, i64 0, !7, i64 2304, !10, i64 6144, !10, i64 6148, !7, i64 6152, !7, i64 6156}
!18 = !{!"_ZTS19drmp3dec_frame_info", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!19 = !{!"_ZTS26drmp3_allocation_callbacks", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSN5drmp3Ut_E", !14, i64 0, !20, i64 8, !20, i64 16}
!22 = !{!12, !10, i64 6800}
!23 = !{!12, !10, i64 6804}


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