#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*/ dd_add(double *, double *, double *);
int /*<<< orphan*/ dd_sub(double *, double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int add_sub_of_pi_e(void) {
  const double pi_hi = 3.141592653589793116e+00;
  const double pi_lo = 1.224646799147353207e-16;
  double dd_pi[2];
  const double e_hi = 2.718281828459045091e+00;
  const double e_lo = 1.445646891729250158e-16;
  double dd_e[2];
  double pi_and_e[2];
  double pi_and_e_minus_pi[2];
  printf("\ntesting pi + e - pi ...\n");
  dd_pi[0] = pi_hi;
  dd_e[0] = e_hi;
  dd_pi[1] = pi_lo;
  dd_e[1] = e_lo;
  printf("      e hi = %21.14e         e lo = %21.14e\n", dd_e[0], dd_e[1]);
  dd_add(dd_pi, dd_e, pi_and_e);
  printf("   pi+e hi = %21.14e      pi+e lo = %21.14e\n", pi_and_e[0],
         pi_and_e[1]);
  dd_sub(pi_and_e, dd_pi, pi_and_e_minus_pi);
  printf("pi+e-pi hi = %21.14e   pi+e-pi lo = %21.14e\n", pi_and_e_minus_pi[0],
         pi_and_e_minus_pi[1]);
  return 0;
}


x86 assembly (clang, -O0):
<add_sub_of_pi_e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  0xed8(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xebb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xe96(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe81(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe6c(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe7b(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1050 <dd_add@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
lea    0xe7f(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1030 <dd_sub@plt>
movsd  -0x60(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
lea    0xe83(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_sub_of_pi_e>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xf69(%rip),%rdi
call   1030 <puts@plt>
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xebe(%rip),%rdi
movsd  0xea6(%rip),%xmm0
movsd  0xea6(%rip),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0x30(%rsp),%r14
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <dd_add@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xea7(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <dd_sub@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xead(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0Atesting pi + e - pi ...\0A\00"
@.str.1 = [45 x i8] c" e hi = %21.14e e lo = %21.14e\0A\00"
@.str.2 = [45 x i8] c" pi+e hi = %21.14e pi+e lo = %21.14e\0A\00"
@.str.3 = [45 x i8] c"pi+e-pi hi = %21.14e pi+e-pi lo = %21.14e\0A\00"
define i32 @add_sub_of_pi_e() {
%1 = alloca double
%2 = alloca double
%3 = alloca [2 x double]
%4 = alloca double
%5 = alloca double
%6 = alloca [2 x double]
%7 = alloca [2 x double]
%8 = alloca [2 x double]
store double 0x400921FB54442D18, double* %1
store double 0x3CA1A62633145C07, double* %2
store double 0x4005BF0A8B145769, double* %4
store double 0x3CA4D57EE2B1013A, double* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
store double 0x400921FB54442D18, double* %10
%11 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
store double 0x4005BF0A8B145769, double* %11
%12 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
store double 0x3CA1A62633145C07, double* %12
%13 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 1
store double 0x3CA4D57EE2B1013A, double* %13
%14 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
%15 = load double, double* %14
%16 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 1
%17 = load double, double* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %15, double %17)
%19 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%20 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
%21 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%22 = call i32 @dd_add(double* %19, double* %20, double* %21)
%23 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%24 = load double, double* %23
%25 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
%26 = load double, double* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %24, double %26)
%28 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%29 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%30 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%31 = call i32 @dd_sub(double* %28, double* %29, double* %30)
%32 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%33 = load double, double* %32
%34 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 1
%35 = load double, double* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), double %33, double %35)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [45 x i8] c" e hi = %21.14e e lo = %21.14e\0A\00"
@.str.2 = [45 x i8] c" pi+e hi = %21.14e pi+e lo = %21.14e\0A\00"
@.str.3 = [45 x i8] c"pi+e-pi hi = %21.14e pi+e-pi lo = %21.14e\0A\00"
@str = [25 x i8] c"\0Atesting pi + e - pi ...\00"
define i32 @add_sub_of_pi_e() {
%1 = alloca <2 x double>
%2 = alloca <2 x double>
%3 = alloca [2 x double]
%4 = alloca [2 x double]
%5 = bitcast <2 x double>* %1 to i8*
%6 = bitcast <2 x double>* %2 to i8*
%7 = bitcast [2 x double]* %3 to i8*
%8 = bitcast [2 x double]* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%10 = getelementptr inbounds <2 x double>, <2 x double>* %1, i64 0, i64 0
%11 = getelementptr inbounds <2 x double>, <2 x double>* %2, i64 0, i64 0
store <2 x double> <double 0x400921FB54442D18, double 0x3CA1A62633145C07>, <2 x double>* %1
store <2 x double> <double 0x4005BF0A8B145769, double 0x3CA4D57EE2B1013A>, <2 x double>* %2
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double 0x4005BF0A8B145769, double 0x3CA4D57EE2B1013A)
%13 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%14 = call i32 @dd_add(double* %10, double* %11, double* %13)
%15 = load double, double* %13
%16 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
%17 = load double, double* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %15, double %17)
%19 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%20 = call i32 @dd_sub(double* %13, double* %10, double* %19)
%21 = load double, double* %19
%22 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 1
%23 = load double, double* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), double %21, double %23)
ret i32 0
}