#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 *crear_vector(int);
double fun_int(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ sim_int(double, double, int, double *);
void simpson_combinado() {
  double h, a, b, *f, sum;
  int n, i;
  printf("SIMPSON COMBINADO\n");
  printf("Ingrese el inicio del intervalo\n");
  scanf("%lf", &a);
  printf("Ingrese el fin del intervalo\n");
  scanf("%lf", &b);
  printf("Ingrese el valor de pasos\n");
  scanf("%d", &n);
  h = (b - a) / n;
  f = crear_vector(n + 1);
  sum = a;
  for (i = 0; i <= n; ++i) {
    f[i] = fun_int(h * i);
  }
  printf("El resultado es %.5lf\n", sim_int(a, b, n, f));
}


x86 assembly (clang, -O0):
<simpson_combinado>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
call   1040 <crear_vector@plt>
mov    %rax,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     1238 <simpson_combinado+0xe8>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <fun_int@plt>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11fe <simpson_combinado+0xae>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <sim_int@plt>
mov    %eax,%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simpson_combinado>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe41(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%ebx
lea    0x1(%rbx),%edi
call   1050 <crear_vector@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
test   %edi,%edi
js     1249 <simpson_combinado+0xe9>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x10(%rsp),%xmm0
call   1070 <fun_int@plt>
movsd  %xmm0,(%r14,%rbx,8)
lea    0x1(%rbx),%rax
movslq 0xc(%rsp),%rdi
cmp    %rdi,%rbx
mov    %rax,%rbx
jl     1220 <simpson_combinado+0xc0>
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    %r14,%rsi
call   1080 <sim_int@plt>
lea    0xda3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"SIMPSON COMBINADO\0A\00"
@.str.1 = [33 x i8] c"Ingrese el inicio del intervalo\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [30 x i8] c"Ingrese el fin del intervalo\0A\00"
@.str.4 = [27 x i8] c"Ingrese el valor de pasos\0A\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [23 x i8] c"El resultado es %.5lf\0A\00"
define void @simpson_combinado() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double*
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%15 = load double, double* %3
%16 = load double, double* %2
%17 = fsub double %15, %16
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
store double %20, double* %1
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
%23 = call double* @crear_vector(i32 %22)
store double* %23, double** %4
%24 = load double, double* %2
store double %24, double* %5
store i32 0, i32* %7
br label %25
25: ; preds = %39, %0
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = load double, double* %1
%31 = load i32, i32* %7
%32 = sitofp i32 %31 to double
%33 = fmul double %30, %32
%34 = call double @fun_int(double %33)
%35 = load double*, double** %4
%36 = load i32, i32* %7
%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* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %25
42: ; preds = %25
%43 = load double, double* %2
%44 = load double, double* %3
%45 = load i32, i32* %6
%46 = load double*, double** %4
%47 = call i32 @sim_int(double %43, double %44, i32 %45, double* %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %47)
ret void
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%lf\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [23 x i8] c"El resultado es %.5lf\0A\00"
@str = [18 x i8] c"SIMPSON COMBINADO\00"
@str.7 = [32 x i8] c"Ingrese el inicio del intervalo\00"
@str.8 = [29 x i8] c"Ingrese el fin del intervalo\00"
@str.9 = [26 x i8] c"Ingrese el valor de pasos\00"
define void @simpson_combinado() {
%1 = alloca double
%2 = alloca double
%3 = alloca i32
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%14 = load double, double* %2
%15 = load double, double* %1
%16 = fsub double %14, %15
%17 = load i32, i32* %3
%18 = sitofp i32 %17 to double
%19 = fdiv double %16, %18
%20 = add nsw i32 %17, 1
%21 = call double* @crear_vector(i32 %20)
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 0
br i1 %23, label %35, label %24
24: ; preds = %0, %24
%25 = phi i64 [ %31, %24 ], [ 0, %0 ]
%26 = trunc i64 %25 to i32
%27 = sitofp i32 %26 to double
%28 = fmul double %19, %27
%29 = call double @fun_int(double %28)
%30 = getelementptr inbounds double, double* %21, i64 %25
store double %29, double* %30
%31 = add nuw nsw i64 %25, 1
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %25, %33
br i1 %34, label %24, label %35
35: ; preds = %24, %0
%36 = phi i32 [ %22, %0 ], [ %32, %24 ]
%37 = load double, double* %1
%38 = load double, double* %2
%39 = call i32 @sim_int(double %37, double %38, i32 %36, double* %21)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %39)
ret void
}