; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/filter (soloud_fftfilter)

; 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::FFTFilterInstance" = type { %"class.SoLoud::FilterInstance", ptr, ptr, ptr, ptr, ptr, [8 x i32], [8 x i32], [8 x i32], ptr }
%"class.SoLoud::FilterInstance" = type { ptr, i32, i32, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6SoLoud17FFTFilterInstance16magFreq2MagPhaseEPfjfj(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1, i32 noundef %2, float noundef %3, i32 noundef %4) #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca i32, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = uitofp i32 %18 to float
  %20 = load float, ptr %9, align 4, !tbaa !11
  %21 = fdiv float %19, %20
  store float %21, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %22 = load float, ptr %11, align 4, !tbaa !11
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = uitofp i32 %23 to float
  %25 = fdiv float %22, %24
  %26 = fmul float %25, 2.000000e+00
  %27 = fmul float %26, 0x400921FB60000000
  store float %27, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %28 = load float, ptr %9, align 4, !tbaa !11
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = uitofp i32 %29 to float
  %31 = fdiv float %28, %30
  store float %31, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %97, %5
  %33 = load i32, ptr %14, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %100

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = mul i32 %39, 2
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %38, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !11
  store float %43, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load i32, ptr %14, align 4, !tbaa !9
  %46 = mul i32 %45, 2
  %47 = add i32 %46, 1
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %44, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !11
  store float %50, ptr %16, align 4, !tbaa !11
  %51 = load i32, ptr %14, align 4, !tbaa !9
  %52 = uitofp i32 %51 to float
  %53 = load float, ptr %13, align 4, !tbaa !11
  %54 = load float, ptr %16, align 4, !tbaa !11
  %55 = fneg float %52
  %56 = call float @llvm.fmuladd.f32(float %55, float %53, float %54)
  store float %56, ptr %16, align 4, !tbaa !11
  %57 = load float, ptr %13, align 4, !tbaa !11
  %58 = load float, ptr %16, align 4, !tbaa !11
  %59 = fdiv float %58, %57
  store float %59, ptr %16, align 4, !tbaa !11
  %60 = load float, ptr %16, align 4, !tbaa !11
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = uitofp i32 %61 to float
  %63 = fdiv float %60, %62
  %64 = fmul float %63, 0x400921FB60000000
  %65 = fmul float %64, 2.000000e+00
  store float %65, ptr %16, align 4, !tbaa !11
  %66 = load i32, ptr %14, align 4, !tbaa !9
  %67 = uitofp i32 %66 to float
  %68 = load float, ptr %12, align 4, !tbaa !11
  %69 = load float, ptr %16, align 4, !tbaa !11
  %70 = call float @llvm.fmuladd.f32(float %67, float %68, float %69)
  store float %70, ptr %16, align 4, !tbaa !11
  %71 = load float, ptr %16, align 4, !tbaa !11
  %72 = getelementptr inbounds %"class.SoLoud::FFTFilterInstance", ptr %17, i32 0, i32 5
  %73 = load ptr, ptr %72, align 8, !tbaa !13
  %74 = load i32, ptr %14, align 4, !tbaa !9
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = mul i32 %75, 256
  %77 = add i32 %74, %76
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %73, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !11
  %81 = fadd float %80, %71
  store float %81, ptr %79, align 4, !tbaa !11
  %82 = getelementptr inbounds %"class.SoLoud::FFTFilterInstance", ptr %17, i32 0, i32 5
  %83 = load ptr, ptr %82, align 8, !tbaa !13
  %84 = load i32, ptr %14, align 4, !tbaa !9
  %85 = load i32, ptr %10, align 4, !tbaa !9
  %86 = mul i32 %85, 256
  %87 = add i32 %84, %86
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %83, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !11
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = load i32, ptr %14, align 4, !tbaa !9
  %93 = mul i32 %92, 2
  %94 = add i32 %93, 1
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds float, ptr %91, i64 %95
  store float %90, ptr %96, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %97

97:                                               ; preds = %37
  %98 = load i32, ptr %14, align 4, !tbaa !9
  %99 = add i32 %98, 1
  store i32 %99, ptr %14, align 4, !tbaa !9
  br label %32, !llvm.loop !16

100:                                              ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 64}
!14 = !{!"_ZTSN6SoLoud17FFTFilterInstanceE", !15, i64 0, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !7, i64 104, !7, i64 136, !6, i64 168}
!15 = !{!"_ZTSN6SoLoud14FilterInstanceE", !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN6SoLoud17FFTFilterInstance16magFreq2MagPhaseEPfjfj(ptr nocapture noundef nonnull readonly align 8 dereferenceable(176) %0, ptr nocapture noundef %1, i32 noundef %2, float noundef %3, i32 noundef %4) local_unnamed_addr #1 align 2 {
  %6 = uitofp i32 %2 to float
  %7 = fdiv float %6, %3
  %8 = fdiv float %7, %6
  %9 = fmul float %8, 2.000000e+00
  %10 = fmul float %9, 0x400921FB60000000
  %11 = fdiv float %3, %6
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = shl i32 %4, 8
  %wide.trip.count = zext i32 %2 to i64
  %min.iters.check = icmp ult i32 %2, 5
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

scalar.ph.preheader:                              ; preds = %vector.body, %vector.memcheck, %vector.scevcheck, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %vector.scevcheck ], [ 0, %.lr.ph ], [ %n.vec, %vector.body ]
  br label %scalar.ph

vector.scevcheck:                                 ; preds = %.lr.ph
  %15 = add nsw i64 %wide.trip.count, -1
  %16 = trunc i64 %15 to i32
  %17 = xor i32 %14, -1
  %18 = icmp ult i32 %17, %16
  %19 = icmp ugt i64 %15, 2147483647
  %20 = or i1 %18, %19
  br i1 %20, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %vector.scevcheck
  %21 = zext i32 %14 to i64
  %22 = shl nuw nsw i64 %21, 2
  %scevgep = getelementptr i8, ptr %13, i64 %22
  %23 = add nuw nsw i64 %wide.trip.count, %21
  %24 = shl nuw nsw i64 %23, 2
  %scevgep32 = getelementptr i8, ptr %13, i64 %24
  %scevgep33 = getelementptr i8, ptr %1, i64 4
  %25 = shl nuw nsw i64 %wide.trip.count, 3
  %scevgep34 = getelementptr i8, ptr %1, i64 %25
  %bound0 = icmp ult ptr %scevgep, %scevgep34
  %bound1 = icmp ult ptr %scevgep33, %scevgep32
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.mod.vf = and i64 %wide.trip.count, 3
  %26 = icmp eq i64 %n.mod.vf, 0
  %27 = select i1 %26, i64 4, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count, %27
  %broadcast.splatinsert = insertelement <4 x float> poison, float %11, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert35 = insertelement <4 x float> poison, float %6, i64 0
  %broadcast.splat36 = shufflevector <4 x float> %broadcast.splatinsert35, <4 x float> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert37 = insertelement <4 x float> poison, float %10, i64 0
  %broadcast.splat38 = shufflevector <4 x float> %broadcast.splatinsert37, <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 ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %28 = trunc i64 %index to i32
  %29 = shl nuw i64 %index, 1
  %30 = shl i64 %index, 1
  %31 = shl i64 %index, 1
  %32 = shl i64 %index, 1
  %33 = and i64 %29, 4294967288
  %34 = and i64 %30, 4294967288
  %35 = and i64 %31, 4294967288
  %36 = and i64 %32, 4294967288
  %37 = or disjoint i64 %33, 1
  %38 = or disjoint i64 %34, 3
  %39 = or disjoint i64 %35, 5
  %40 = or disjoint i64 %36, 7
  %41 = getelementptr inbounds float, ptr %1, i64 %37
  %42 = getelementptr inbounds float, ptr %1, i64 %38
  %43 = getelementptr inbounds float, ptr %1, i64 %39
  %44 = getelementptr inbounds float, ptr %1, i64 %40
  %wide.vec = load <8 x float>, ptr %41, align 4, !tbaa !12
  %strided.vec = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %45 = uitofp <4 x i32> %vec.ind to <4 x float>
  %46 = fneg <4 x float> %45
  %47 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %46, <4 x float> %broadcast.splat, <4 x float> %strided.vec)
  %48 = fdiv <4 x float> %47, %broadcast.splat
  %49 = fdiv <4 x float> %48, %broadcast.splat36
  %50 = fmul <4 x float> %49, <float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000>
  %51 = fmul <4 x float> %50, <float 2.000000e+00, float 2.000000e+00, float 2.000000e+00, float 2.000000e+00>
  %52 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %45, <4 x float> %broadcast.splat38, <4 x float> %51)
  %53 = add i32 %14, %28
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds float, ptr %13, i64 %54
  %wide.load = load <4 x float>, ptr %55, align 4, !tbaa !12, !alias.scope !14, !noalias !17
  %56 = fadd <4 x float> %wide.load, %52
  store <4 x float> %56, ptr %55, align 4, !tbaa !12, !alias.scope !14, !noalias !17
  %57 = extractelement <4 x float> %56, i64 0
  store float %57, ptr %41, align 4, !tbaa !12, !alias.scope !17
  %58 = extractelement <4 x float> %56, i64 1
  store float %58, ptr %42, align 4, !tbaa !12, !alias.scope !17
  %59 = extractelement <4 x float> %56, i64 2
  store float %59, ptr %43, align 4, !tbaa !12, !alias.scope !17
  %60 = extractelement <4 x float> %56, i64 3
  store float %60, ptr %44, align 4, !tbaa !12, !alias.scope !17
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %61 = icmp eq i64 %index.next, %n.vec
  br i1 %61, label %scalar.ph.preheader, label %vector.body, !llvm.loop !19

