void flodivmod(x, y, divp, modp) double x, y;
double *divp, *modp;
{
  double div, mod;
  {
    double z;
    modf(x / y, &z);
    mod = x - z * y;
  }
  if (isinf(x) && !isinf(y) && !isnan(y))
    div = x;
  else
    div = (x - mod) / y;
  if (y * mod < 0) {
    mod += y;
    div -= 1.0;
  }
  if (modp)
    *modp = mod;
  if (divp)
    *divp = div;
}


x86 assembly (clang, -O0):
<flodivmod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
lea    -0x38(%rbp),%rdi
call   1030 <modf@plt>
movsd  -0x8(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    $0x1,%al
call   1050 <isinf@plt>
cmp    $0x0,%eax
je     11de <flodivmod+0xae>
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
call   1050 <isinf@plt>
cmp    $0x0,%eax
jne    11de <flodivmod+0xae>
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
call   1040 <isnan@plt>
cmp    $0x0,%eax
jne    11de <flodivmod+0xae>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11f2 <flodivmod+0xc2>
movsd  -0x8(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    122e <flodivmod+0xfe>
movsd  -0x10(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xddb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1246 <flodivmod+0x116>
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     125e <flodivmod+0x12e>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flodivmod>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movapd %xmm1,(%rsp)
movapd %xmm0,0x20(%rsp)
divsd  %xmm1,%xmm0
lea    0x30(%rsp),%rdi
call   1030 <modf@plt>
movsd  0x30(%rsp),%xmm2
mulsd  (%rsp),%xmm2
movapd 0x20(%rsp),%xmm0
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    $0x1,%al
call   1050 <isinf@plt>
test   %eax,%eax
je     11a0 <flodivmod+0x70>
movapd (%rsp),%xmm0
mov    $0x1,%al
call   1050 <isinf@plt>
test   %eax,%eax
jne    11a0 <flodivmod+0x70>
movapd (%rsp),%xmm0
mov    $0x1,%al
call   1040 <isnan@plt>
test   %eax,%eax
je     1219 <flodivmod+0xe9>
movapd 0x20(%rsp),%xmm3
movsd  0x18(%rsp),%xmm5
subsd  %xmm5,%xmm3
movapd (%rsp),%xmm4
divsd  %xmm4,%xmm3
movapd %xmm5,%xmm0
mulsd  %xmm4,%xmm0
xorpd  %xmm1,%xmm1
cmpltsd %xmm1,%xmm0
test   %rbx,%rbx
je     11ef <flodivmod+0xbf>
andpd  %xmm0,%xmm4
movsd  0xe2d(%rip),%xmm1
movapd %xmm0,%xmm2
andnpd %xmm1,%xmm2
orpd   %xmm4,%xmm2
addsd  %xmm2,%xmm5
movsd  %xmm5,(%rbx)
test   %r14,%r14
je     1211 <flodivmod+0xe1>
movsd  0xe04(%rip),%xmm1
addsd  %xmm3,%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
movsd  %xmm0,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
movapd 0x20(%rsp),%xmm3
movapd (%rsp),%xmm4
movsd  0x18(%rsp),%xmm5
jmp    11b9 <flodivmod+0x89>

LLVM IR (-O0):
define void @flodivmod(double %0, double %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%12 = load double, double* %5
%13 = load double, double* %6
%14 = fdiv double %12, %13
%15 = call double @modf(double %14, double* %11)
%16 = load double, double* %5
%17 = load double, double* %11
%18 = load double, double* %6
%19 = fneg double %17
%20 = call double @llvm.fmuladd.f64(double %19, double %18, double %16)
store double %20, double* %10
%21 = load double, double* %5
%22 = call i32 (double, ...) bitcast (i32 (...)* @isinf to i32 (double, ...)*)(double %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %4
%25 = load double, double* %6
%26 = call i32 (double, ...) bitcast (i32 (...)* @isinf to i32 (double, ...)*)(double %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %24
%29 = load double, double* %6
%30 = call i32 (double, ...) bitcast (i32 (...)* @isnan to i32 (double, ...)*)(double %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = load double, double* %5
store double %33, double* %9
br label %40
34: ; preds = %28, %24, %4
%35 = load double, double* %5
%36 = load double, double* %10
%37 = fsub double %35, %36
%38 = load double, double* %6
%39 = fdiv double %37, %38
store double %39, double* %9
br label %40
40: ; preds = %34, %32
%41 = load double, double* %6
%42 = load double, double* %10
%43 = fmul double %41, %42
%44 = fcmp olt double %43, 0.000000e+00
br i1 %44, label %45, label %51
45: ; preds = %40
%46 = load double, double* %6
%47 = load double, double* %10
%48 = fadd double %47, %46
store double %48, double* %10
%49 = load double, double* %9
%50 = fsub double %49, 1.000000e+00
store double %50, double* %9
br label %51
51: ; preds = %45, %40
%52 = load double*, double** %8
%53 = icmp ne double* %52, null
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load double, double* %10
%56 = load double*, double** %8
store double %55, double* %56
br label %57
57: ; preds = %54, %51
%58 = load double*, double** %7
%59 = icmp ne double* %58, null
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load double, double* %9
%62 = load double*, double** %7
store double %61, double* %62
br label %63
63: ; preds = %60, %57
ret void
}

LLVM IR (-O2):
define void @flodivmod(double %0, double %1, double* writeonly %2, double* writeonly %3) {
%5 = alloca double
%6 = bitcast double* %5 to i8*
%7 = fdiv double %0, %1
%8 = call double @modf(double %7, double* %5)
%9 = load double, double* %5
%10 = fneg double %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double %1, double %0)
%12 = tail call i32 (double, ...) bitcast (i32 (...)* @isinf to i32 (double, ...)*)(double %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %4
%15 = tail call i32 (double, ...) bitcast (i32 (...)* @isinf to i32 (double, ...)*)(double %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i32 (double, ...) bitcast (i32 (...)* @isnan to i32 (double, ...)*)(double %1)
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17, %14, %4
%21 = fsub double %0, %11
%22 = fdiv double %21, %1
br label %23
23: ; preds = %17, %20
%24 = phi double [ %22, %20 ], [ %0, %17 ]
%25 = fmul double %11, %1
%26 = fcmp olt double %25, 0.000000e+00
%27 = fadd double %24, -1.000000e+00
%28 = select i1 %26, double %27, double %24
%29 = icmp eq double* %3, null
br i1 %29, label %33, label %30
30: ; preds = %23
%31 = select i1 %26, double %1, double -0.000000e+00
%32 = fadd double %11, %31
store double %32, double* %3
br label %33
33: ; preds = %30, %23
%34 = icmp eq double* %2, null
br i1 %34, label %36, label %35
35: ; preds = %33
store double %28, double* %2
br label %36
36: ; preds = %35, %33
ret void
}