; LLVM IR from jgaeddert/liquid-dsp :: src/nco/src (nco_crcf)

; 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.synth_crcf_s = type { float, float, ptr, i32, i32, float, { float, float }, { float, float }, { float, float }, float, float }

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

; Function Attrs: nounwind uwtable
define dso_local void @synth_crcf_mix_up(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #0 {
  %4 = alloca { float, float }, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca { float, float }, align 4
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %9 = load float, ptr %8, align 4
  %10 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %11 = load float, ptr %10, align 4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.synth_crcf_s, ptr %12, i32 0, i32 7
  %14 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %15 = load float, ptr %14, align 4
  %16 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %17 = load float, ptr %16, align 4
  %18 = fmul float %9, %15
  %19 = fmul float %11, %17
  %20 = fmul float %9, %17
  %21 = fmul float %11, %15
  %22 = fsub float %18, %19
  %23 = fadd float %20, %21
  %24 = fcmp uno float %22, %22
  br i1 %24, label %25, label %33, !prof !9

25:                                               ; preds = %3
  %26 = fcmp uno float %23, %23
  br i1 %26, label %27, label %33, !prof !9

27:                                               ; preds = %25
  %28 = call <2 x float> @__mulsc3(float noundef %9, float noundef %11, float noundef %15, float noundef %17) #1
  store <2 x float> %28, ptr %7, align 4
  %29 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %30 = load float, ptr %29, align 4
  %31 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %32 = load float, ptr %31, align 4
  br label %33

33:                                               ; preds = %27, %25, %3
  %34 = phi float [ %22, %3 ], [ %22, %25 ], [ %30, %27 ]
  %35 = phi float [ %23, %3 ], [ %23, %25 ], [ %32, %27 ]
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds { float, float }, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds { float, float }, ptr %36, i32 0, i32 1
  store float %34, ptr %37, align 4
  store float %35, ptr %38, align 4
  ret void
}

attributes #0 = { 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 #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, !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}


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

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

; Function Attrs: nounwind uwtable
define dso_local void @synth_crcf_mix_up(ptr nocapture noundef readonly %0, <2 x float> noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = shufflevector <2 x float> %1, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %5 = getelementptr inbounds i8, ptr %0, i64 36
  %6 = load <2 x float>, ptr %5, align 4
  %7 = fmul <2 x float> %6, %1
  %8 = fmul <2 x float> %4, %6
  %shift = shufflevector <2 x float> %7, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %9 = fsub <2 x float> %7, %shift
  %10 = extractelement <2 x float> %9, i64 0
  %shift3 = shufflevector <2 x float> %8, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %11 = fadd <2 x float> %8, %shift3
  %12 = extractelement <2 x float> %11, i64 0
  %13 = fcmp uno float %10, 0.000000e+00
  br i1 %13, label %14, label %22, !prof !5

14:                                               ; preds = %3
  %15 = fcmp uno float %12, 0.000000e+00
  br i1 %15, label %16, label %22, !prof !5

16:                                               ; preds = %14
  %17 = extractelement <2 x float> %6, i64 0
  %18 = extractelement <2 x float> %6, i64 1
  %19 = extractelement <2 x float> %1, i64 0
  %20 = extractelement <2 x float> %1, i64 1
  %21 = tail call <2 x float> @__mulsc3(float noundef %19, float noundef %20, float noundef %17, float noundef %18) #1
  %.sroa.0.0.vec.extract = extractelement <2 x float> %21, i64 0
  %.sroa.0.4.vec.extract = extractelement <2 x float> %21, i64 1
  br label %22

22:                                               ; preds = %16, %14, %3
  %23 = phi float [ %10, %3 ], [ %10, %14 ], [ %.sroa.0.0.vec.extract, %16 ]
  %24 = phi float [ %12, %3 ], [ %12, %14 ], [ %.sroa.0.4.vec.extract, %16 ]
  %25 = getelementptr inbounds i8, ptr %2, i64 4
  store float %23, ptr %2, align 4
  store float %24, ptr %25, align 4
  ret void
}

attributes #0 = { 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 #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 = !{!"branch_weights", i32 1, i32 1048575}


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