#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 */
int ieee754_rem_pio2l(long double, long double *);
long double kernel_tanl(long double, long double, int);
long double tanl(long double x) {
  long double y[2], z = 0.0L;
  int n;
  if (x >= -0.7853981633974483096156608458198757210492 &&
      x <= 0.7853981633974483096156608458198757210492)
    return kernel_tanl(x, z, 1);
  else if (x + x == x || x != x)
    return x - x;
  else {
    n = ieee754_rem_pio2l(x, y);
    return kernel_tanl(y[0], y[1], 1 - ((n & 1) << 1));
  }
}


x86 assembly (clang, -O0):
<tanl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldz
fstpt  -0x50(%rbp)
fldt   -0x20(%rbp)
fldl   0xec1(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     1188 <tanl+0x68>
jmp    1150 <tanl+0x30>
fldt   -0x20(%rbp)
fldl   0xeaf(%rip)
fucomip %st(1),%st
fstp   %st(0)
jb     1188 <tanl+0x68>
jmp    1168 <tanl+0x48>
fldt   -0x20(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
mov    $0x1,%edi
call   1030 <kernel_tanl@plt>
fstpt  -0x10(%rbp)
jmp    11fa <tanl+0xda>
fldt   -0x20(%rbp)
fld    %st(0)
fadd   %st(1),%st
fucomip %st(1),%st
fstp   %st(0)
jne    11a4 <tanl+0x84>
jp     11a4 <tanl+0x84>
jmp    11b4 <tanl+0x94>
fldt   -0x20(%rbp)
fucomip %st(0),%st
jnp    11c1 <tanl+0xa1>
jmp    11b4 <tanl+0x94>
fldt   -0x20(%rbp)
fsub   %st,%st(0)
fstpt  -0x10(%rbp)
jmp    11fa <tanl+0xda>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    -0x40(%rbp),%rdi
call   1040 <ieee754_rem_pio2l@plt>
mov    %eax,-0x54(%rbp)
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
mov    -0x54(%rbp),%eax
and    $0x1,%eax
add    %eax,%eax
mov    $0x1,%edi
sub    %eax,%edi
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <kernel_tanl@plt>
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tanl>:
sub    $0x48,%rsp
fldt   0x50(%rsp)
fldl   0xed2(%rip)
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
jb     1150 <tanl+0x30>
fldl   0xecc(%rip)
fucomip %st(1),%st
jb     1150 <tanl+0x30>
fldz
fstpt  0x10(%rsp)
fstpt  (%rsp)
mov    $0x1,%edi
jmp    1190 <tanl+0x70>
fld    %st(0)
fadd   %st(1),%st
fxch   %st(1)
fucomi %st(0),%st
jp     119a <tanl+0x7a>
fxch   %st(1)
fucomip %st(1),%st
fldz
fxch   %st(1)
jne    1166 <tanl+0x46>
jnp    119a <tanl+0x7a>
fstp   %st(1)
fstpt  (%rsp)
lea    0x20(%rsp),%rdi
call   1040 <ieee754_rem_pio2l@plt>
fldt   0x20(%rsp)
fldt   0x30(%rsp)
add    %eax,%eax
and    $0x2,%eax
mov    $0x1,%edi
sub    %eax,%edi
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1030 <kernel_tanl@plt>
add    $0x48,%rsp
ret
fstp   %st(1)
fsub   %st,%st(0)
add    $0x48,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @tanl(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca [2 x x86_fp80]
%5 = alloca x86_fp80
%6 = alloca i32
store x86_fp80 %0, x86_fp80* %3
store x86_fp80 0xK00000000000000000000, x86_fp80* %5
%7 = load x86_fp80, x86_fp80* %3
%8 = fcmp oge x86_fp80 %7, 0xKBFFEC90FDAA22168C000
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load x86_fp80, x86_fp80* %3
%11 = fcmp ole x86_fp80 %10, 0xK3FFEC90FDAA22168C000
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load x86_fp80, x86_fp80* %3
%14 = load x86_fp80, x86_fp80* %5
%15 = call x86_fp80 @kernel_tanl(x86_fp80 %13, x86_fp80 %14, i32 1)
store x86_fp80 %15, x86_fp80* %2
br label %43
16: ; preds = %9, %1
%17 = load x86_fp80, x86_fp80* %3
%18 = load x86_fp80, x86_fp80* %3
%19 = fadd x86_fp80 %17, %18
%20 = load x86_fp80, x86_fp80* %3
%21 = fcmp oeq x86_fp80 %19, %20
br i1 %21, label %26, label %22
22: ; preds = %16
%23 = load x86_fp80, x86_fp80* %3
%24 = load x86_fp80, x86_fp80* %3
%25 = fcmp une x86_fp80 %23, %24
br i1 %25, label %26, label %30
26: ; preds = %22, %16
%27 = load x86_fp80, x86_fp80* %3
%28 = load x86_fp80, x86_fp80* %3
%29 = fsub x86_fp80 %27, %28
store x86_fp80 %29, x86_fp80* %2
br label %43
30: ; preds = %22
%31 = load x86_fp80, x86_fp80* %3
%32 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %4, i64 0, i64 0
%33 = call i32 @ieee754_rem_pio2l(x86_fp80 %31, x86_fp80* %32)
store i32 %33, i32* %6
%34 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %4, i64 0, i64 0
%35 = load x86_fp80, x86_fp80* %34
%36 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %4, i64 0, i64 1
%37 = load x86_fp80, x86_fp80* %36
%38 = load i32, i32* %6
%39 = and i32 %38, 1
%40 = shl i32 %39, 1
%41 = sub nsw i32 1, %40
%42 = call x86_fp80 @kernel_tanl(x86_fp80 %35, x86_fp80 %37, i32 %41)
store x86_fp80 %42, x86_fp80* %2
br label %43
43: ; preds = %30, %26, %12
%44 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %44
}

LLVM IR (-O2):
define x86_fp80 @tanl(x86_fp80 %0) {
%2 = alloca [2 x x86_fp80]
%3 = bitcast [2 x x86_fp80]* %2 to i8*
%4 = fcmp oge x86_fp80 %0, 0xKBFFEC90FDAA22168C000
%5 = fcmp ole x86_fp80 %0, 0xK3FFEC90FDAA22168C000
%6 = and i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call x86_fp80 @kernel_tanl(x86_fp80 %0, x86_fp80 0xK00000000000000000000, i32 1)
br label %26
9: ; preds = %1
%10 = fadd x86_fp80 %0, %0
%11 = fcmp oeq x86_fp80 %10, %0
%12 = fcmp uno x86_fp80 %0, 0xK00000000000000000000
%13 = or i1 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = fsub x86_fp80 %0, %0
br label %26
16: ; preds = %9
%17 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %2, i64 0, i64 0
%18 = call i32 @ieee754_rem_pio2l(x86_fp80 %0, x86_fp80* %17)
%19 = load x86_fp80, x86_fp80* %17
%20 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %2, i64 0, i64 1
%21 = load x86_fp80, x86_fp80* %20
%22 = shl i32 %18, 1
%23 = and i32 %22, 2
%24 = sub nsw i32 1, %23
%25 = call x86_fp80 @kernel_tanl(x86_fp80 %19, x86_fp80 %21, i32 %24)
br label %26
26: ; preds = %16, %14, %7
%27 = phi x86_fp80 [ %8, %7 ], [ %15, %14 ], [ %25, %16 ]
ret x86_fp80 %27
}