; 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_execute(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca { float, float }, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca { float, float }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %10 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  store float 0.000000e+00, ptr %9, align 4
  store float 0.000000e+00, ptr %10, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %11, i32 0, i32 7
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = call i32 @windowcf_read(ptr noundef %13, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %15

15:                                               ; preds = %77, %2
  %16 = load i32, ptr %7, align 4, !tbaa !13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %20 = icmp ult i32 %16, %19
  br i1 %20, label %21, label %80

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %22, i32 0, i32 3
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = load i32, ptr %7, align 4, !tbaa !13
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds { float, float }, ptr %24, i64 %26
  %28 = getelementptr inbounds { float, float }, ptr %27, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %27, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  %32 = fpext float %29 to double
  %33 = fpext float %31 to double
  %34 = fneg double %33
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !13
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds { float, float }, ptr %35, i64 %37
  %39 = getelementptr inbounds { float, float }, ptr %38, i32 0, i32 0
  %40 = load float, ptr %39, align 4
  %41 = getelementptr inbounds { float, float }, ptr %38, i32 0, i32 1
  %42 = load float, ptr %41, align 4
  %43 = fpext float %40 to double
  %44 = fpext float %42 to double
  %45 = fmul double %32, %43
  %46 = fmul double %34, %44
  %47 = fmul double %32, %44
  %48 = fmul double %34, %43
  %49 = fsub double %45, %46
  %50 = fadd double %47, %48
  %51 = fcmp uno double %49, %49
  br i1 %51, label %52, label %58, !prof !16

52:                                               ; preds = %21
  %53 = fcmp uno double %50, %50
  br i1 %53, label %54, label %58, !prof !16

54:                                               ; preds = %52
  %55 = call { double, double } @__muldc3(double noundef %32, double noundef %34, double noundef %43, double noundef %44) #3
  %56 = extractvalue { double, double } %55, 0
  %57 = extractvalue { double, double } %55, 1
  br label %58

58:                                               ; preds = %54, %52, %21
  %59 = phi double [ %49, %21 ], [ %49, %52 ], [ %56, %54 ]
  %60 = phi double [ %50, %21 ], [ %50, %52 ], [ %57, %54 ]
  %61 = fptrunc double %59 to float
  %62 = fptrunc double %60 to float
  %63 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %64 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %61, ptr %63, align 4
  store float %62, ptr %64, align 4
  %65 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %66 = load float, ptr %65, align 4
  %67 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %68 = load float, ptr %67, align 4
  %69 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %70 = load float, ptr %69, align 4
  %71 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %72 = load float, ptr %71, align 4
  %73 = fadd float %70, %66
  %74 = fadd float %72, %68
  %75 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %76 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  store float %73, ptr %75, align 4
  store float %74, ptr %76, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %77

77:                                               ; preds = %58
  %78 = load i32, ptr %7, align 4, !tbaa !13
  %79 = add i32 %78, 1
  store i32 %79, ptr %7, align 4, !tbaa !13
  br label %15, !llvm.loop !17

80:                                               ; preds = %15
  %81 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %82 = load float, ptr %81, align 4
  %83 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %84 = load float, ptr %83, align 4
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds { float, float }, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds { float, float }, ptr %85, i32 0, i32 1
  store float %82, ptr %86, align 4
  store float %84, ptr %87, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i32 0
}

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

declare { double, double } @__muldc3(double, double, double, double)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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, !6, i64 40}
!10 = !{!"eqlms_cccf_s", !11, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !6, i64 48, !12, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!"branch_weights", i32 1, i32 1048575}
!17 = distinct !{!17, !18}
!18 = !{!"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: nounwind uwtable
define dso_local noundef i32 @eqlms_cccf_execute(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = call i32 @windowcf_read(ptr noundef %5, ptr noundef nonnull %3) #3
  %7 = load i32, ptr %0, align 8, !tbaa !12
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  br label %9

9:                                                ; preds = %.lr.ph, %47
  %10 = phi i32 [ %7, %.lr.ph ], [ %48, %47 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %47 ]
  %11 = phi <2 x float> [ zeroinitializer, %.lr.ph ], [ %51, %47 ]
  %12 = load ptr, ptr %8, align 8, !tbaa !13
  %13 = getelementptr inbounds { float, float }, ptr %12, i64 %indvars.iv
  %14 = load float, ptr %13, align 4
  %15 = getelementptr inbounds i8, ptr %13, i64 4
  %16 = load float, ptr %15, align 4
  %17 = fpext float %14 to double
  %18 = fpext float %16 to double
  %19 = fneg double %18
  %20 = load ptr, ptr %3, align 8, !tbaa !14
  %21 = getelementptr inbounds { float, float }, ptr %20, i64 %indvars.iv
  %22 = load <2 x float>, ptr %21, align 4
  %23 = fpext <2 x float> %22 to <2 x double>
  %24 = insertelement <2 x double> poison, double %17, i64 0
  %25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
  %26 = fmul <2 x double> %25, %23
  %27 = insertelement <2 x double> poison, double %18, i64 0
  %28 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> zeroinitializer
  %29 = fmul <2 x double> %28, %23
  %30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %31 = fadd <2 x double> %26, %30
  %32 = fsub <2 x double> %26, %30
  %33 = shufflevector <2 x double> %31, <2 x double> %32, <2 x i32> <i32 0, i32 3>
  %34 = extractelement <2 x double> %31, i64 0
  %35 = fcmp uno double %34, 0.000000e+00
  br i1 %35, label %36, label %47, !prof !15

36:                                               ; preds = %9
  %37 = extractelement <2 x double> %32, i64 1
  %38 = fcmp uno double %37, 0.000000e+00
  br i1 %38, label %39, label %47, !prof !15

39:                                               ; preds = %36
  %40 = extractelement <2 x double> %23, i64 0
  %41 = extractelement <2 x double> %23, i64 1
  %42 = call { double, double } @__muldc3(double noundef %17, double noundef %19, double noundef %40, double noundef %41) #3
  %43 = extractvalue { double, double } %42, 0
  %44 = extractvalue { double, double } %42, 1
  %.pre = load i32, ptr %0, align 8, !tbaa !12
  %45 = insertelement <2 x double> poison, double %43, i64 0
  %46 = insertelement <2 x double> %45, double %44, i64 1
  br label %47

47:                                               ; preds = %39, %36, %9
  %48 = phi i32 [ %10, %9 ], [ %10, %36 ], [ %.pre, %39 ]
  %49 = phi <2 x double> [ %33, %9 ], [ %33, %36 ], [ %46, %39 ]
  %50 = fptrunc <2 x double> %49 to <2 x float>
  %51 = fadd <2 x float> %11, %50
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %52 = zext i32 %48 to i64
  %53 = icmp ult i64 %indvars.iv.next, %52
  br i1 %53, label %9, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %47, %2
  %54 = phi <2 x float> [ zeroinitializer, %2 ], [ %51, %47 ]
  store <2 x float> %54, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i32 0
}

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

declare { double, double } @__muldc3(double, double, double, double) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 40}
!6 = !{!"eqlms_cccf_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 0}
!13 = !{!6, !11, i64 16}
!14 = !{!11, !11, i64 0}
!15 = !{!"branch_weights", i32 1, i32 1048575}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass