; 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_stbvorbis = type { %struct.ma_data_source_base, ptr, ptr, ptr, ptr, %struct.ma_allocation_callbacks, i32, i32, i32, i64, ptr, i32, %struct.anon.60 }
%struct.ma_data_source_base = type { ptr, i64, i64, i64, i64, ptr, ptr, ptr, i32 }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.anon.60 = type { ptr, i64, i64, i32, i32, ptr }

; 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 @_Z28ma_stbvorbis_get_data_formatP12ma_stbvorbisP9ma_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 %73

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_stbvorbis, ptr %43, i32 0, i32 6
  %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 %55

50:                                               ; preds = %47
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ma_stbvorbis, ptr %51, i32 0, i32 7
  %53 = load i32, ptr %52, align 4, !tbaa !21
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %53, ptr %54, align 4, !tbaa !13
  br label %55

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

58:                                               ; preds = %55
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.ma_stbvorbis, ptr %59, i32 0, i32 8
  %61 = load i32, ptr %60, align 8, !tbaa !22
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %61, ptr %62, align 4, !tbaa !13
  br label %63

63:                                               ; preds = %58, %55
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %72

66:                                               ; preds = %63
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = load i64, ptr %13, align 8, !tbaa !9
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ma_stbvorbis, ptr %69, i32 0, i32 7
  %71 = load i32, ptr %70, align 4, !tbaa !21
  call void @ma_channel_map_init_standard(i32 noundef 4, ptr noundef %67, i64 noundef %68, i32 noundef %71)
  br label %72

72:                                               ; preds = %66, %63
  store i32 0, ptr %7, align 4
  br label %73

73:                                               ; preds = %72, %38
  %74 = load i32, ptr %7, align 4
  ret i32 %74
}

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 136}
!16 = !{!"_ZTS12ma_stbvorbis", !17, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !19, i64 104, !12, i64 136, !14, i64 140, !14, i64 144, !18, i64 152, !6, i64 160, !14, i64 168, !20, i64 176}
!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 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"_ZTSN12ma_stbvorbisUt_E", !6, i64 0, !10, i64 8, !10, i64 16, !14, i64 24, !14, i64 28, !6, i64 32}
!21 = !{!16, !14, i64 140}
!22 = !{!16, !14, i64 144}


; 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 @_Z28ma_stbvorbis_get_data_formatP12ma_stbvorbisP9ma_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 136
  %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 140
  %23 = load i32, ptr %22, align 4, !tbaa !19
  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 144
  %27 = load i32, ptr %26, align 8, !tbaa !20
  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 140
  %31 = load i32, ptr %30, align 4, !tbaa !19
  tail call void @ma_channel_map_init_standard(i32 noundef 4, 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 136}
!12 = !{!"_ZTS12ma_stbvorbis", !13, i64 0, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !16, i64 104, !6, i64 136, !10, i64 140, !10, i64 144, !15, i64 152, !14, i64 160, !10, i64 168, !17, i64 176}
!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 = !{!"_ZTS23ma_allocation_callbacks", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!17 = !{!"_ZTSN12ma_stbvorbisUt_E", !14, i64 0, !18, i64 8, !18, i64 16, !10, i64 24, !10, i64 28, !14, i64 32}
!18 = !{!"long", !7, i64 0}
!19 = !{!12, !10, i64 140}
!20 = !{!12, !10, i64 144}


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