#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 fun_int(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int /*<<< orphan*/ system(char *);
void simpson_13() {
  system("cls");
  double xi, xf, xm, fxi, fxf, fxm, r;
  printf("\n\t\t REGLA DE SIMPSON 1/3");
  printf("\n\n\n Digite el punto inicial (xi) = ");
  scanf("%lf", &xi);
  printf("\n\n\n Digite el punto final (xf) = ");
  scanf("%lf", &xf);
  xm = (xi + xf) / 2;
  fxi = fun_int(xi);
  fxf = fun_int(xf);
  fxm = fun_int(xm);
  r = ((xf - xi) / 6) * (fxi + (4 * fxm) + fxf);
  printf("\n\n\t El resultado de la integral es: %f", r);
  system("pause");
}


x86 assembly (clang, -O0):
<simpson_13>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xec9(%rip),%rdi
call   1030 <system@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xe60(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1060 <fun_int@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <fun_int@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <fun_int@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  0xe10(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
movsd  0xdf2(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
call   1030 <system@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simpson_13>:
push   %rbx
sub    $0x30,%rsp
lea    0xecc(%rip),%rdi
call   1030 <system@plt>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee5(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe4c(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
call   1060 <fun_int@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <fun_int@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <fun_int@plt>
movsd  0x8(%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
divsd  0xe13(%rip),%xmm1
mulsd  0xe13(%rip),%xmm0
addsd  0x28(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
lea    0xe6b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
call   1030 <system@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [25 x i8] c"\0A\09\09 REGLA DE SIMPSON 1/3\00"
@.str.2 = [36 x i8] c"\0A\0A\0A Digite el punto inicial (xi) = \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [34 x i8] c"\0A\0A\0A Digite el punto final (xf) = \00"
@.str.5 = [39 x i8] c"\0A\0A\09 El resultado de la integral es: %f\00"
@.str.6 = [6 x i8] c"pause\00"
define void @simpson_13() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %1)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
%14 = load double, double* %1
%15 = load double, double* %2
%16 = fadd double %14, %15
%17 = fdiv double %16, 2.000000e+00
store double %17, double* %3
%18 = load double, double* %1
%19 = call double @fun_int(double %18)
store double %19, double* %4
%20 = load double, double* %2
%21 = call double @fun_int(double %20)
store double %21, double* %5
%22 = load double, double* %3
%23 = call double @fun_int(double %22)
store double %23, double* %6
%24 = load double, double* %2
%25 = load double, double* %1
%26 = fsub double %24, %25
%27 = fdiv double %26, 6.000000e+00
%28 = load double, double* %4
%29 = load double, double* %6
%30 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %29, double %28)
%31 = load double, double* %5
%32 = fadd double %30, %31
%33 = fmul double %27, %32
store double %33, double* %7
%34 = load double, double* %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), double %34)
%36 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.1 = [25 x i8] c"\0A\09\09 REGLA DE SIMPSON 1/3\00"
@.str.2 = [36 x i8] c"\0A\0A\0A Digite el punto inicial (xi) = \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [34 x i8] c"\0A\0A\0A Digite el punto final (xf) = \00"
@.str.5 = [39 x i8] c"\0A\0A\09 El resultado de la integral es: %f\00"
@.str.6 = [6 x i8] c"pause\00"
define void @simpson_13() {
%1 = alloca double
%2 = alloca double
%3 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
%11 = load double, double* %1
%12 = load double, double* %2
%13 = fadd double %11, %12
%14 = fmul double %13, 5.000000e-01
%15 = call double @fun_int(double %11)
%16 = load double, double* %2
%17 = call double @fun_int(double %16)
%18 = call double @fun_int(double %14)
%19 = load double, double* %2
%20 = load double, double* %1
%21 = fsub double %19, %20
%22 = fdiv double %21, 6.000000e+00
%23 = call double @llvm.fmuladd.f64(double %18, double 4.000000e+00, double %15)
%24 = fadd double %17, %23
%25 = fmul double %24, %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), double %25)
%27 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret void
}