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

; 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 noundef i32 @_Z19drmp3_init_internalP5drmp3PFmPvS1_mEPFjS1_i17drmp3_seek_originES1_PK12drmp3_configPK26drmp3_allocation_callbacks(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

14:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  br label %40

15:                                               ; preds = %5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %16, i8 0, i64 21264, i1 false)
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %22, label %19

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

22:                                               ; preds = %19, %15
  store i32 0, ptr %6, align 4
  br label %40

23:                                               ; preds = %19
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.drmp3, ptr %25, i32 0, i32 22
  %27 = getelementptr inbounds %struct.anon.0, ptr %26, i32 0, i32 0
  store ptr %24, ptr %27, align 8, !tbaa !11
  %28 = load i64, ptr %9, align 8, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.drmp3, ptr %29, i32 0, i32 22
  %31 = getelementptr inbounds %struct.anon.0, ptr %30, i32 0, i32 1
  store i64 %28, ptr %31, align 8, !tbaa !22
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.drmp3, ptr %32, i32 0, i32 22
  %34 = getelementptr inbounds %struct.anon.0, ptr %33, i32 0, i32 2
  store i64 0, ptr %34, align 8, !tbaa !23
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = call noundef i32 @_Z19drmp3_init_internalP5drmp3PFmPvS1_mEPFjS1_i17drmp3_seek_originES1_PK12drmp3_configPK26drmp3_allocation_callbacks(ptr noundef %35, ptr noundef @_ZL21drmp3__on_read_memoryPvS_m, ptr noundef @_ZL21drmp3__on_seek_memoryPvi17drmp3_seek_origin, ptr noundef %36, ptr noundef %37, ptr noundef %38)
  store i32 %39, ptr %6, align 4
  br label %40

40:                                               ; preds = %23, %22, %14
  %41 = load i32, ptr %6, align 4
  ret i32 %41
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL21drmp3__on_read_memoryPvS_m(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL21drmp3__on_seek_memoryPvi17drmp3_seek_origin(ptr noundef, i32 noundef, i32 noundef) #2

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

!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, !6, i64 21240}
!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}
!22 = !{!12, !10, i64 21248}
!23 = !{!12, !10, i64 21256}


; 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 noundef i32 @_Z19drmp3_init_internalP5drmp3PFmPvS1_mEPFjS1_i17drmp3_seek_originES1_PK12drmp3_configPK26drmp3_allocation_callbacks(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @drmp3_init_memory(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = icmp eq ptr %0, null
  br i1 %6, label %14, label %7

7:                                                ; preds = %5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(21264) %0, i8 0, i64 21264, i1 false)
  %8 = icmp eq ptr %1, null
  %9 = icmp eq i64 %2, 0
  %or.cond = or i1 %8, %9
  br i1 %or.cond, label %14, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 21240
  store ptr %1, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 21248
  store i64 %2, ptr %12, align 8, !tbaa !20
  %13 = tail call noundef i32 @_Z19drmp3_init_internalP5drmp3PFmPvS1_mEPFjS1_i17drmp3_seek_originES1_PK12drmp3_configPK26drmp3_allocation_callbacks(ptr noundef nonnull %0, ptr noundef nonnull @_ZL21drmp3__on_read_memoryPvS_m, ptr noundef nonnull @_ZL21drmp3__on_seek_memoryPvi17drmp3_seek_origin, ptr noundef nonnull %0, ptr noundef %3, ptr noundef %4)
  br label %14

14:                                               ; preds = %7, %5, %10
  %.0 = phi i32 [ %13, %10 ], [ 0, %5 ], [ 0, %7 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL21drmp3__on_read_memoryPvS_m(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL21drmp3__on_seek_memoryPvi17drmp3_seek_origin(ptr noundef, i32 noundef, i32 noundef) #2

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

!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 21240}
!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}
!20 = !{!6, !14, i64 21248}


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