; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_audio_basics)

; 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.juce::FFT" = type <{ %"class.juce::ScopedPointer.27", i32, [4 x i8] }>
%"class.juce::ScopedPointer.27" = type { ptr }
%"struct.juce::FFT::Complex" = type { float, float }

; 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 nounwind uwtable
declare dso_local void @_ZNK4juce3FFT7performEPKNS0_7ComplexEPS1_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK4juce3FFT31performRealOnlyInverseTransformEPNS0_7ComplexEPf(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  br label %10

10:                                               ; preds = %3
  br label %11

11:                                               ; preds = %10
  br label %12

12:                                               ; preds = %11
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNK4juce3FFT7performEPKNS0_7ComplexEPS1_(ptr noundef nonnull align 8 dereferenceable(12) %9, ptr noundef %13, ptr noundef %14) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %15 = getelementptr inbounds %"class.juce::FFT", ptr %9, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = sitofp i32 %16 to float
  %18 = fdiv float 1.000000e+00, %17
  store float %18, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !15
  br label %19

19:                                               ; preds = %53, %12
  %20 = load i32, ptr %8, align 4, !tbaa !15
  %21 = getelementptr inbounds %"class.juce::FFT", ptr %9, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp slt i32 %20, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %56

25:                                               ; preds = %19
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !15
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %26, i64 %28
  %30 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !16
  %32 = load float, ptr %7, align 4, !tbaa !13
  %33 = fmul float %31, %32
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !15
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  store float %33, ptr %37, align 4, !tbaa !13
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load i32, ptr %8, align 4, !tbaa !15
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %38, i64 %40
  %42 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %41, i32 0, i32 1
  %43 = load float, ptr %42, align 4, !tbaa !18
  %44 = load float, ptr %7, align 4, !tbaa !13
  %45 = fmul float %43, %44
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %8, align 4, !tbaa !15
  %48 = getelementptr inbounds %"class.juce::FFT", ptr %9, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !9
  %50 = add nsw i32 %47, %49
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds float, ptr %46, i64 %51
  store float %45, ptr %52, align 4, !tbaa !13
  br label %53

53:                                               ; preds = %25
  %54 = load i32, ptr %8, align 4, !tbaa !15
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %8, align 4, !tbaa !15
  br label %19, !llvm.loop !19

56:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 8}
!10 = !{!"_ZTSN4juce3FFTE", !11, i64 0, !12, i64 8}
!11 = !{!"_ZTSN4juce13ScopedPointerINS_3FFT9FFTConfigEEE", !6, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !14, i64 0}
!17 = !{!"_ZTSN4juce3FFT7ComplexE", !14, i64 0, !14, i64 4}
!18 = !{!17, !14, i64 4}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%"struct.juce::FFT::Complex" = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK4juce3FFT7performEPKNS0_7ComplexEPS1_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK4juce3FFT31performRealOnlyInverseTransformEPNS0_7ComplexEPf(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZNK4juce3FFT7performEPKNS0_7ComplexEPS1_(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %2, ptr noundef %1) #1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = sitofp i32 %5 to float
  %7 = fdiv float 1.000000e+00, %6
  %8 = icmp sgt i32 %5, 0
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %9 = zext nneg i32 %5 to i64
  %invariant.gep = getelementptr inbounds float, ptr %2, i64 %9
  %min.iters.check = icmp ult i32 %5, 8
  br i1 %min.iters.check, label %.lr.ph.preheader21, label %vector.memcheck

.lr.ph.preheader21:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %9, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader21
  %10 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %1, i64 %indvars.iv.ph
  %11 = load float, ptr %10, align 4, !tbaa !12
  %12 = fmul float %7, %11
  %13 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.ph
  store float %12, ptr %13, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %10, i64 4
  %15 = load float, ptr %14, align 4, !tbaa !16
  %16 = fmul float %7, %15
  %gep.prol = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv.ph
  store float %16, ptr %gep.prol, align 4, !tbaa !15
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader21
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader21 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %17 = add nsw i64 %9, -1
  %18 = icmp eq i64 %indvars.iv.ph, %17
  br i1 %18, label %._crit_edge, label %.lr.ph

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %19 = shl nuw nsw i64 %9, 3
  %scevgep = getelementptr i8, ptr %2, i64 %19
  %scevgep16 = getelementptr i8, ptr %1, i64 %19
  %bound0 = icmp ult ptr %invariant.gep, %scevgep16
  %bound1 = icmp ugt ptr %scevgep, %1
  %found.conflict = and i1 %bound0, %bound1
  %bound017 = icmp ugt ptr %scevgep16, %2
  %bound118 = icmp ugt ptr %invariant.gep, %1
  %found.conflict19 = and i1 %bound017, %bound118
  %conflict.rdx = or i1 %found.conflict, %found.conflict19
  br i1 %conflict.rdx, label %.lr.ph.preheader21, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %9, 2147483644
  %broadcast.splatinsert = insertelement <4 x float> poison, float %7, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %20 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %1, i64 %index
  %wide.vec = load <8 x float>, ptr %20, align 4, !tbaa !15
  %strided.vec = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %strided.vec20 = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %21 = fmul <4 x float> %broadcast.splat, %strided.vec
  %22 = getelementptr inbounds float, ptr %2, i64 %index
  store <4 x float> %21, ptr %22, align 4, !tbaa !15, !alias.scope !17, !noalias !20
  %23 = fmul <4 x float> %broadcast.splat, %strided.vec20
  %24 = getelementptr inbounds float, ptr %invariant.gep, i64 %index
  store <4 x float> %23, ptr %24, align 4, !tbaa !15, !alias.scope !22, !noalias !20
  %index.next = add nuw i64 %index, 4
  %25 = icmp eq i64 %index.next, %n.vec
  br i1 %25, label %middle.block, label %vector.body, !llvm.loop !24

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %9
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader21

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %3
  ret void

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %26 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %1, i64 %indvars.iv
  %27 = load float, ptr %26, align 4, !tbaa !12
  %28 = fmul float %7, %27
  %29 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  store float %28, ptr %29, align 4, !tbaa !15
  %30 = getelementptr inbounds i8, ptr %26, i64 4
  %31 = load float, ptr %30, align 4, !tbaa !16
  %32 = fmul float %7, %31
  %gep = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv
  store float %32, ptr %gep, align 4, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %33 = getelementptr inbounds %"struct.juce::FFT::Complex", ptr %1, i64 %indvars.iv.next
  %34 = load float, ptr %33, align 4, !tbaa !12
  %35 = fmul float %7, %34
  %36 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.next
  store float %35, ptr %36, align 4, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %33, i64 4
  %38 = load float, ptr %37, align 4, !tbaa !16
  %39 = fmul float %7, %38
  %gep.1 = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv.next
  store float %39, ptr %gep.1, align 4, !tbaa !15
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %9
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !28
}

attributes #0 = { 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 #1 = { 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, !11, i64 8}
!6 = !{!"_ZTSN4juce3FFTE", !7, i64 0, !11, i64 8}
!7 = !{!"_ZTSN4juce13ScopedPointerINS_3FFT9FFTConfigEEE", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTSN4juce3FFT7ComplexE", !14, i64 0, !14, i64 4}
!14 = !{!"float", !9, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!13, !14, i64 4}
!17 = !{!18}
!18 = distinct !{!18, !19}
!19 = distinct !{!19, !"LVerDomain"}
!20 = !{!21}
!21 = distinct !{!21, !19}
!22 = !{!23}
!23 = distinct !{!23, !19}
!24 = distinct !{!24, !25, !26, !27}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!"llvm.loop.isvectorized", i32 1}
!27 = !{!"llvm.loop.unroll.runtime.disable"}
!28 = distinct !{!28, !25, !26}


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