; LLVM IR from jgaeddert/liquid-dsp :: src/modem/src (modemcf)

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

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

; Function Attrs: nounwind
declare float @cargf(<2 x float> noundef) #0

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

27:                                               ; preds = %3
  %28 = fcmp uno float %25, %25
  br i1 %28, label %29, label %35, !prof !9

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

35:                                               ; preds = %29, %27, %3
  %36 = phi float [ %24, %3 ], [ %24, %27 ], [ %32, %29 ]
  %37 = phi float [ %25, %3 ], [ %25, %27 ], [ %34, %29 ]
  %38 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %39 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %36, ptr %38, align 4
  store float %37, ptr %39, align 4
  %40 = load <2 x float>, ptr %8, align 4
  %41 = call float @cargf(<2 x float> noundef %40) #2
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.freqdem_s, ptr %42, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !10
  %45 = fmul float %41, %44
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  store float %45, ptr %46, align 4, !tbaa !13
  %47 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %48 = load float, ptr %47, align 4
  %49 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %50 = load float, ptr %49, align 4
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.freqdem_s, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 1
  store float %48, ptr %53, align 4
  store float %50, ptr %54, align 4
  ret i32 0
}

attributes #0 = { nounwind "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 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 = { 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, !12, i64 4}
!11 = !{!"freqdem_s", !12, i64 0, !12, i64 4, !7, i64 8}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}


; 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
declare float @cargf(<2 x float> noundef) local_unnamed_addr #0

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

19:                                               ; preds = %3
  %20 = fcmp uno float %16, 0.000000e+00
  br i1 %20, label %21, label %23, !prof !5

21:                                               ; preds = %19
  %22 = tail call <2 x float> @__mulsc3(float noundef %10, float noundef %9, float noundef %5, float noundef %4) #2
  br label %23

23:                                               ; preds = %21, %19, %3
  %24 = phi <2 x float> [ %18, %3 ], [ %18, %19 ], [ %22, %21 ]
  %25 = tail call float @cargf(<2 x float> noundef %24) #2
  %26 = getelementptr inbounds i8, ptr %0, i64 4
  %27 = load float, ptr %26, align 4, !tbaa !6
  %28 = fmul float %25, %27
  store float %28, ptr %2, align 4, !tbaa !11
  store <2 x float> %1, ptr %6, align 4
  ret i32 0
}

attributes #0 = { nounwind "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 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 = { 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, !8, i64 4}
!7 = !{!"freqdem_s", !8, i64 0, !8, i64 4, !9, i64 8}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!8, !8, i64 0}


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