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

; 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: mustprogress uwtable
define dso_local noundef i32 @_Z23ma_flac_read_pcm_framesP7ma_flacPvyPy(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %18

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

18:                                               ; preds = %16, %4
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store i32 -2, ptr %5, align 4
  br label %73

22:                                               ; preds = %18
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i32 -2, ptr %5, align 4
  br label %73

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store i64 0, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call noundef i32 @_Z23ma_flac_get_data_formatP7ma_flacP9ma_formatPjS3_Phm(ptr noundef %27, ptr noundef %12, ptr noundef null, ptr noundef null, ptr noundef null, i64 noundef 0)
  %29 = load i32, ptr %12, align 4, !tbaa !13
  switch i32 %29, label %52 [
    i32 5, label %30
    i32 2, label %37
    i32 4, label %44
    i32 1, label %51
    i32 3, label %51
    i32 0, label %51
  ]

30:                                               ; preds = %26
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ma_flac, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load i64, ptr %8, align 8, !tbaa !9
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call i64 @drflac_read_pcm_frames_f32(ptr noundef %33, i64 noundef %34, ptr noundef %35)
  store i64 %36, ptr %11, align 8, !tbaa !9
  br label %53

37:                                               ; preds = %26
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ma_flac, ptr %38, i32 0, i32 6
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = load i64, ptr %8, align 8, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = call i64 @drflac_read_pcm_frames_s16(ptr noundef %40, i64 noundef %41, ptr noundef %42)
  store i64 %43, ptr %11, align 8, !tbaa !9
  br label %53

44:                                               ; preds = %26
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ma_flac, ptr %45, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = load i64, ptr %8, align 8, !tbaa !9
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = call i64 @drflac_read_pcm_frames_s32(ptr noundef %47, i64 noundef %48, ptr noundef %49)
  store i64 %50, ptr %11, align 8, !tbaa !9
  br label %53

51:                                               ; preds = %26, %26, %26
  br label %52

52:                                               ; preds = %51, %26
  store i32 -3, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %72

53:                                               ; preds = %44, %37, %30
  %54 = load i64, ptr %11, align 8, !tbaa !9
  %55 = icmp eq i64 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  store i32 -17, ptr %10, align 4, !tbaa !11
  br label %57

57:                                               ; preds = %56, %53
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %63

60:                                               ; preds = %57
  %61 = load i64, ptr %11, align 8, !tbaa !9
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %61, ptr %62, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %60, %57
  %64 = load i32, ptr %10, align 4, !tbaa !11
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %66, label %70

66:                                               ; preds = %63
  %67 = load i64, ptr %11, align 8, !tbaa !9
  %68 = icmp eq i64 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  store i32 -17, ptr %10, align 4, !tbaa !11
  br label %70

70:                                               ; preds = %69, %66, %63
  %71 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %71, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %72

72:                                               ; preds = %70, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %73

73:                                               ; preds = %72, %25, %21
  %74 = load i32, ptr %5, align 4
  ret i32 %74
}

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 0}
!12 = !{!"_ZTS9ma_result", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTS9ma_format", !7, i64 0}
!15 = !{!16, !6, i64 112}
!16 = !{!"_ZTS7ma_flac", !17, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !14, i64 104, !6, i64 112}
!17 = !{!"_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, !18, i64 64}
!18 = !{!"int", !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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

7:                                                ; preds = %6, %4
  %8 = icmp eq i64 %2, 0
  %9 = icmp eq ptr %0, null
  %or.cond = or i1 %9, %8
  br i1 %or.cond, label %29, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  %11 = call noundef i32 @_Z23ma_flac_get_data_formatP7ma_flacP9ma_formatPjS3_Phm(ptr noundef nonnull %0, ptr noundef nonnull %5, ptr noundef null, ptr noundef null, ptr noundef null, i64 noundef 0)
  %12 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %12, label %28 [
    i32 5, label %13
    i32 2, label %17
    i32 4, label %21
  ]

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 112
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = call i64 @drflac_read_pcm_frames_f32(ptr noundef %15, i64 noundef %2, ptr noundef %1)
  br label %25

17:                                               ; preds = %10
  %18 = getelementptr inbounds i8, ptr %0, i64 112
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = call i64 @drflac_read_pcm_frames_s16(ptr noundef %19, i64 noundef %2, ptr noundef %1)
  br label %25

21:                                               ; preds = %10
  %22 = getelementptr inbounds i8, ptr %0, i64 112
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = call i64 @drflac_read_pcm_frames_s32(ptr noundef %23, i64 noundef %2, ptr noundef %1)
  br label %25

25:                                               ; preds = %21, %17, %13
  %.0 = phi i64 [ %24, %21 ], [ %20, %17 ], [ %16, %13 ]
  %26 = icmp eq i64 %.0, 0
  %spec.select = select i1 %26, i32 -17, i32 0
  br i1 %.not, label %28, label %27

27:                                               ; preds = %25
  store i64 %.0, ptr %3, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %25, %27, %10
  %.023 = phi i32 [ -3, %10 ], [ %spec.select, %27 ], [ %spec.select, %25 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  br label %29

29:                                               ; preds = %7, %28
  %.1 = phi i32 [ %.023, %28 ], [ -2, %7 ]
  ret i32 %.1
}

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS9ma_format", !7, i64 0}
!11 = !{!12, !14, i64 112}
!12 = !{!"_ZTS7ma_flac", !13, i64 0, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !10, i64 104, !14, i64 112}
!13 = !{!"_ZTS19ma_data_source_base", !14, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !15, i64 64}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"int", !7, i64 0}


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