#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 const, double const, double *);
int /*<<< orphan*/ qd_renorm5(double *, double *, double *, double *, double *);
int /*<<< orphan*/ qd_three_sum(double *, double *, double *);
void qd_add_dd(const double *a, const double *b, double *c) {
  double s0, s1, s2, s3, t0, t1;
  s0 = dd_two_sum(a[0], b[0], &t0);
  s1 = dd_two_sum(a[1], b[1], &t1);
  s1 = dd_two_sum(s1, t0, &t0);
  s2 = a[2];
  qd_three_sum(&s2, &t0, &t1);
  s3 = dd_two_sum(t0, a[3], &t0);
  t0 += t1;
  qd_renorm5(&s0, &s1, &s2, &s3, &t0);
  c[0] = s0;
  c[1] = s1;
  c[2] = s2;
  c[3] = s3;
}


x86 assembly (clang, -O0):
<qd_add_dd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
lea    -0x40(%rbp),%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
lea    -0x48(%rbp),%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    -0x40(%rbp),%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1050 <qd_three_sum@plt>
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
lea    -0x40(%rbp),%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
call   1040 <qd_renorm5@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qd_add_dd>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm1
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%r12),%xmm0
movsd  0x8(%rbx),%xmm1
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <dd_two_sum@plt>
movsd  (%rsp),%xmm1
mov    %r14,%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <qd_three_sum@plt>
movsd  (%rsp),%xmm0
movsd  0x18(%r12),%xmm1
mov    %r14,%rdi
call   1030 <dd_two_sum@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0x8(%rsp),%rcx
mov    %r13,%rdx
mov    %r14,%r8
call   1040 <qd_renorm5@plt>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%r15)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%r15)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%r15)
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @qd_add_dd(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
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
%16 = load double*, double** %5
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = call double @dd_two_sum(double %15, double %18, double* %11)
store double %19, double* %7
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = call double @dd_two_sum(double %22, double %25, double* %12)
store double %26, double* %8
%27 = load double, double* %8
%28 = load double, double* %11
%29 = call double @dd_two_sum(double %27, double %28, double* %11)
store double %29, double* %8
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
store double %32, double* %9
%33 = call i32 @qd_three_sum(double* %9, double* %11, double* %12)
%34 = load double, double* %11
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 3
%37 = load double, double* %36
%38 = call double @dd_two_sum(double %34, double %37, double* %11)
store double %38, double* %10
%39 = load double, double* %12
%40 = load double, double* %11
%41 = fadd double %40, %39
store double %41, double* %11
%42 = call i32 @qd_renorm5(double* %7, double* %8, double* %9, double* %10, double* %11)
%43 = load double, double* %7
%44 = load double*, double** %6
%45 = getelementptr inbounds double, double* %44, i64 0
store double %43, double* %45
%46 = load double, double* %8
%47 = load double*, double** %6
%48 = getelementptr inbounds double, double* %47, i64 1
store double %46, double* %48
%49 = load double, double* %9
%50 = load double*, double** %6
%51 = getelementptr inbounds double, double* %50, i64 2
store double %49, double* %51
%52 = load double, double* %10
%53 = load double*, double** %6
%54 = getelementptr inbounds double, double* %53, i64 3
store double %52, double* %54
ret void
}

LLVM IR (-O2):
define void @qd_add_dd(double* nocapture %0, double* nocapture %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 = bitcast double* %8 to i8*
%15 = bitcast double* %9 to i8*
%16 = load double, double* %0
%17 = load double, double* %1
%18 = call double @dd_two_sum(double %16, double %17, double* %8)
store double %18, double* %4
%19 = getelementptr inbounds double, double* %0, i64 1
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %1, i64 1
%22 = load double, double* %21
%23 = call double @dd_two_sum(double %20, double %22, double* %9)
%24 = load double, double* %8
%25 = call double @dd_two_sum(double %23, double %24, double* %8)
store double %25, double* %5
%26 = getelementptr inbounds double, double* %0, i64 2
%27 = load double, double* %26
store double %27, double* %6
%28 = call i32 @qd_three_sum(double* %6, double* %8, double* %9)
%29 = load double, double* %8
%30 = getelementptr inbounds double, double* %0, i64 3
%31 = load double, double* %30
%32 = call double @dd_two_sum(double %29, double %31, double* %8)
store double %32, double* %7
%33 = load double, double* %9
%34 = load double, double* %8
%35 = fadd double %33, %34
store double %35, double* %8
%36 = call i32 @qd_renorm5(double* %4, double* %5, double* %6, double* %7, double* %8)
%37 = load double, double* %4
store double %37, double* %2
%38 = load double, double* %5
%39 = getelementptr inbounds double, double* %2, i64 1
store double %38, double* %39
%40 = load double, double* %6
%41 = getelementptr inbounds double, double* %2, i64 2
store double %40, double* %41
%42 = load double, double* %7
%43 = getelementptr inbounds double, double* %2, i64 3
store double %42, double* %43
ret void
}