long double atand(long double x) {
  long double f, g;
  long double num, den;
  long double result;
  static const long double a[4] = {
      0, (long double)(0.52359877559829887307710723054658L),
      (long double)(1.5707963267948966192313216916398L),
      (long double)(1.0471975511965977461542144610932L)};
  int n = 0;
  f = x;
  if (f < 0.0) {
    f = -f;
  }
  if (f > 1.0) {
    f = ((long double)(1.0) / (long double)(f));
    n = 2;
  }
  if (f > (0.26794919243112270647255365849413L)) {
    num = ((long double)((0.73205080756887729352744634150587L)) *
           (long double)(f));
    num = ((long double)(num) - (long double)(0.5));
    num = ((long double)(num) - (long double)(0.5));
    num = ((long double)(num) + (long double)(f));
    den = ((long double)((1.7320508075688772935274463415059L)) +
           (long double)(f));
    f = ((long double)(num) / (long double)(den));
    n = n + 1;
  }
  g = f;
  if (g < 0.0) {
    g = -g;
  }
  if (g < (+1.490116119385e-8L)) {
    result = f;
  } else {
    g = ((long double)(f) * (long double)(f));
    num = ((long double)((-8.3758299368150059274e-1L)) * (long double)(g));
    num = ((long double)(num) + (long double)((-8.4946240351320683534L)));
    num = ((long double)(num) * (long double)(g));
    num = ((long double)(num) + (long double)((-2.0505855195861651981e1L)));
    num = ((long double)(num) * (long double)(g));
    num = ((long double)(num) + (long double)((-1.3688768894191926929e1L)));
    num = ((long double)(num) * (long double)(g));
    den = ((long double)(g) + (long double)((+1.5024001160028576121e1L)));
    den = ((long double)(den) * (long double)(g));
    den = ((long double)(den) + (long double)((+5.9578436142597344465e1L)));
    den = ((long double)(den) * (long double)(g));
    den = ((long double)(den) + (long double)((+8.6157349597130242515e1L)));
    den = ((long double)(den) * (long double)(g));
    den = ((long double)(den) + (long double)((+4.1066306682575781263e1L)));
    result = ((long double)(num) / (long double)(den));
    result = ((long double)(result) * (long double)(f));
    result = ((long double)(result) + (long double)(f));
  }
  if (n > 1) {
    result = -result;
  }
  result = ((long double)(a[n]) + (long double)(result));
  if (x < 0.0) {
    result = -result;
  }
  return result;
}


