#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 *ej1(int);
double *ej2(double *, double *, int);
int /*<<< orphan*/ ej3(double *, double, int);
int /*<<< orphan*/ ej4(double *, int);
int /*<<< orphan*/ ej5(double *, int);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
void ej6() {
  int N;
  printf("Introduzca un entero N:\n");
  scanf("%d", &N);
  printf("a) Entero introducido: %d\n", N);
  printf("b) ");
  double *vec1, *vec2, *vec3, *vec4;
  vec1 = ej1(N);
  ej4(vec1, N);
  vec2 = ej1(N);
  ej4(vec2, N);
  vec3 = ej1(N);
  ej4(vec3, N);
  vec4 = ej1(N);
  ej4(vec4, N);
  double s;
  printf("Factor de escalamiento:\n");
  scanf("%lf", &s);
  ej3(vec1, s, N);
  ej3(vec2, s, N);
  double *u, *v;
  u = ej2(vec1, vec2, N);
  v = ej2(vec3, vec4, N);
  double *ans;
  ans = ej2(u, v, N);
  printf("c) Factor de escalamiento: %lf\n", s);
  printf("d) Primer vector escalado:\n");
  ej5(vec1, N);
  printf("   Segundo vector escalado:\n");
  ej5(vec2, N);
  printf("e) Vector u:\n");
  ej5(u, N);
  printf("   Vector v:\n");
  ej5(v, N);
  printf("f) Producto vectorial u x v:\n");
  ej5(ans, N);
  free(vec1);
  free(vec2);
  free(vec3);
  free(vec4);
}


