; 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 nounwind uwtable
declare dso_local noundef i32 @_Z19drwav_preinit_writeP5drwavPK17drwav_data_formatjPFmPvPKvmEPFjS4_i17drwav_seek_originES4_PK26drwav_allocation_callbacks(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

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

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

21:                                               ; preds = %18, %7
  store i32 0, ptr %8, align 4
  br label %55

22:                                               ; preds = %18
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %24, align 8, !tbaa !9
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = load i32, ptr %14, align 4, !tbaa !11
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %15, align 8, !tbaa !5
  %30 = call noundef i32 @_Z19drwav_preinit_writeP5drwavPK17drwav_data_formatjPFmPvPKvmEPFjS4_i17drwav_seek_originES4_PK26drwav_allocation_callbacks(ptr noundef %25, ptr noundef %26, i32 noundef %27, ptr noundef @_ZL22drwav__on_write_memoryPvPKvm, ptr noundef @_ZL27drwav__on_seek_memory_writePvi17drwav_seek_origin, ptr noundef %28, ptr noundef %29)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %22
  store i32 0, ptr %8, align 4
  br label %55

33:                                               ; preds = %22
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.drwav, ptr %35, i32 0, i32 19
  %37 = getelementptr inbounds %struct.drwav__memory_stream_write, ptr %36, i32 0, i32 0
  store ptr %34, ptr %37, align 8, !tbaa !13
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.drwav, ptr %39, i32 0, i32 19
  %41 = getelementptr inbounds %struct.drwav__memory_stream_write, ptr %40, i32 0, i32 1
  store ptr %38, ptr %41, align 8, !tbaa !25
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.drwav, ptr %42, i32 0, i32 19
  %44 = getelementptr inbounds %struct.drwav__memory_stream_write, ptr %43, i32 0, i32 2
  store i64 0, ptr %44, align 8, !tbaa !26
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.drwav, ptr %45, i32 0, i32 19
  %47 = getelementptr inbounds %struct.drwav__memory_stream_write, ptr %46, i32 0, i32 3
  store i64 0, ptr %47, align 8, !tbaa !27
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.drwav, ptr %48, i32 0, i32 19
  %50 = getelementptr inbounds %struct.drwav__memory_stream_write, ptr %49, i32 0, i32 4
  store i64 0, ptr %50, align 8, !tbaa !28
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = load i64, ptr %13, align 8, !tbaa !9
  %54 = call noundef i32 @_Z26drwav_init_write__internalP5drwavPK17drwav_data_formatm(ptr noundef %51, ptr noundef %52, i64 noundef %53)
  store i32 %54, ptr %8, align 4
  br label %55

55:                                               ; preds = %33, %32, %21
  %56 = load i32, ptr %8, align 4
  ret i32 %56
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZL22drwav__on_write_memoryPvPKvm(ptr noundef, ptr noundef, i64 noundef) #1

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

attributes #0 = { 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 #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" }

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


; 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 nounwind uwtable
declare dso_local noundef i32 @_Z19drwav_preinit_writeP5drwavPK17drwav_data_formatjPFmPvPKvmEPFjS4_i17drwav_seek_originES4_PK26drwav_allocation_callbacks(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z33drwav_init_memory_write__internalP5drwavPPvPmPK17drwav_data_formatmjPK26drwav_allocation_callbacks(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, i32 noundef %5, ptr noundef %6) local_unnamed_addr #1 {
  %8 = icmp eq ptr %1, null
  %9 = icmp eq ptr %2, null
  %or.cond = or i1 %8, %9
  br i1 %or.cond, label %17, label %10

10:                                               ; preds = %7
  store ptr null, ptr %1, align 8, !tbaa !5
  store i64 0, ptr %2, align 8, !tbaa !9
  %11 = tail call noundef i32 @_Z19drwav_preinit_writeP5drwavPK17drwav_data_formatjPFmPvPKvmEPFjS4_i17drwav_seek_originES4_PK26drwav_allocation_callbacks(ptr noundef %0, ptr noundef %3, i32 noundef %5, ptr noundef nonnull @_ZL22drwav__on_write_memoryPvPKvm, ptr noundef nonnull @_ZL27drwav__on_seek_memory_writePvi17drwav_seek_origin, ptr noundef %0, ptr noundef %6)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %17, label %12

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 248
  store ptr %1, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %0, i64 256
  store ptr %2, ptr %14, align 8, !tbaa !24
  %15 = getelementptr inbounds i8, ptr %0, i64 264
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %15, i8 0, i64 24, i1 false)
  %16 = tail call noundef i32 @_Z26drwav_init_write__internalP5drwavPK17drwav_data_formatm(ptr noundef %0, ptr noundef %3, i64 noundef %4)
  br label %17

17:                                               ; preds = %10, %7, %12
  %.0 = phi i32 [ %16, %12 ], [ 0, %7 ], [ 0, %10 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZL22drwav__on_write_memoryPvPKvm(ptr noundef, ptr noundef, i64 noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 248}
!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, !6, i64 256}


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