; 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.drwav = type { ptr, ptr, ptr, ptr, %struct.drwav_allocation_callbacks, i32, %struct.drwav_fmt, i32, i16, i16, i16, i64, i64, i64, i64, i64, i32, %struct.drwav_smpl, %struct.drwav__memory_stream, %struct.drwav__memory_stream_write, %struct.anon.1, %struct.anon.2, %struct.anon.3 }
%struct.drwav_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.drwav_fmt = type { i16, i16, i32, i32, i16, i16, i16, i16, i32, [16 x i8] }
%struct.drwav_smpl = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, [1 x %struct.drwav_smpl_loop] }
%struct.drwav_smpl_loop = type { i32, i32, i32, i32, i32, i32 }
%struct.drwav__memory_stream = type { ptr, i64, i64 }
%struct.drwav__memory_stream_write = type { ptr, ptr, i64, i64, i64 }
%struct.anon.1 = type { i64 }
%struct.anon.2 = type { i32, [2 x i16], [2 x i32], [4 x i32], i32, [2 x [2 x i32]] }
%struct.anon.3 = type { i32, [2 x i32], [2 x i32], [16 x i32], i32 }

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

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

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

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

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

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

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

10:                                               ; preds = %3
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %16, label %13

13:                                               ; preds = %10
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13, %10, %3
  store i64 0, ptr %4, align 8
  br label %99

17:                                               ; preds = %13
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.drwav, ptr %19, i32 0, i32 8
  %21 = load i16, ptr %20, align 8, !tbaa !11
  %22 = zext i16 %21 to i64
  %23 = mul i64 %18, %22
  %24 = mul i64 %23, 4
  %25 = icmp ugt i64 %24, -1
  br i1 %25, label %26, label %32

26:                                               ; preds = %17
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.drwav, ptr %27, i32 0, i32 8
  %29 = load i16, ptr %28, align 8, !tbaa !11
  %30 = zext i16 %29 to i64
  %31 = udiv i64 4611686018427387903, %30
  store i64 %31, ptr %6, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %26, %17
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.drwav, ptr %33, i32 0, i32 10
  %35 = load i16, ptr %34, align 4, !tbaa !24
  %36 = zext i16 %35 to i32
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %38, label %43

38:                                               ; preds = %32
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = call noundef i64 @_Z30drwav_read_pcm_frames_f32__pcmP5drwavmPf(ptr noundef %39, i64 noundef %40, ptr noundef %41)
  store i64 %42, ptr %4, align 8
  br label %99

43:                                               ; preds = %32
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.drwav, ptr %44, i32 0, i32 10
  %46 = load i16, ptr %45, align 4, !tbaa !24
  %47 = zext i16 %46 to i32
  %48 = icmp eq i32 %47, 2
  br i1 %48, label %49, label %54

49:                                               ; preds = %43
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load i64, ptr %6, align 8, !tbaa !9
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = call noundef i64 @_Z34drwav_read_pcm_frames_f32__msadpcmP5drwavmPf(ptr noundef %50, i64 noundef %51, ptr noundef %52)
  store i64 %53, ptr %4, align 8
  br label %99

54:                                               ; preds = %43
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.drwav, ptr %55, i32 0, i32 10
  %57 = load i16, ptr %56, align 4, !tbaa !24
  %58 = zext i16 %57 to i32
  %59 = icmp eq i32 %58, 3
  br i1 %59, label %60, label %65

60:                                               ; preds = %54
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = call noundef i64 @_Z31drwav_read_pcm_frames_f32__ieeeP5drwavmPf(ptr noundef %61, i64 noundef %62, ptr noundef %63)
  store i64 %64, ptr %4, align 8
  br label %99

65:                                               ; preds = %54
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.drwav, ptr %66, i32 0, i32 10
  %68 = load i16, ptr %67, align 4, !tbaa !24
  %69 = zext i16 %68 to i32
  %70 = icmp eq i32 %69, 6
  br i1 %70, label %71, label %76

71:                                               ; preds = %65
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load i64, ptr %6, align 8, !tbaa !9
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call noundef i64 @_Z31drwav_read_pcm_frames_f32__alawP5drwavmPf(ptr noundef %72, i64 noundef %73, ptr noundef %74)
  store i64 %75, ptr %4, align 8
  br label %99

76:                                               ; preds = %65
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.drwav, ptr %77, i32 0, i32 10
  %79 = load i16, ptr %78, align 4, !tbaa !24
  %80 = zext i16 %79 to i32
  %81 = icmp eq i32 %80, 7
  br i1 %81, label %82, label %87

82:                                               ; preds = %76
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load i64, ptr %6, align 8, !tbaa !9
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = call noundef i64 @_Z32drwav_read_pcm_frames_f32__mulawP5drwavmPf(ptr noundef %83, i64 noundef %84, ptr noundef %85)
  store i64 %86, ptr %4, align 8
  br label %99

87:                                               ; preds = %76
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.drwav, ptr %88, i32 0, i32 10
  %90 = load i16, ptr %89, align 4, !tbaa !24
  %91 = zext i16 %90 to i32
  %92 = icmp eq i32 %91, 17
  br i1 %92, label %93, label %98

93:                                               ; preds = %87
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = load i64, ptr %6, align 8, !tbaa !9
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = call noundef i64 @_Z30drwav_read_pcm_frames_f32__imaP5drwavmPf(ptr noundef %94, i64 noundef %95, ptr noundef %96)
  store i64 %97, ptr %4, align 8
  br label %99

