; 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_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 }

; 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 i64 @_Z24drmp3_src_read_frames_exP9drmp3_srcmPvj(ptr noundef %0, i64 noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %20, label %14

14:                                               ; preds = %4
  %15 = load i64, ptr %7, align 8, !tbaa !9
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %20, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %14, %4
  store i64 0, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %51

21:                                               ; preds = %17
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.drmp3_src, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.drmp3_src_config, ptr %23, i32 0, i32 3
  %25 = load i32, ptr %24, align 4, !tbaa !13
  store i32 %25, ptr %10, align 4, !tbaa !18
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.drmp3_src, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.drmp3_src_config, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !19
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.drmp3_src, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.drmp3_src_config, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !20
  %34 = icmp eq i32 %29, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %21
  store i32 0, ptr %10, align 4, !tbaa !18
  br label %36

36:                                               ; preds = %35, %21
  %37 = load i32, ptr %10, align 4, !tbaa !18
  switch i32 %37, label %50 [
    i32 0, label %38
    i32 1, label %44
  ]

38:                                               ; preds = %36
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !11
  %43 = call noundef i64 @_Z33drmp3_src_read_frames_passthroughP9drmp3_srcmPvj(ptr noundef %39, i64 noundef %40, ptr noundef %41, i32 noundef %42)
  store i64 %43, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %51

44:                                               ; preds = %36
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i64, ptr %7, align 8, !tbaa !9
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i32, ptr %9, align 4, !tbaa !11
  %49 = call noundef i64 @_Z28drmp3_src_read_frames_linearP9drmp3_srcmPvj(ptr noundef %45, i64 noundef %46, ptr noundef %47, i32 noundef %48)
  store i64 %49, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %51

50:                                               ; preds = %36
  store i64 0, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %51

51:                                               ; preds = %50, %44, %38, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %52 = load i64, ptr %5, align 8
  ret i64 %52
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z28drmp3_src_read_frames_linearP9drmp3_srcmPvj(ptr noundef, i64 noundef, 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 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !16, i64 12}
!14 = !{!"_ZTS9drmp3_src", !15, i64 0, !6, i64 24, !6, i64 32, !7, i64 40, !17, i64 1064, !7, i64 5176}
!15 = !{!"_ZTS16drmp3_src_config", !12, i64 0, !12, i64 4, !12, i64 8, !16, i64 12, !12, i64 16}
!16 = !{!"_ZTS19drmp3_src_algorithm", !7, i64 0}
!17 = !{!"_ZTS15drmp3_src_cache", !6, i64 0, !7, i64 8, !12, i64 4104, !12, i64 4108}
!18 = !{!16, !16, i64 0}
!19 = !{!14, !12, i64 0}
!20 = !{!14, !12, i64 4}


; 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 uwtable
define dso_local noundef i64 @_Z24drmp3_src_read_frames_exP9drmp3_srcmPvj(ptr noundef %0, i64 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %0, null
  %6 = icmp eq i64 %1, 0
  %or.cond = or i1 %5, %6
  %7 = icmp eq ptr %2, null
  %or.cond3 = or i1 %or.cond, %7
  br i1 %or.cond3, label %19, label %8

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = load i32, ptr %0, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !15
  %14 = icmp eq i32 %11, %13
  %spec.select = select i1 %14, i32 0, i32 %10
  switch i32 %spec.select, label %19 [
    i32 0, label %15
    i32 1, label %17
  ]

15:                                               ; preds = %8
  %16 = tail call noundef i64 @_Z33drmp3_src_read_frames_passthroughP9drmp3_srcmPvj(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2, i32 noundef %3)
  br label %19

17:                                               ; preds = %8
  %18 = tail call noundef i64 @_Z28drmp3_src_read_frames_linearP9drmp3_srcmPvj(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2, i32 noundef %3)
  br label %19

19:                                               ; preds = %8, %4, %17, %15
  %.018 = phi i64 [ %18, %17 ], [ %16, %15 ], [ 0, %4 ], [ 0, %8 ]
  ret i64 %.018
}

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

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

attributes #0 = { 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, !11, i64 12}
!6 = !{!"_ZTS9drmp3_src", !7, i64 0, !12, i64 24, !12, i64 32, !9, i64 40, !13, i64 1064, !9, i64 5176}
!7 = !{!"_ZTS16drmp3_src_config", !8, i64 0, !8, i64 4, !8, i64 8, !11, i64 12, !8, i64 16}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS19drmp3_src_algorithm", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_ZTS15drmp3_src_cache", !12, i64 0, !9, i64 8, !8, i64 4104, !8, i64 4108}
!14 = !{!6, !8, i64 0}
!15 = !{!6, !8, i64 4}


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