#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 fabsf(float);
float atan2_approx(float y, float x) {
  float res, absX, absY;
  absX = fabsf(x);
  absY = fabsf(y);
  res = ((absX) > (absY) ? (absX) : (absY));
  if (res)
    res = ((absX) < (absY) ? (absX) : (absY)) / res;
  else
    res = 0.0f;
  res = -((((0.05030176425872175f * res - 0.3099814292351353f) * res -
            0.14744007058297684f) *
               res -
           0.99997356613987f) *
              res -
          3.14551665884836e-07f) /
        ((0.6444640676891548f * res + 0.1471039133652469f) * res + 1.0f);
  if (absY > absX)
    res = (3.14159265358979323846f / 2.0f) - res;
  if (x < 0)
    res = 3.14159265358979323846f - res;
  if (y < 0)
    res = -res;
  return res;
}


x86 assembly (clang, -O0):
<atan2_approx>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movaps 0xee6(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movaps 0xed1(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    1156 <atan2_approx+0x56>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1160 <atan2_approx+0x60>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1186 <atan2_approx+0x86>
jp     1186 <atan2_approx+0x86>
jmp    11c6 <atan2_approx+0xc6>
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11a8 <atan2_approx+0xa8>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11b2 <atan2_approx+0xb2>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11ce <atan2_approx+0xce>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe4d(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe45(%rip),%xmm1
addss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe28(%rip),%xmm1
addss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe0f(%rip),%xmm1
addss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xdf6(%rip),%xmm1
addss  %xmm1,%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xdd0(%rip),%xmm2
mulss  %xmm2,%xmm1
movss  0xdc8(%rip),%xmm2
addss  %xmm2,%xmm1
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xdab(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    1293 <atan2_approx+0x193>
movss  0xda7(%rip),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    12b2 <atan2_approx+0x1b2>
movss  0xd8c(%rip),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    12d6 <atan2_approx+0x1d6>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2_approx>:
movaps 0xef9(%rip),%xmm4
movaps %xmm1,%xmm3
andps  %xmm4,%xmm3
andps  %xmm0,%xmm4
movaps %xmm3,%xmm5
maxss  %xmm4,%xmm5
xorps  %xmm8,%xmm8
ucomiss %xmm8,%xmm5
xorps  %xmm7,%xmm7
jne    1126 <atan2_approx+0x26>
jnp    1131 <atan2_approx+0x31>
movaps %xmm3,%xmm7
minss  %xmm4,%xmm7
divss  %xmm5,%xmm7
movss  0xee7(%rip),%xmm6
mulss  %xmm7,%xmm6
addss  0xedf(%rip),%xmm6
mulss  %xmm7,%xmm6
addss  0xed7(%rip),%xmm6
mulss  %xmm7,%xmm6
addss  0xecf(%rip),%xmm6
mulss  %xmm7,%xmm6
addss  0xec7(%rip),%xmm6
movaps 0xea0(%rip),%xmm5
xorps  %xmm5,%xmm6
movss  0xeb9(%rip),%xmm2
mulss  %xmm7,%xmm2
addss  0xeb1(%rip),%xmm2
mulss  %xmm7,%xmm2
addss  0xea9(%rip),%xmm2
divss  %xmm2,%xmm6
movss  0xea1(%rip),%xmm2
subss  %xmm6,%xmm2
cmpltss %xmm4,%xmm3
movaps %xmm3,%xmm4
andnps %xmm6,%xmm4
andps  %xmm2,%xmm3
orps   %xmm4,%xmm3
movss  0xe88(%rip),%xmm2
subss  %xmm3,%xmm2
cmpltss %xmm8,%xmm1
movaps %xmm1,%xmm4
andnps %xmm3,%xmm4
andps  %xmm2,%xmm1
orps   %xmm4,%xmm1
xorps  %xmm1,%xmm5
cmpltss %xmm8,%xmm0
movaps %xmm0,%xmm2
andnps %xmm1,%xmm2
andps  %xmm5,%xmm0
orps   %xmm2,%xmm0
ret

LLVM IR (-O0):
define float @atan2_approx(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %3
store float %1, float* %4
%8 = load float, float* %4
%9 = call float @llvm.fabs.f32(float %8)
store float %9, float* %6
%10 = load float, float* %3
%11 = call float @llvm.fabs.f32(float %10)
store float %11, float* %7
%12 = load float, float* %6
%13 = load float, float* %7
%14 = fcmp ogt float %12, %13
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load float, float* %6
br label %19
17: ; preds = %2
%18 = load float, float* %7
br label %19
19: ; preds = %17, %15
%20 = phi float [ %16, %15 ], [ %18, %17 ]
store float %20, float* %5
%21 = load float, float* %5
%22 = fcmp une float %21, 0.000000e+00
br i1 %22, label %23, label %35
23: ; preds = %19
%24 = load float, float* %6
%25 = load float, float* %7
%26 = fcmp olt float %24, %25
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load float, float* %6
br label %31
29: ; preds = %23
%30 = load float, float* %7
br label %31
31: ; preds = %29, %27
%32 = phi float [ %28, %27 ], [ %30, %29 ]
%33 = load float, float* %5
%34 = fdiv float %32, %33
store float %34, float* %5
br label %36
35: ; preds = %19
store float 0.000000e+00, float* %5
br label %36
36: ; preds = %35, %31
%37 = load float, float* %5
%38 = call float @llvm.fmuladd.f32(float 0x3FA9C12720000000, float %37, float 0xBFD3D6BC60000000)
%39 = load float, float* %5
%40 = call float @llvm.fmuladd.f32(float %38, float %39, float 0xBFC2DF5100000000)
%41 = load float, float* %5
%42 = call float @llvm.fmuladd.f32(float %40, float %41, float 0xBFEFFFC8A0000000)
%43 = load float, float* %5
%44 = call float @llvm.fmuladd.f32(float %42, float %43, float 0xBE951BF4E0000000)
%45 = fneg float %44
%46 = load float, float* %5
%47 = call float @llvm.fmuladd.f32(float 0x3FE49F7320000000, float %46, float 0x3FC2D44D20000000)
%48 = load float, float* %5
%49 = call float @llvm.fmuladd.f32(float %47, float %48, float 1.000000e+00)
%50 = fdiv float %45, %49
store float %50, float* %5
%51 = load float, float* %7
%52 = load float, float* %6
%53 = fcmp ogt float %51, %52
br i1 %53, label %54, label %57
54: ; preds = %36
%55 = load float, float* %5
%56 = fsub float 0x3FF921FB60000000, %55
store float %56, float* %5
br label %57
57: ; preds = %54, %36
%58 = load float, float* %4
%59 = fcmp olt float %58, 0.000000e+00
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load float, float* %5
%62 = fsub float 0x400921FB60000000, %61
store float %62, float* %5
br label %63
63: ; preds = %60, %57
%64 = load float, float* %3
%65 = fcmp olt float %64, 0.000000e+00
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load float, float* %5
%68 = fneg float %67
store float %68, float* %5
br label %69
69: ; preds = %66, %63
%70 = load float, float* %5
ret float %70
}

LLVM IR (-O2):
define float @atan2_approx(float %0, float %1) {
%3 = tail call float @llvm.fabs.f32(float %1)
%4 = tail call float @llvm.fabs.f32(float %0)
%5 = fcmp ogt float %3, %4
%6 = select i1 %5, float %3, float %4
%7 = fcmp une float %6, 0.000000e+00
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = fcmp olt float %3, %4
%10 = select i1 %9, float %3, float %4
%11 = fdiv float %10, %6
br label %12
12: ; preds = %2, %8
%13 = phi float [ %11, %8 ], [ 0.000000e+00, %2 ]
%14 = tail call float @llvm.fmuladd.f32(float %13, float 0x3FA9C12720000000, float 0xBFD3D6BC60000000)
%15 = tail call float @llvm.fmuladd.f32(float %14, float %13, float 0xBFC2DF5100000000)
%16 = tail call float @llvm.fmuladd.f32(float %15, float %13, float 0xBFEFFFC8A0000000)
%17 = tail call float @llvm.fmuladd.f32(float %16, float %13, float 0xBE951BF4E0000000)
%18 = fneg float %17
%19 = tail call float @llvm.fmuladd.f32(float %13, float 0x3FE49F7320000000, float 0x3FC2D44D20000000)
%20 = tail call float @llvm.fmuladd.f32(float %19, float %13, float 1.000000e+00)
%21 = fdiv float %18, %20
%22 = fcmp ogt float %4, %3
%23 = fsub float 0x3FF921FB60000000, %21
%24 = select i1 %22, float %23, float %21
%25 = fcmp olt float %1, 0.000000e+00
%26 = fsub float 0x400921FB60000000, %24
%27 = select i1 %25, float %26, float %24
%28 = fcmp olt float %0, 0.000000e+00
%29 = fneg float %27
%30 = select i1 %28, float %29, float %27
ret float %30
}