x86 assembly (clang, -O0):
<atand>:
push   %rbp
mov    %rsp,%rbp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
movl   $0x0,-0x64(%rbp)
fldt   -0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    1133 <atand+0x33>
jmp    112b <atand+0x2b>
fldt   -0x20(%rbp)
fchs
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    115a <atand+0x5a>
jmp    1149 <atand+0x49>
fldt   -0x20(%rbp)
fld1
fdivp  %st,%st(1)
fstpt  -0x20(%rbp)
movl   $0x2,-0x64(%rbp)
fldt   -0x20(%rbp)
fldt   0xe9d(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    11c7 <atand+0xc7>
jmp    1174 <atand+0x74>
fldt   -0x20(%rbp)
fldt   0xe93(%rip)
fmulp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
flds   0xf35(%rip)
fsubr  %st,%st(1)
fxch   %st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fsubp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x20(%rbp)
fldt   0xe72(%rip)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x40(%rbp)
fldt   -0x50(%rbp)
fdivrp %st,%st(1)
fstpt  -0x20(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
fldt   -0x20(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    11e9 <atand+0xe9>
jmp    11e1 <atand+0xe1>
fldt   -0x30(%rbp)
fchs
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldt   0xe3e(%rip)
fucomip %st(1),%st
fstp   %st(0)
jbe    120c <atand+0x10c>
jmp    1201 <atand+0x101>
fldt   -0x20(%rbp)
fstpt  -0x60(%rbp)
jmp    12e7 <atand+0x1e7>
fldt   -0x20(%rbp)
fmul   %st,%st(0)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldt   0xe23(%rip)
fmulp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   0xe25(%rip)
faddp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   0xe1c(%rip)
faddp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   0xe13(%rip)
faddp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x30(%rbp)
fldt   0xe0a(%rip)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   0xe01(%rip)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   0xdf8(%rip)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   0xdef(%rip)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x40(%rbp)
fldt   -0x50(%rbp)
fdivrp %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x60(%rbp)
fldt   -0x20(%rbp)
fmulp  %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x60(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x60(%rbp)
cmpl   $0x1,-0x64(%rbp)
jle    12f9 <atand+0x1f9>
fldt   -0x60(%rbp)
fchs
fstpt  -0x60(%rbp)
movslq -0x64(%rbp),%rax
shl    $0x4,%rax
lea    0xdc8(%rip),%rcx
fldt   (%rax,%rcx,1)
fldt   -0x60(%rbp)
faddp  %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x10(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    132f <atand+0x22f>
jmp    1327 <atand+0x227>
fldt   -0x60(%rbp)
fchs
fstpt  -0x60(%rbp)
fldt   -0x60(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<atand>:
fldt   0x8(%rsp)
fldz
fucomi %st(1),%st
fld    %st(1)
fchs
fld    %st(2)
fcmovnbe %st(1),%st
fstp   %st(1)
fld1
xor    %eax,%eax
fxch   %st(1)
fucomi %st(1),%st
seta   %al
fdivr  %st,%st(1)
fcmovnbe %st(1),%st
fstp   %st(1)
add    %eax,%eax
fldt   0xed5(%rip)
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
jbe    1154 <atand+0x54>
fldt   0xed7(%rip)
fmul   %st(1),%st
flds   0xf7f(%rip)
fadd   %st,%st(1)
faddp  %st,%st(1)
fadd   %st(1),%st
fldt   0xed3(%rip)
faddp  %st,%st(2)
fdivp  %st,%st(1)
or     $0x1,%eax
fxch   %st(1)
fucomi %st(1),%st
fld    %st(1)
fchs
fld    %st(2)
fcmovnbe %st(1),%st
fldt   0xeca(%rip)
fucomip %st(1),%st
fstp   %st(0)
ja     11c8 <atand+0xc8>
fstp   %st(0)
fld    %st(1)
fmul   %st(2),%st
fldt   0xec8(%rip)
fmul   %st(1),%st
fldt   0xed0(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
fldt   0xed6(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
fldt   0xedc(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
fldt   0xee2(%rip)
fadd   %st(2),%st
fmul   %st(2),%st
fldt   0xee8(%rip)
faddp  %st,%st(1)
fmul   %st(2),%st
fldt   0xeee(%rip)
faddp  %st,%st(1)
fmulp  %st,%st(2)
fldt   0xef4(%rip)
faddp  %st,%st(2)
fdivp  %st,%st(1)
fmul   %st(2),%st
faddp  %st,%st(2)
fld    %st(1)
fchs
cmp    $0x2,%eax
setge  %cl
test   %cl,%cl
fxch   %st(2)
fcmovne %st(2),%st
fstp   %st(2)
mov    %eax,%eax
shl    $0x4,%rax
fucomip %st(2),%st
fstp   %st(1)
lea    0xee9(%rip),%rcx
fldt   (%rax,%rcx,1)
faddp  %st,%st(1)
fld    %st(0)
fchs
fxch   %st(1)
fcmovnbe %st(1),%st
fstp   %st(1)
ret

LLVM IR (-O0):
@atand.a = internal constant [4 x x86_fp80] [x86_fp80 0xK00000000000000000000, x86_fp80 0xK3FFE860A91C16B9B2C23, x86_fp80 0xK3FFFC90FDAA22168C235, x86_fp80 0xK3FFF860A91C16B9B2C23]
define x86_fp80 @atand(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca x86_fp80
%8 = alloca i32
store x86_fp80 %0, x86_fp80* %2
store i32 0, i32* %8
%9 = load x86_fp80, x86_fp80* %2
store x86_fp80 %9, x86_fp80* %3
%10 = load x86_fp80, x86_fp80* %3
%11 = fcmp olt x86_fp80 %10, 0xK00000000000000000000
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load x86_fp80, x86_fp80* %3
%14 = fneg x86_fp80 %13
store x86_fp80 %14, x86_fp80* %3
br label %15
15: ; preds = %12, %1
%16 = load x86_fp80, x86_fp80* %3
%17 = fcmp ogt x86_fp80 %16, 0xK3FFF8000000000000000
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load x86_fp80, x86_fp80* %3
%20 = fdiv x86_fp80 0xK3FFF8000000000000000, %19
store x86_fp80 %20, x86_fp80* %3
store i32 2, i32* %8
br label %21
21: ; preds = %18, %15
%22 = load x86_fp80, x86_fp80* %3
%23 = fcmp ogt x86_fp80 %22, 0xK3FFD8930A2F4F66AB18A
br i1 %23, label %24, label %41
24: ; preds = %21
%25 = load x86_fp80, x86_fp80* %3
%26 = fmul x86_fp80 0xK3FFEBB67AE8584CAA73B, %25
store x86_fp80 %26, x86_fp80* %5
%27 = load x86_fp80, x86_fp80* %5
%28 = fsub x86_fp80 %27, 0xK3FFE8000000000000000
store x86_fp80 %28, x86_fp80* %5
%29 = load x86_fp80, x86_fp80* %5
%30 = fsub x86_fp80 %29, 0xK3FFE8000000000000000
store x86_fp80 %30, x86_fp80* %5
%31 = load x86_fp80, x86_fp80* %5
%32 = load x86_fp80, x86_fp80* %3
%33 = fadd x86_fp80 %31, %32
store x86_fp80 %33, x86_fp80* %5
%34 = load x86_fp80, x86_fp80* %3
%35 = fadd x86_fp80 0xK3FFFDDB3D742C265539E, %34
store x86_fp80 %35, x86_fp80* %6
%36 = load x86_fp80, x86_fp80* %5
%37 = load x86_fp80, x86_fp80* %6
%38 = fdiv x86_fp80 %36, %37
store x86_fp80 %38, x86_fp80* %3
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %41
41: ; preds = %24, %21
%42 = load x86_fp80, x86_fp80* %3
store x86_fp80 %42, x86_fp80* %4
%43 = load x86_fp80, x86_fp80* %4
%44 = fcmp olt x86_fp80 %43, 0xK00000000000000000000
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load x86_fp80, x86_fp80* %4
%47 = fneg x86_fp80 %46
store x86_fp80 %47, x86_fp80* %4
br label %48
48: ; preds = %45, %41
%49 = load x86_fp80, x86_fp80* %4
%50 = fcmp olt x86_fp80 %49, 0xK3FE580000000001622D7
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = load x86_fp80, x86_fp80* %3
store x86_fp80 %52, x86_fp80* %7
br label %100
53: ; preds = %48
%54 = load x86_fp80, x86_fp80* %3
%55 = load x86_fp80, x86_fp80* %3
%56 = fmul x86_fp80 %54, %55
store x86_fp80 %56, x86_fp80* %4
%57 = load x86_fp80, x86_fp80* %4
%58 = fmul x86_fp80 0xKBFFED66BD6CD8C3DE934, %57
store x86_fp80 %58, x86_fp80* %5
%59 = load x86_fp80, x86_fp80* %5
%60 = fadd x86_fp80 %59, 0xKC00287E9FAE46B531A29
store x86_fp80 %60, x86_fp80* %5
%61 = load x86_fp80, x86_fp80* %5
%62 = load x86_fp80, x86_fp80* %4
%63 = fmul x86_fp80 %61, %62
store x86_fp80 %63, x86_fp80* %5
%64 = load x86_fp80, x86_fp80* %5
%65 = fadd x86_fp80 %64, 0xKC003A40BFDCF15E65691
store x86_fp80 %65, x86_fp80* %5
%66 = load x86_fp80, x86_fp80* %5
%67 = load x86_fp80, x86_fp80* %4
%68 = fmul x86_fp80 %66, %67
store x86_fp80 %68, x86_fp80* %5
%69 = load x86_fp80, x86_fp80* %5
%70 = fadd x86_fp80 %69, 0xKC002DB05328830E70EB4
store x86_fp80 %70, x86_fp80* %5
%71 = load x86_fp80, x86_fp80* %5
%72 = load x86_fp80, x86_fp80* %4
%73 = fmul x86_fp80 %71, %72
store x86_fp80 %73, x86_fp80* %5
%74 = load x86_fp80, x86_fp80* %4
%75 = fadd x86_fp80 %74, 0xK4002F0624F0A56388310
store x86_fp80 %75, x86_fp80* %6
%76 = load x86_fp80, x86_fp80* %6
%77 = load x86_fp80, x86_fp80* %4
%78 = fmul x86_fp80 %76, %77
store x86_fp80 %78, x86_fp80* %6
%79 = load x86_fp80, x86_fp80* %6
%80 = fadd x86_fp80 %79, 0xK4004EE5051906D1EB4E8
store x86_fp80 %80, x86_fp80* %6
%81 = load x86_fp80, x86_fp80* %6
%82 = load x86_fp80, x86_fp80* %4
%83 = fmul x86_fp80 %81, %82
store x86_fp80 %83, x86_fp80* %6
%84 = load x86_fp80, x86_fp80* %6
%85 = fadd x86_fp80 %84, 0xK4005AC5090205B6D243B
store x86_fp80 %85, x86_fp80* %6
%86 = load x86_fp80, x86_fp80* %6
%87 = load x86_fp80, x86_fp80* %4
%88 = fmul x86_fp80 %86, %87
store x86_fp80 %88, x86_fp80* %6
%89 = load x86_fp80, x86_fp80* %6
%90 = fadd x86_fp80 %89, 0xK4004A443E5E624AD4B90
store x86_fp80 %90, x86_fp80* %6
%91 = load x86_fp80, x86_fp80* %5
%92 = load x86_fp80, x86_fp80* %6
%93 = fdiv x86_fp80 %91, %92
store x86_fp80 %93, x86_fp80* %7
%94 = load x86_fp80, x86_fp80* %7
%95 = load x86_fp80, x86_fp80* %3
%96 = fmul x86_fp80 %94, %95
store x86_fp80 %96, x86_fp80* %7
%97 = load x86_fp80, x86_fp80* %7
%98 = load x86_fp80, x86_fp80* %3
%99 = fadd x86_fp80 %97, %98
store x86_fp80 %99, x86_fp80* %7
br label %100
100: ; preds = %53, %51
%101 = load i32, i32* %8
%102 = icmp sgt i32 %101, 1
br i1 %102, label %103, label %106
103: ; preds = %100
%104 = load x86_fp80, x86_fp80* %7
%105 = fneg x86_fp80 %104
store x86_fp80 %105, x86_fp80* %7
br label %106
106: ; preds = %103, %100
%107 = load i32, i32* %8
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* @atand.a, i64 0, i64 %108
%110 = load x86_fp80, x86_fp80* %109
%111 = load x86_fp80, x86_fp80* %7
%112 = fadd x86_fp80 %110, %111
store x86_fp80 %112, x86_fp80* %7
%113 = load x86_fp80, x86_fp80* %2
%114 = fcmp olt x86_fp80 %113, 0xK00000000000000000000
br i1 %114, label %115, label %118
115: ; preds = %106
%116 = load x86_fp80, x86_fp80* %7
%117 = fneg x86_fp80 %116
store x86_fp80 %117, x86_fp80* %7
br label %118
118: ; preds = %115, %106
%119 = load x86_fp80, x86_fp80* %7
ret x86_fp80 %119
}

LLVM IR (-O2):
@atand.a = internal unnamed_addr constant [4 x x86_fp80] [x86_fp80 0xK00000000000000000000, x86_fp80 0xK3FFE860A91C16B9B2C23, x86_fp80 0xK3FFFC90FDAA22168C235, x86_fp80 0xK3FFF860A91C16B9B2C23]
define x86_fp80 @atand(x86_fp80 %0) {
%2 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
%3 = fneg x86_fp80 %0
%4 = select i1 %2, x86_fp80 %3, x86_fp80 %0
%5 = fcmp ogt x86_fp80 %4, 0xK3FFF8000000000000000
%6 = fdiv x86_fp80 0xK3FFF8000000000000000, %4
%7 = select i1 %5, x86_fp80 %6, x86_fp80 %4
%8 = select i1 %5, i32 2, i32 0
%9 = fcmp ogt x86_fp80 %7, 0xK3FFD8930A2F4F66AB18A
br i1 %9, label %10, label %18
10: ; preds = %1
%11 = fmul x86_fp80 %7, 0xK3FFEBB67AE8584CAA73B
%12 = fadd x86_fp80 %11, 0xKBFFE8000000000000000
%13 = fadd x86_fp80 %12, 0xKBFFE8000000000000000
%14 = fadd x86_fp80 %7, %13
%15 = fadd x86_fp80 %7, 0xK3FFFDDB3D742C265539E
%16 = fdiv x86_fp80 %14, %15
%17 = or i32 %8, 1
br label %18
18: ; preds = %10, %1
%19 = phi x86_fp80 [ %16, %10 ], [ %7, %1 ]
%20 = phi i32 [ %17, %10 ], [ %8, %1 ]
%21 = fcmp olt x86_fp80 %19, 0xK00000000000000000000
%22 = fneg x86_fp80 %19
%23 = select i1 %21, x86_fp80 %22, x86_fp80 %19
%24 = fcmp olt x86_fp80 %23, 0xK3FE580000000001622D7
br i1 %24, label %45, label %25
25: ; preds = %18
%26 = fmul x86_fp80 %19, %19
%27 = fmul x86_fp80 %26, 0xK3FFED66BD6CD8C3DE934
%28 = fsub x86_fp80 0xKC00287E9FAE46B531A29, %27
%29 = fmul x86_fp80 %26, %28
%30 = fadd x86_fp80 %29, 0xKC003A40BFDCF15E65691
%31 = fmul x86_fp80 %26, %30
%32 = fadd x86_fp80 %31, 0xKC002DB05328830E70EB4
%33 = fmul x86_fp80 %26, %32
%34 = fadd x86_fp80 %26, 0xK4002F0624F0A56388310
%35 = fmul x86_fp80 %26, %34
%36 = fadd x86_fp80 %35, 0xK4004EE5051906D1EB4E8
%37 = fmul x86_fp80 %26, %36
%38 = fadd x86_fp80 %37, 0xK4005AC5090205B6D243B
%39 = fmul x86_fp80 %26, %38
%40 = fadd x86_fp80 %39, 0xK4004A443E5E624AD4B90
%41 = fdiv x86_fp80 %33, %40
%42 = fmul x86_fp80 %19, %41
%43 = fadd x86_fp80 %19, %42
%44 = fneg x86_fp80 %43
br label %45
45: ; preds = %18, %25
%46 = phi x86_fp80 [ %22, %18 ], [ %44, %25 ]
%47 = phi x86_fp80 [ %19, %18 ], [ %43, %25 ]
%48 = icmp sgt i32 %20, 1
%49 = select i1 %48, x86_fp80 %46, x86_fp80 %47
%50 = zext i32 %20 to i64
%51 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* @atand.a, i64 0, i64 %50
%52 = load x86_fp80, x86_fp80* %51
%53 = fadd x86_fp80 %52, %49
%54 = fneg x86_fp80 %53
%55 = select i1 %2, x86_fp80 %54, x86_fp80 %53
ret x86_fp80 %55
}