#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_exp(double *, double *);
int /*<<< orphan*/ dd_log(double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int log_exp_of_pi(void) {
  const double pi_hi = 3.141592653589793116e+00;
  const double pi_lo = 1.224646799147353207e-16;
  double dd_pi[2];
  double exp_of_pi[2];
  double log_of_exp_of_pi[2];
  printf("\ntesting log(exp(pi)) = pi ...\n");
  dd_pi[0] = pi_hi;
  dd_pi[1] = pi_lo;
  printf("          pi hi = %21.14e            pi lo = %21.14e\n", dd_pi[0],
         dd_pi[1]);
  dd_exp(dd_pi, exp_of_pi);
  printf("     exp(pi) hi = %21.14e       exp(pi) lo = %21.14e\n", exp_of_pi[0],
         exp_of_pi[1]);
  dd_log(exp_of_pi, log_of_exp_of_pi);
  printf("log(exp(pi)) hi = %21.14e  log(exp(pi)) lo = %21.14e\n",
         log_of_exp_of_pi[0], log_of_exp_of_pi[1]);
  return 0;
}


x86 assembly (clang, -O0):
<log_exp_of_pi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xea0(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xea5(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <dd_exp@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xeb6(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <dd_log@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xec7(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_exp_of_pi>:
push   %rbx
sub    $0x30,%rsp
lea    0xf76(%rip),%rdi
call   1040 <puts@plt>
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xebc(%rip),%rdi
movsd  0xea4(%rip),%xmm0
movsd  0xea4(%rip),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <dd_exp@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xeb6(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <dd_log@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xec8(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

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