; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_bus.ll (ZN6SoLoud11BusInstanceD2Ev)

; 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::BusInstance" = type { %"class.SoLoud::AudioSourceInstance", ptr, i32, [4 x i8], %"class.SoLoud::AlignedFloatBuffer", [8 x float], [256 x float] }
%"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 }
%"class.SoLoud::AlignedFloatBuffer" = type <{ 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 }
%"class.SoLoud::Soloud" = type <{ ptr, ptr, i8, [7 x i8], ptr, ptr, ptr, i32, i32, %"class.SoLoud::AlignedFloatBuffer", i32, [4 x i8], %"class.SoLoud::AlignedFloatBuffer", ptr, %"class.SoLoud::AlignedFloatBuffer", ptr, [1024 x ptr], i32, i32, i32, i32, ptr, i32, i32, float, float, i32, i32, %"class.SoLoud::Fader", double, double, [8 x ptr], [8 x ptr], [8 x float], [256 x float], [256 x float], [256 x float], [3 x float], [3 x float], [3 x float], [3 x float], float, [24 x float], [4 x i8], [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr, i32, [1024 x i32], i32, i8, [7 x i8] }>
%"class.SoLoud::AudioSourceInstance3dData" = type <{ [3 x float], [3 x float], float, float, float, i32, float, [4 x i8], ptr, ptr, i32, float, float, [8 x float], i32, i32, [4 x i8] }>
%"class.SoLoud::Bus" = type { %"class.SoLoud::AudioSource", ptr, i32, i32, [256 x float], [256 x float] }

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

declare i32 @__gxx_personality_v0(...)

; 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: nounwind
declare void @_ZN6SoLoud18AlignedFloatBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #1

; 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 @_ZN6SoLoud11BusInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(1592) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTVN6SoLoud11BusInstanceE, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %6 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %7, i32 0, i32 12
  %9 = load ptr, ptr %8, align 8, !tbaa !19
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !21
  br label %10

10:                                               ; preds = %43, %1
  %11 = load i32, ptr %4, align 4, !tbaa !21
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %12, i32 0, i32 8
  %14 = load i32, ptr %13, align 4, !tbaa !22
  %15 = icmp slt i32 %11, %14
  br i1 %15, label %16, label %46

16:                                               ; preds = %10
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %17, i32 0, i32 16
  %19 = load i32, ptr %4, align 4, !tbaa !21
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1024 x ptr], ptr %18, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %42

24:                                               ; preds = %16
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %25, i32 0, i32 16
  %27 = load i32, ptr %4, align 4, !tbaa !21
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1024 x ptr], ptr %26, i64 0, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance", ptr %30, i32 0, i32 23
  %32 = load i32, ptr %31, align 8, !tbaa !25
  %33 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %5, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds %"class.SoLoud::Bus", ptr %34, i32 0, i32 2
  %36 = load i32, ptr %35, align 8, !tbaa !26
  %37 = icmp eq i32 %32, %36
  br i1 %37, label %38, label %42

38:                                               ; preds = %24
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !21
  invoke void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %39, i32 noundef %40)
          to label %41 unwind label %48

41:                                               ; preds = %38
  br label %42

42:                                               ; preds = %41, %24, %16
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %4, align 4, !tbaa !21
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %4, align 4, !tbaa !21
  br label %10, !llvm.loop !28

46:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  %47 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %5, i32 0, i32 4
  call void @_ZN6SoLoud18AlignedFloatBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %47) #5
  call void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496) %5) #5
  ret void

48:                                               ; preds = %38
  %49 = landingpad { ptr, i32 }
          catch ptr null
  %50 = extractvalue { ptr, i32 } %49, 0
  call void @__clang_call_terminate(ptr %50) #6
  unreachable
}

declare void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }
attributes #6 = { 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 = !{!"_ZTSN6SoLoud11BusInstanceE", !13, i64 0, !6, i64 496, !14, i64 504, !18, i64 512, !7, i64 536, !7, i64 568}
!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 = !{!"_ZTSN6SoLoud18AlignedFloatBufferE", !6, i64 0, !6, i64 8, !14, i64 16}
!19 = !{!20, !6, i64 112}
!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 = !{!14, !14, i64 0}
!22 = !{!23, !14, i64 52}
!23 = !{!"_ZTSN6SoLoud6SoloudE", !6, i64 0, !6, i64 8, !24, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !14, i64 48, !14, i64 52, !18, i64 56, !14, i64 80, !18, i64 88, !6, i64 112, !18, i64 120, !6, i64 144, !7, i64 152, !14, i64 8344, !14, i64 8348, !14, i64 8352, !14, i64 8356, !6, i64 8360, !14, i64 8368, !14, i64 8372, !15, i64 8376, !15, i64 8380, !14, i64 8384, !14, i64 8388, !17, i64 8392, !16, i64 8440, !16, i64 8448, !7, i64 8456, !7, i64 8520, !7, i64 8584, !7, i64 8616, !7, i64 9640, !7, i64 10664, !7, i64 11688, !7, i64 11700, !7, i64 11712, !7, i64 11724, !15, i64 11736, !7, i64 11740, !7, i64 11840, !6, i64 134720, !14, i64 134728, !7, i64 134732, !14, i64 138828, !24, i64 138832}
!24 = !{!"bool", !7, i64 0}
!25 = !{!13, !14, i64 384}
!26 = !{!27, !14, i64 160}
!27 = !{!"_ZTSN6SoLoud3BusE", !20, i64 0, !6, i64 152, !14, i64 160, !14, i64 164, !7, i64 168, !7, i64 1192}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN6SoLoud18AlignedFloatBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6SoLoud11BusInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(1592) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 56) (i8, ptr @_ZTVN6SoLoud11BusInstanceE, 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 112
  %5 = load ptr, ptr %4, align 8, !tbaa !18
  %6 = getelementptr inbounds i8, ptr %5, i64 52
  %7 = load i32, ptr %6, align 4, !tbaa !20
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %9 = getelementptr inbounds i8, ptr %5, i64 152
  br label %10

10:                                               ; preds = %.lr.ph, %23
  %11 = phi i32 [ %7, %.lr.ph ], [ %24, %23 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %12 = getelementptr inbounds [1024 x ptr], ptr %9, i64 0, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !23
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %23, label %14

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %13, i64 384
  %16 = load i32, ptr %15, align 8, !tbaa !24
  %17 = load ptr, ptr %2, align 8, !tbaa !8
  %18 = getelementptr inbounds i8, ptr %17, i64 160
  %19 = load i32, ptr %18, align 8, !tbaa !25
  %20 = icmp eq i32 %16, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %14
  %22 = trunc nuw nsw i64 %indvars.iv to i32
  invoke void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %5, i32 noundef %22)
          to label %._crit_edge12 unwind label %28

._crit_edge12:                                    ; preds = %21
  %.pre = load i32, ptr %6, align 4, !tbaa !20
  br label %23

23:                                               ; preds = %._crit_edge12, %10, %14
  %24 = phi i32 [ %.pre, %._crit_edge12 ], [ %11, %10 ], [ %11, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next, %25
  br i1 %26, label %10, label %._crit_edge, !llvm.loop !27

._crit_edge:                                      ; preds = %23, %1
  %27 = getelementptr inbounds i8, ptr %0, i64 512
  tail call void @_ZN6SoLoud18AlignedFloatBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %27) #4
  tail call void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496) %0) #4
  ret void

28:                                               ; preds = %21
  %29 = landingpad { ptr, i32 }
          catch ptr null
  %30 = extractvalue { ptr, i32 } %29, 0
  tail call void @__clang_call_terminate(ptr %30) #5
  unreachable
}

declare void @_ZN6SoLoud6Soloud18stopVoice_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) local_unnamed_addr #2

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

attributes #0 = { 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 = { 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 #2 = { "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 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!"_ZTSN6SoLoud11BusInstanceE", !10, i64 0, !16, i64 496, !11, i64 504, !17, i64 512, !12, i64 536, !12, i64 568}
!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 = !{!"_ZTSN6SoLoud18AlignedFloatBufferE", !16, i64 0, !16, i64 8, !11, i64 16}
!18 = !{!19, !16, i64 112}
!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 = !{!21, !11, i64 52}
!21 = !{!"_ZTSN6SoLoud6SoloudE", !16, i64 0, !16, i64 8, !22, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !11, i64 48, !11, i64 52, !17, i64 56, !11, i64 80, !17, i64 88, !16, i64 112, !17, i64 120, !16, i64 144, !12, i64 152, !11, i64 8344, !11, i64 8348, !11, i64 8352, !11, i64 8356, !16, i64 8360, !11, i64 8368, !11, i64 8372, !13, i64 8376, !13, i64 8380, !11, i64 8384, !11, i64 8388, !15, i64 8392, !14, i64 8440, !14, i64 8448, !12, i64 8456, !12, i64 8520, !12, i64 8584, !12, i64 8616, !12, i64 9640, !12, i64 10664, !12, i64 11688, !12, i64 11700, !12, i64 11712, !12, i64 11724, !13, i64 11736, !12, i64 11740, !12, i64 11840, !16, i64 134720, !11, i64 134728, !12, i64 134732, !11, i64 138828, !22, i64 138832}
!22 = !{!"bool", !12, i64 0}
!23 = !{!16, !16, i64 0}
!24 = !{!10, !11, i64 384}
!25 = !{!26, !11, i64 160}
!26 = !{!"_ZTSN6SoLoud3BusE", !19, i64 0, !16, i64 152, !11, i64 160, !11, i64 164, !12, i64 168, !12, i64 1192}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass