; LLVM IR from jgaeddert/liquid-dsp :: src/equalization/src (equalizer_rrrf)

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

%struct.eqlms_rrrf_s = type { i32, float, ptr, ptr, ptr, i32, i32, ptr, ptr, 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

declare i32 @windowf_read(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @eqlms_rrrf_step(ptr noundef %0, float noundef %1, float noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %11, i32 0, i32 6
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %28, label %15

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %16, i32 0, i32 5
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = icmp ult i32 %18, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %15
  store i32 0, ptr %4, align 4
  br label %96

24:                                               ; preds = %15
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %25, i32 0, i32 6
  store i32 1, ptr %26, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %24
  br label %28

28:                                               ; preds = %27, %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %29 = load float, ptr %6, align 4, !tbaa !9
  %30 = load float, ptr %7, align 4, !tbaa !9
  %31 = fsub float %29, %30
  store float %31, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %32, i32 0, i32 7
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = call i32 @windowf_read(ptr noundef %34, ptr noundef %10)
  store i32 0, ptr %8, align 4, !tbaa !17
  br label %36

36:                                               ; preds = %81, %28
  %37 = load i32, ptr %8, align 4, !tbaa !17
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !15
  %41 = icmp ult i32 %37, %40
  br i1 %41, label %42, label %84

42:                                               ; preds = %36
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %43, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !18
  %46 = load i32, ptr %8, align 4, !tbaa !17
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds float, ptr %45, i64 %47
  %49 = load float, ptr %48, align 4, !tbaa !9
  %50 = fpext float %49 to double
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %51, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !19
  %54 = fpext float %53 to double
  %55 = load float, ptr %9, align 4, !tbaa !9
  %56 = fpext float %55 to double
  %57 = fmul double %54, %56
  %58 = fmul double %54, -0.000000e+00
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !17
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %59, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !9
  %64 = fpext float %63 to double
  %65 = fmul double %57, %64
  %66 = fmul double %58, %64
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %67, i32 0, i32 9
  %69 = load float, ptr %68, align 8, !tbaa !20
  %70 = fpext float %69 to double
  %71 = fdiv double %65, %70
  %72 = fdiv double %66, %70
  %73 = fadd double %50, %71
  %74 = fptrunc double %73 to float
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !21
  %78 = load i32, ptr %8, align 4, !tbaa !17
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds float, ptr %77, i64 %79
  store float %74, ptr %80, align 4, !tbaa !9
  br label %81

81:                                               ; preds = %42
  %82 = load i32, ptr %8, align 4, !tbaa !17
  %83 = add i32 %82, 1
  store i32 %83, ptr %8, align 4, !tbaa !17
  br label %36, !llvm.loop !22

84:                                               ; preds = %36
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %85, i32 0, i32 3
  %87 = load ptr, ptr %86, align 8, !tbaa !18
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %88, i32 0, i32 4
  %90 = load ptr, ptr %89, align 8, !tbaa !21
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %91, i32 0, i32 0
  %93 = load i32, ptr %92, align 8, !tbaa !15
  %94 = zext i32 %93 to i64
  %95 = mul i64 %94, 4
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %87, ptr align 4 %90, i64 %95, i1 false)
  store i32 0, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %96

96:                                               ; preds = %84, %23
  %97 = load i32, ptr %4, align 4
  ret i32 %97
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 36}
!12 = !{!"eqlms_rrrf_s", !13, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 36, !6, i64 40, !6, i64 48, !10, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 32}
!15 = !{!12, !13, i64 0}
!16 = !{!12, !6, i64 40}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !6, i64 16}
!19 = !{!12, !10, i64 4}
!20 = !{!12, !10, i64 56}
!21 = !{!12, !6, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

declare i32 @windowf_read(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @eqlms_rrrf_step(ptr nocapture noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #3 {
  %4 = alloca ptr, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 36
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %13

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %10 = load i32, ptr %0, align 8, !tbaa !13
  %11 = icmp ult i32 %9, %10
  br i1 %11, label %62, label %12

12:                                               ; preds = %7
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %12, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = call i32 @windowf_read(ptr noundef %15, ptr noundef nonnull %4) #4
  %17 = load i32, ptr %0, align 8, !tbaa !13
  %.not23 = icmp eq i32 %17, 0
  br i1 %.not23, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %13
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 16
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !15
  %.phi.trans.insert25 = getelementptr inbounds i8, ptr %0, i64 24
  %.pre26 = load ptr, ptr %.phi.trans.insert25, align 8, !tbaa !16
  br label %._crit_edge

.lr.ph:                                           ; preds = %13
  %18 = fsub float %1, %2
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %0, i64 4
  %22 = fpext float %18 to double
  %23 = load ptr, ptr %4, align 8, !tbaa !17
  %24 = getelementptr inbounds i8, ptr %0, i64 56
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %wide.trip.count = zext i32 %17 to i64
  %min.iters.check = icmp ult i32 %17, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %27 = shl nuw nsw i64 %wide.trip.count, 2
  %scevgep = getelementptr i8, ptr %26, i64 %27
  %scevgep28 = getelementptr i8, ptr %20, i64 %27
  %scevgep29 = getelementptr i8, ptr %0, i64 60
  %scevgep30 = getelementptr i8, ptr %23, i64 %27
  %bound0 = icmp ult ptr %26, %scevgep28
  %bound1 = icmp ult ptr %20, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  %bound031 = icmp ult ptr %26, %scevgep29
  %bound132 = icmp ult ptr %21, %scevgep
  %found.conflict33 = and i1 %bound031, %bound132
  %conflict.rdx = or i1 %found.conflict, %found.conflict33
  %bound034 = icmp ult ptr %26, %scevgep30
  %bound135 = icmp ult ptr %23, %scevgep
  %found.conflict36 = and i1 %bound034, %bound135
  %conflict.rdx37 = or i1 %conflict.rdx, %found.conflict36
  br i1 %conflict.rdx37, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 4294967292
  %broadcast.splatinsert38 = insertelement <4 x double> poison, double %22, i64 0
  %broadcast.splat39 = shufflevector <4 x double> %broadcast.splatinsert38, <4 x double> poison, <4 x i32> zeroinitializer
  %28 = load float, ptr %21, align 4, !tbaa !18, !alias.scope !19
  %broadcast.splatinsert = insertelement <4 x float> poison, float %28, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  %29 = fpext <4 x float> %broadcast.splat to <4 x double>
  %30 = fmul <4 x double> %broadcast.splat39, %29
  %31 = load float, ptr %24, align 8, !tbaa !22, !alias.scope !19
  %broadcast.splatinsert41 = insertelement <4 x float> poison, float %31, i64 0
  %broadcast.splat42 = shufflevector <4 x float> %broadcast.splatinsert41, <4 x float> poison, <4 x i32> zeroinitializer
  %32 = fpext <4 x float> %broadcast.splat42 to <4 x double>
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %33 = getelementptr inbounds float, ptr %20, i64 %index
  %wide.load = load <4 x float>, ptr %33, align 4, !tbaa !23, !alias.scope !24
  %34 = fpext <4 x float> %wide.load to <4 x double>
  %35 = getelementptr inbounds float, ptr %23, i64 %index
  %wide.load40 = load <4 x float>, ptr %35, align 4, !tbaa !23, !alias.scope !26
  %36 = fpext <4 x float> %wide.load40 to <4 x double>
  %37 = fmul <4 x double> %30, %36
  %38 = fdiv <4 x double> %37, %32
  %39 = fadd <4 x double> %38, %34
  %40 = fptrunc <4 x double> %39 to <4 x float>
  %41 = getelementptr inbounds float, ptr %26, i64 %index
  store <4 x float> %40, ptr %41, align 4, !tbaa !23, !alias.scope !28, !noalias !30
  %index.next = add nuw i64 %index, 4
  %42 = icmp eq i64 %index.next, %n.vec
  br i1 %42, label %middle.block, label %vector.body, !llvm.loop !31

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge.loopexit, label %scalar.ph.preheader

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

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %43 = getelementptr inbounds float, ptr %20, i64 %indvars.iv
  %44 = load float, ptr %43, align 4, !tbaa !23
  %45 = fpext float %44 to double
  %46 = load float, ptr %21, align 4, !tbaa !18
  %47 = fpext float %46 to double
  %48 = fmul double %22, %47
  %49 = getelementptr inbounds float, ptr %23, i64 %indvars.iv
  %50 = load float, ptr %49, align 4, !tbaa !23
  %51 = fpext float %50 to double
  %52 = fmul double %48, %51
  %53 = load float, ptr %24, align 8, !tbaa !22
  %54 = fpext float %53 to double
  %55 = fdiv double %52, %54
  %56 = fadd double %55, %45
  %57 = fptrunc double %56 to float
  %58 = getelementptr inbounds float, ptr %26, i64 %indvars.iv
  store float %57, ptr %58, align 4, !tbaa !23
  %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.loopexit, label %scalar.ph, !llvm.loop !35

._crit_edge.loopexit:                             ; preds = %scalar.ph, %middle.block
  %59 = shl nuw nsw i64 %wide.trip.count, 2
  br label %._crit_edge

._crit_edge:                                      ; preds = %.._crit_edge_crit_edge, %._crit_edge.loopexit
  %.pre-phi = phi i64 [ 0, %.._crit_edge_crit_edge ], [ %59, %._crit_edge.loopexit ]
  %60 = phi ptr [ %.pre26, %.._crit_edge_crit_edge ], [ %26, %._crit_edge.loopexit ]
  %61 = phi ptr [ %.pre, %.._crit_edge_crit_edge ], [ %20, %._crit_edge.loopexit ]
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %61, ptr align 4 %60, i64 %.pre-phi, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %62

62:                                               ; preds = %7, %._crit_edge
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !7, i64 36}
!6 = !{!"eqlms_rrrf_s", !7, i64 0, !10, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 36, !11, i64 40, !11, i64 48, !10, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !11, i64 40}
!15 = !{!6, !11, i64 16}
!16 = !{!6, !11, i64 24}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !10, i64 4}
!19 = !{!20}
!20 = distinct !{!20, !21}
!21 = distinct !{!21, !"LVerDomain"}
!22 = !{!6, !10, i64 56}
!23 = !{!10, !10, i64 0}
!24 = !{!25}
!25 = distinct !{!25, !21}
!26 = !{!27}
!27 = distinct !{!27, !21}
!28 = !{!29}
!29 = distinct !{!29, !21}
!30 = !{!25, !20, !27}
!31 = distinct !{!31, !32, !33, !34}
!32 = !{!"llvm.loop.mustprogress"}
!33 = !{!"llvm.loop.isvectorized", i32 1}
!34 = !{!"llvm.loop.unroll.runtime.disable"}
!35 = distinct !{!35, !32, !33}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass