#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 */
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ imprimeVector(int, int *);
int /*<<< orphan*/ mayorMenorVector(int, int *, int *, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rellenaVector(int, int *, int, int *, int *);
int *reservaVector(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int nEle = 0, num = 0;
  int *vector, *menores, *mayores;
  int menor = 0, mayor = 0;
  printf("\nIntroduzca el numero de elemetos del vector: ");
  scanf("%i", &nEle);
  vector = reservaVector(nEle);
  printf("\n\nIntroduzca el numero para hallar los mayores/menores: ");
  scanf("%i", &num);
  rellenaVector(nEle, vector, num, &mayor, &menor);
  menores = reservaVector(menor);
  mayores = reservaVector(mayor);
  mayorMenorVector(nEle, vector, mayores, menores, num);
  printf("\n\nLos valores del vector original son: ");
  imprimeVector(nEle, vector);
  printf("\nLos valores menores que %i son: ", num);
  imprimeVector(menor, menores);
  printf("\nLos valores mayores o iguales que %i son: ", num);
  imprimeVector(mayor, mayores);
  printf("\n");
  free(vector);
  vector = NULL;
  free(mayores);
  mayores = NULL;
  free(menores);
  menores = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1070 <reservaVector@plt>
mov    %rax,-0x18(%rbp)
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe55(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    -0x30(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1040 <rellenaVector@plt>
mov    -0x2c(%rbp),%edi
call   1070 <reservaVector@plt>
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%edi
call   1070 <reservaVector@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0xc(%rbp),%r8d
call   1060 <mayorMenorVector@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1090 <imprimeVector@plt>
mov    -0xc(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1090 <imprimeVector@plt>
mov    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1090 <imprimeVector@plt>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe72(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
mov    0x4(%rsp),%edi
call   1080 <reservaVector@plt>
mov    %rax,%r15
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%edx
lea    0x8(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %r15,%rsi
call   1050 <rellenaVector@plt>
mov    0xc(%rsp),%edi
call   1080 <reservaVector@plt>
mov    %rax,%r14
mov    0x8(%rsp),%edi
call   1080 <reservaVector@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%edi
mov    (%rsp),%r8d
mov    %r15,%rsi
mov    %rax,%rdx
mov    %r14,%rcx
call   1070 <mayorMenorVector@plt>
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%edi
mov    %r15,%rsi
call   10a0 <imprimeVector@plt>
mov    (%rsp),%esi
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   10a0 <imprimeVector@plt>
mov    (%rsp),%esi
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   10a0 <imprimeVector@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0AIntroduzca el numero de elemetos del vector: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [57 x i8] c"\0A\0AIntroduzca el numero para hallar los mayores/menores: \00"
@.str.3 = [40 x i8] c"\0A\0ALos valores del vector original son: \00"
@.str.4 = [34 x i8] c"\0ALos valores menores que %i son: \00"
@.str.5 = [44 x i8] c"\0ALos valores mayores o iguales que %i son: \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 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 = call i32* @reservaVector(i32 %11)
store i32* %12, i32** %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %2
%16 = load i32*, i32** %4
%17 = load i32, i32* %3
%18 = call i32 @rellenaVector(i32 %15, i32* %16, i32 %17, i32* %8, i32* %7)
%19 = load i32, i32* %7
%20 = call i32* @reservaVector(i32 %19)
store i32* %20, i32** %5
%21 = load i32, i32* %8
%22 = call i32* @reservaVector(i32 %21)
store i32* %22, i32** %6
%23 = load i32, i32* %2
%24 = load i32*, i32** %4
%25 = load i32*, i32** %6
%26 = load i32*, i32** %5
%27 = load i32, i32* %3
%28 = call i32 @mayorMenorVector(i32 %23, i32* %24, i32* %25, i32* %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %2
%31 = load i32*, i32** %4
%32 = call i32 @imprimeVector(i32 %30, i32* %31)
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %7
%36 = load i32*, i32** %5
%37 = call i32 @imprimeVector(i32 %35, i32* %36)
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %8
%41 = load i32*, i32** %6
%42 = call i32 @imprimeVector(i32 %40, i32* %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32*, i32** %4
%45 = call i32 @free(i32* %44)
store i32* null, i32** %4
%46 = load i32*, i32** %6
%47 = call i32 @free(i32* %46)
store i32* null, i32** %6
%48 = load i32*, i32** %5
%49 = call i32 @free(i32* %48)
store i32* null, i32** %5
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"\0AIntroduzca el numero de elemetos del vector: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [57 x i8] c"\0A\0AIntroduzca el numero para hallar los mayores/menores: \00"
@.str.3 = [40 x i8] c"\0A\0ALos valores del vector original son: \00"
@.str.4 = [34 x i8] c"\0ALos valores menores que %i son: \00"
@.str.5 = [44 x i8] c"\0ALos valores mayores o iguales que %i son: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 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* %1)
%11 = load i32, i32* %1
%12 = call i32* @reservaVector(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call i32 @rellenaVector(i32 %15, i32* %12, i32 %16, i32* %4, i32* %3)
%18 = load i32, i32* %3
%19 = call i32* @reservaVector(i32 %18)
%20 = load i32, i32* %4
%21 = call i32* @reservaVector(i32 %20)
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = call i32 @mayorMenorVector(i32 %22, i32* %12, i32* %21, i32* %19, i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = call i32 @imprimeVector(i32 %26, i32* %12)
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %3
%31 = call i32 @imprimeVector(i32 %30, i32* %19)
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %4
%35 = call i32 @imprimeVector(i32 %34, i32* %21)
%36 = call i32 @putchar(i32 10)
%37 = call i32 @free(i32* %12)
%38 = call i32 @free(i32* %21)
%39 = call i32 @free(i32* %19)
ret i32 0
}