#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 mlaf(float, float, float);
float atan2kf(float y, float x) {
  float s, t, u;
  int q = 0;
  if (x < 0) {
    x = -x;
    q = -2;
  }
  if (y > x) {
    t = x;
    x = y;
    y = -t;
    q += 1;
  }
  s = y / x;
  t = s * s;
  u = 0.00282363896258175373077393f;
  u = mlaf(u, t, -0.0159569028764963150024414f);
  u = mlaf(u, t, 0.0425049886107444763183594f);
  u = mlaf(u, t, -0.0748900920152664184570312f);
  u = mlaf(u, t, 0.106347933411598205566406f);
  u = mlaf(u, t, -0.142027363181114196777344f);
  u = mlaf(u, t, 0.199926957488059997558594f);
  u = mlaf(u, t, -0.333331018686294555664062f);
  t = u * t * s + s;
  t = q * (float)(M_PI / 2) + t;
  return t;
}


x86 assembly (clang, -O0):
<atan2kf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1154 <atan2kf+0x44>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0xfffffffe,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1197 <atan2kf+0x87>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe5f(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xe44(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xe24(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xe04(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xde4(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xdc4(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xda4(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xd84(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm2
movss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2kf>:
push   %rbx
sub    $0x10,%rsp
xorps  %xmm3,%xmm3
xor    %eax,%eax
ucomiss %xmm1,%xmm3
setbe  %al
movaps 0xed9(%rip),%xmm5
movaps %xmm1,%xmm4
xorps  %xmm5,%xmm4
movaps %xmm1,%xmm2
cmpltss %xmm3,%xmm2
andps  %xmm2,%xmm4
andnps %xmm1,%xmm2
orps   %xmm4,%xmm2
xor    %ecx,%ecx
ucomiss %xmm2,%xmm0
seta   %dl
movaps %xmm0,%xmm1
maxss  %xmm2,%xmm1
jbe    1155 <atan2kf+0x45>
xorps  %xmm5,%xmm2
movaps %xmm2,%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %dl,%cl
lea    (%rcx,%rax,2),%ebx
add    $0xfffffffe,%ebx
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0xe94(%rip),%xmm0
movss  0xe90(%rip),%xmm2
call   1030 <mlaf@plt>
movss  0xe87(%rip),%xmm2
movss  0x8(%rsp),%xmm1
call   1030 <mlaf@plt>
movss  0xe78(%rip),%xmm2
movss  0x8(%rsp),%xmm1
call   1030 <mlaf@plt>
movss  0xe69(%rip),%xmm2
movss  0x8(%rsp),%xmm1
call   1030 <mlaf@plt>
movss  0xe5a(%rip),%xmm2
movss  0x8(%rsp),%xmm1
call   1030 <mlaf@plt>
movss  0xe4b(%rip),%xmm2
movss  0x8(%rsp),%xmm1
call   1030 <mlaf@plt>
movss  0xe3c(%rip),%xmm2
movss  0x8(%rsp),%xmm1
call   1030 <mlaf@plt>
mulss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm2,%xmm2
cvtsi2ss %ecx,%xmm2
movss  0xc(%rsp),%xmm3
mulss  %xmm3,%xmm0
addss  %xmm3,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i32 0
define float @atan2kf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
store float %0, float* %3
store float %1, float* %4
store i32 0, i32* %8
%9 = load float, float* %4
%10 = fcmp olt float %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load float, float* %4
%13 = fneg float %12
store float %13, float* %4
store i32 -2, i32* %8
br label %14
14: ; preds = %11, %2
%15 = load float, float* %3
%16 = load float, float* %4
%17 = fcmp ogt float %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load float, float* %4
store float %19, float* %6
%20 = load float, float* %3
store float %20, float* %4
%21 = load float, float* %6
%22 = fneg float %21
store float %22, float* %3
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 1
store i32 %24, i32* %8
br label %25
25: ; preds = %18, %14
%26 = load float, float* %3
%27 = load float, float* %4
%28 = fdiv float %26, %27
store float %28, float* %5
%29 = load float, float* %5
%30 = load float, float* %5
%31 = fmul float %29, %30
store float %31, float* %6
store float 0x3F672199A0000000, float* %7
%32 = load float, float* %7
%33 = load float, float* %6
%34 = call float @mlaf(float %32, float %33, float 0xBF905701A0000000)
store float %34, float* %7
%35 = load float, float* %7
%36 = load float, float* %6
%37 = call float @mlaf(float %35, float %36, float 0x3FA5C336C0000000)
store float %37, float* %7
%38 = load float, float* %7
%39 = load float, float* %6
%40 = call float @mlaf(float %38, float %39, float 0xBFB32BFF40000000)
store float %40, float* %7
%41 = load float, float* %7
%42 = load float, float* %6
%43 = call float @mlaf(float %41, float %42, float 0x3FBB399E40000000)
store float %43, float* %7
%44 = load float, float* %7
%45 = load float, float* %6
%46 = call float @mlaf(float %44, float %45, float 0xBFC22DF3E0000000)
store float %46, float* %7
%47 = load float, float* %7
%48 = load float, float* %6
%49 = call float @mlaf(float %47, float %48, float 0x3FC99734E0000000)
store float %49, float* %7
%50 = load float, float* %7
%51 = load float, float* %6
%52 = call float @mlaf(float %50, float %51, float 0xBFD5554BA0000000)
store float %52, float* %7
%53 = load float, float* %7
%54 = load float, float* %6
%55 = fmul float %53, %54
%56 = load float, float* %5
%57 = load float, float* %5
%58 = call float @llvm.fmuladd.f32(float %55, float %56, float %57)
store float %58, float* %6
%59 = load i32, i32* %8
%60 = sitofp i32 %59 to float
%61 = load i32, i32* @M_PI
%62 = sdiv i32 %61, 2
%63 = sitofp i32 %62 to float
%64 = load float, float* %6
%65 = call float @llvm.fmuladd.f32(float %60, float %63, float %64)
store float %65, float* %6
%66 = load float, float* %6
ret float %66
}

LLVM IR (-O2):
@M_PI = global i32 0
define float @atan2kf(float %0, float %1) {
%3 = fcmp olt float %1, 0.000000e+00
%4 = fneg float %1
%5 = select i1 %3, float %4, float %1
%6 = select i1 %3, i32 -2, i32 0
%7 = fcmp olt float %5, %0
%8 = fneg float %5
%9 = select i1 %7, float %0, float %5
%10 = select i1 %7, float %8, float %0
%11 = zext i1 %7 to i32
%12 = or i32 %6, %11
%13 = fdiv float %10, %9
%14 = fmul float %13, %13
%15 = tail call float @mlaf(float 0x3F672199A0000000, float %14, float 0xBF905701A0000000)
%16 = tail call float @mlaf(float %15, float %14, float 0x3FA5C336C0000000)
%17 = tail call float @mlaf(float %16, float %14, float 0xBFB32BFF40000000)
%18 = tail call float @mlaf(float %17, float %14, float 0x3FBB399E40000000)
%19 = tail call float @mlaf(float %18, float %14, float 0xBFC22DF3E0000000)
%20 = tail call float @mlaf(float %19, float %14, float 0x3FC99734E0000000)
%21 = tail call float @mlaf(float %20, float %14, float 0xBFD5554BA0000000)
%22 = fmul float %14, %21
%23 = tail call float @llvm.fmuladd.f32(float %22, float %13, float %13)
%24 = sitofp i32 %12 to float
%25 = load i32, i32* @M_PI
%26 = sdiv i32 %25, 2
%27 = sitofp i32 %26 to float
%28 = tail call float @llvm.fmuladd.f32(float %24, float %27, float %23)
ret float %28
}