#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ M_PI;
float atan2f(float, float);
float fabsf(float);
float frequency_discriminator(float I, float Q, float prev_I, float prev_Q) {
  float dot = fabsf(I * prev_I) + fabsf(Q * prev_Q);
  float cross = prev_I * Q - I * prev_Q;
  return atan2f(cross, dot) / ((float)M_PI);
}


x86 assembly (clang, -O0):
<frequency_discriminator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movaps 0xec3(%rip),%xmm1
pand   %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movaps 0xeae(%rip),%xmm2
pand   %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1030 <atan2f@plt>
mov    0x2e45(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frequency_discriminator>:
push   %rax
movaps %xmm0,%xmm4
unpcklps %xmm1,%xmm4
movaps %xmm2,%xmm5
unpcklps %xmm3,%xmm5
mulps  %xmm4,%xmm5
andps  0xed9(%rip),%xmm5
pshufd $0x55,%xmm5,%xmm4
addss  %xmm5,%xmm4
mulss  %xmm3,%xmm0
mulss  %xmm1,%xmm2
subss  %xmm0,%xmm2
movaps %xmm2,%xmm0
movaps %xmm4,%xmm1
call   1030 <atan2f@plt>
mov    0x2e9a(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@M_PI = global i64 0
define float @frequency_discriminator(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%11 = load float, float* %5
%12 = load float, float* %7
%13 = fmul float %11, %12
%14 = call float @llvm.fabs.f32(float %13)
%15 = load float, float* %6
%16 = load float, float* %8
%17 = fmul float %15, %16
%18 = call float @llvm.fabs.f32(float %17)
%19 = fadd float %14, %18
store float %19, float* %9
%20 = load float, float* %7
%21 = load float, float* %6
%22 = load float, float* %5
%23 = load float, float* %8
%24 = fmul float %22, %23
%25 = fneg float %24
%26 = call float @llvm.fmuladd.f32(float %20, float %21, float %25)
store float %26, float* %10
%27 = load float, float* %10
%28 = load float, float* %9
%29 = call float @atan2f(float %27, float %28)
%30 = load i64, i64* @M_PI
%31 = sitofp i64 %30 to float
%32 = fdiv float %29, %31
ret float %32
}

LLVM IR (-O2):
@M_PI = global i64 0
define float @frequency_discriminator(float %0, float %1, float %2, float %3) {
%5 = insertelement <2 x float> poison, float %0, i64 0
%6 = insertelement <2 x float> %5, float %1, i64 1
%7 = insertelement <2 x float> poison, float %2, i64 0
%8 = insertelement <2 x float> %7, float %3, i64 1
%9 = fmul <2 x float> %6, %8
%10 = call <2 x float> @llvm.fabs.v2f32(<2 x float> %9)
%11 = shufflevector <2 x float> %10, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%12 = fadd <2 x float> %10, %11
%13 = extractelement <2 x float> %12, i64 0
%14 = fneg float %0
%15 = fmul float %14, %3
%16 = tail call float @llvm.fmuladd.f32(float %2, float %1, float %15)
%17 = tail call float @atan2f(float %16, float %13)
%18 = load i64, i64* @M_PI
%19 = sitofp i64 %18 to float
%20 = fdiv float %17, %19
ret float %20
}