; 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_wav = type { %struct.ma_data_source_base, ptr, ptr, ptr, ptr, i32, %struct.drwav }
%struct.ma_data_source_base = type { ptr, i64, i64, i64, i64, ptr, ptr, ptr, i32 }
%struct.drwav = type { ptr, ptr, ptr, ptr, %struct.drwav_allocation_callbacks, i32, %struct.drwav_fmt, i32, i16, i16, i16, i64, i64, i64, i64, i64, i64, i32, i32, ptr, i32, %struct.drwav__memory_stream, %struct.drwav__memory_stream_write, %struct.anon.57, %struct.anon.58 }
%struct.drwav_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.drwav_fmt = type { i16, i16, i32, i32, i16, i16, i16, i16, i32, [16 x i8] }
%struct.drwav__memory_stream = type { ptr, i64, i64 }
%struct.drwav__memory_stream_write = type { ptr, ptr, i64, i64, i64 }
%struct.anon.57 = type { i32, [2 x i16], [2 x i32], [4 x i32], i32, [2 x [2 x i32]] }
%struct.anon.58 = type { i32, [2 x i32], [2 x i32], [16 x i32], i32 }

; 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_wav_get_data_formatP6ma_wavP9ma_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 %78

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_wav, 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 %57

50:                                               ; preds = %47
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ma_wav, ptr %51, i32 0, i32 6
  %53 = getelementptr inbounds %struct.drwav, ptr %52, i32 0, i32 8
  %54 = load i16, ptr %53, align 8, !tbaa !29
  %55 = zext i16 %54 to i32
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %55, ptr %56, align 4, !tbaa !13
  br label %57

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

60:                                               ; preds = %57
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ma_wav, ptr %61, i32 0, i32 6
  %63 = getelementptr inbounds %struct.drwav, ptr %62, i32 0, i32 7
  %64 = load i32, ptr %63, align 4, !tbaa !30
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %64, ptr %65, align 4, !tbaa !13
  br label %66

66:                                               ; preds = %60, %57
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %77

69:                                               ; preds = %66
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = load i64, ptr %13, align 8, !tbaa !9
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ma_wav, ptr %72, i32 0, i32 6
  %74 = getelementptr inbounds %struct.drwav, ptr %73, i32 0, i32 8
  %75 = load i16, ptr %74, align 8, !tbaa !29
  %76 = zext i16 %75 to i32
  call void @ma_channel_map_init_standard(i32 noundef 0, ptr noundef %70, i64 noundef %71, i32 noundef %76)
  br label %77

77:                                               ; preds = %69, %66
  store i32 0, ptr %7, align 4
  br label %78

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

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_wav", !17, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !12, i64 104, !19, i64 112}
!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 = !{!"_ZTS5drwav", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !20, i64 32, !21, i64 64, !22, i64 68, !14, i64 108, !23, i64 112, !23, i64 114, !23, i64 116, !18, i64 120, !18, i64 128, !18, i64 136, !18, i64 144, !18, i64 152, !18, i64 160, !14, i64 168, !24, i64 172, !6, i64 176, !14, i64 184, !25, i64 192, !26, i64 216, !27, i64 256, !28, i64 308}
!20 = !{!"_ZTS26drwav_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!"_ZTS15drwav_container", !7, i64 0}
!22 = !{!"_ZTS9drwav_fmt", !23, i64 0, !23, i64 2, !14, i64 4, !14, i64 8, !23, i64 12, !23, i64 14, !23, i64 16, !23, i64 18, !14, i64 20, !7, i64 24}
!23 = !{!"short", !7, i64 0}
!24 = !{!"_ZTS19drwav_metadata_type", !7, i64 0}
!25 = !{!"_ZTS20drwav__memory_stream", !6, i64 0, !10, i64 8, !10, i64 16}
!26 = !{!"_ZTS26drwav__memory_stream_write", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!27 = !{!"_ZTSN5drwavUt_E", !14, i64 0, !7, i64 4, !7, i64 8, !7, i64 16, !14, i64 32, !7, i64 36}
!28 = !{!"_ZTSN5drwavUt0_E", !14, i64 0, !7, i64 4, !7, i64 12, !7, i64 20, !14, i64 84}
!29 = !{!16, !23, i64 224}
!30 = !{!16, !14, i64 220}


; 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_wav_get_data_formatP6ma_wavP9ma_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 %34, 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 %25, label %21

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

25:                                               ; preds = %21, %20
  br i1 %.not32, label %29, label %26

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

29:                                               ; preds = %26, %25
  br i1 %.not33, label %34, label %30

30:                                               ; preds = %29
  %31 = getelementptr inbounds i8, ptr %0, i64 224
  %32 = load i16, ptr %31, align 8, !tbaa !27
  %33 = zext i16 %32 to i32
  tail call void @ma_channel_map_init_standard(i32 noundef 0, ptr noundef nonnull %4, i64 noundef %5, i32 noundef %33)
  br label %34

34:                                               ; preds = %29, %30, %14
  %.0 = phi i32 [ -3, %14 ], [ 0, %30 ], [ 0, %29 ]
  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_wav", !13, i64 0, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !6, i64 104, !16, i64 112}
!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 = !{!"_ZTS5drwav", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !17, i64 32, !18, i64 64, !19, i64 68, !10, i64 108, !20, i64 112, !20, i64 114, !20, i64 116, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !15, i64 160, !10, i64 168, !21, i64 172, !14, i64 176, !10, i64 184, !22, i64 192, !24, i64 216, !25, i64 256, !26, i64 308}
!17 = !{!"_ZTS26drwav_allocation_callbacks", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!18 = !{!"_ZTS15drwav_container", !7, i64 0}
!19 = !{!"_ZTS9drwav_fmt", !20, i64 0, !20, i64 2, !10, i64 4, !10, i64 8, !20, i64 12, !20, i64 14, !20, i64 16, !20, i64 18, !10, i64 20, !7, i64 24}
!20 = !{!"short", !7, i64 0}
!21 = !{!"_ZTS19drwav_metadata_type", !7, i64 0}
!22 = !{!"_ZTS20drwav__memory_stream", !14, i64 0, !23, i64 8, !23, i64 16}
!23 = !{!"long", !7, i64 0}
!24 = !{!"_ZTS26drwav__memory_stream_write", !14, i64 0, !14, i64 8, !23, i64 16, !23, i64 24, !23, i64 32}
!25 = !{!"_ZTSN5drwavUt_E", !10, i64 0, !7, i64 4, !7, i64 8, !7, i64 16, !10, i64 32, !7, i64 36}
!26 = !{!"_ZTSN5drwavUt0_E", !10, i64 0, !7, i64 4, !7, i64 12, !7, i64 20, !10, i64 84}
!27 = !{!12, !20, i64 224}
!28 = !{!12, !10, i64 220}


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