; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/wav (soloud_wavstream)

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

%"class.SoLoud::WavStreamInstance" = type { %"class.SoLoud::AudioSourceInstance", ptr, i32, ptr, %"union.SoLoud::WavStreamInstance::codec", i32, i32, ptr }
%"class.SoLoud::AudioSourceInstance" = type { ptr, i32, i32, i32, float, [8 x float], float, float, float, float, i32, float, float, double, double, %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", i32, [8 x float], i32, i32, [8 x ptr], [2 x ptr], i32, i32, i32, double }
%"class.SoLoud::Fader" = type { float, float, float, double, double, double, float, i32 }
%"union.SoLoud::WavStreamInstance::codec" = type { ptr }
%"class.SoLoud::WavStream" = type <{ %"class.SoLoud::AudioSource", i32, [4 x i8], ptr, ptr, ptr, i32, [4 x i8] }>
%"class.SoLoud::AudioSource" = type { ptr, i32, float, float, i32, i32, float, float, float, i32, float, [8 x ptr], ptr, ptr, ptr, i32, double }

@_ZTVN6SoLoud17WavStreamInstanceE = external dso_local unnamed_addr constant { [9 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind
declare void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496)) unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6SoLoud17WavStreamInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(544) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTVN6SoLoud17WavStreamInstanceE, i32 0, i32 0, i32 2), ptr %3, align 8, !tbaa !9
  %4 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 1
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds %"class.SoLoud::WavStream", ptr %5, i32 0, i32 1
  %7 = load i32, ptr %6, align 8, !tbaa !18
  switch i32 %7, label %57 [
    i32 1, label %8
    i32 2, label %17
    i32 3, label %26
    i32 0, label %41
  ]

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !21
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %16

12:                                               ; preds = %8
  %13 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %14 = load ptr, ptr %13, align 8, !tbaa !21
  invoke void @stb_vorbis_close(ptr noundef %14)
          to label %15 unwind label %75

15:                                               ; preds = %12
  br label %16

16:                                               ; preds = %15, %8
  br label %57

17:                                               ; preds = %1
  %18 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %19 = load ptr, ptr %18, align 8, !tbaa !21
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %25

21:                                               ; preds = %17
  %22 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %23 = load ptr, ptr %22, align 8, !tbaa !21
  invoke void @drflac_close(ptr noundef %23)
          to label %24 unwind label %75

24:                                               ; preds = %21
  br label %25

25:                                               ; preds = %24, %17
  br label %57

26:                                               ; preds = %1
  %27 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %40

30:                                               ; preds = %26
  %31 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  invoke void @drmp3_uninit(ptr noundef %32)
          to label %33 unwind label %75

33:                                               ; preds = %30
  %34 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = icmp eq ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  call void @_ZdlPvm(ptr noundef %35, i64 noundef 16080) #5
  br label %38

38:                                               ; preds = %37, %33
  %39 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  store ptr null, ptr %39, align 8, !tbaa !21
  br label %40

40:                                               ; preds = %38, %26
  br label %57

41:                                               ; preds = %1
  %42 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %56

45:                                               ; preds = %41
  %46 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %48 = invoke i32 @drwav_uninit(ptr noundef %47)
          to label %49 unwind label %75

49:                                               ; preds = %45
  %50 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  %51 = load ptr, ptr %50, align 8, !tbaa !21
  %52 = icmp eq ptr %51, null
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  call void @_ZdlPvm(ptr noundef %51, i64 noundef 400) #5
  br label %54

54:                                               ; preds = %53, %49
  %55 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 4
  store ptr null, ptr %55, align 8, !tbaa !21
  br label %56

56:                                               ; preds = %54, %41
  br label %57

57:                                               ; preds = %56, %40, %25, %16, %1
  %58 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !22
  %60 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = getelementptr inbounds %"class.SoLoud::WavStream", ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !23
  %64 = icmp ne ptr %59, %63
  br i1 %64, label %65, label %74

65:                                               ; preds = %57
  %66 = getelementptr inbounds %"class.SoLoud::WavStreamInstance", ptr %3, i32 0, i32 3
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  %68 = icmp eq ptr %67, null
  br i1 %68, label %73, label %69

69:                                               ; preds = %65
  %70 = load ptr, ptr %67, align 8, !tbaa !9
  %71 = getelementptr inbounds ptr, ptr %70, i64 1
  %72 = load ptr, ptr %71, align 8
  call void %72(ptr noundef nonnull align 8 dereferenceable(8) %67) #6
  br label %73

