void sincosl(long double __x, long double *p_sin, long double *p_cos) {
  long double c, s;
  __asm__ __volatile__("fsincos\n\t"
                       "fnstsw    %%ax\n\t"
                       "testl     $0x400, %%eax\n\t"
                       "jz        1f\n\t"
                       "fldpi\n\t"
                       "fadd      %%st(0)\n\t"
                       "fxch      %%st(1)\n\t"
                       "2: fprem1\n\t"
                       "fnstsw    %%ax\n\t"
                       "testl     $0x400, %%eax\n\t"
                       "jnz       2b\n\t"
                       "fstp      %%st(1)\n\t"
                       "fsincos\n\t"
                       "1:"
                       : "=t"(c), "=u"(s)
                       : "0"(__x));
  *p_sin = s;
  *p_cos = c;
}


x86 assembly (clang, -O0):
<sincosl>:
push   %rbp
mov    %rsp,%rbp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
fldt   -0x10(%rbp)
fsincos
fnstsw %ax
test   $0x400,%eax
je     113d <sincosl+0x3d>
fldpi
fadd   %st(0),%st
fxch   %st(1)
fprem1
fnstsw %ax
test   $0x400,%eax
jne    112a <sincosl+0x2a>
fstp   %st(1)
fsincos
fstpt  -0x30(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
mov    -0x18(%rbp),%rax
fstpt  (%rax)
fldt   -0x30(%rbp)
mov    -0x20(%rbp),%rax
fstpt  (%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<sincosl>:
fldt   0x8(%rsp)
fsincos
fnstsw %ax
test   $0x400,%eax
je     1124 <sincosl+0x24>
fldpi
fadd   %st(0),%st
fxch   %st(1)
fprem1
fnstsw %ax
test   $0x400,%eax
jne    1115 <sincosl+0x15>
fstp   %st(1)
fsincos
fxch   %st(1)
fstpt  (%rdi)
fstpt  (%rsi)
ret

LLVM IR (-O0):
define void @sincosl(x86_fp80 %0, x86_fp80* %1, x86_fp80* %2) {
%4 = alloca x86_fp80
%5 = alloca x86_fp80*
%6 = alloca x86_fp80*
%7 = alloca x86_fp80
%8 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80* %1, x86_fp80** %5
store x86_fp80* %2, x86_fp80** %6
%9 = load x86_fp80, x86_fp80* %4
%10 = call { x86_fp80, x86_fp80 } asm sideeffect "fsincos\0A\09fnstsw %ax\0A\09testl $$0x400, %eax\0A\09jz 1f\0A\09fldpi\0A\09fadd %st(0)\0A\09fxch %st(1)\0A\092: fprem1\0A\09fnstsw %ax\0A\09testl $$0x400, %eax\0A\09jnz 2b\0A\09fstp %st(1)\0A\09fsincos\0A\091:", "={st},={st(1)},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 %9)
%11 = extractvalue { x86_fp80, x86_fp80 } %10, 0
%12 = extractvalue { x86_fp80, x86_fp80 } %10, 1
store x86_fp80 %11, x86_fp80* %7
store x86_fp80 %12, x86_fp80* %8
%13 = load x86_fp80, x86_fp80* %8
%14 = load x86_fp80*, x86_fp80** %5
store x86_fp80 %13, x86_fp80* %14
%15 = load x86_fp80, x86_fp80* %7
%16 = load x86_fp80*, x86_fp80** %6
store x86_fp80 %15, x86_fp80* %16
ret void
}

LLVM IR (-O2):
define void @sincosl(x86_fp80 %0, x86_fp80* nocapture writeonly %1, x86_fp80* nocapture writeonly %2) {
%4 = tail call { x86_fp80, x86_fp80 } asm sideeffect "fsincos\0A\09fnstsw %ax\0A\09testl $$0x400, %eax\0A\09jz 1f\0A\09fldpi\0A\09fadd %st(0)\0A\09fxch %st(1)\0A\092: fprem1\0A\09fnstsw %ax\0A\09testl $$0x400, %eax\0A\09jnz 2b\0A\09fstp %st(1)\0A\09fsincos\0A\091:", "={st},={st(1)},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 %0)
%5 = extractvalue { x86_fp80, x86_fp80 } %4, 0
%6 = extractvalue { x86_fp80, x86_fp80 } %4, 1
store x86_fp80 %6, x86_fp80* %1
store x86_fp80 %5, x86_fp80* %2
ret void
}