#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 (y == 0) ? 0 : ((y > 0) ? 3.14159265f : -3.14159265f);
}


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    12a1 <fast_atan2f+0x191>
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  0xe5e(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a1 <fast_atan2f+0x191>
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  0xe1c(%rip),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a1 <fast_atan2f+0x191>
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  0xdd1(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a1 <fast_atan2f+0x191>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1269 <fast_atan2f+0x159>
jp     1269 <fast_atan2f+0x159>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1297 <fast_atan2f+0x187>
movss  -0x8(%rbp),%xmm1
movss  0xd8a(%rip),%xmm3
movss  0xd86(%rip),%xmm2
xorps  %xmm0,%xmm0
cmpltss %xmm1,%xmm0
movaps %xmm0,%xmm1
andps  %xmm3,%xmm1
andnps %xmm2,%xmm0
orps   %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%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     1151 <fast_atan2f+0x41>
xorps  %xmm2,%xmm2
ucomiss %xmm1,%xmm2
jbe    1151 <fast_atan2f+0x41>
xorps  0xed5(%rip),%xmm0
divss  %xmm1,%xmm0
call   1030 <fast_atanf@plt>
movaps %xmm0,%xmm1
movss  0xed5(%rip),%xmm0
jmp    1199 <fast_atan2f+0x89>
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
jbe    1171 <fast_atan2f+0x61>
ucomiss %xmm1,%xmm2
jbe    1171 <fast_atan2f+0x61>
divss  %xmm1,%xmm0
call   1030 <fast_atanf@plt>
addss  0xeb5(%rip),%xmm0
pop    %rax
ret
ucomiss %xmm0,%xmm2
jbe    119f <fast_atan2f+0x8f>
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jbe    119f <fast_atan2f+0x8f>
xorps  0xe8b(%rip),%xmm0
divss  %xmm1,%xmm0
call   1030 <fast_atanf@plt>
movaps %xmm0,%xmm1
movss  0xe87(%rip),%xmm0
subss  %xmm1,%xmm0
pop    %rax
ret
xorps  %xmm1,%xmm1
xor    %eax,%eax
ucomiss %xmm1,%xmm0
seta   %al
lea    0xe4f(%rip),%rcx
movss  (%rcx,%rax,4),%xmm2
cmpeqss %xmm1,%xmm0
andnps %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 %65
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 %65
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 %65
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 %65
54: ; preds = %44, %41
%55 = load float, float* %4
%56 = fcmp oeq float %55, 0.000000e+00
br i1 %56, label %57, label %58
57: ; preds = %54
br label %63
58: ; preds = %54
%59 = load float, float* %4
%60 = fcmp ogt float %59, 0.000000e+00
%61 = zext i1 %60 to i64
%62 = select i1 %60, float 0x400921FB60000000, float 0xC00921FB60000000
br label %63
63: ; preds = %58, %57
%64 = phi float [ 0.000000e+00, %57 ], [ %62, %58 ]
store float %64, float* %3
br label %65
65: ; preds = %63, %47, %35, %22, %11
%66 = load float, float* %3
ret float %66
}

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 %36
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 %36
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 %36
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 %36
31: ; preds = %24
%32 = fcmp oeq float %0, 0.000000e+00
%33 = fcmp ogt float %0, 0.000000e+00
%34 = select i1 %33, float 0x400921FB60000000, float 0xC00921FB60000000
%35 = select i1 %32, float 0.000000e+00, float %34
br label %36
36: ; preds = %31, %26, %20, %12, %6
%37 = phi float [ %8, %6 ], [ %16, %12 ], [ %23, %20 ], [ %30, %26 ], [ %35, %31 ]
ret float %37
}