#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 */
int M_PI;
float atan2(double, double);
double getDirection(double x, double y) {
  float heading = atan2(-y, x);
  if (heading < 0)
    heading += 2 * M_PI;
  return heading * (180 / M_PI);
}


x86 assembly (clang, -O0):
<getDirection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <atan2@plt>
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    1174 <getDirection+0x64>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
mov    $0xb4,%eax
mov    0x2e63(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDirection>:
push   %rax
movaps %xmm0,%xmm2
xorps  0xee5(%rip),%xmm1
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   1030 <atan2@plt>
mov    0x2ebb(%rip),%rax
mov    (%rax),%ecx
lea    (%rcx,%rcx,1),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
xorps  %xmm2,%xmm2
movaps %xmm0,%xmm3
cmpltss %xmm2,%xmm3
movss  0xec4(%rip),%xmm2
movaps %xmm3,%xmm4
andnps %xmm2,%xmm4
andps  %xmm1,%xmm3
mov    $0xb4,%eax
xor    %edx,%edx
idiv   %ecx
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
orps   %xmm4,%xmm3
addss  %xmm0,%xmm3
mulss  %xmm3,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @getDirection(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca float
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %4
%7 = fneg double %6
%8 = load double, double* %3
%9 = call float @atan2(double %7, double %8)
store float %9, float* %5
%10 = load float, float* %5
%11 = fcmp olt float %10, 0.000000e+00
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @M_PI
%14 = mul nsw i32 2, %13
%15 = sitofp i32 %14 to float
%16 = load float, float* %5
%17 = fadd float %16, %15
store float %17, float* %5
br label %18
18: ; preds = %12, %2
%19 = load float, float* %5
%20 = load i32, i32* @M_PI
%21 = sdiv i32 180, %20
%22 = sitofp i32 %21 to float
%23 = fmul float %19, %22
%24 = fpext float %23 to double
ret double %24
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @getDirection(double %0, double %1) {
%3 = fneg double %1
%4 = tail call float @atan2(double %3, double %0)
%5 = fcmp olt float %4, 0.000000e+00
%6 = load i32, i32* @M_PI
%7 = shl nsw i32 %6, 1
%8 = sitofp i32 %7 to float
%9 = select i1 %5, float %8, float -0.000000e+00
%10 = fadd float %4, %9
%11 = sdiv i32 180, %6
%12 = sitofp i32 %11 to float
%13 = fmul float %10, %12
%14 = fpext float %13 to double
ret double %14
}