x86 assembly (clang, -O0):
<ej6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x4(%rbp),%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1060 <ej1@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1090 <ej4@plt>
mov    -0x4(%rbp),%edi
call   1060 <ej1@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1090 <ej4@plt>
mov    -0x4(%rbp),%edi
call   1060 <ej1@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1090 <ej4@plt>
mov    -0x4(%rbp),%edi
call   1060 <ej1@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1090 <ej4@plt>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe18(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x10(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
mov    -0x4(%rbp),%esi
call   1070 <ej3@plt>
mov    -0x18(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
mov    -0x4(%rbp),%esi
call   1070 <ej3@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   10a0 <ej2@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   10a0 <ej2@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   10a0 <ej2@plt>
mov    %rax,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xda7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <ej5@plt>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <ej5@plt>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <ej5@plt>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <ej5@plt>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <ej5@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ej6>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4f(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
call   1070 <ej1@plt>
mov    %rax,%r14
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   10a0 <ej4@plt>
mov    0x4(%rsp),%edi
call   1070 <ej1@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   10a0 <ej4@plt>
mov    0x4(%rsp),%edi
call   1070 <ej1@plt>
mov    %rax,%r15
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   10a0 <ej4@plt>
mov    0x4(%rsp),%edi
call   1070 <ej1@plt>
mov    %rax,%r12
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   10a0 <ej4@plt>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
lea    0xdd2(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1080 <ej3@plt>
movsd  0x8(%rsp),%xmm0
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1080 <ej3@plt>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <ej2@plt>
mov    %rax,%r13
mov    0x4(%rsp),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <ej2@plt>
mov    %rax,%rbp
mov    0x4(%rsp),%edx
mov    %r13,%rdi
mov    %rax,%rsi
call   10b0 <ej2@plt>
mov    %rax,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
lea    0xd61(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xda3(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1060 <ej5@plt>
lea    0xda6(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1060 <ej5@plt>
lea    0xdaa(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %r13,%rdi
call   1060 <ej5@plt>
lea    0xd9f(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
call   1060 <ej5@plt>
lea    0xd94(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    0x10(%rsp),%rdi
call   1060 <ej5@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Introduzca un entero N:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"a) Entero introducido: %d\0A\00"
@.str.3 = [4 x i8] c"b) \00"
@.str.4 = [25 x i8] c"Factor de escalamiento:\0A\00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [32 x i8] c"c) Factor de escalamiento: %lf\0A\00"
@.str.7 = [28 x i8] c"d) Primer vector escalado:\0A\00"
@.str.8 = [29 x i8] c" Segundo vector escalado:\0A\00"
@.str.9 = [14 x i8] c"e) Vector u:\0A\00"
@.str.10 = [14 x i8] c" Vector v:\0A\00"
@.str.11 = [30 x i8] c"f) Producto vectorial u x v:\0A\00"
define void @ej6() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca double*
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = call double* @ej1(i32 %15)
store double* %16, double** %2
%17 = load double*, double** %2
%18 = load i32, i32* %1
%19 = call i32 @ej4(double* %17, i32 %18)
%20 = load i32, i32* %1
%21 = call double* @ej1(i32 %20)
store double* %21, double** %3
%22 = load double*, double** %3
%23 = load i32, i32* %1
%24 = call i32 @ej4(double* %22, i32 %23)
%25 = load i32, i32* %1
%26 = call double* @ej1(i32 %25)
store double* %26, double** %4
%27 = load double*, double** %4
%28 = load i32, i32* %1
%29 = call i32 @ej4(double* %27, i32 %28)
%30 = load i32, i32* %1
%31 = call double* @ej1(i32 %30)
store double* %31, double** %5
%32 = load double*, double** %5
%33 = load i32, i32* %1
%34 = call i32 @ej4(double* %32, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %6)
%37 = load double*, double** %2
%38 = load double, double* %6
%39 = load i32, i32* %1
%40 = call i32 @ej3(double* %37, double %38, i32 %39)
%41 = load double*, double** %3
%42 = load double, double* %6
%43 = load i32, i32* %1
%44 = call i32 @ej3(double* %41, double %42, i32 %43)
%45 = load double*, double** %2
%46 = load double*, double** %3
%47 = load i32, i32* %1
%48 = call double* @ej2(double* %45, double* %46, i32 %47)
store double* %48, double** %7
%49 = load double*, double** %4
%50 = load double*, double** %5
%51 = load i32, i32* %1
%52 = call double* @ej2(double* %49, double* %50, i32 %51)
store double* %52, double** %8
%53 = load double*, double** %7
%54 = load double*, double** %8
%55 = load i32, i32* %1
%56 = call double* @ej2(double* %53, double* %54, i32 %55)
store double* %56, double** %9
%57 = load double, double* %6
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), double %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%60 = load double*, double** %2
%61 = load i32, i32* %1
%62 = call i32 @ej5(double* %60, i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%64 = load double*, double** %3
%65 = load i32, i32* %1
%66 = call i32 @ej5(double* %64, i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%68 = load double*, double** %7
%69 = load i32, i32* %1
%70 = call i32 @ej5(double* %68, i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%72 = load double*, double** %8
%73 = load i32, i32* %1
%74 = call i32 @ej5(double* %72, i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%76 = load double*, double** %9
%77 = load i32, i32* %1
%78 = call i32 @ej5(double* %76, i32 %77)
%79 = load double*, double** %2
%80 = call i32 @free(double* %79)
%81 = load double*, double** %3
%82 = call i32 @free(double* %81)
%83 = load double*, double** %4
%84 = call i32 @free(double* %83)
%85 = load double*, double** %5
%86 = call i32 @free(double* %85)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"a) Entero introducido: %d\0A\00"
@.str.3 = [4 x i8] c"b) \00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [32 x i8] c"c) Factor de escalamiento: %lf\0A\00"
@str = [24 x i8] c"Introduzca un entero N:\00"
@str.12 = [24 x i8] c"Factor de escalamiento:\00"
@str.13 = [27 x i8] c"d) Primer vector escalado:\00"
@str.14 = [28 x i8] c" Segundo vector escalado:\00"
@str.15 = [13 x i8] c"e) Vector u:\00"
@str.16 = [13 x i8] c" Vector v:\00"
@str.17 = [29 x i8] c"f) Producto vectorial u x v:\00"
define void @ej6() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = call double* @ej1(i32 %9)
%11 = load i32, i32* %1
%12 = call i32 @ej4(double* %10, i32 %11)
%13 = load i32, i32* %1
%14 = call double* @ej1(i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @ej4(double* %14, i32 %15)
%17 = load i32, i32* %1
%18 = call double* @ej1(i32 %17)
%19 = load i32, i32* %1
%20 = call i32 @ej4(double* %18, i32 %19)
%21 = load i32, i32* %1
%22 = call double* @ej1(i32 %21)
%23 = load i32, i32* %1
%24 = call i32 @ej4(double* %22, i32 %23)
%25 = bitcast double* %2 to i8*
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.12, i64 0, i64 0))
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %2)
%28 = load double, double* %2
%29 = load i32, i32* %1
%30 = call i32 @ej3(double* %10, double %28, i32 %29)
%31 = load double, double* %2
%32 = load i32, i32* %1
%33 = call i32 @ej3(double* %14, double %31, i32 %32)
%34 = load i32, i32* %1
%35 = call double* @ej2(double* %10, double* %14, i32 %34)
%36 = load i32, i32* %1
%37 = call double* @ej2(double* %18, double* %22, i32 %36)
%38 = load i32, i32* %1
%39 = call double* @ej2(double* %35, double* %37, i32 %38)
%40 = load double, double* %2
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), double %40)
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
%43 = load i32, i32* %1
%44 = call i32 @ej5(double* %10, i32 %43)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.14, i64 0, i64 0))
%46 = load i32, i32* %1
%47 = call i32 @ej5(double* %14, i32 %46)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.15, i64 0, i64 0))
%49 = load i32, i32* %1
%50 = call i32 @ej5(double* %35, i32 %49)
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.16, i64 0, i64 0))
%52 = load i32, i32* %1
%53 = call i32 @ej5(double* %37, i32 %52)
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, i64 0, i64 0))
%55 = load i32, i32* %1
%56 = call i32 @ej5(double* %39, i32 %55)
%57 = call i32 @free(double* %10)
%58 = call i32 @free(double* %14)
%59 = call i32 @free(double* %18)
%60 = call i32 @free(double* %22)
ret void
}