double atan2(double y, double x) {
  float t0, t1, t2, t3, t4;
  t3 = ((x < 0) ? -x : x);
  t1 = ((y < 0) ? -y : y);
  t0 = ((t3 >= t1) ? t3 : t1);
  t1 = ((t3 <= t1) ? t3 : t1);
  t3 = (float)1.0f / t0;
  t3 = t1 * t3;
  t4 = t3 * t3;
  t0 = -(float)0.013480470;
  t0 = t0 * t4 + (float)0.057477314;
  t0 = t0 * t4 - (float)0.121239071;
  t0 = t0 * t4 + (float)0.195635925;
  t0 = t0 * t4 - (float)0.332994597;
  t0 = t0 * t4 + (float)0.999995630;
  t3 = t0 * t3;
  t3 = (((y < 0) ? -y : y) > ((x < 0) ? -x : x)) ? (float)1.570796327 - t3 : t3;
  t3 = (x < 0) ? (float)3.141592654 - t3 : t3;
  t3 = (y < 0) ? -t3 : t3;
  return t3;
}


x86 assembly (clang, -O0):
<atan2>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1142 <atan2+0x42>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    114c <atan2+0x4c>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    118e <atan2+0x8e>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1198 <atan2+0x98>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x20(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jb     11c4 <atan2+0xc4>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
jmp    11ce <atan2+0xce>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x20(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11fa <atan2+0xfa>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
jmp    1204 <atan2+0x104>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe02(%rip),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xdce(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xdaf(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xd8c(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xd69(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xd46(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xd23(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1329 <atan2+0x229>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1333 <atan2+0x233>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1371 <atan2+0x271>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    137b <atan2+0x27b>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    13a6 <atan2+0x2a6>
movss  0xc85(%rip),%xmm0
subss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
jmp    13b0 <atan2+0x2b0>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x5c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    13df <atan2+0x2df>
movss  0xc50(%rip),%xmm0
subss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
jmp    13e9 <atan2+0x2e9>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x60(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    141d <atan2+0x31d>
movss  -0x20(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x64(%rbp)
jmp    1427 <atan2+0x327>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2>:
movapd 0xef8(%rip),%xmm4
movapd %xmm1,%xmm5
xorpd  %xmm4,%xmm5
xorpd  %xmm8,%xmm8
movapd %xmm1,%xmm3
cmpltsd %xmm8,%xmm3
andpd  %xmm3,%xmm5
andnpd %xmm1,%xmm3
orpd   %xmm5,%xmm3
cvtsd2ss %xmm3,%xmm6
xorpd  %xmm0,%xmm4
movapd %xmm0,%xmm5
cmpltsd %xmm8,%xmm5
andpd  %xmm5,%xmm4
andnpd %xmm0,%xmm5
orpd   %xmm4,%xmm5
xorps  %xmm4,%xmm4
cvtsd2ss %xmm5,%xmm4
movaps %xmm4,%xmm7
cmpless %xmm6,%xmm7
movaps %xmm7,%xmm2
andps  %xmm6,%xmm2
andnps %xmm4,%xmm7
orps   %xmm2,%xmm7
movaps %xmm6,%xmm2
cmpless %xmm4,%xmm2
andps  %xmm2,%xmm6
andnps %xmm4,%xmm2
orps   %xmm6,%xmm2
movss  0xea3(%rip),%xmm6
divss  %xmm7,%xmm6
mulss  %xmm2,%xmm6
movaps %xmm6,%xmm2
mulss  %xmm6,%xmm2
movss  0xe90(%rip),%xmm4
mulss  %xmm2,%xmm4
addss  0xe88(%rip),%xmm4
mulss  %xmm2,%xmm4
addss  0xe80(%rip),%xmm4
mulss  %xmm2,%xmm4
addss  0xe78(%rip),%xmm4
mulss  %xmm2,%xmm4
addss  0xe70(%rip),%xmm4
mulss  %xmm2,%xmm4
addss  0xe68(%rip),%xmm4
mulss  %xmm6,%xmm4
ucomisd %xmm3,%xmm5
ja     11f0 <atan2+0xf0>
ucomisd %xmm1,%xmm8
ja     1206 <atan2+0x106>
ucomisd %xmm0,%xmm8
ja     121c <atan2+0x11c>
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
ret
movss  0xe44(%rip),%xmm2
subss  %xmm4,%xmm2
movaps %xmm2,%xmm4
ucomisd %xmm1,%xmm8
jbe    11e1 <atan2+0xe1>
movss  0xe32(%rip),%xmm1
subss  %xmm4,%xmm1
movaps %xmm1,%xmm4
ucomisd %xmm0,%xmm8
jbe    11e8 <atan2+0xe8>
xorps  0xded(%rip),%xmm4
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
ret

LLVM IR (-O0):
define double @atan2(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store double %0, double* %3
store double %1, double* %4
%10 = load double, double* %4
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load double, double* %4
%14 = fneg double %13
br label %17
15: ; preds = %2
%16 = load double, double* %4
br label %17
17: ; preds = %15, %12
%18 = phi double [ %14, %12 ], [ %16, %15 ]
%19 = fptrunc double %18 to float
store float %19, float* %8
%20 = load double, double* %3
%21 = fcmp olt double %20, 0.000000e+00
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load double, double* %3
%24 = fneg double %23
br label %27
25: ; preds = %17
%26 = load double, double* %3
br label %27
27: ; preds = %25, %22
%28 = phi double [ %24, %22 ], [ %26, %25 ]
%29 = fptrunc double %28 to float
store float %29, float* %6
%30 = load float, float* %8
%31 = load float, float* %6
%32 = fcmp oge float %30, %31
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = load float, float* %8
br label %37
35: ; preds = %27
%36 = load float, float* %6
br label %37
37: ; preds = %35, %33
%38 = phi float [ %34, %33 ], [ %36, %35 ]
store float %38, float* %5
%39 = load float, float* %8
%40 = load float, float* %6
%41 = fcmp ole float %39, %40
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = load float, float* %8
br label %46
44: ; preds = %37
%45 = load float, float* %6
br label %46
46: ; preds = %44, %42
%47 = phi float [ %43, %42 ], [ %45, %44 ]
store float %47, float* %6
%48 = load float, float* %5
%49 = fdiv float 1.000000e+00, %48
store float %49, float* %8
%50 = load float, float* %6
%51 = load float, float* %8
%52 = fmul float %50, %51
store float %52, float* %8
%53 = load float, float* %8
%54 = load float, float* %8
%55 = fmul float %53, %54
store float %55, float* %9
store float 0xBF8B9BA600000000, float* %5
%56 = load float, float* %5
%57 = load float, float* %9
%58 = call float @llvm.fmuladd.f32(float %56, float %57, float 0x3FAD6DAAA0000000)
store float %58, float* %5
%59 = load float, float* %5
%60 = load float, float* %9
%61 = call float @llvm.fmuladd.f32(float %59, float %60, float 0xBFBF098620000000)
store float %61, float* %5
%62 = load float, float* %5
%63 = load float, float* %9
%64 = call float @llvm.fmuladd.f32(float %62, float %63, float 0x3FC90A9920000000)
store float %64, float* %5
%65 = load float, float* %5
%66 = load float, float* %9
%67 = call float @llvm.fmuladd.f32(float %65, float %66, float 0xBFD54FC8A0000000)
store float %67, float* %5
%68 = load float, float* %5
%69 = load float, float* %9
%70 = call float @llvm.fmuladd.f32(float %68, float %69, float 0x3FEFFFF6E0000000)
store float %70, float* %5
%71 = load float, float* %5
%72 = load float, float* %8
%73 = fmul float %71, %72
store float %73, float* %8
%74 = load double, double* %3
%75 = fcmp olt double %74, 0.000000e+00
br i1 %75, label %76, label %79
76: ; preds = %46
%77 = load double, double* %3
%78 = fneg double %77
br label %81
79: ; preds = %46
%80 = load double, double* %3
br label %81
81: ; preds = %79, %76
%82 = phi double [ %78, %76 ], [ %80, %79 ]
%83 = load double, double* %4
%84 = fcmp olt double %83, 0.000000e+00
br i1 %84, label %85, label %88
85: ; preds = %81
%86 = load double, double* %4
%87 = fneg double %86
br label %90
88: ; preds = %81
%89 = load double, double* %4
br label %90
90: ; preds = %88, %85
%91 = phi double [ %87, %85 ], [ %89, %88 ]
%92 = fcmp ogt double %82, %91
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load float, float* %8
%95 = fsub float 0x3FF921FB60000000, %94
br label %98
96: ; preds = %90
%97 = load float, float* %8
br label %98
98: ; preds = %96, %93
%99 = phi float [ %95, %93 ], [ %97, %96 ]
store float %99, float* %8
%100 = load double, double* %4
%101 = fcmp olt double %100, 0.000000e+00
br i1 %101, label %102, label %105
102: ; preds = %98
%103 = load float, float* %8
%104 = fsub float 0x400921FB60000000, %103
br label %107
105: ; preds = %98
%106 = load float, float* %8
br label %107
107: ; preds = %105, %102
%108 = phi float [ %104, %102 ], [ %106, %105 ]
store float %108, float* %8
%109 = load double, double* %3
%110 = fcmp olt double %109, 0.000000e+00
br i1 %110, label %111, label %114
111: ; preds = %107
%112 = load float, float* %8
%113 = fneg float %112
br label %116
114: ; preds = %107
%115 = load float, float* %8
br label %116
116: ; preds = %114, %111
%117 = phi float [ %113, %111 ], [ %115, %114 ]
store float %117, float* %8
%118 = load float, float* %8
%119 = fpext float %118 to double
ret double %119
}

LLVM IR (-O2):
define double @atan2(double %0, double %1) {
%3 = fcmp olt double %1, 0.000000e+00
%4 = fneg double %1
%5 = select i1 %3, double %4, double %1
%6 = fptrunc double %5 to float
%7 = fcmp olt double %0, 0.000000e+00
%8 = fneg double %0
%9 = select i1 %7, double %8, double %0
%10 = fptrunc double %9 to float
%11 = fcmp oge float %6, %10
%12 = select i1 %11, float %6, float %10
%13 = fcmp ole float %6, %10
%14 = select i1 %13, float %6, float %10
%15 = fdiv float 1.000000e+00, %12
%16 = fmul float %14, %15
%17 = fmul float %16, %16
%18 = tail call float @llvm.fmuladd.f32(float %17, float 0xBF8B9BA600000000, float 0x3FAD6DAAA0000000)
%19 = tail call float @llvm.fmuladd.f32(float %18, float %17, float 0xBFBF098620000000)
%20 = tail call float @llvm.fmuladd.f32(float %19, float %17, float 0x3FC90A9920000000)
%21 = tail call float @llvm.fmuladd.f32(float %20, float %17, float 0xBFD54FC8A0000000)
%22 = tail call float @llvm.fmuladd.f32(float %21, float %17, float 0x3FEFFFF6E0000000)
%23 = fmul float %16, %22
%24 = fcmp ogt double %9, %5
%25 = fsub float 0x3FF921FB60000000, %23
%26 = select i1 %24, float %25, float %23
%27 = fsub float 0x400921FB60000000, %26
%28 = select i1 %3, float %27, float %26
%29 = fneg float %28
%30 = select i1 %7, float %29, float %28
%31 = fpext float %30 to double
ret double %31
}