98:                                               ; preds = %87
  store i64 0, ptr %4, align 8
  br label %99

99:                                               ; preds = %98, %93, %82, %71, %60, %49, %38, %16
  %100 = load i64, ptr %4, align 8
  ret i64 %100
}

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, !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, !16, i64 112}
!12 = !{!"_ZTS5drwav", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !14, i64 64, !15, i64 68, !17, i64 108, !16, i64 112, !16, i64 114, !16, i64 116, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !17, i64 160, !18, i64 164, !19, i64 224, !20, i64 248, !21, i64 288, !22, i64 296, !23, i64 348}
!13 = !{!"_ZTS26drwav_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!"_ZTS15drwav_container", !7, i64 0}
!15 = !{!"_ZTS9drwav_fmt", !16, i64 0, !16, i64 2, !17, i64 4, !17, i64 8, !16, i64 12, !16, i64 14, !16, i64 16, !16, i64 18, !17, i64 20, !7, i64 24}
!16 = !{!"short", !7, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_ZTS10drwav_smpl", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20, !17, i64 24, !17, i64 28, !17, i64 32, !7, i64 36}
!19 = !{!"_ZTS20drwav__memory_stream", !6, i64 0, !10, i64 8, !10, i64 16}
!20 = !{!"_ZTS26drwav__memory_stream_write", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!21 = !{!"_ZTSN5drwavUt_E", !10, i64 0}
!22 = !{!"_ZTSN5drwavUt0_E", !17, i64 0, !7, i64 4, !7, i64 8, !7, i64 16, !17, i64 32, !7, i64 36}
!23 = !{!"_ZTSN5drwavUt1_E", !17, i64 0, !7, i64 4, !7, i64 12, !7, i64 20, !17, i64 84}
!24 = !{!12, !16, i64 116}


; 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
declare dso_local noundef i64 @_Z30drwav_read_pcm_frames_f32__pcmP5drwavmPf(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @drwav_read_pcm_frames_f32(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %0, null
  %5 = icmp eq i64 %1, 0
  %or.cond = or i1 %4, %5
  %6 = icmp eq ptr %2, null
  %or.cond3 = or i1 %or.cond, %6
  br i1 %or.cond3, label %22, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 116
  %9 = load i16, ptr %8, align 4, !tbaa !5
  switch i16 %9, label %22 [
    i16 1, label %10
    i16 2, label %12
    i16 3, label %14
    i16 6, label %16
    i16 7, label %18
    i16 17, label %20
  ]

10:                                               ; preds = %7
  %11 = tail call noundef i64 @_Z30drwav_read_pcm_frames_f32__pcmP5drwavmPf(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2)
  br label %22

12:                                               ; preds = %7
  %13 = tail call noundef i64 @_Z34drwav_read_pcm_frames_f32__msadpcmP5drwavmPf(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2)
  br label %22

14:                                               ; preds = %7
  %15 = tail call noundef i64 @_Z31drwav_read_pcm_frames_f32__ieeeP5drwavmPf(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2)
  br label %22

16:                                               ; preds = %7
  %17 = tail call noundef i64 @_Z31drwav_read_pcm_frames_f32__alawP5drwavmPf(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2)
  br label %22

18:                                               ; preds = %7
  %19 = tail call noundef i64 @_Z32drwav_read_pcm_frames_f32__mulawP5drwavmPf(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2)
  br label %22

20:                                               ; preds = %7
  %21 = tail call noundef i64 @_Z30drwav_read_pcm_frames_f32__imaP5drwavmPf(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2)
  br label %22

22:                                               ; preds = %7, %3, %20, %18, %16, %14, %12, %10
  %.0 = phi i64 [ %11, %10 ], [ %13, %12 ], [ %15, %14 ], [ %17, %16 ], [ %19, %18 ], [ %21, %20 ], [ 0, %3 ], [ 0, %7 ]
  ret i64 %.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, !13, i64 116}
!6 = !{!"_ZTS5drwav", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 64, !12, i64 68, !14, i64 108, !13, i64 112, !13, i64 114, !13, i64 116, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !14, i64 160, !16, i64 164, !17, i64 224, !18, i64 248, !19, i64 288, !20, i64 296, !21, i64 348}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS26drwav_allocation_callbacks", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!11 = !{!"_ZTS15drwav_container", !8, i64 0}
!12 = !{!"_ZTS9drwav_fmt", !13, i64 0, !13, i64 2, !14, i64 4, !14, i64 8, !13, i64 12, !13, i64 14, !13, i64 16, !13, i64 18, !14, i64 20, !8, i64 24}
!13 = !{!"short", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!"_ZTS10drwav_smpl", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !8, i64 36}
!17 = !{!"_ZTS20drwav__memory_stream", !7, i64 0, !15, i64 8, !15, i64 16}
!18 = !{!"_ZTS26drwav__memory_stream_write", !7, i64 0, !7, i64 8, !15, i64 16, !15, i64 24, !15, i64 32}
!19 = !{!"_ZTSN5drwavUt_E", !15, i64 0}
!20 = !{!"_ZTSN5drwavUt0_E", !14, i64 0, !8, i64 4, !8, i64 8, !8, i64 16, !14, i64 32, !8, i64 36}
!21 = !{!"_ZTSN5drwavUt1_E", !14, i64 0, !8, i64 4, !8, i64 12, !8, i64 20, !14, i64 84}


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