; 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 @_ZN7vraudio14SpectralReverb25GenerateRandomPhaseBufferEv(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 i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %7 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %6, i32 0, i32 6
  %8 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %7, i64 noundef 0)
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %9 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %6, i32 0, i32 6
  %10 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %9, i64 noundef 1)
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN7vraudio20GenerateUniformNoiseEffjPNS_11ChannelViewE(float noundef 0.000000e+00, float noundef 0x400921FB60000000, i32 noundef 1, ptr noundef %11)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %35, %1
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds %"class.vraudio::SpectralReverb", ptr %6, i32 0, i32 6
  %15 = call noundef i64 @_ZNK7vraudio11AudioBuffer10num_framesEv(ptr noundef nonnull align 8 dereferenceable(68) %14)
  %16 = icmp ult i64 %13, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %38

18:                                               ; preds = %12
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %19, i64 noundef %20)
  %22 = load float, ptr %21, align 4, !tbaa !11
  %23 = call noundef float @_ZSt3cosf(float noundef %22)
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %24, i64 noundef %25)
  store float %23, ptr %26, align 4, !tbaa !11
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %27, i64 noundef %28)
  %30 = load float, ptr %29, align 4, !tbaa !11
  %31 = call noundef float @_ZSt3sinf(float noundef %30)
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %32, i64 noundef %33)
  store float %31, ptr %34, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %18
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = add i64 %36, 1
  store i64 %37, ptr %5, align 8, !tbaa !9
  br label %12, !llvm.loop !13

38:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7vraudio11AudioBuffer10num_framesEv(ptr noundef nonnull align 8 dereferenceable(68)) #2 align 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 @_ZN7vraudio20GenerateUniformNoiseEffjPNS_11ChannelViewE(float noundef, float noundef, i32 noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) #4

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 = { 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 = { inlinehint 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 #5 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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 @_ZN7vraudio14SpectralReverb25GenerateRandomPhaseBufferEv(ptr noundef nonnull align 8 dereferenceable(1242) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 216
  %3 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %2, i64 noundef 0)
  %4 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %2, i64 noundef 1)
  tail call void @_ZN7vraudio20GenerateUniformNoiseEffjPNS_11ChannelViewE(float noundef 0.000000e+00, float noundef 0x400921FB60000000, i32 noundef 1, ptr noundef nonnull %3)
  %5 = tail call noundef i64 @_ZNK7vraudio11AudioBuffer10num_framesEv(ptr noundef nonnull align 8 dereferenceable(68) %2)
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  ret void

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.011 = phi i64 [ %14, %.lr.ph ], [ 0, %1 ]
  %6 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef %.011)
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = tail call noundef float @_ZSt3cosf(float noundef %7)
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %4, i64 noundef %.011)
  store float %8, ptr %9, align 4, !tbaa !5
  %10 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef %.011)
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = tail call noundef float @_ZSt3sinf(float noundef %11)
  %13 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef %.011)
  store float %12, ptr %13, align 4, !tbaa !5
  %14 = add nuw i64 %.011, 1
  %15 = tail call noundef i64 @_ZNK7vraudio11AudioBuffer10num_framesEv(ptr noundef nonnull align 8 dereferenceable(68) %2)
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !9
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7vraudio11AudioBuffer10num_framesEv(ptr noundef nonnull align 8 dereferenceable(68)) local_unnamed_addr #1 align 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) 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 @_ZN7vraudio20GenerateUniformNoiseEffjPNS_11ChannelViewE(float noundef, float noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) local_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 = { 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 = { inlinehint 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" }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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