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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud11BusInstanceC2EPNS_3BusE(ptr noundef nonnull align 8 dereferenceable(1592) %0, ptr noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @_ZN6SoLoud19AudioSourceInstanceC2Ev(ptr noundef nonnull align 8 dereferenceable(496) %9)
  store ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTVN6SoLoud11BusInstanceE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %9, i32 0, i32 4
  invoke void @_ZN6SoLoud18AlignedFloatBufferC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %10)
          to label %11 unwind label %21

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %9, i32 0, i32 1
  store ptr %12, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance", ptr %9, i32 0, i32 3
  %15 = load i32, ptr %14, align 8, !tbaa !19
  %16 = or i32 %15, 130
  store i32 %16, ptr %14, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !20
  br label %17

17:                                               ; preds = %30, %11
  %18 = load i32, ptr %7, align 4, !tbaa !20
  %19 = icmp slt i32 %18, 8
  br i1 %19, label %25, label %20

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %33

21:                                               ; preds = %2
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %5, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %6, align 4
  br label %58

25:                                               ; preds = %17
  %26 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %9, i32 0, i32 5
  %27 = load i32, ptr %7, align 4, !tbaa !20
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [8 x float], ptr %26, i64 0, i64 %28
  store float 0.000000e+00, ptr %29, align 4, !tbaa !21
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %7, align 4, !tbaa !20
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %7, align 4, !tbaa !20
  br label %17, !llvm.loop !22

33:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !20
  br label %34

34:                                               ; preds = %43, %33
  %35 = load i32, ptr %8, align 4, !tbaa !20
  %36 = icmp slt i32 %35, 256
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %46

38:                                               ; preds = %34
  %39 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %9, i32 0, i32 6
  %40 = load i32, ptr %8, align 4, !tbaa !20
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [256 x float], ptr %39, i64 0, i64 %41
  store float 0.000000e+00, ptr %42, align 4, !tbaa !21
  br label %43

43:                                               ; preds = %38
  %44 = load i32, ptr %8, align 4, !tbaa !20
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %8, align 4, !tbaa !20
  br label %34, !llvm.loop !24

46:                                               ; preds = %37
  %47 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %9, i32 0, i32 2
  store i32 512, ptr %47, align 8, !tbaa !25
  %48 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %9, i32 0, i32 4
  %49 = getelementptr inbounds %"class.SoLoud::BusInstance", ptr %9, i32 0, i32 2
  %50 = load i32, ptr %49, align 8, !tbaa !25
  %51 = mul i32 %50, 8
  %52 = invoke noundef i32 @_ZN6SoLoud18AlignedFloatBuffer4initEj(ptr noundef nonnull align 8 dereferenceable(20) %48, i32 noundef %51)
          to label %53 unwind label %54

53:                                               ; preds = %46
  ret void

54:                                               ; preds = %46
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %5, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %6, align 4
  call void @_ZN6SoLoud18AlignedFloatBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %10) #4
  br label %58

58:                                               ; preds = %54, %21
  call void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496) %9) #4
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %5, align 8
  %61 = load i32, ptr %6, align 4
  %62 = insertvalue { ptr, i32 } poison, ptr %60, 0
  %63 = insertvalue { ptr, i32 } %62, i32 %61, 1
  resume { ptr, i32 } %63
}

declare void @_ZN6SoLoud19AudioSourceInstanceC2Ev(ptr noundef nonnull align 8 dereferenceable(496)) unnamed_addr #1

declare void @_ZN6SoLoud18AlignedFloatBufferC1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #1

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) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

declare noundef i32 @_ZN6SoLoud18AlignedFloatBuffer4initEj(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) #1

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

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

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" }
attributes #1 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!13, !14, i64 16}
!20 = !{!14, !14, i64 0}
!21 = !{!15, !15, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = !{!12, !14, i64 504}


; 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud11BusInstanceC2EPNS_3BusE(ptr noundef nonnull align 8 dereferenceable(1592) %0, ptr noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN6SoLoud19AudioSourceInstanceC2Ev(ptr noundef nonnull align 8 dereferenceable(496) %0)
  store ptr getelementptr inbounds inrange(-16, 56) (i8, ptr @_ZTVN6SoLoud11BusInstanceE, i64 16), ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 512
  invoke void @_ZN6SoLoud18AlignedFloatBufferC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %3)
          to label %.preheader unwind label %11

.preheader:                                       ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 496
  store ptr %1, ptr %4, align 8, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !18
  %7 = or i32 %6, 130
  store i32 %7, ptr %5, align 8, !tbaa !18
  %8 = getelementptr inbounds i8, ptr %0, i64 536
  %9 = getelementptr inbounds i8, ptr %0, i64 504
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1056) %8, i8 0, i64 1056, i1 false)
  store i32 512, ptr %9, align 8, !tbaa !19
  %10 = invoke noundef i32 @_ZN6SoLoud18AlignedFloatBuffer4initEj(ptr noundef nonnull align 8 dereferenceable(20) %3, i32 noundef 4096)
          to label %13 unwind label %14

11:                                               ; preds = %2
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %16

13:                                               ; preds = %.preheader
  ret void

14:                                               ; preds = %.preheader
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN6SoLoud18AlignedFloatBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %3) #4
  br label %16

16:                                               ; preds = %14, %11
  %.pn = phi { ptr, i32 } [ %15, %14 ], [ %12, %11 ]
  tail call void @_ZN6SoLoud19AudioSourceInstanceD2Ev(ptr noundef nonnull align 8 dereferenceable(496) %0) #4
  resume { ptr, i32 } %.pn
}

declare void @_ZN6SoLoud19AudioSourceInstanceC2Ev(ptr noundef nonnull align 8 dereferenceable(496)) unnamed_addr #1

declare void @_ZN6SoLoud18AlignedFloatBufferC1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare noundef i32 @_ZN6SoLoud18AlignedFloatBuffer4initEj(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) local_unnamed_addr #1

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

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

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

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" }
attributes #1 = { "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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!10, !11, i64 16}
!19 = !{!9, !11, i64 504}


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