#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 /*<<< orphan*/ double_split(double, double *, double *);
double double_mul_err(double a, double b, double *err) {
  double a_hi, a_lo, b_hi, b_lo;
  double p = a * b;
  volatile double c, d;
  double_split(a, &a_hi, &a_lo);
  double_split(b, &b_hi, &b_lo);
  c = a_hi * b_hi - p;
  d = c + a_hi * b_lo + a_lo * b_hi;
  *err = d + a_lo * b_lo;
  return p;
}


x86 assembly (clang, -O0):
<double_mul_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <double_split@plt>
movsd  -0x10(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <double_split@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_mul_err>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
movsd  %xmm1,(%rsp)
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
lea    0x38(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1030 <double_split@plt>
lea    0x28(%rsp),%rdi
lea    0x20(%rsp),%rsi
movsd  (%rsp),%xmm0
call   1030 <double_split@plt>
movsd  0x38(%rsp),%xmm4
movsd  0x28(%rsp),%xmm1
movapd %xmm4,%xmm2
mulsd  %xmm1,%xmm2
movsd  0x8(%rsp),%xmm0
subsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  0x20(%rsp),%xmm2
mulsd  %xmm2,%xmm4
addsd  0x18(%rsp),%xmm4
movsd  0x30(%rsp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm2,%xmm3
addsd  0x10(%rsp),%xmm3
movsd  %xmm3,(%rbx)
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @double_mul_err(double %0, double %1, double* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %4
store double %1, double* %5
store double* %2, double** %6
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fmul double %14, %15
store double %16, double* %11
%17 = load double, double* %4
%18 = call i32 @double_split(double %17, double* %7, double* %8)
%19 = load double, double* %5
%20 = call i32 @double_split(double %19, double* %9, double* %10)
%21 = load double, double* %7
%22 = load double, double* %9
%23 = load double, double* %11
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %21, double %22, double %24)
store volatile double %25, double* %12
%26 = load volatile double, double* %12
%27 = load double, double* %7
%28 = load double, double* %10
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double %26)
%30 = load double, double* %8
%31 = load double, double* %9
%32 = call double @llvm.fmuladd.f64(double %30, double %31, double %29)
store volatile double %32, double* %13
%33 = load volatile double, double* %13
%34 = load double, double* %8
%35 = load double, double* %10
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %33)
%37 = load double*, double** %6
store double %36, double* %37
%38 = load double, double* %11
ret double %38
}

LLVM IR (-O2):
define double @double_mul_err(double %0, double %1, double* nocapture writeonly %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = bitcast double* %4 to i8*
%11 = bitcast double* %5 to i8*
%12 = bitcast double* %6 to i8*
%13 = bitcast double* %7 to i8*
%14 = fmul double %0, %1
%15 = bitcast double* %8 to i8*
%16 = bitcast double* %9 to i8*
%17 = call i32 @double_split(double %0, double* %4, double* %5)
%18 = call i32 @double_split(double %1, double* %6, double* %7)
%19 = load double, double* %4
%20 = load double, double* %6
%21 = fneg double %14
%22 = call double @llvm.fmuladd.f64(double %19, double %20, double %21)
store volatile double %22, double* %8
%23 = load volatile double, double* %8
%24 = load double, double* %7
%25 = call double @llvm.fmuladd.f64(double %19, double %24, double %23)
%26 = load double, double* %5
%27 = call double @llvm.fmuladd.f64(double %26, double %20, double %25)
store volatile double %27, double* %9
%28 = load volatile double, double* %9
%29 = call double @llvm.fmuladd.f64(double %26, double %24, double %28)
store double %29, double* %2
ret double %14
}