#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 */
double dd_two_sum(double, double, double *);
double qd_quick_three_accum(double *a, double *b, double c) {
  double s;
  int za, zb;
  s = dd_two_sum(*b, c, b);
  s = dd_two_sum(*a, s, a);
  za = (*a != 0.0) ? 1 : 0;
  zb = (*b != 0.0) ? 1 : 0;
  if ((za == 1) && (zb == 1))
    return s;
  if (zb == 0) {
    *b = *a;
    *a = s;
  } else
    *a = s;
  return 0.0;
}


x86 assembly (clang, -O0):
<qd_quick_three_accum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
xor    %eax,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
setp   %sil
setne  %dl
or     %sil,%dl
cmovne %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
xor    %eax,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
setp   %sil
setne  %dl
or     %sil,%dl
cmovne %ecx,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x2c(%rbp)
jne    11ca <qd_quick_three_accum+0xba>
cmpl   $0x1,-0x30(%rbp)
jne    11ca <qd_quick_three_accum+0xba>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120b <qd_quick_three_accum+0xfb>
cmpl   $0x0,-0x30(%rbp)
jne    11f6 <qd_quick_three_accum+0xe6>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1203 <qd_quick_three_accum+0xf3>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qd_quick_three_accum>:
push   %r14
push   %rbx
push   %rax
movaps %xmm0,%xmm1
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rsi),%xmm0
mov    %rsi,%rdi
call   1030 <dd_two_sum@plt>
movaps %xmm0,%xmm1
movsd  (%rbx),%xmm0
mov    %rbx,%rdi
call   1030 <dd_two_sum@plt>
movsd  (%rbx),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
movsd  (%r14),%xmm3
jne    114d <qd_quick_three_accum+0x3d>
jnp    1155 <qd_quick_three_accum+0x45>
ucomisd %xmm2,%xmm3
jne    1169 <qd_quick_three_accum+0x59>
jp     1169 <qd_quick_three_accum+0x59>
ucomisd %xmm2,%xmm3
jne    1162 <qd_quick_three_accum+0x52>
jp     1162 <qd_quick_three_accum+0x52>
movsd  %xmm1,(%r14)
movsd  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @qd_quick_three_accum(double* %0, double* %1, double %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
%11 = load double*, double** %6
%12 = load double, double* %11
%13 = load double, double* %7
%14 = load double*, double** %6
%15 = call double @dd_two_sum(double %12, double %13, double* %14)
store double %15, double* %8
%16 = load double*, double** %5
%17 = load double, double* %16
%18 = load double, double* %8
%19 = load double*, double** %5
%20 = call double @dd_two_sum(double %17, double %18, double* %19)
store double %20, double* %8
%21 = load double*, double** %5
%22 = load double, double* %21
%23 = fcmp une double %22, 0.000000e+00
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 1, i32 0
store i32 %25, i32* %9
%26 = load double*, double** %6
%27 = load double, double* %26
%28 = fcmp une double %27, 0.000000e+00
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 1, i32 0
store i32 %30, i32* %10
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %38
33: ; preds = %3
%34 = load i32, i32* %10
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = load double, double* %8
store double %37, double* %4
br label %51
38: ; preds = %33, %3
%39 = load i32, i32* %10
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = load double*, double** %5
%43 = load double, double* %42
%44 = load double*, double** %6
store double %43, double* %44
%45 = load double, double* %8
%46 = load double*, double** %5
store double %45, double* %46
br label %50
47: ; preds = %38
%48 = load double, double* %8
%49 = load double*, double** %5
store double %48, double* %49
br label %50
50: ; preds = %47, %41
store double 0.000000e+00, double* %4
br label %51
51: ; preds = %50, %36
%52 = load double, double* %4
ret double %52
}

LLVM IR (-O2):
define double @qd_quick_three_accum(double* %0, double* %1, double %2) {
%4 = load double, double* %1
%5 = tail call double @dd_two_sum(double %4, double %2, double* %1)
%6 = load double, double* %0
%7 = tail call double @dd_two_sum(double %6, double %5, double* %0)
%8 = load double, double* %0
%9 = fcmp une double %8, 0.000000e+00
%10 = load double, double* %1
%11 = fcmp une double %10, 0.000000e+00
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %16, label %13
13: ; preds = %3
br i1 %11, label %15, label %14
14: ; preds = %13
store double %8, double* %1
br label %15
15: ; preds = %13, %14
store double %7, double* %0
br label %16
16: ; preds = %3, %15
%17 = phi double [ 0.000000e+00, %15 ], [ %7, %3 ]
ret double %17
}