#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 */
float fast_atanf(float);
float fast_atan2f(float y, float x) {
  if (x > 0 && y >= 0)
    return fast_atanf(y / x);
  if (x < 0 && y >= 0)
    return 3.14159265f - fast_atanf(-y / x);
  if (x < 0 && y < 0)
    return 3.14159265f + fast_atanf(y / x);
  if (x > 0 && y < 0)
    return 2 * 3.14159265f - fast_atanf(-y / x);
  return 0;
}


x86 assembly (clang, -O0):
<fast_atan2f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    115d <fast_atan2f+0x4d>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     115d <fast_atan2f+0x4d>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <fast_atanf@plt>
movss  %xmm0,-0x4(%rbp)
jmp    124d <fast_atan2f+0x13d>
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11b0 <fast_atan2f+0xa0>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11b0 <fast_atan2f+0xa0>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <fast_atanf@plt>
movaps %xmm0,%xmm1
movss  0xe62(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    124d <fast_atan2f+0x13d>
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11f2 <fast_atan2f+0xe2>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11f2 <fast_atan2f+0xe2>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <fast_atanf@plt>
movaps %xmm0,%xmm1
movss  0xe20(%rip),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    124d <fast_atan2f+0x13d>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1245 <fast_atan2f+0x135>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1245 <fast_atan2f+0x135>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <fast_atanf@plt>
movaps %xmm0,%xmm1
movss  0xdc9(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    124d <fast_atan2f+0x13d>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fast_atan2f>:
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jb     1126 <fast_atan2f+0x16>
ucomiss %xmm2,%xmm1
jbe    1126 <fast_atan2f+0x16>
divss  %xmm1,%xmm0
jmp    1030 <fast_atanf@plt>
push   %rax
ucomiss %xmm2,%xmm0
jb     114e <fast_atan2f+0x3e>
xorps  %xmm2,%xmm2
ucomiss %xmm1,%xmm2
jbe    114e <fast_atan2f+0x3e>
xorps  0xec5(%rip),%xmm0
divss  %xmm1,%xmm0
call   1030 <fast_atanf@plt>
movss  0xec8(%rip),%xmm2
jmp    1199 <fast_atan2f+0x89>
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
jbe    1174 <fast_atan2f+0x64>
xorps  %xmm3,%xmm3
ucomiss %xmm1,%xmm3
jbe    1174 <fast_atan2f+0x64>
divss  %xmm1,%xmm0
call   1030 <fast_atanf@plt>
movaps %xmm0,%xmm2
addss  0xea2(%rip),%xmm2
jmp    119d <fast_atan2f+0x8d>
ucomiss %xmm0,%xmm2
jbe    119d <fast_atan2f+0x8d>
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm1
jbe    119d <fast_atan2f+0x8d>
xorps  0xe78(%rip),%xmm0
divss  %xmm1,%xmm0
call   1030 <fast_atanf@plt>
movss  0xe77(%rip),%xmm2
subss  %xmm0,%xmm2
movaps %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @fast_atan2f(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %4
store float %1, float* %5
%6 = load float, float* %5
%7 = fcmp ogt float %6, 0.000000e+00
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = load float, float* %4
%10 = fcmp oge float %9, 0.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load float, float* %4
%13 = load float, float* %5
%14 = fdiv float %12, %13
%15 = call float @fast_atanf(float %14)
store float %15, float* %3
br label %55
16: ; preds = %8, %2
%17 = load float, float* %5
%18 = fcmp olt float %17, 0.000000e+00
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load float, float* %4
%21 = fcmp oge float %20, 0.000000e+00
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load float, float* %4
%24 = fneg float %23
%25 = load float, float* %5
%26 = fdiv float %24, %25
%27 = call float @fast_atanf(float %26)
%28 = fsub float 0x400921FB60000000, %27
store float %28, float* %3
br label %55
29: ; preds = %19, %16
%30 = load float, float* %5
%31 = fcmp olt float %30, 0.000000e+00
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load float, float* %4
%34 = fcmp olt float %33, 0.000000e+00
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load float, float* %4
%37 = load float, float* %5
%38 = fdiv float %36, %37
%39 = call float @fast_atanf(float %38)
%40 = fadd float 0x400921FB60000000, %39
store float %40, float* %3
br label %55
41: ; preds = %32, %29
%42 = load float, float* %5
%43 = fcmp ogt float %42, 0.000000e+00
br i1 %43, label %44, label %54
44: ; preds = %41
%45 = load float, float* %4
%46 = fcmp olt float %45, 0.000000e+00
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = load float, float* %4
%49 = fneg float %48
%50 = load float, float* %5
%51 = fdiv float %49, %50
%52 = call float @fast_atanf(float %51)
%53 = fsub float 0x401921FB60000000, %52
store float %53, float* %3
br label %55
54: ; preds = %44, %41
store float 0.000000e+00, float* %3
br label %55
55: ; preds = %54, %47, %35, %22, %11
%56 = load float, float* %3
ret float %56
}

LLVM IR (-O2):
define float @fast_atan2f(float %0, float %1) {
%3 = fcmp ogt float %1, 0.000000e+00
%4 = fcmp oge float %0, 0.000000e+00
%5 = and i1 %4, %3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = fdiv float %0, %1
%8 = tail call float @fast_atanf(float %7)
br label %31
9: ; preds = %2
%10 = fcmp olt float %1, 0.000000e+00
%11 = and i1 %4, %10
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = fneg float %0
%14 = fdiv float %13, %1
%15 = tail call float @fast_atanf(float %14)
%16 = fsub float 0x400921FB60000000, %15
br label %31
17: ; preds = %9
%18 = fcmp olt float %0, 0.000000e+00
%19 = and i1 %18, %10
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = fdiv float %0, %1
%22 = tail call float @fast_atanf(float %21)
%23 = fadd float %22, 0x400921FB60000000
br label %31
24: ; preds = %17
%25 = and i1 %18, %3
br i1 %25, label %26, label %31
26: ; preds = %24
%27 = fneg float %0
%28 = fdiv float %27, %1
%29 = tail call float @fast_atanf(float %28)
%30 = fsub float 0x401921FB60000000, %29
br label %31
31: ; preds = %24, %26, %20, %12, %6
%32 = phi float [ %8, %6 ], [ %16, %12 ], [ %23, %20 ], [ %30, %26 ], [ 0.000000e+00, %24 ]
ret float %32
}