#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*/ td_fast_renorm(double, double, double, double, double *,
                                  double *, double *);
void td_add(const double *a, const double *b, double *c) {
  double f0, f1, f2, f3, e;
  f2 = dd_two_sum(a[2], b[2], &f3);
  f1 = dd_two_sum(a[1], b[1], &e);
  f2 = dd_two_sum(f2, e, &e);
  f3 += e;
  f0 = dd_two_sum(a[0], b[0], &e);
  f1 = dd_two_sum(f1, e, &e);
  f2 = dd_two_sum(f2, e, &e);
  f3 += e;
  td_fast_renorm(f0, f1, f2, f3, &c[0], &c[1], &c[2]);
}


x86 assembly (clang, -O0):
<td_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
lea    -0x38(%rbp),%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
lea    -0x40(%rbp),%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    -0x40(%rbp),%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
lea    -0x40(%rbp),%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    -0x40(%rbp),%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    -0x40(%rbp),%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x8,%rsi
mov    -0x18(%rbp),%rdx
add    $0x10,%rdx
call   1030 <td_fast_renorm@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<td_add>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
movsd  0x10(%rdi),%xmm0
movsd  0x10(%rsi),%xmm1
lea    0x8(%rsp),%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rbx),%xmm0
movsd  0x8(%r12),%xmm1
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mov    %r15,%rdi
call   1040 <dd_two_sum@plt>
movsd  (%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x20(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  (%rbx),%xmm0
movsd  (%r12),%xmm1
mov    %r15,%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
mov    %r15,%rdi
call   1040 <dd_two_sum@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
mov    %r15,%rdi
call   1040 <dd_two_sum@plt>
movsd  (%rsp),%xmm3
addsd  0x8(%rsp),%xmm3
movaps %xmm0,%xmm2
movsd  %xmm3,0x8(%rsp)
lea    0x8(%r14),%rsi
lea    0x10(%r14),%rdx
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    %r14,%rdi
call   1030 <td_fast_renorm@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @td_add(double* nocapture %0, double* nocapture %1, double* %2) {
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %4 to i8*
%7 = bitcast double* %5 to i8*
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 2
%11 = load double, double* %10
%12 = call double @dd_two_sum(double %9, double %11, double* %4)
%13 = getelementptr inbounds double, double* %0, i64 1
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 1
%16 = load double, double* %15
%17 = call double @dd_two_sum(double %14, double %16, double* %5)
%18 = load double, double* %5
%19 = call double @dd_two_sum(double %12, double %18, double* %5)
%20 = load double, double* %5
%21 = load double, double* %4
%22 = fadd double %20, %21
store double %22, double* %4
%23 = load double, double* %0
%24 = load double, double* %1
%25 = call double @dd_two_sum(double %23, double %24, double* %5)
%26 = load double, double* %5
%27 = call double @dd_two_sum(double %17, double %26, double* %5)
%28 = load double, double* %5
%29 = call double @dd_two_sum(double %19, double %28, double* %5)
%30 = load double, double* %5
%31 = load double, double* %4
%32 = fadd double %30, %31
store double %32, double* %4
%33 = getelementptr inbounds double, double* %2, i64 1
%34 = getelementptr inbounds double, double* %2, i64 2
%35 = call i32 @td_fast_renorm(double %25, double %27, double %29, double %32, double* %2, double* %33, double* %34)
ret void
}