#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*/ freqcount(int *, int *, int);
int /*<<< orphan*/ freqscan(int *, int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, k, *vet, *freq;
  printf("Quantos numeros serao entrados?");
  scanf("%d", &n);
  while (n < 1) {
    printf("Favor digitar um numero maior que 0.\n");
    scanf("%d", &n);
  }
  vet = (int *)malloc(n * sizeof(int));
  freq = (int *)malloc(n * sizeof(int));
  printf("Digite os numeros: ");
  for (k = 0; k < n; k++)
    scanf("%d", &vet[k]);
  freqcount(vet, freq, n);
  printf("O(s) elemnto(s) com a maior frequencia eh(sao):");
  freqscan(vet, freq, n);
  free(vet);
  free(freq);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jge    11b6 <main+0x56>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
jmp    118b <main+0x2b>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1224 <main+0xc4>
mov    -0x18(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe0f(%rip),%rdi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ef <main+0x8f>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1080 <freqcount@plt>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <freqscan@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe90(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jg     11db <main+0x6b>
lea    0xebe(%rip),%r14
lea    0xe70(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    11c0 <main+0x50>
shl    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe27(%rip),%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    123d <main+0xcd>
xor    %r13d,%r13d
lea    0xe0d(%rip),%r12
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
add    $0x1,%r13
movslq 0xc(%rsp),%rdx
add    $0x4,%rbx
cmp    %rdx,%r13
jl     1220 <main+0xb0>
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <freqcount@plt>
lea    0xde8(%rip),%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <freqscan@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Quantos numeros serao entrados?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Favor digitar um numero maior que 0.\0A\00"
@.str.3 = [20 x i8] c"Digite os numeros: \00"
@.str.4 = [48 x i8] c"O(s) elemnto(s) com a maior frequencia eh(sao):\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
14: ; preds = %8
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %4
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %5
%27 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %28
28: ; preds = %38, %14
%29 = load i32, i32* %3
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i32*, i32** %4
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %36)
br label %38
38: ; preds = %32
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %28
41: ; preds = %28
%42 = load i32*, i32** %4
%43 = load i32*, i32** %5
%44 = load i32, i32* %2
%45 = call i32 @freqcount(i32* %42, i32* %43, i32 %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32*, i32** %4
%48 = load i32*, i32** %5
%49 = load i32, i32* %2
%50 = call i32 @freqscan(i32* %47, i32* %48, i32 %49)
%51 = load i32*, i32** %4
%52 = call i32 @free(i32* %51)
%53 = load i32*, i32** %5
%54 = call i32 @free(i32* %53)
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@.str = [32 x i8] c"Quantos numeros serao entrados?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"Digite os numeros: \00"
@.str.4 = [48 x i8] c"O(s) elemnto(s) com a maior frequencia eh(sao):\00"
@str = [37 x i8] c"Favor digitar um numero maior que 0.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %12
7: ; preds = %0, %7
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %7, label %12
12: ; preds = %7, %0
%13 = phi i32 [ %5, %0 ], [ %10, %7 ]
%14 = shl i32 %13, 2
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
%17 = load i32, i32* %1
%18 = shl i32 %17, 2
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %12, %24
%25 = phi i64 [ %28, %24 ], [ 0, %12 ]
%26 = getelementptr inbounds i32, i32* %16, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = add nuw nsw i64 %25, 1
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %24, label %32
32: ; preds = %24, %12
%33 = phi i32 [ %22, %12 ], [ %29, %24 ]
%34 = call i32 @freqcount(i32* %16, i32* %20, i32 %33)
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%36 = load i32, i32* %1
%37 = call i32 @freqscan(i32* %16, i32* %20, i32 %36)
%38 = call i32 @free(i32* %16)
%39 = call i32 @free(i32* %20)
ret i32 0
}