#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 P(int, double);
double exp(double);
double fabs(double);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ system(char *);
int main() {
  double x = 1;
  double f;
  double sol;
  double error;
  int grado = 10;
  f = P(grado, x);
  printf("estimacion---> P: %lf\n", f);
  sol = exp(x / 2.);
  error = fabs(sol - f);
  printf("error---> error: %.15lf\n", error);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0xa,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
call   1030 <P@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe9f(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movaps 0xe4e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xec7(%rip),%xmm0
mov    $0xa,%edi
call   1030 <P@plt>
movsd  %xmm0,(%rsp)
lea    0xed1(%rip),%rdi
call   1050 <printf@plt>
movsd  0xeac(%rip),%xmm0
subsd  (%rsp),%xmm0
andpd  0xea7(%rip),%xmm0
lea    0xec7(%rip),%rdi
call   1050 <printf@plt>
lea    0xed4(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"estimacion---> P: %lf\0A\00"
@.str.1 = [25 x i8] c"error---> error: %.15lf\0A\00"
@.str.2 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store i32 10, i32* %6
%7 = load i32, i32* %6
%8 = load double, double* %2
%9 = call double @P(i32 %7, double %8)
store double %9, double* %3
%10 = load double, double* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %10)
%12 = load double, double* %2
%13 = fdiv double %12, 2.000000e+00
%14 = call double @exp(double %13)
store double %14, double* %4
%15 = load double, double* %4
%16 = load double, double* %3
%17 = fsub double %15, %16
%18 = call double @llvm.fabs.f64(double %17)
store double %18, double* %5
%19 = load double, double* %5
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"estimacion---> P: %lf\0A\00"
@.str.1 = [25 x i8] c"error---> error: %.15lf\0A\00"
@.str.2 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = tail call double @P(i32 10, double 1.000000e+00)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %1)
%3 = fsub double 0x3FFA61298E1E069C, %1
%4 = tail call double @llvm.fabs.f64(double %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %4)
%6 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}