#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 mlaf(float, float, float);
__attribute__((always_)) const 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;
  float t2 = t * t, t4 = t2 * t2;
  u = mlaf(t4,
           mlaf(t2,
                mlaf(t, (0.00282363896258175373077393f),
                     (-0.0159569028764963150024414f)),
                mlaf(t, (0.0425049886107444763183594f),
                     (-0.0748900920152664184570312f))),
           mlaf(t2,
                mlaf(t, (0.106347933411598205566406f),
                     (-0.142027363181114196777344f)),
                mlaf(t, (0.199926957488059997558594f),
                     (-0.333331018686294555664062f))));
  t = u * t * s + s;
  t = q * (float)(3.141592653589793238462643383279502884 / 2) + t;
  return t;
}


x86 assembly (clang, -O0):
<atan2kf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe28(%rip),%xmm1
movss  0xe24(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe01(%rip),%xmm1
movss  0xdfd(%rip),%xmm2
call   1030 <mlaf@plt>
movss  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x34(%rbp),%xmm0
call   1030 <mlaf@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xdbe(%rip),%xmm1
movss  0xdba(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xd97(%rip),%xmm1
movss  0xd93(%rip),%xmm2
call   1030 <mlaf@plt>
movss  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x2c(%rbp),%xmm0
call   1030 <mlaf@plt>
movss  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x24(%rbp),%xmm0
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
movss  -0x10(%rbp),%xmm1
movss  0xd2a(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2kf>:
push   %rbx
sub    $0x20,%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   %cl
lea    -0x2(%rcx,%rax,2),%ebx
movaps %xmm0,%xmm1
maxss  %xmm2,%xmm1
jbe    1159 <atan2kf+0x49>
xorps  %xmm5,%xmm2
movaps %xmm2,%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x1c(%rsp)
mulss  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
mulss  %xmm1,%xmm1
movss  %xmm1,0x18(%rsp)
movss  0xe84(%rip),%xmm1
movss  0xe80(%rip),%xmm2
call   1030 <mlaf@plt>
movss  %xmm0,0xc(%rsp)
movss  0xe71(%rip),%xmm1
movss  0xe6d(%rip),%xmm2
movss  0x8(%rsp),%xmm0
call   1030 <mlaf@plt>
movaps %xmm0,%xmm2
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1030 <mlaf@plt>
movss  %xmm0,0xc(%rsp)
movss  0xe44(%rip),%xmm1
movss  0xe40(%rip),%xmm2
movss  0x8(%rsp),%xmm0
call   1030 <mlaf@plt>
movss  %xmm0,0x14(%rsp)
movss  0xe2b(%rip),%xmm1
movss  0xe27(%rip),%xmm2
movss  0x8(%rsp),%xmm0
call   1030 <mlaf@plt>
movaps %xmm0,%xmm2
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
call   1030 <mlaf@plt>
movaps %xmm0,%xmm2
movss  0x18(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1030 <mlaf@plt>
mulss  0x8(%rsp),%xmm0
movss  0x1c(%rsp),%xmm2
mulss  %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
addss  %xmm2,%xmm0
mulss  0xdd5(%rip),%xmm1
addss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

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

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