long double fmodl(long double x, long double y) {
  long double r;
  if (isinf(x))
    return __domain_error_noerrno();
  if (!y)
    return __domain_error();
  __asm__ __volatile__("fprem" : "=t"(r) : "0"(x));
  return r;
}


x86 assembly (clang, -O0):
<fmodl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
xor    %eax,%eax
call   1050 <isinf@plt>
cmp    $0x0,%eax
je     1171 <fmodl+0x41>
xor    %eax,%eax
call   1040 <__domain_error_noerrno@plt>
mov    %eax,-0x48(%rbp)
fildl  -0x48(%rbp)
fstpt  -0x10(%rbp)
jmp    11b0 <fmodl+0x80>
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11a2 <fmodl+0x72>
jp     11a2 <fmodl+0x72>
jmp    118d <fmodl+0x5d>
xor    %eax,%eax
call   1030 <__domain_error@plt>
mov    %eax,-0x44(%rbp)
fildl  -0x44(%rbp)
fstpt  -0x10(%rbp)
jmp    11b0 <fmodl+0x80>
fldt   -0x20(%rbp)
fprem
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmodl>:
sub    $0x38,%rsp
fldt   0x50(%rsp)
fstpt  0x2c(%rsp)
fldt   0x40(%rsp)
fld    %st(0)
fstpt  0x20(%rsp)
fstpt  (%rsp)
xor    %eax,%eax
call   1050 <isinf@plt>
test   %eax,%eax
je     1168 <fmodl+0x38>
xor    %eax,%eax
call   1040 <__domain_error_noerrno@plt>
mov    %eax,0x1c(%rsp)
fildl  0x1c(%rsp)
add    $0x38,%rsp
ret
fldt   0x20(%rsp)
fldz
fldt   0x2c(%rsp)
fucomip %st(1),%st
fstp   %st(0)
jne    117a <fmodl+0x4a>
jnp    1181 <fmodl+0x51>
fprem
add    $0x38,%rsp
ret
fstp   %st(0)
xor    %eax,%eax
call   1030 <__domain_error@plt>
mov    %eax,0x18(%rsp)
fildl  0x18(%rsp)
add    $0x38,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @fmodl(x86_fp80 %0, x86_fp80 %1) {
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
%7 = load x86_fp80, x86_fp80* %4
%8 = call i32 (x86_fp80, ...) bitcast (i32 (...)* @isinf to i32 (x86_fp80, ...)*)(x86_fp80 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (...) @__domain_error_noerrno()
%12 = sitofp i32 %11 to x86_fp80
store x86_fp80 %12, x86_fp80* %3
br label %23
13: ; preds = %2
%14 = load x86_fp80, x86_fp80* %5
%15 = fcmp une x86_fp80 %14, 0xK00000000000000000000
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = call i32 (...) @__domain_error()
%18 = sitofp i32 %17 to x86_fp80
store x86_fp80 %18, x86_fp80* %3
br label %23
19: ; preds = %13
%20 = load x86_fp80, x86_fp80* %4
%21 = call x86_fp80 asm sideeffect "fprem", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 %20)
store x86_fp80 %21, x86_fp80* %6
%22 = load x86_fp80, x86_fp80* %6
store x86_fp80 %22, x86_fp80* %3
br label %23
23: ; preds = %19, %16, %10
%24 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %24
}

LLVM IR (-O2):
define x86_fp80 @fmodl(x86_fp80 %0, x86_fp80 %1) {
%3 = tail call i32 (x86_fp80, ...) bitcast (i32 (...)* @isinf to i32 (x86_fp80, ...)*)(x86_fp80 %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 (...) @__domain_error_noerrno()
%7 = sitofp i32 %6 to x86_fp80
br label %15
8: ; preds = %2
%9 = fcmp une x86_fp80 %1, 0xK00000000000000000000
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 (...) @__domain_error()
%12 = sitofp i32 %11 to x86_fp80
br label %15
13: ; preds = %8
%14 = tail call x86_fp80 asm sideeffect "fprem", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 %0)
br label %15
15: ; preds = %13, %10, %5
%16 = phi x86_fp80 [ %7, %5 ], [ %14, %13 ], [ %12, %10 ]
ret x86_fp80 %16
}