#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 */
scalar_t__ intGauss(double, double, double, double);
int /*<<< orphan*/ printf(char *, double);
double sqrt(int);
int /*<<< orphan*/ system(char *);
int main() {
  double a = 2;
  double b = 5;
  double x0 = -sqrt(1 / 3.);
  double x1 = sqrt(1 / 3.);
  ;
  double integral = 0;
  double h = (b - a) / 10;
  double X[10 + 1];
  int i;
  for (i = 0; i < 10 + 1; i++)
    X[i] = a + h * i;
  for (i = 0; i < 10; i++)
    integral += intGauss(x0, x1, X[i], X[i + 1]);
  printf("estimacion de la integral: %lf\n", integral);
  system("PAUSE");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xor    %edi,%edi
call   1060 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
xor    %edi,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0xb,-0x94(%rbp)
jge    1213 <main+0xd3>
movsd  -0x10(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x94(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x94(%rbp),%rax
movsd  %xmm0,-0x90(%rbp,%rax,8)
ff ff
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11c8 <main+0x88>
movl   $0x0,-0x94(%rbp)
cmpl   $0xa,-0x94(%rbp)
jge    1280 <main+0x140>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movslq -0x94(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm2
ff ff
mov    -0x94(%rbp),%eax
add    $0x1,%eax
cltq
movsd  -0x90(%rbp,%rax,8),%xmm3
ff ff
call   1050 <intGauss@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    121d <main+0xdd>
movsd  -0x30(%rbp),%xmm0
lea    0xd8c(%rip),%rdi
call   1040 <printf@plt>
lea    0xda0(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
xor    %edi,%edi
call   1060 <sqrt@plt>
movaps %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
xorps  0xe94(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0xe97(%rip),%xmm2
movsd  0xe97(%rip),%xmm3
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe85(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xe6a(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe5b(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xe40(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe31(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xe16(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe07(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xdec(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xddd(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xdc2(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdb3(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xd98(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xd89(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xd6e(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xd5f(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xd44(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xd35(%rip),%xmm3
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xd1a(%rip),%xmm2
call   1050 <intGauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
lea    0xd11(%rip),%rdi
call   1040 <printf@plt>
lea    0xd25(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"estimacion de la integral: %lf\0A\00"
@.str.1 = [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 double
%7 = alloca double
%8 = alloca [11 x double]
%9 = alloca i32
store i32 0, i32* %1
store double 2.000000e+00, double* %2
store double 5.000000e+00, double* %3
%10 = call double @sqrt(i32 0)
%11 = fneg double %10
store double %11, double* %4
%12 = call double @sqrt(i32 0)
store double %12, double* %5
store double 0.000000e+00, double* %6
%13 = load double, double* %3
%14 = load double, double* %2
%15 = fsub double %13, %14
%16 = fdiv double %15, 1.000000e+01
store double %16, double* %7
store i32 0, i32* %9
br label %17
17: ; preds = %29, %0
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 11
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load double, double* %2
%22 = load double, double* %7
%23 = load i32, i32* %9
%24 = sitofp i32 %23 to double
%25 = call double @llvm.fmuladd.f64(double %22, double %24, double %21)
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [11 x double], [11 x double]* %8, i64 0, i64 %27
store double %25, double* %28
br label %29
29: ; preds = %20
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %17
32: ; preds = %17
store i32 0, i32* %9
br label %33
33: ; preds = %52, %32
%34 = load i32, i32* %9
%35 = icmp slt i32 %34, 10
br i1 %35, label %36, label %55
36: ; preds = %33
%37 = load double, double* %4
%38 = load double, double* %5
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [11 x double], [11 x double]* %8, i64 0, i64 %40
%42 = load double, double* %41
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [11 x double], [11 x double]* %8, i64 0, i64 %45
%47 = load double, double* %46
%48 = call i64 @intGauss(double %37, double %38, double %42, double %47)
%49 = sitofp i64 %48 to double
%50 = load double, double* %6
%51 = fadd double %50, %49
store double %51, double* %6
br label %52
52: ; preds = %36
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %33
55: ; preds = %33
%56 = load double, double* %6
%57 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %56)
%58 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@.str = [32 x i8] c"estimacion de la integral: %lf\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = tail call double @sqrt(i32 0)
%2 = tail call double @sqrt(i32 0)
%3 = fneg double %1
%4 = tail call i64 @intGauss(double %3, double %2, double 2.000000e+00, double 2.300000e+00)
%5 = sitofp i64 %4 to double
%6 = tail call i64 @intGauss(double %3, double %2, double 2.300000e+00, double 2.600000e+00)
%7 = sitofp i64 %6 to double
%8 = fadd double %5, %7
%9 = tail call i64 @intGauss(double %3, double %2, double 2.600000e+00, double 2.900000e+00)
%10 = sitofp i64 %9 to double
%11 = fadd double %8, %10
%12 = tail call i64 @intGauss(double %3, double %2, double 2.900000e+00, double 3.200000e+00)
%13 = sitofp i64 %12 to double
%14 = fadd double %11, %13
%15 = tail call i64 @intGauss(double %3, double %2, double 3.200000e+00, double 3.500000e+00)
%16 = sitofp i64 %15 to double
%17 = fadd double %14, %16
%18 = tail call i64 @intGauss(double %3, double %2, double 3.500000e+00, double 3.800000e+00)
%19 = sitofp i64 %18 to double
%20 = fadd double %17, %19
%21 = tail call i64 @intGauss(double %3, double %2, double 3.800000e+00, double 4.100000e+00)
%22 = sitofp i64 %21 to double
%23 = fadd double %20, %22
%24 = tail call i64 @intGauss(double %3, double %2, double 4.100000e+00, double 4.400000e+00)
%25 = sitofp i64 %24 to double
%26 = fadd double %23, %25
%27 = tail call i64 @intGauss(double %3, double %2, double 4.400000e+00, double 4.700000e+00)
%28 = sitofp i64 %27 to double
%29 = fadd double %26, %28
%30 = tail call i64 @intGauss(double %3, double %2, double 4.700000e+00, double 5.000000e+00)
%31 = sitofp i64 %30 to double
%32 = fadd double %29, %31
%33 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %32)
%34 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}