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

; 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_cccf_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: nounwind uwtable
define dso_local i32 @eqlms_cccf_update_sumsq(ptr noundef %0, <2 x float> noundef %1) #1 {
  %3 = alloca { float, float }, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca { float, float }, align 4
  %7 = alloca float, align 4
  store <2 x float> %1, ptr %3, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %8 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %9 = load float, ptr %8, align 4
  %10 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %11 = load float, ptr %10, align 4
  %12 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %13 = load float, ptr %12, align 4
  %14 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %15 = load float, ptr %14, align 4
  %16 = fneg float %15
  %17 = fmul float %9, %13
  %18 = fmul float %11, %16
  %19 = fmul float %9, %16
  %20 = fmul float %11, %13
  %21 = fsub float %17, %18
  %22 = fadd float %19, %20
  %23 = fcmp uno float %21, %21
  br i1 %23, label %24, label %32, !prof !9

24:                                               ; preds = %2
  %25 = fcmp uno float %22, %22
  br i1 %25, label %26, label %32, !prof !9

26:                                               ; preds = %24
  %27 = call <2 x float> @__mulsc3(float noundef %9, float noundef %11, float noundef %13, float noundef %16) #3
  store <2 x float> %27, ptr %6, align 4
  %28 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  br label %32

32:                                               ; preds = %26, %24, %2
  %33 = phi float [ %21, %2 ], [ %21, %24 ], [ %29, %26 ]
  %34 = phi float [ %22, %2 ], [ %22, %24 ], [ %31, %26 ]
  store float %33, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %35, i32 0, i32 8
  %37 = load ptr, ptr %36, align 8, !tbaa !12
  %38 = load float, ptr %5, align 4, !tbaa !10
  %39 = call i32 @wdelayf_push(ptr noundef %37, float noundef %38)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %40, i32 0, i32 8
  %42 = load ptr, ptr %41, align 8, !tbaa !12
  %43 = call i32 @wdelayf_read(ptr noundef %42, ptr noundef %7)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %44, i32 0, i32 9
  %46 = load float, ptr %45, align 8, !tbaa !15
  %47 = load float, ptr %5, align 4, !tbaa !10
  %48 = fadd float %46, %47
  %49 = load float, ptr %7, align 4, !tbaa !10
  %50 = fsub float %48, %49
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %51, i32 0, i32 9
  store float %50, ptr %52, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 0
}

declare <2 x float> @__mulsc3(float, float, float, float)

declare i32 @wdelayf_push(ptr noundef, float noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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/C++ TBAA"}
!9 = !{!"branch_weights", i32 1, i32 1048575}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !6, i64 48}
!13 = !{!"eqlms_cccf_s", !14, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !14, i64 36, !6, i64 40, !6, i64 48, !11, i64 56}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !11, i64 56}


; 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: nounwind uwtable
define dso_local noundef i32 @eqlms_cccf_update_sumsq(ptr nocapture noundef %0, <2 x float> noundef %1) local_unnamed_addr #1 {
  %3 = extractelement <2 x float> %1, i64 1
  %4 = extractelement <2 x float> %1, i64 0
  %5 = alloca float, align 4
  %6 = fneg float %3
  %7 = fmul <2 x float> %1, %1
  %shift = shufflevector <2 x float> %7, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %8 = fadd <2 x float> %7, %shift
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fcmp uno float %9, 0.000000e+00
  br i1 %10, label %11, label %17, !prof !5

11:                                               ; preds = %2
  %12 = fmul float %3, %4
  %13 = fsub float %12, %12
  %14 = fcmp uno float %13, 0.000000e+00
  br i1 %14, label %15, label %17, !prof !5

15:                                               ; preds = %11
  %16 = tail call <2 x float> @__mulsc3(float noundef %4, float noundef %3, float noundef %4, float noundef %6) #3
  %.sroa.0.0.vec.extract = extractelement <2 x float> %16, i64 0
  br label %17

17:                                               ; preds = %15, %11, %2
  %18 = phi float [ %9, %2 ], [ %9, %11 ], [ %.sroa.0.0.vec.extract, %15 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 48
  %20 = load ptr, ptr %19, align 8, !tbaa !6
  %21 = tail call i32 @wdelayf_push(ptr noundef %20, float noundef %18) #3
  %22 = load ptr, ptr %19, align 8, !tbaa !6
  %23 = call i32 @wdelayf_read(ptr noundef %22, ptr noundef nonnull %5) #3
  %24 = getelementptr inbounds i8, ptr %0, i64 56
  %25 = load float, ptr %24, align 8, !tbaa !13
  %26 = fadd float %18, %25
  %27 = load float, ptr %5, align 4, !tbaa !14
  %28 = fsub float %26, %27
  store float %28, ptr %24, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  ret i32 0
}

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

declare i32 @wdelayf_push(ptr noundef, float noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !12, i64 48}
!7 = !{!"eqlms_cccf_s", !8, i64 0, !11, i64 4, !12, i64 8, !12, i64 16, !12, i64 24, !8, i64 32, !8, i64 36, !12, i64 40, !12, i64 48, !11, i64 56}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!7, !11, i64 56}
!14 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass