float fast_atan2f(float y, float x) {
  float x2, y2;
  x2 = x * x;
  y2 = y * y;
  if (x2 + y2 < 1e-18f) {
    return 0;
  }
  if (x2 < y2) {
    float den = (y2 + 0.67848403f * x2) * (y2 + 0.08595542f * x2);
    return -x * y * (y2 + 0.43157974f * x2) / den +
           (y < 0 ? -((float)3.141592653f / 2) : ((float)3.141592653f / 2));
  } else {
    float den = (x2 + 0.67848403f * y2) * (x2 + 0.08595542f * y2);
    return x * y * (x2 + 0.43157974f * y2) / den +
           (y < 0 ? -((float)3.141592653f / 2) : ((float)3.141592653f / 2)) -
           (x * y < 0 ? -((float)3.141592653f / 2) : ((float)3.141592653f / 2));
  }
}


x86 assembly (clang, -O0):
<fast_atan2f>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm1
addss  -0x14(%rbp),%xmm1
movss  0xec2(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    1154 <fast_atan2f+0x54>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e3 <fast_atan2f+0x1e3>
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1215 <fast_atan2f+0x115>
movss  -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movss  0xe9b(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
movss  0xe7d(%rip),%xmm3
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
movss  0xe3f(%rip),%xmm3
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
divss  -0x18(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xe19(%rip),%xmm4
movss  0xe15(%rip),%xmm3
xorps  %xmm2,%xmm2
cmpltss %xmm2,%xmm1
movaps %xmm1,%xmm2
andps  %xmm4,%xmm2
andnps %xmm3,%xmm1
orps   %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e3 <fast_atan2f+0x1e3>
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movss  0xded(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
movss  0xdcf(%rip),%xmm3
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
movss  0xd9e(%rip),%xmm3
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
divss  -0x1c(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xd78(%rip),%xmm4
movss  0xd74(%rip),%xmm3
xorps  %xmm2,%xmm2
cmpltss %xmm2,%xmm1
movaps %xmm1,%xmm2
andps  %xmm4,%xmm2
andnps %xmm3,%xmm1
orps   %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
movss  0xd46(%rip),%xmm4
movss  0xd42(%rip),%xmm3
xorps  %xmm2,%xmm2
cmpltss %xmm2,%xmm1
movaps %xmm1,%xmm2
andps  %xmm4,%xmm2
andnps %xmm3,%xmm1
orps   %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<fast_atan2f>:
movaps %xmm1,%xmm3
mulss  %xmm1,%xmm3
movaps %xmm0,%xmm4
mulss  %xmm0,%xmm4
movaps %xmm4,%xmm5
addss  %xmm3,%xmm5
xorps  %xmm2,%xmm2
movss  0xee0(%rip),%xmm6
ucomiss %xmm5,%xmm6
ja     11f6 <fast_atan2f+0xf6>
movss  0xed3(%rip),%xmm2
ucomiss %xmm3,%xmm4
jbe    1187 <fast_atan2f+0x87>
mulss  %xmm3,%xmm2
xorps  0xedf(%rip),%xmm1
xorps  %xmm5,%xmm5
xor    %eax,%eax
ucomiss %xmm0,%xmm5
addss  %xmm4,%xmm2
seta   %al
mulss  %xmm0,%xmm1
unpcklps %xmm2,%xmm1
shufps $0x0,%xmm3,%xmm3
mulps  0xeae(%rip),%xmm3
shufps $0x0,%xmm4,%xmm4
addps  %xmm4,%xmm3
mulps  %xmm1,%xmm3
movaps %xmm3,%xmm0
shufps $0x55,%xmm3,%xmm0
divss  %xmm0,%xmm3
lea    0xeb2(%rip),%rcx
addss  (%rcx,%rax,4),%xmm3
movaps %xmm3,%xmm0
ret
mulss  %xmm4,%xmm2
addss  %xmm3,%xmm2
mulss  %xmm0,%xmm1
shufps $0x0,%xmm4,%xmm4
shufps $0x0,%xmm3,%xmm3
mulps  0xe6e(%rip),%xmm4
addps  %xmm3,%xmm4
movaps %xmm1,%xmm3
unpcklps %xmm2,%xmm3
mulps  %xmm4,%xmm3
movaps %xmm3,%xmm2
shufps $0x55,%xmm3,%xmm2
divss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cmpltss %xmm2,%xmm0
movss  0xe3f(%rip),%xmm4
movaps %xmm0,%xmm5
andps  %xmm4,%xmm5
movss  0xe35(%rip),%xmm6
andnps %xmm6,%xmm0
orps   %xmm5,%xmm0
addss  %xmm3,%xmm0
cmpltss %xmm2,%xmm1
andps  %xmm1,%xmm4
andnps %xmm6,%xmm1
orps   %xmm4,%xmm1
subss  %xmm1,%xmm0
movaps %xmm0,%xmm2
movaps %xmm2,%xmm0
ret

LLVM IR (-O0):
define float @fast_atan2f(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %4
store float %1, float* %5
%10 = load float, float* %5
%11 = load float, float* %5
%12 = fmul float %10, %11
store float %12, float* %6
%13 = load float, float* %4
%14 = load float, float* %4
%15 = fmul float %13, %14
store float %15, float* %7
%16 = load float, float* %6
%17 = load float, float* %7
%18 = fadd float %16, %17
%19 = fcmp olt float %18, 0x3C32725DE0000000
br i1 %19, label %20, label %21
20: ; preds = %2
store float 0.000000e+00, float* %3
br label %77
21: ; preds = %2
%22 = load float, float* %6
%23 = load float, float* %7
%24 = fcmp olt float %22, %23
br i1 %24, label %25, label %48
25: ; preds = %21
%26 = load float, float* %7
%27 = load float, float* %6
%28 = call float @llvm.fmuladd.f32(float 0x3FE5B62420000000, float %27, float %26)
%29 = load float, float* %7
%30 = load float, float* %6
%31 = call float @llvm.fmuladd.f32(float 0x3FB6012CA0000000, float %30, float %29)
%32 = fmul float %28, %31
store float %32, float* %8
%33 = load float, float* %5
%34 = fneg float %33
%35 = load float, float* %4
%36 = fmul float %34, %35
%37 = load float, float* %7
%38 = load float, float* %6
%39 = call float @llvm.fmuladd.f32(float 0x3FDB9F00A0000000, float %38, float %37)
%40 = fmul float %36, %39
%41 = load float, float* %8
%42 = fdiv float %40, %41
%43 = load float, float* %4
%44 = fcmp olt float %43, 0.000000e+00
%45 = zext i1 %44 to i64
%46 = select i1 %44, float 0xBFF921FB60000000, float 0x3FF921FB60000000
%47 = fadd float %42, %46
store float %47, float* %3
br label %77
48: ; preds = %21
%49 = load float, float* %6
%50 = load float, float* %7
%51 = call float @llvm.fmuladd.f32(float 0x3FE5B62420000000, float %50, float %49)
%52 = load float, float* %6
%53 = load float, float* %7
%54 = call float @llvm.fmuladd.f32(float 0x3FB6012CA0000000, float %53, float %52)
%55 = fmul float %51, %54
store float %55, float* %9
%56 = load float, float* %5
%57 = load float, float* %4
%58 = fmul float %56, %57
%59 = load float, float* %6
%60 = load float, float* %7
%61 = call float @llvm.fmuladd.f32(float 0x3FDB9F00A0000000, float %60, float %59)
%62 = fmul float %58, %61
%63 = load float, float* %9
%64 = fdiv float %62, %63
%65 = load float, float* %4
%66 = fcmp olt float %65, 0.000000e+00
%67 = zext i1 %66 to i64
%68 = select i1 %66, float 0xBFF921FB60000000, float 0x3FF921FB60000000
%69 = fadd float %64, %68
%70 = load float, float* %5
%71 = load float, float* %4
%72 = fmul float %70, %71
%73 = fcmp olt float %72, 0.000000e+00
%74 = zext i1 %73 to i64
%75 = select i1 %73, float 0xBFF921FB60000000, float 0x3FF921FB60000000
%76 = fsub float %69, %75
store float %76, float* %3
br label %77
77: ; preds = %48, %25, %20
%78 = load float, float* %3
ret float %78
}

LLVM IR (-O2):
define float @fast_atan2f(float %0, float %1) {
%3 = fmul float %1, %1
%4 = fmul float %0, %0
%5 = fadd float %4, %3
%6 = fcmp olt float %5, 0x3C32725DE0000000
br i1 %6, label %47, label %7
7: ; preds = %2
%8 = fcmp olt float %3, %4
br i1 %8, label %9, label %27
9: ; preds = %7
%10 = tail call float @llvm.fmuladd.f32(float %3, float 0x3FE5B62420000000, float %4)
%11 = fneg float %1
%12 = fmul float %11, %0
%13 = insertelement <2 x float> poison, float %3, i64 0
%14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
%15 = insertelement <2 x float> poison, float %4, i64 0
%16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> zeroinitializer
%17 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %14, <2 x float> <float 0x3FDB9F00A0000000, float 0x3FB6012CA0000000>, <2 x float> %16)
%18 = insertelement <2 x float> poison, float %12, i64 0
%19 = insertelement <2 x float> %18, float %10, i64 1
%20 = fmul <2 x float> %19, %17
%21 = extractelement <2 x float> %20, i64 0
%22 = extractelement <2 x float> %20, i64 1
%23 = fdiv float %21, %22
%24 = fcmp olt float %0, 0.000000e+00
%25 = select i1 %24, float 0xBFF921FB60000000, float 0x3FF921FB60000000
%26 = fadd float %25, %23
br label %47
27: ; preds = %7
%28 = tail call float @llvm.fmuladd.f32(float %4, float 0x3FE5B62420000000, float %3)
%29 = fmul float %0, %1
%30 = insertelement <2 x float> poison, float %4, i64 0
%31 = shufflevector <2 x float> %30, <2 x float> poison, <2 x i32> zeroinitializer
%32 = insertelement <2 x float> poison, float %3, i64 0
%33 = shufflevector <2 x float> %32, <2 x float> poison, <2 x i32> zeroinitializer
%34 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %31, <2 x float> <float 0x3FDB9F00A0000000, float 0x3FB6012CA0000000>, <2 x float> %33)
%35 = insertelement <2 x float> poison, float %29, i64 0
%36 = insertelement <2 x float> %35, float %28, i64 1
%37 = fmul <2 x float> %36, %34
%38 = extractelement <2 x float> %37, i64 0
%39 = extractelement <2 x float> %37, i64 1
%40 = fdiv float %38, %39
%41 = fcmp olt float %0, 0.000000e+00
%42 = select i1 %41, float 0xBFF921FB60000000, float 0x3FF921FB60000000
%43 = fadd float %42, %40
%44 = fcmp olt float %29, 0.000000e+00
%45 = select i1 %44, float 0xBFF921FB60000000, float 0x3FF921FB60000000
%46 = fsub float %43, %45
br label %47
47: ; preds = %2, %27, %9
%48 = phi float [ %26, %9 ], [ %46, %27 ], [ 0.000000e+00, %2 ]
ret float %48
}