#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*/ encontrarMayorPosicion(int *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ leerValores(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ mostrarValores(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf_s(char *, int *);
int main() {
  int *p;
  int n = 0;
  printf("Escribe la cantidad de valores a leer: ");
  scanf_s("%i", &n);
  p = (int *)malloc(n * sizeof(int));
  if (p == NULL) {
    printf("No hay suficiente memoria");
    exit(0);
  }
  leerValores(p, n);
  mostrarValores(p, n);
  encontrarMayorPosicion(p, n);
  free(p);
  getchar();
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe53(%rip),%rdi
call   1070 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   10a0 <scanf_s@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f3 <main+0x63>
lea    0xe44(%rip),%rdi
call   1070 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <leerValores@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <mostrarValores@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <encontrarMayorPosicion@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe5c(%rip),%rdi
call   1070 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <scanf_s@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1210 <main+0x80>
mov    %rax,%rbx
mov    0xc(%rsp),%esi
mov    %rax,%rdi
call   1050 <leerValores@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <mostrarValores@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1040 <encontrarMayorPosicion@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe14(%rip),%rdi
call   1070 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Escribe la cantidad de valores a leer: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [26 x i8] c"No hay suficiente memoria\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 4
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %0
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = call i32 @leerValores(i32* %18, i32 %19)
%21 = load i32*, i32** %2
%22 = load i32, i32* %3
%23 = call i32 @mostrarValores(i32* %21, i32 %22)
%24 = load i32*, i32** %2
%25 = load i32, i32* %3
%26 = call i32 @encontrarMayorPosicion(i32* %24, i32 %25)
%27 = load i32*, i32** %2
%28 = call i32 @free(i32* %27)
%29 = call i32 (...) @getchar()
%30 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"Escribe la cantidad de valores a leer: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [26 x i8] c"No hay suficiente memoria\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf_s(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, 2
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = load i32, i32* %1
%15 = call i32 @leerValores(i32* %8, i32 %14)
%16 = load i32, i32* %1
%17 = call i32 @mostrarValores(i32* %8, i32 %16)
%18 = load i32, i32* %1
%19 = call i32 @encontrarMayorPosicion(i32* %8, i32 %18)
%20 = call i32 @free(i32* %8)
%21 = call i32 (...) @getchar()
%22 = call i32 (...) @getchar()
ret i32 0
}