73:                                               ; preds = %69, %65
  br label %74

74:                                               ; preds = %73, %57
  call void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496) %3) #6
  ret void

75:                                               ; preds = %45, %30, %21, %12
  %76 = landingpad { ptr, i32 }
          catch ptr null
  %77 = extractvalue { ptr, i32 } %76, 0
  call void @__clang_call_terminate(ptr %77) #7
  unreachable
}

declare void @stb_vorbis_close(ptr noundef) #3

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #4

declare void @drflac_close(ptr noundef) #3

declare void @drmp3_uninit(ptr noundef) #3

declare i32 @drwav_uninit(ptr noundef) #3

attributes #0 = { nobuiltin 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 = { 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 #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" }
attributes #3 = { "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 #4 = { noinline noreturn nounwind uwtable "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 #5 = { builtin nounwind }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 496}
!12 = !{!"_ZTSN6SoLoud17WavStreamInstanceE", !13, i64 0, !6, i64 496, !14, i64 504, !6, i64 512, !7, i64 520, !14, i64 528, !14, i64 532, !6, i64 536}
!13 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !14, i64 8, !14, i64 12, !14, i64 16, !15, i64 20, !7, i64 24, !15, i64 56, !15, i64 60, !15, i64 64, !15, i64 68, !14, i64 72, !15, i64 76, !15, i64 80, !16, i64 88, !16, i64 96, !17, i64 104, !17, i64 152, !17, i64 200, !17, i64 248, !17, i64 296, !14, i64 344, !7, i64 348, !14, i64 380, !14, i64 384, !7, i64 392, !7, i64 456, !14, i64 472, !14, i64 476, !14, i64 480, !16, i64 488}
!14 = !{!"int", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!"_ZTSN6SoLoud5FaderE", !15, i64 0, !15, i64 4, !15, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !15, i64 40, !14, i64 44}
!18 = !{!19, !14, i64 152}
!19 = !{!"_ZTSN6SoLoud9WavStreamE", !20, i64 0, !14, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !14, i64 184}
!20 = !{!"_ZTSN6SoLoud11AudioSourceE", !14, i64 8, !15, i64 12, !15, i64 16, !14, i64 20, !14, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !14, i64 40, !15, i64 44, !7, i64 48, !6, i64 112, !6, i64 120, !6, i64 128, !14, i64 136, !16, i64 144}
!21 = !{!7, !7, i64 0}
!22 = !{!12, !6, i64 512}
!23 = !{!19, !6, i64 176}


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

