double atan(x)
double x;
{
  double f, r, g;
  int n;
  static double Avals[4] = {0.0, 0.52359877559829887308, 1.57079632679489661923,
                            1.04719755119659774615};
  n = 0;
  f = fabs(x);
  if (f > 1.0) {
    f = 1.0 / f;
    n = 2;
  }
  if (f > 0.26794919243112270647) {
    f = (((0.73205080756887729353 * f - 0.5) - 0.5) + f) /
        (1.73205080756887729353 + f);
    ++n;
  }
  if (fabs(f) < 2.3e-10)
    r = f;
  else {
    g = f * f;
    r = f +
        f * (((((-0.83758299368150059274e+0 * g - 0.84946240351320683534e+1) *
                    g -
                0.20505855195861651981e+2) *
                   g -
               0.13688768894191926929e+2) *
              g) /
             ((((g + 0.15024001160028576121e+2) * g +
                0.59578436142597344465e+2) *
                   g +
               0.86157349597130242515e+2) *
                  g +
              0.41066306682575781263e+2));
  }
  if (n > 1)
    r = -r;
  r += Avals[n];
  if (x < 0.0)
    r = -r;
  return r;
}


x86 assembly (clang, -O0):
<atan>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xf64(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xece(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1155 <atan+0x55>
movsd  0xebc(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x2,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b9 <atan+0xb9>
movsd  -0x10(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea3(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe87(%rip),%xmm1
subsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm1
movaps 0xebb(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe5f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ea <atan+0xea>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12ac <atan+0x1ac>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  0xe58(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe54(%rip),%xmm3
addsd  %xmm3,%xmm2
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe2f(%rip),%xmm3
addsd  %xmm3,%xmm2
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe12(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  -0x20(%rbp),%xmm2
movsd  0xdf9(%rip),%xmm3
addsd  -0x20(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xddb(%rip),%xmm4
addsd  %xmm4,%xmm3
movsd  -0x20(%rbp),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xdbe(%rip),%xmm4
addsd  %xmm4,%xmm3
movsd  -0x20(%rbp),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xda1(%rip),%xmm4
addsd  %xmm4,%xmm3
divsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x1,-0x24(%rbp)
jle    12d7 <atan+0x1d7>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movslq -0x24(%rbp),%rcx
lea    0x2d4e(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1320 <atan+0x220>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan>:
movapd 0xef8(%rip),%xmm2
andpd  %xmm0,%xmm2
movsd  0xf0c(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm2
seta   %cl
ja     1125 <atan+0x25>
movapd %xmm2,%xmm1
jmp    1129 <atan+0x29>
divsd  %xmm2,%xmm1
mov    %cl,%al
add    %eax,%eax
ucomisd 0xef3(%rip),%xmm1
jbe    116a <atan+0x6a>
movsd  0xef1(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  0xeed(%rip),%xmm3
addsd  %xmm3,%xmm2
addsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
addsd  0xee1(%rip),%xmm1
divsd  %xmm1,%xmm2
or     $0x1,%eax
movapd %xmm2,%xmm1
movapd 0xe8e(%rip),%xmm2
andpd  %xmm1,%xmm2
movsd  0xeca(%rip),%xmm3
ucomisd %xmm2,%xmm3
ja     11f8 <atan+0xf8>
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
movsd  0xebc(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xeb8(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xeb4(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xeb0(%rip),%xmm2
movsd  0xeb0(%rip),%xmm4
addsd  %xmm3,%xmm4
mulsd  %xmm3,%xmm4
addsd  0xea8(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xea4(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xea0(%rip),%xmm4
mulsd  %xmm3,%xmm2
divsd  %xmm4,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm2,%xmm1
movapd 0xe10(%rip),%xmm2
cmp    $0x2,%eax
jl     1209 <atan+0x109>
xorpd  %xmm2,%xmm1
mov    %eax,%eax
lea    0xe7e(%rip),%rcx
addsd  (%rcx,%rax,8),%xmm1
xorpd  %xmm1,%xmm2
xorpd  %xmm3,%xmm3
cmpltsd %xmm3,%xmm0
movapd %xmm0,%xmm3
andnpd %xmm1,%xmm3
andpd  %xmm2,%xmm0
orpd   %xmm3,%xmm0
ret

LLVM IR (-O0):
@atan.Avals = internal global [4 x double] [double 0.000000e+00, double 0x3FE0C152382D7366, double 0x3FF921FB54442D18, double 0x3FF0C152382D7366]
define double @atan(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double %0, double* %2
store i32 0, i32* %6
%7 = load double, double* %2
%8 = call double @llvm.fabs.f64(double %7)
store double %8, double* %3
%9 = load double, double* %3
%10 = fcmp ogt double %9, 1.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load double, double* %3
%13 = fdiv double 1.000000e+00, %12
store double %13, double* %3
store i32 2, i32* %6
br label %14
14: ; preds = %11, %1
%15 = load double, double* %3
%16 = fcmp ogt double %15, 0x3FD126145E9ECD56
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load double, double* %3
%19 = call double @llvm.fmuladd.f64(double 0x3FE76CF5D0B09955, double %18, double -5.000000e-01)
%20 = fsub double %19, 5.000000e-01
%21 = load double, double* %3
%22 = fadd double %20, %21
%23 = load double, double* %3
%24 = fadd double 0x3FFBB67AE8584CAA, %23
%25 = fdiv double %22, %24
store double %25, double* %3
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %28
28: ; preds = %17, %14
%29 = load double, double* %3
%30 = call double @llvm.fabs.f64(double %29)
%31 = fcmp olt double %30, 2.300000e-10
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load double, double* %3
store double %33, double* %4
br label %58
34: ; preds = %28
%35 = load double, double* %3
%36 = load double, double* %3
%37 = fmul double %35, %36
store double %37, double* %5
%38 = load double, double* %3
%39 = load double, double* %3
%40 = load double, double* %5
%41 = call double @llvm.fmuladd.f64(double 0xBFEACD7AD9B187BD, double %40, double 0xC020FD3F5C8D6A63)
%42 = load double, double* %5
%43 = call double @llvm.fmuladd.f64(double %41, double %42, double 0xC034817FB9E2BCCB)
%44 = load double, double* %5
%45 = call double @llvm.fmuladd.f64(double %43, double %44, double 0xC02B60A651061CE2)
%46 = load double, double* %5
%47 = fmul double %45, %46
%48 = load double, double* %5
%49 = fadd double %48, 0x402E0C49E14AC710
%50 = load double, double* %5
%51 = call double @llvm.fmuladd.f64(double %49, double %50, double 0x404DCA0A320DA3D7)
%52 = load double, double* %5
%53 = call double @llvm.fmuladd.f64(double %51, double %52, double 0x40558A12040B6DA5)
%54 = load double, double* %5
%55 = call double @llvm.fmuladd.f64(double %53, double %54, double 0x4044887CBCC495A9)
%56 = fdiv double %47, %55
%57 = call double @llvm.fmuladd.f64(double %39, double %56, double %38)
store double %57, double* %4
br label %58
58: ; preds = %34, %32
%59 = load i32, i32* %6
%60 = icmp sgt i32 %59, 1
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load double, double* %4
%63 = fneg double %62
store double %63, double* %4
br label %64
64: ; preds = %61, %58
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [4 x double], [4 x double]* @atan.Avals, i64 0, i64 %66
%68 = load double, double* %67
%69 = load double, double* %4
%70 = fadd double %69, %68
store double %70, double* %4
%71 = load double, double* %2
%72 = fcmp olt double %71, 0.000000e+00
br i1 %72, label %73, label %76
73: ; preds = %64
%74 = load double, double* %4
%75 = fneg double %74
store double %75, double* %4
br label %76
76: ; preds = %73, %64
%77 = load double, double* %4
ret double %77
}

LLVM IR (-O2):
@atan.Avals = internal unnamed_addr constant [4 x double] [double 0.000000e+00, double 0x3FE0C152382D7366, double 0x3FF921FB54442D18, double 0x3FF0C152382D7366]
define double @atan(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp ogt double %2, 1.000000e+00
%4 = fdiv double 1.000000e+00, %2
%5 = select i1 %3, double %4, double %2
%6 = select i1 %3, i32 2, i32 0
%7 = fcmp ogt double %5, 0x3FD126145E9ECD56
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FE76CF5D0B09955, double -5.000000e-01)
%10 = fadd double %9, -5.000000e-01
%11 = fadd double %5, %10
%12 = fadd double %5, 0x3FFBB67AE8584CAA
%13 = fdiv double %11, %12
%14 = or i32 %6, 1
br label %15
15: ; preds = %8, %1
%16 = phi double [ %13, %8 ], [ %5, %1 ]
%17 = phi i32 [ %14, %8 ], [ %6, %1 ]
%18 = tail call double @llvm.fabs.f64(double %16)
%19 = fcmp olt double %18, 2.300000e-10
br i1 %19, label %32, label %20
20: ; preds = %15
%21 = fmul double %16, %16
%22 = tail call double @llvm.fmuladd.f64(double %21, double 0xBFEACD7AD9B187BD, double 0xC020FD3F5C8D6A63)
%23 = tail call double @llvm.fmuladd.f64(double %22, double %21, double 0xC034817FB9E2BCCB)
%24 = tail call double @llvm.fmuladd.f64(double %23, double %21, double 0xC02B60A651061CE2)
%25 = fmul double %21, %24
%26 = fadd double %21, 0x402E0C49E14AC710
%27 = tail call double @llvm.fmuladd.f64(double %26, double %21, double 0x404DCA0A320DA3D7)
%28 = tail call double @llvm.fmuladd.f64(double %27, double %21, double 0x40558A12040B6DA5)
%29 = tail call double @llvm.fmuladd.f64(double %28, double %21, double 0x4044887CBCC495A9)
%30 = fdiv double %25, %29
%31 = tail call double @llvm.fmuladd.f64(double %16, double %30, double %16)
br label %32
32: ; preds = %15, %20
%33 = phi double [ %31, %20 ], [ %16, %15 ]
%34 = icmp sgt i32 %17, 1
%35 = fneg double %33
%36 = select i1 %34, double %35, double %33
%37 = zext i32 %17 to i64
%38 = getelementptr inbounds [4 x double], [4 x double]* @atan.Avals, i64 0, i64 %37
%39 = load double, double* %38
%40 = fadd double %36, %39
%41 = fcmp olt double %0, 0.000000e+00
%42 = fneg double %40
%43 = select i1 %41, double %42, double %40
ret double %43
}