._crit_edge:                                      ; preds = %scalar.ph, %5
  ret void

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %62 = trunc nuw i64 %indvars.iv to i32
  %63 = shl nuw i64 %indvars.iv, 1
  %64 = and i64 %63, 4294967294
  %65 = or disjoint i64 %64, 1
  %66 = getelementptr inbounds float, ptr %1, i64 %65
  %67 = load float, ptr %66, align 4, !tbaa !12
  %68 = uitofp i32 %62 to float
  %69 = fneg float %68
  %70 = tail call float @llvm.fmuladd.f32(float %69, float %11, float %67)
  %71 = fdiv float %70, %11
  %72 = fdiv float %71, %6
  %73 = fmul float %72, 0x400921FB60000000
  %74 = fmul float %73, 2.000000e+00
  %75 = tail call float @llvm.fmuladd.f32(float %68, float %10, float %74)
  %76 = add i32 %14, %62
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds float, ptr %13, i64 %77
  %79 = load float, ptr %78, align 4, !tbaa !12
  %80 = fadd float %79, %75
  store float %80, ptr %78, align 4, !tbaa !12
  store float %80, ptr %66, align 4, !tbaa !12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !23
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 64}
!6 = !{!"_ZTSN6SoLoud17FFTFilterInstanceE", !7, i64 0, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !9, i64 72, !9, i64 104, !9, i64 136, !11, i64 168}
!7 = !{!"_ZTSN6SoLoud14FilterInstanceE", !8, i64 8, !8, i64 12, !11, i64 16, !11, i64 24}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !9, i64 0}
!14 = !{!15}
!15 = distinct !{!15, !16}
!16 = distinct !{!16, !"LVerDomain"}
!17 = !{!18}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !21}


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