@_ZTVN6SoLoud17WavStreamInstanceE = external dso_local unnamed_addr constant { [9 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496)) unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6SoLoud17WavStreamInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(544) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 56) (i8, ptr @_ZTVN6SoLoud17WavStreamInstanceE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 496
  %3 = load ptr, ptr %2, align 8, !tbaa !8
  %4 = getelementptr inbounds i8, ptr %3, i64 152
  %5 = load i32, ptr %4, align 8, !tbaa !17
  switch i32 %5, label %31 [
    i32 1, label %6
    i32 2, label %10
    i32 3, label %14
    i32 0, label %22
  ]

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 520
  %8 = load ptr, ptr %7, align 8, !tbaa !20
  %.not9 = icmp eq ptr %8, null
  br i1 %.not9, label %31, label %9

9:                                                ; preds = %6
  invoke void @stb_vorbis_close(ptr noundef nonnull %8)
          to label %31 unwind label %43

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 520
  %12 = load ptr, ptr %11, align 8, !tbaa !20
  %.not8 = icmp eq ptr %12, null
  br i1 %.not8, label %31, label %13

13:                                               ; preds = %10
  invoke void @drflac_close(ptr noundef nonnull %12)
          to label %31 unwind label %43

14:                                               ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 520
  %16 = load ptr, ptr %15, align 8, !tbaa !20
  %.not7 = icmp eq ptr %16, null
  br i1 %.not7, label %31, label %17

17:                                               ; preds = %14
  invoke void @drmp3_uninit(ptr noundef nonnull %16)
          to label %18 unwind label %43

18:                                               ; preds = %17
  %19 = load ptr, ptr %15, align 8, !tbaa !20
  %20 = icmp eq ptr %19, null
  br i1 %20, label %.sink.split, label %21

21:                                               ; preds = %18
  tail call void @_ZdlPvm(ptr noundef nonnull %19, i64 noundef 16080) #5
  br label %.sink.split

22:                                               ; preds = %1
  %23 = getelementptr inbounds i8, ptr %0, i64 520
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %31, label %25

25:                                               ; preds = %22
  %26 = invoke i32 @drwav_uninit(ptr noundef nonnull %24)
          to label %27 unwind label %43

27:                                               ; preds = %25
  %28 = load ptr, ptr %23, align 8, !tbaa !20
  %29 = icmp eq ptr %28, null
  br i1 %29, label %.sink.split, label %30

30:                                               ; preds = %27
  tail call void @_ZdlPvm(ptr noundef nonnull %28, i64 noundef 400) #5
  br label %.sink.split

.sink.split:                                      ; preds = %27, %30, %18, %21
  %.sink = phi ptr [ %15, %21 ], [ %15, %18 ], [ %23, %30 ], [ %23, %27 ]
  store ptr null, ptr %.sink, align 8, !tbaa !20
  br label %31

31:                                               ; preds = %.sink.split, %22, %14, %10, %13, %6, %9, %1
  %32 = getelementptr inbounds i8, ptr %0, i64 512
  %33 = load ptr, ptr %32, align 8, !tbaa !21
  %34 = load ptr, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds i8, ptr %34, i64 176
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %.not10 = icmp eq ptr %33, %36
  %37 = icmp eq ptr %33, null
  %or.cond = or i1 %37, %.not10
  br i1 %or.cond, label %42, label %38

38:                                               ; preds = %31
  %39 = load ptr, ptr %33, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 8
  %41 = load ptr, ptr %40, align 8
  tail call void %41(ptr noundef nonnull align 8 dereferenceable(8) %33) #6
  br label %42

42:                                               ; preds = %38, %31
  tail call void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496) %0) #6
  ret void

43:                                               ; preds = %25, %17, %13, %9
  %44 = landingpad { ptr, i32 }
          catch ptr null
  %45 = extractvalue { ptr, i32 } %44, 0
  tail call void @__clang_call_terminate(ptr %45) #7
  unreachable
}

declare void @stb_vorbis_close(ptr noundef) local_unnamed_addr #3

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #4

declare void @drflac_close(ptr noundef) local_unnamed_addr #3

declare void @drmp3_uninit(ptr noundef) local_unnamed_addr #3

declare i32 @drwav_uninit(ptr noundef) local_unnamed_addr #3

attributes #0 = { nobuiltin 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 = { 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 #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" }
attributes #3 = { "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 #4 = { noinline noreturn nounwind uwtable "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 #5 = { builtin nounwind }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !16, i64 496}
!9 = !{!"_ZTSN6SoLoud17WavStreamInstanceE", !10, i64 0, !16, i64 496, !11, i64 504, !16, i64 512, !12, i64 520, !11, i64 528, !11, i64 532, !16, i64 536}
!10 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !11, i64 8, !11, i64 12, !11, i64 16, !13, i64 20, !12, i64 24, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !11, i64 72, !13, i64 76, !13, i64 80, !14, i64 88, !14, i64 96, !15, i64 104, !15, i64 152, !15, i64 200, !15, i64 248, !15, i64 296, !11, i64 344, !12, i64 348, !11, i64 380, !11, i64 384, !12, i64 392, !12, i64 456, !11, i64 472, !11, i64 476, !11, i64 480, !14, i64 488}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"float", !12, i64 0}
!14 = !{!"double", !12, i64 0}
!15 = !{!"_ZTSN6SoLoud5FaderE", !13, i64 0, !13, i64 4, !13, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !13, i64 40, !11, i64 44}
!16 = !{!"any pointer", !12, i64 0}
!17 = !{!18, !11, i64 152}
!18 = !{!"_ZTSN6SoLoud9WavStreamE", !19, i64 0, !11, i64 152, !16, i64 160, !16, i64 168, !16, i64 176, !11, i64 184}
!19 = !{!"_ZTSN6SoLoud11AudioSourceE", !11, i64 8, !13, i64 12, !13, i64 16, !11, i64 20, !11, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !11, i64 40, !13, i64 44, !12, i64 48, !16, i64 112, !16, i64 120, !16, i64 128, !11, i64 136, !14, i64 144}
!20 = !{!12, !12, i64 0}
!21 = !{!9, !16, i64 512}
!22 = !{!18, !16, i64 176}


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