; 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 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
declare dso_local noundef i32 @_Z28ma_stbvorbis_read_pcm_framesP12ma_stbvorbisPvyPy(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z30ma_stbvorbis_seek_to_pcm_frameP12ma_stbvorbisy(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca [4096 x float], align 16
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i32 -2, ptr %3, align 4
  br label %113

15:                                               ; preds = %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ma_stbvorbis, ptr %16, i32 0, i32 11
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %91

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 16384, ptr %7) #3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ma_stbvorbis, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ma_stbvorbis, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  %27 = call noundef i32 %23(ptr noundef %26, i64 noundef 0, i32 noundef 0)
  store i32 %27, ptr %6, align 4, !tbaa !21
  %28 = load i32, ptr %6, align 4, !tbaa !21
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %20
  %31 = load i32, ptr %6, align 4, !tbaa !21
  store i32 %31, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

32:                                               ; preds = %20
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ma_stbvorbis, ptr %33, i32 0, i32 10
  %35 = load ptr, ptr %34, align 8, !tbaa !23
  call void @stb_vorbis_flush_pushdata(ptr noundef %35)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ma_stbvorbis, ptr %36, i32 0, i32 12
  %38 = getelementptr inbounds %struct.anon.60, ptr %37, i32 0, i32 4
  store i32 0, ptr %38, align 4, !tbaa !24
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ma_stbvorbis, ptr %39, i32 0, i32 12
  %41 = getelementptr inbounds %struct.anon.60, ptr %40, i32 0, i32 1
  store i64 0, ptr %41, align 8, !tbaa !25
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ma_stbvorbis, ptr %42, i32 0, i32 9
  store i64 0, ptr %43, align 8, !tbaa !26
  br label %44

44:                                               ; preds = %86, %32
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ma_stbvorbis, ptr %45, i32 0, i32 9
  %47 = load i64, ptr %46, align 8, !tbaa !26
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = icmp ult i64 %47, %48
  br i1 %49, label %50, label %87

50:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ma_stbvorbis, ptr %51, i32 0, i32 7
  %53 = load i32, ptr %52, align 4, !tbaa !27
  %54 = zext i32 %53 to i64
  %55 = udiv i64 4096, %54
  store i64 %55, ptr %10, align 8, !tbaa !9
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = load i64, ptr %5, align 8, !tbaa !9
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ma_stbvorbis, ptr %58, i32 0, i32 9
  %60 = load i64, ptr %59, align 8, !tbaa !26
  %61 = sub i64 %57, %60
  %62 = icmp ugt i64 %56, %61
  br i1 %62, label %63, label %69

63:                                               ; preds = %50
  %64 = load i64, ptr %5, align 8, !tbaa !9
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ma_stbvorbis, ptr %65, i32 0, i32 9
  %67 = load i64, ptr %66, align 8, !tbaa !26
  %68 = sub i64 %64, %67
  store i64 %68, ptr %10, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %63, %50
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds [4096 x float], ptr %7, i64 0, i64 0
  %72 = load i64, ptr %10, align 8, !tbaa !9
  %73 = call noundef i32 @_Z28ma_stbvorbis_read_pcm_framesP12ma_stbvorbisPvyPy(ptr noundef %70, ptr noundef %71, i64 noundef %72, ptr noundef %9)
  store i32 %73, ptr %6, align 4, !tbaa !21
  %74 = load i64, ptr %9, align 8, !tbaa !9
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ma_stbvorbis, ptr %75, i32 0, i32 9
  %77 = load i64, ptr %76, align 8, !tbaa !26
  %78 = add i64 %77, %74
  store i64 %78, ptr %76, align 8, !tbaa !26
  %79 = load i32, ptr %6, align 4, !tbaa !21
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %69
  %82 = load i32, ptr %6, align 4, !tbaa !21
  store i32 %82, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %84

83:                                               ; preds = %69
  store i32 0, ptr %8, align 4
  br label %84

84:                                               ; preds = %83, %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %85 = load i32, ptr %8, align 4
  switch i32 %85, label %88 [
    i32 0, label %86
  ]

86:                                               ; preds = %84
  br label %44, !llvm.loop !28

87:                                               ; preds = %44
  store i32 0, ptr %8, align 4
  br label %88

88:                                               ; preds = %87, %84, %30
  call void @llvm.lifetime.end.p0(i64 16384, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %89 = load i32, ptr %8, align 4
  switch i32 %89, label %115 [
    i32 0, label %90
    i32 1, label %113
  ]

90:                                               ; preds = %88
  br label %112

91:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %92 = load i64, ptr %5, align 8, !tbaa !9
  %93 = icmp ugt i64 %92, 4294967295
  br i1 %93, label %94, label %95

94:                                               ; preds = %91
  store i32 -2, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %109

95:                                               ; preds = %91
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ma_stbvorbis, ptr %96, i32 0, i32 10
  %98 = load ptr, ptr %97, align 8, !tbaa !23
  %99 = load i64, ptr %5, align 8, !tbaa !9
  %100 = trunc i64 %99 to i32
  %101 = call i32 @stb_vorbis_seek(ptr noundef %98, i32 noundef %100)
  store i32 %101, ptr %11, align 4, !tbaa !30
  %102 = load i32, ptr %11, align 4, !tbaa !30
  %103 = icmp eq i32 %102, 0
  br i1 %103, label %104, label %105

104:                                              ; preds = %95
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %109

105:                                              ; preds = %95
  %106 = load i64, ptr %5, align 8, !tbaa !9
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.ma_stbvorbis, ptr %107, i32 0, i32 9
  store i64 %106, ptr %108, align 8, !tbaa !26
  store i32 0, ptr %8, align 4
  br label %109

109:                                              ; preds = %105, %104, %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %110 = load i32, ptr %8, align 4
  switch i32 %110, label %115 [
    i32 0, label %111
    i32 1, label %113
  ]

111:                                              ; preds = %109
  br label %112

112:                                              ; preds = %111, %90
  store i32 0, ptr %3, align 4
  br label %113

113:                                              ; preds = %112, %109, %88, %14
  %114 = load i32, ptr %3, align 4
  ret i32 %114

115:                                              ; preds = %109, %88
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @stb_vorbis_flush_pushdata(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @stb_vorbis_seek(ptr noundef, i32 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 = { 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 = { 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, !14, i64 168}
!12 = !{!"_ZTS12ma_stbvorbis", !13, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !15, i64 104, !16, i64 136, !14, i64 140, !14, i64 144, !10, i64 152, !6, i64 160, !14, i64 168, !17, i64 176}
!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 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"_ZTS9ma_format", !7, i64 0}
!17 = !{!"_ZTSN12ma_stbvorbisUt_E", !6, i64 0, !18, i64 8, !18, i64 16, !14, i64 24, !14, i64 28, !6, i64 32}
!18 = !{!"long", !7, i64 0}
!19 = !{!12, !6, i64 80}
!20 = !{!12, !6, i64 96}
!21 = !{!22, !22, i64 0}
!22 = !{!"_ZTS9ma_result", !7, i64 0}
!23 = !{!12, !6, i64 160}
!24 = !{!12, !14, i64 204}
!25 = !{!12, !18, i64 184}
!26 = !{!12, !10, i64 152}
!27 = !{!12, !14, i64 140}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!14, !14, 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
declare dso_local noundef i32 @_Z28ma_stbvorbis_read_pcm_framesP12ma_stbvorbisPvyPy(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z30ma_stbvorbis_seek_to_pcm_frameP12ma_stbvorbisy(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = alloca [4096 x float], align 16
  %4 = alloca i64, align 8
  %5 = icmp eq ptr %0, null
  br i1 %5, label %.thread51, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 168
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %35, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 16384, ptr nonnull %3) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load ptr, ptr %10, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %14 = tail call noundef i32 %11(ptr noundef %13, i64 noundef 0, i32 noundef 0)
  %.not43 = icmp eq i32 %14, 0
  br i1 %.not43, label %15, label %.thread

15:                                               ; preds = %9
  %16 = getelementptr inbounds i8, ptr %0, i64 160
  %17 = load ptr, ptr %16, align 8, !tbaa !19
  tail call void @stb_vorbis_flush_pushdata(ptr noundef %17)
  %18 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 0, ptr %18, align 4, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %0, i64 184
  store i64 0, ptr %19, align 8, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %0, i64 152
  store i64 0, ptr %20, align 8, !tbaa !22
  %21 = getelementptr inbounds i8, ptr %0, i64 140
  br label %22

22:                                               ; preds = %25, %15
  %23 = phi i64 [ %33, %25 ], [ 0, %15 ]
  %24 = icmp ult i64 %23, %1
  br i1 %24, label %25, label %34

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %26 = load i32, ptr %21, align 4, !tbaa !23
  %27 = udiv i32 4096, %26
  %28 = zext nneg i32 %27 to i64
  %29 = sub i64 %1, %23
  %spec.select = call i64 @llvm.umin.i64(i64 %29, i64 %28)
  %30 = call noundef i32 @_Z28ma_stbvorbis_read_pcm_framesP12ma_stbvorbisPvyPy(ptr noundef nonnull %0, ptr noundef nonnull %3, i64 noundef %spec.select, ptr noundef nonnull %4)
  %31 = load i64, ptr %4, align 8, !tbaa !24
  %32 = load i64, ptr %20, align 8, !tbaa !22
  %33 = add i64 %32, %31
  store i64 %33, ptr %20, align 8, !tbaa !22
  %.not44 = icmp eq i32 %30, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br i1 %.not44, label %22, label %.thread, !llvm.loop !25

.thread:                                          ; preds = %25, %9
  %.2.ph = phi i32 [ %14, %9 ], [ %30, %25 ]
  call void @llvm.lifetime.end.p0(i64 16384, ptr nonnull %3) #4
  br label %.thread51

34:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 16384, ptr nonnull %3) #4
  br label %.thread51

35:                                               ; preds = %6
  %36 = icmp ugt i64 %1, 4294967295
  br i1 %36, label %.thread51, label %37

37:                                               ; preds = %35
  %38 = getelementptr inbounds i8, ptr %0, i64 160
  %39 = load ptr, ptr %38, align 8, !tbaa !19
  %40 = trunc nuw i64 %1 to i32
  %41 = tail call i32 @stb_vorbis_seek(ptr noundef %39, i32 noundef %40)
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %.thread51, label %43

43:                                               ; preds = %37
  %44 = getelementptr inbounds i8, ptr %0, i64 152
  store i64 %1, ptr %44, align 8, !tbaa !22
  br label %.thread51

.thread51:                                        ; preds = %37, %35, %34, %43, %.thread, %2
  %.4 = phi i32 [ -2, %2 ], [ %.2.ph, %.thread ], [ 0, %43 ], [ 0, %34 ], [ -1, %37 ], [ -2, %35 ]
  ret i32 %.4
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @stb_vorbis_flush_pushdata(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #3

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !12, i64 168}
!6 = !{!"_ZTS12ma_stbvorbis", !7, i64 0, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !13, i64 104, !14, i64 136, !12, i64 140, !12, i64 144, !11, i64 152, !8, i64 160, !12, i64 168, !15, i64 176}
!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 = !{!"_ZTS23ma_allocation_callbacks", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!14 = !{!"_ZTS9ma_format", !9, i64 0}
!15 = !{!"_ZTSN12ma_stbvorbisUt_E", !8, i64 0, !16, i64 8, !16, i64 16, !12, i64 24, !12, i64 28, !8, i64 32}
!16 = !{!"long", !9, i64 0}
!17 = !{!6, !8, i64 80}
!18 = !{!6, !8, i64 96}
!19 = !{!6, !8, i64 160}
!20 = !{!6, !12, i64 204}
!21 = !{!6, !16, i64 184}
!22 = !{!6, !11, i64 152}
!23 = !{!6, !12, i64 140}
!24 = !{!11, !11, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass