double fmod(double x, double y) {
  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):
<fmod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
call   1050 <isinf@plt>
cmp    $0x0,%eax
je     116c <fmod+0x3c>
mov    $0x0,%al
call   1040 <__domain_error_noerrno@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bf <fmod+0x8f>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1199 <fmod+0x69>
jp     1199 <fmod+0x69>
mov    $0x0,%al
call   1030 <__domain_error@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bf <fmod+0x8f>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
fldl   -0x28(%rbp)
fprem
fstpl  -0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmod>:
sub    $0x28,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1050 <isinf@plt>
test   %eax,%eax
je     115e <fmod+0x2e>
xor    %eax,%eax
call   1040 <__domain_error_noerrno@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x28,%rsp
ret
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
movsd  0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
jne    1176 <fmod+0x46>
jnp    1191 <fmod+0x61>
movsd  %xmm1,0x20(%rsp)
fldl   0x20(%rsp)
fprem
fstpl  0x18(%rsp)
movsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
ret
xor    %eax,%eax
call   1030 <__domain_error@plt>
jmp    1152 <fmod+0x22>

LLVM IR (-O0):
define double @fmod(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = call i32 (double, ...) bitcast (i32 (...)* @isinf to i32 (double, ...)*)(double %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 double
store double %12, double* %3
br label %23
13: ; preds = %2
%14 = load double, double* %5
%15 = fcmp une double %14, 0.000000e+00
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = call i32 (...) @__domain_error()
%18 = sitofp i32 %17 to double
store double %18, double* %3
br label %23
19: ; preds = %13
%20 = load double, double* %4
%21 = call double asm sideeffect "fprem", "={st},0,~{dirflag},~{fpsr},~{flags}"(double %20)
store double %21, double* %6
%22 = load double, double* %6
store double %22, double* %3
br label %23
23: ; preds = %19, %16, %10
%24 = load double, double* %3
ret double %24
}

LLVM IR (-O2):
define double @fmod(double %0, double %1) {
%3 = tail call i32 (double, ...) bitcast (i32 (...)* @isinf to i32 (double, ...)*)(double %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 double
br label %15
8: ; preds = %2
%9 = fcmp une double %1, 0.000000e+00
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 (...) @__domain_error()
%12 = sitofp i32 %11 to double
br label %15
13: ; preds = %8
%14 = tail call double asm sideeffect "fprem", "={st},0,~{dirflag},~{fpsr},~{flags}"(double %0)
br label %15
15: ; preds = %13, %10, %5
%16 = phi double [ %7, %5 ], [ %14, %13 ], [ %12, %10 ]
ret double %16
}