#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 intCompSimp(double *, double, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int n;
  int i;
  double a = 2;
  double b = 7;
  double *X;
  double h;
  double integral;
  printf("dame el numero de partes a dividir el intervalo:");
  scanf("%d", &n);
  X = (double *)malloc((n + 1) * sizeof(double));
  h = (b - a) / n;
  for (i = 0; i < n + 1; i++)
    X[i] = a + h * i;
  integral = intCompSimp(X, h, n);
  printf("estimacion de la integral--> %lf\n", integral);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe8c(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1210 <main+0xc0>
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <main+0x7d>
mov    -0x28(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%esi
call   1030 <intCompSimp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe12(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe26(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf18(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf3b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
lea    0x8(,%rax,8),%edi
call   1060 <malloc@plt>
mov    0x4(%rsp),%esi
cvtsi2sd %esi,%xmm1
movsd  0xe70(%rip),%xmm0
divsd  %xmm1,%xmm0
test   %esi,%esi
js     12ed <main+0x19d>
lea    0x1(%rsi),%r9
cmp    $0x3,%esi
jae    11ac <main+0x5c>
xor    %edx,%edx
jmp    12bd <main+0x16d>
mov    %r9d,%edx
and    $0xfffffffc,%edx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rdx),%rcx
mov    %rcx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rcx,%rcx
je     1313 <main+0x1c3>
mov    %r8,%rcx
and    $0xfffffffffffffffe,%rcx
movdqa 0xe2f(%rip),%xmm3
xor    %edi,%edi
movdqa 0xe34(%rip),%xmm8
movapd 0xe3c(%rip),%xmm4
movdqa 0xe43(%rip),%xmm9
movdqa 0xe4b(%rip),%xmm6
movdqa 0xe53(%rip),%xmm7
nopl   (%rax)
movdqa %xmm3,%xmm2
cvtdq2pd %xmm3,%xmm5
paddd  %xmm8,%xmm2
cvtdq2pd %xmm2,%xmm2
mulpd  %xmm1,%xmm5
addpd  %xmm4,%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
movupd %xmm5,(%rax,%rdi,8)
movupd %xmm2,0x10(%rax,%rdi,8)
movdqa %xmm3,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm3,%xmm5
cvtdq2pd %xmm2,%xmm2
paddd  %xmm6,%xmm5
cvtdq2pd %xmm5,%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm5
addpd  %xmm4,%xmm5
movupd %xmm2,0x20(%rax,%rdi,8)
movupd %xmm5,0x30(%rax,%rdi,8)
add    $0x8,%rdi
paddd  %xmm7,%xmm3
add    $0xfffffffffffffffe,%rcx
jne    1210 <main+0xc0>
test   $0x1,%r8b
je     12b8 <main+0x168>
cvtdq2pd %xmm3,%xmm2
paddd  0xd8f(%rip),%xmm3
cvtdq2pd %xmm3,%xmm3
mulpd  %xmm1,%xmm2
movapd 0xd8f(%rip),%xmm4
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm4,%xmm3
movupd %xmm2,(%rax,%rdi,8)
movupd %xmm3,0x10(%rax,%rdi,8)
cmp    %r9,%rdx
je     12ed <main+0x19d>
movsd  0xd43(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm2,%xmm2
cvtsi2sd %edx,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rax,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%r9
jne    12d0 <main+0x180>
mov    %rax,%rdi
call   1030 <intCompSimp@plt>
lea    0xda8(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdbc(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
pop    %rcx
ret
movdqa 0xcf5(%rip),%xmm3
xor    %edi,%edi
test   $0x1,%r8b
jne    1285 <main+0x135>
jmp    12b8 <main+0x168>

LLVM IR (-O0):
@.str = [49 x i8] c"dame el numero de partes a dividir el intervalo:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"estimacion de la integral--> %lf\0A\00"
@.str.3 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
store double 2.000000e+00, double* %4
store double 7.000000e+00, double* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to double*
store double* %17, double** %6
%18 = load double, double* %5
%19 = load double, double* %4
%20 = fsub double %18, %19
%21 = load i32, i32* %2
%22 = sitofp i32 %21 to double
%23 = fdiv double %20, %22
store double %23, double* %7
store i32 0, i32* %3
br label %24
24: ; preds = %39, %0
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %42
29: ; preds = %24
%30 = load double, double* %4
%31 = load double, double* %7
%32 = load i32, i32* %3
%33 = sitofp i32 %32 to double
%34 = call double @llvm.fmuladd.f64(double %31, double %33, double %30)
%35 = load double*, double** %6
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
store double %34, double* %38
br label %39
39: ; preds = %29
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %24
42: ; preds = %24
%43 = load double*, double** %6
%44 = load double, double* %7
%45 = load i32, i32* %2
%46 = call double @intCompSimp(double* %43, double %44, i32 %45)
store double %46, double* %8
%47 = load double, double* %8
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %47)
%49 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [49 x i8] c"dame el numero de partes a dividir el intervalo:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"estimacion de la integral--> %lf\0A\00"
@.str.3 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl i32 %5, 3
%7 = add i32 %6, 8
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = load i32, i32* %1
%11 = sitofp i32 %10 to double
%12 = fdiv double 5.000000e+00, %11
%13 = icmp slt i32 %10, 0
br i1 %13, label %85, label %14
14: ; preds = %0
%15 = add nuw i32 %10, 1
%16 = zext i32 %15 to i64
%17 = icmp ult i32 %10, 3
br i1 %17, label %75, label %18
18: ; preds = %14
%19 = and i64 %16, 4294967292
%20 = insertelement <2 x double> poison, double %12, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = insertelement <2 x double> poison, double %12, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = add nsw i64 %19, -4
%25 = lshr exact i64 %24, 2
%26 = add nuw nsw i64 %25, 1
%27 = and i64 %26, 1
%28 = icmp eq i64 %24, 0
br i1 %28, label %59, label %29
29: ; preds = %18
%30 = and i64 %26, 9223372036854775806
br label %31
31: ; preds = %31, %29
%32 = phi i64 [ 0, %29 ], [ %55, %31 ]
%33 = phi <2 x i32> [ <i32 0, i32 1>, %29 ], [ %56, %31 ]
%34 = phi i64 [ 0, %29 ], [ %57, %31 ]
%35 = add <2 x i32> %33, <i32 2, i32 2>
%36 = sitofp <2 x i32> %33 to <2 x double>
%37 = sitofp <2 x i32> %35 to <2 x double>
%38 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %36, <2 x double> <double 2.000000e+00, double 2.000000e+00>)
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %37, <2 x double> <double 2.000000e+00, double 2.000000e+00>)
%40 = getelementptr inbounds double, double* %9, i64 %32
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> %38, <2 x double>* %41
%42 = getelementptr inbounds double, double* %40, i64 2
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> %39, <2 x double>* %43
%44 = or i64 %32, 4
%45 = add <2 x i32> %33, <i32 4, i32 4>
%46 = add <2 x i32> %33, <i32 6, i32 6>
%47 = sitofp <2 x i32> %45 to <2 x double>
%48 = sitofp <2 x i32> %46 to <2 x double>
%49 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %47, <2 x double> <double 2.000000e+00, double 2.000000e+00>)
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %48, <2 x double> <double 2.000000e+00, double 2.000000e+00>)
%51 = getelementptr inbounds double, double* %9, i64 %44
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %49, <2 x double>* %52
%53 = getelementptr inbounds double, double* %51, i64 2
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %50, <2 x double>* %54
%55 = add nuw i64 %32, 8
%56 = add <2 x i32> %33, <i32 8, i32 8>
%57 = add i64 %34, 2
%58 = icmp eq i64 %57, %30
br i1 %58, label %59, label %31
59: ; preds = %31, %18
%60 = phi i64 [ 0, %18 ], [ %55, %31 ]
%61 = phi <2 x i32> [ <i32 0, i32 1>, %18 ], [ %56, %31 ]
%62 = icmp eq i64 %27, 0
br i1 %62, label %73, label %63
63: ; preds = %59
%64 = add <2 x i32> %61, <i32 2, i32 2>
%65 = sitofp <2 x i32> %61 to <2 x double>
%66 = sitofp <2 x i32> %64 to <2 x double>
%67 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %65, <2 x double> <double 2.000000e+00, double 2.000000e+00>)
%68 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %66, <2 x double> <double 2.000000e+00, double 2.000000e+00>)
%69 = getelementptr inbounds double, double* %9, i64 %60
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %67, <2 x double>* %70
%71 = getelementptr inbounds double, double* %69, i64 2
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %68, <2 x double>* %72
br label %73
73: ; preds = %59, %63
%74 = icmp eq i64 %19, %16
br i1 %74, label %85, label %75
75: ; preds = %14, %73
%76 = phi i64 [ 0, %14 ], [ %19, %73 ]
br label %77
77: ; preds = %75, %77
%78 = phi i64 [ %83, %77 ], [ %76, %75 ]
%79 = trunc i64 %78 to i32
%80 = sitofp i32 %79 to double
%81 = call double @llvm.fmuladd.f64(double %12, double %80, double 2.000000e+00)
%82 = getelementptr inbounds double, double* %9, i64 %78
store double %81, double* %82
%83 = add nuw nsw i64 %78, 1
%84 = icmp eq i64 %83, %16
br i1 %84, label %85, label %77
85: ; preds = %77, %73, %0
%86 = call double @intCompSimp(double* %9, double %12, i32 %10)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %86)
%88 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}