; LLVM IR from merpheus-dev/LavaEngine :: src/Utils/soloud/src/audiosource/wav (dr_impl)

; 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.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, %struct.drmp3_src, ptr, i32, i64, i64, ptr, i8, %struct.anon.0 }
%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.drmp3_src = type { %struct.drmp3_src_config, ptr, ptr, [256 x float], %struct.drmp3_src_cache, %union.anon }
%struct.drmp3_src_config = type { i32, i32, i32, i32, i32 }
%struct.drmp3_src_cache = type { ptr, [1024 x float], i32, i32 }
%union.anon = type { %struct.anon }
%struct.anon = type { double, i8 }
%struct.anon.0 = type { ptr, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m = external hidden unnamed_addr constant [73 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [36 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %11

9:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 3380, ptr noundef @__PRETTY_FUNCTION__._Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m) #2
  unreachable

10:                                               ; No predecessors!
  br label %11

11:                                               ; preds = %10, %8
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.drmp3, ptr %13, i32 0, i32 13
  %15 = load i64, ptr %14, align 8, !tbaa !11
  %16 = icmp eq i64 %12, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %11
  store i32 1, ptr %3, align 4
  br label %47

18:                                               ; preds = %11
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.drmp3, ptr %20, i32 0, i32 13
  %22 = load i64, ptr %21, align 8, !tbaa !11
  %23 = icmp ult i64 %19, %22
  br i1 %23, label %24, label %30

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = call noundef i32 @_Z29drmp3_seek_to_start_of_streamP5drmp3(ptr noundef %25)
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 0, ptr %3, align 4
  br label %47

29:                                               ; preds = %24
  br label %30

30:                                               ; preds = %29, %18
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.drmp3, ptr %32, i32 0, i32 13
  %34 = load i64, ptr %33, align 8, !tbaa !11
  %35 = icmp uge i64 %31, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  br label %39

37:                                               ; preds = %30
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 3397, ptr noundef @__PRETTY_FUNCTION__._Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m) #2
  unreachable

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %36
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.drmp3, ptr %42, i32 0, i32 13
  %44 = load i64, ptr %43, align 8, !tbaa !11
  %45 = sub i64 %41, %44
  %46 = call noundef i32 @_Z45drmp3_seek_forward_by_pcm_frames__brute_forceP5drmp3m(ptr noundef %40, i64 noundef %45)
  store i32 %46, ptr %3, align 4
  br label %47

47:                                               ; preds = %39, %28, %17
  %48 = load i32, ptr %3, align 4
  ret i32 %48
}

attributes #0 = { noreturn nounwind "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 #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 = { noreturn 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", !7, i64 0}
!11 = !{!12, !10, i64 15984}
!12 = !{!"_ZTS5drmp3", !13, i64 0, !15, i64 6668, !14, i64 6688, !14, i64 6692, !6, i64 6696, !6, i64 6704, !6, i64 6712, !16, i64 6720, !14, i64 6752, !14, i64 6756, !14, i64 6760, !14, i64 6764, !7, i64 6768, !10, i64 15984, !10, i64 15992, !17, i64 16000, !6, i64 21192, !14, i64 21200, !10, i64 21208, !10, i64 21216, !6, i64 21224, !14, i64 21232, !21, i64 21240}
!13 = !{!"_ZTS8drmp3dec", !7, i64 0, !7, i64 2304, !14, i64 6144, !14, i64 6148, !7, i64 6152, !7, i64 6156}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTS19drmp3dec_frame_info", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16}
!16 = !{!"_ZTS26drmp3_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"_ZTS9drmp3_src", !18, i64 0, !6, i64 24, !6, i64 32, !7, i64 40, !20, i64 1064, !7, i64 5176}
!18 = !{!"_ZTS16drmp3_src_config", !14, i64 0, !14, i64 4, !14, i64 8, !19, i64 12, !14, i64 16}
!19 = !{!"_ZTS19drmp3_src_algorithm", !7, i64 0}
!20 = !{!"_ZTS15drmp3_src_cache", !6, i64 0, !7, i64 8, !14, i64 4104, !14, i64 4108}
!21 = !{!"_ZTSN5drmp3Ut_E", !6, i64 0, !10, i64 8, !10, i64 16}


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

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m = external hidden unnamed_addr constant [73 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [36 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 3380, ptr noundef nonnull @__PRETTY_FUNCTION__._Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m) #2
  unreachable

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 15984
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i64 %6, %1
  br i1 %7, label %18, label %8

8:                                                ; preds = %4
  %9 = icmp ugt i64 %6, %1
  br i1 %9, label %10, label %12

10:                                               ; preds = %8
  %11 = tail call noundef i32 @_Z29drmp3_seek_to_start_of_streamP5drmp3(ptr noundef nonnull %0)
  %.not15 = icmp eq i32 %11, 0
  br i1 %.not15, label %18, label %._crit_edge

._crit_edge:                                      ; preds = %10
  %.pre = load i64, ptr %5, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %._crit_edge, %8
  %13 = phi i64 [ %.pre, %._crit_edge ], [ %6, %8 ]
  %.not16 = icmp ugt i64 %13, %1
  br i1 %.not16, label %14, label %15

14:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 3397, ptr noundef nonnull @__PRETTY_FUNCTION__._Z36drmp3_seek_to_pcm_frame__brute_forceP5drmp3m) #2
  unreachable

15:                                               ; preds = %12
  %16 = sub i64 %1, %13
  %17 = tail call noundef i32 @_Z45drmp3_seek_forward_by_pcm_frames__brute_forceP5drmp3m(ptr noundef nonnull %0, i64 noundef %16)
  br label %18

18:                                               ; preds = %10, %4, %15
  %.0 = phi i32 [ %17, %15 ], [ 1, %4 ], [ 0, %10 ]
  ret i32 %.0
}

attributes #0 = { noreturn nounwind "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 #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 = { noreturn 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, !14, i64 15984}
!6 = !{!"_ZTS5drmp3", !7, i64 0, !11, i64 6668, !10, i64 6688, !10, i64 6692, !12, i64 6696, !12, i64 6704, !12, i64 6712, !13, i64 6720, !10, i64 6752, !10, i64 6756, !10, i64 6760, !10, i64 6764, !8, i64 6768, !14, i64 15984, !14, i64 15992, !15, i64 16000, !12, i64 21192, !10, i64 21200, !14, i64 21208, !14, i64 21216, !12, i64 21224, !10, i64 21232, !19, i64 21240}
!7 = !{!"_ZTS8drmp3dec", !8, i64 0, !8, i64 2304, !10, i64 6144, !10, i64 6148, !8, i64 6152, !8, i64 6156}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS19drmp3dec_frame_info", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"_ZTS26drmp3_allocation_callbacks", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!14 = !{!"long", !8, i64 0}
!15 = !{!"_ZTS9drmp3_src", !16, i64 0, !12, i64 24, !12, i64 32, !8, i64 40, !18, i64 1064, !8, i64 5176}
!16 = !{!"_ZTS16drmp3_src_config", !10, i64 0, !10, i64 4, !10, i64 8, !17, i64 12, !10, i64 16}
!17 = !{!"_ZTS19drmp3_src_algorithm", !8, i64 0}
!18 = !{!"_ZTS15drmp3_src_cache", !12, i64 0, !8, i64 8, !10, i64 4104, !10, i64 4108}
!19 = !{!"_ZTSN5drmp3Ut_E", !12, i64 0, !14, i64 8, !14, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass