; LLVM IR from glaretechnologies/substrata :: resonance-audio/resonance_audio/dsp (spectral_reverb)

; 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.vraudio::SpectralReverb" = type <{ i32, [4 x i8], i64, i64, i64, %"class.vraudio::FftManager", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::CircularBuffer", %"class.std::vector.5", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", %"class.std::vector.10", i8, i8, [6 x i8] }>
%"class.vraudio::FftManager" = type { i64, i64, float, [4 x i8], %"class.vraudio::AudioBuffer", %"class.vraudio::AudioBuffer", ptr, ptr }
%"class.vraudio::CircularBuffer" = type { i64, i64, %"class.vraudio::AudioBuffer", i64, i64, i64 }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<std::unique_ptr<vraudio::CircularBuffer>, std::allocator<std::unique_ptr<vraudio::CircularBuffer>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unique_ptr<vraudio::CircularBuffer>, std::allocator<std::unique_ptr<vraudio::CircularBuffer>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unique_ptr<vraudio::CircularBuffer>, std::allocator<std::unique_ptr<vraudio::CircularBuffer>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unique_ptr<vraudio::CircularBuffer>, std::allocator<std::unique_ptr<vraudio::CircularBuffer>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.vraudio::AudioBuffer" = type <{ i64, %"class.std::vector", i64, %"class.std::vector.0", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl" }
%"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl" }
%"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl" = type { %"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<vraudio::AudioBuffer, std::allocator<vraudio::AudioBuffer>>::_Vector_impl" }
%"struct.std::_Vector_base<vraudio::AudioBuffer, std::allocator<vraudio::AudioBuffer>>::_Vector_impl" = type { %"struct.std::_Vector_base<vraudio::AudioBuffer, std::allocator<vraudio::AudioBuffer>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vraudio::AudioBuffer, std::allocator<vraudio::AudioBuffer>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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: mustprogress uwtable
define dso_local void @_ZN7vraudio14SpectralReverb22GenerateAnalysisWindowEv(ptr noundef nonnull align 8 dereferenceable(1242) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %9 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %8, i32 0, i32 8
  %10 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %9, i64 noundef 0)
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %8, i32 0, i32 7
  %12 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %11, i64 noundef 0)
  call void @_ZN7vraudio18GenerateHannWindowEbmPNS_11ChannelViewE(i1 noundef zeroext true, i64 noundef 2049, ptr noundef %12)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %13 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %8, i32 0, i32 7
  %14 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %13, i64 noundef 0)
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %14, i64 noundef 0)
  store ptr %15, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store float 7.500000e-01, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN7vraudio14ScalarMultiplyEmfPKfPf(i64 noundef 2049, float noundef 7.500000e-01, ptr noundef %16, ptr noundef %17)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %18

18:                                               ; preds = %29, %1
  %19 = load i64, ptr %6, align 8, !tbaa !11
  %20 = icmp ult i64 %19, 3072
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %32

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load i64, ptr %6, align 8, !tbaa !11
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %23, i64 noundef %24)
  store ptr %25, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN7vraudio12AddPointwiseEmPKfS1_Pf(i64 noundef 2049, ptr noundef %26, ptr noundef %27, ptr noundef %28)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %29

29:                                               ; preds = %22
  %30 = load i64, ptr %6, align 8, !tbaa !11
  %31 = add i64 %30, 1024
  store i64 %31, ptr %6, align 8, !tbaa !11
  br label %18, !llvm.loop !13

32:                                               ; preds = %21
  %33 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %8, i32 0, i32 5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN7vraudio10FftManager22ApplyReverseFftScalingEPNS_11ChannelViewE(ptr noundef nonnull align 8 dereferenceable(184) %33, ptr noundef %34)
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %8, i32 0, i32 7
  %37 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %36, i64 noundef 0)
  %38 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewaSERKS0_(ptr noundef nonnull align 8 dereferenceable(17) %37, ptr noundef nonnull align 8 dereferenceable(17) %35)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare void @_ZN7vraudio14ScalarMultiplyEmfPKfPf(i64 noundef, float noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17), i64 noundef) #1 align 2

declare void @_ZN7vraudio12AddPointwiseEmPKfS1_Pf(i64 noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @_ZN7vraudio18GenerateHannWindowEbmPNS_11ChannelViewE(i1 noundef zeroext, i64 noundef, ptr noundef) #2

declare void @_ZN7vraudio10FftManager22ApplyReverseFftScalingEPNS_11ChannelViewE(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewaSERKS0_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7vraudio14SpectralReverb22GenerateAnalysisWindowEv(ptr noundef nonnull align 8 dereferenceable(1242) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 360
  %3 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %2, i64 noundef 0)
  %4 = getelementptr inbounds i8, ptr %0, i64 288
  %5 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %4, i64 noundef 0)
  tail call void @_ZN7vraudio18GenerateHannWindowEbmPNS_11ChannelViewE(i1 noundef zeroext true, i64 noundef 2049, ptr noundef nonnull %5)
  %6 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %4, i64 noundef 0)
  %7 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %6, i64 noundef 0)
  tail call void @_ZN7vraudio14ScalarMultiplyEmfPKfPf(i64 noundef 2049, float noundef 7.500000e-01, ptr noundef nonnull %7, ptr noundef nonnull %7)
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef 0)
  tail call void @_ZN7vraudio12AddPointwiseEmPKfS1_Pf(i64 noundef 2049, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %8)
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef 1024)
  tail call void @_ZN7vraudio12AddPointwiseEmPKfS1_Pf(i64 noundef 2049, ptr noundef nonnull %7, ptr noundef nonnull %9, ptr noundef nonnull %9)
  %10 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef 2048)
  tail call void @_ZN7vraudio12AddPointwiseEmPKfS1_Pf(i64 noundef 2049, ptr noundef nonnull %7, ptr noundef nonnull %10, ptr noundef nonnull %10)
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZN7vraudio10FftManager22ApplyReverseFftScalingEPNS_11ChannelViewE(ptr noundef nonnull align 8 dereferenceable(184) %11, ptr noundef nonnull %3)
  %12 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %4, i64 noundef 0)
  %13 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewaSERKS0_(ptr noundef nonnull align 8 dereferenceable(17) %12, ptr noundef nonnull align 8 dereferenceable(17) %3)
  ret void
}

declare void @_ZN7vraudio14ScalarMultiplyEmfPKfPf(i64 noundef, float noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17), i64 noundef) local_unnamed_addr #0 align 2

declare void @_ZN7vraudio12AddPointwiseEmPKfS1_Pf(i64 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN7vraudio18GenerateHannWindowEbmPNS_11ChannelViewE(i1 noundef zeroext, i64 noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN7vraudio10FftManager22ApplyReverseFftScalingEPNS_11ChannelViewE(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewaSERKS0_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #0 align 2

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

!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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass