#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ ordenar_vet(float *, int);
int /*<<< orphan*/ printf(char *, ...);
int qnt_ap(float *, int, float);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float *vetor, procurado;
  int i, indice, loops, vezes_q_apareceu;
  printf("digite os loops: ");
  scanf("%d", &loops);
  vetor = (float *)(malloc(sizeof(float) * loops));
  for (i = 0; i < loops; i++) {
    printf("Digite o numero %d: ", i + 1);
    scanf("%f", &vetor[i]);
  }
  ordenar_vet(vetor, loops);
  for (i = 0; i < loops; i++) {
    procurado = vetor[i];
    vezes_q_apareceu = qnt_ap(vetor, loops, procurado);
    if (vezes_q_apareceu == 2) {
      printf("o numero %.2f repetiu : %d vez\n", vetor[i],
             vezes_q_apareceu - 1);
    } else {
      printf("o numero %.2f repetiu : %d vezes\n", vetor[i],
             vezes_q_apareceu - 1);
    }
    i += vezes_q_apareceu - 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11e4 <main+0x94>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <main+0x49>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <ordenar_vet@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    129c <main+0x14c>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
movss  -0x14(%rbp),%xmm0
call   1070 <qnt_ap@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jne    125d <main+0x10d>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
lea    0xddc(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1282 <main+0x132>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
lea    0xdd2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f7 <main+0xa7>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11db <main+0x8b>
lea    0xe7b(%rip),%r14
lea    0xe89(%rip),%r15
mov    %r12,%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movslq 0x4(%rsp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     11b0 <main+0x60>
mov    %r12,%rdi
call   1050 <ordenar_vet@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1246 <main+0xf6>
xor    %ebp,%ebp
lea    0xe39(%rip),%r14
lea    0xe52(%rip),%r15
jmp    1219 <main+0xc9>
nopl   (%rax)
lea    -0x1(%r13),%esi
mov    %r15,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    %r13d,%ebp
mov    0x4(%rsp),%esi
cmp    %esi,%ebp
jge    1246 <main+0xf6>
movslq %ebp,%rbx
movss  (%r12,%rbx,4),%xmm0
mov    %r12,%rdi
call   1070 <qnt_ap@plt>
mov    %eax,%r13d
movss  (%r12,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
cmp    $0x2,%eax
jne    1200 <main+0xb0>
mov    %r14,%rdi
mov    $0x1,%esi
jmp    1207 <main+0xb7>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"digite os loops: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Digite o numero %d: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [32 x i8] c"o numero %.2f repetiu : %d vez\0A\00"
@.str.5 = [34 x i8] c"o numero %.2f repetiu : %d vezes\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float*
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = mul i64 4, %11
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to float*
store float* %15, float** %2
store i32 0, i32* %4
br label %16
16: ; preds = %29, %0
%17 = load i32, i32* %4
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load float*, float** %2
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %27)
br label %29
29: ; preds = %20
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %16
32: ; preds = %16
%33 = load float*, float** %2
%34 = load i32, i32* %6
%35 = call i32 @ordenar_vet(float* %33, i32 %34)
store i32 0, i32* %4
br label %36
36: ; preds = %77, %32
%37 = load i32, i32* %4
%38 = load i32, i32* %6
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %80
40: ; preds = %36
%41 = load float*, float** %2
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds float, float* %41, i64 %43
%45 = load float, float* %44
store float %45, float* %3
%46 = load float*, float** %2
%47 = load i32, i32* %6
%48 = load float, float* %3
%49 = call i32 @qnt_ap(float* %46, i32 %47, float %48)
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %62
52: ; preds = %40
%53 = load float*, float** %2
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds float, float* %53, i64 %55
%57 = load float, float* %56
%58 = fpext float %57 to double
%59 = load i32, i32* %7
%60 = sub nsw i32 %59, 1
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), double %58, i32 %60)
br label %72
62: ; preds = %40
%63 = load float*, float** %2
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
%67 = load float, float* %66
%68 = fpext float %67 to double
%69 = load i32, i32* %7
%70 = sub nsw i32 %69, 1
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %68, i32 %70)
br label %72
72: ; preds = %62, %52
%73 = load i32, i32* %7
%74 = sub nsw i32 %73, 1
%75 = load i32, i32* %4
%76 = add nsw i32 %75, %74
store i32 %76, i32* %4
br label %77
77: ; preds = %72
%78 = load i32, i32* %4
%79 = add nsw i32 %78, 1
store i32 %79, i32* %4
br label %36
80: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"digite os loops: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Digite o numero %d: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [32 x i8] c"o numero %.2f repetiu : %d vez\0A\00"
@.str.5 = [34 x i8] c"o numero %.2f repetiu : %d vezes\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @scanf(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 float*
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %0, %11
%12 = phi i64 [ %13, %11 ], [ 0, %0 ]
%13 = add nuw nsw i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds float, float* %8, i64 %12
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %16)
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %13, %19
br i1 %20, label %11, label %21
21: ; preds = %11, %0
%22 = phi i32 [ %9, %0 ], [ %18, %11 ]
%23 = call i32 @ordenar_vet(float* %8, i32 %22)
%24 = load i32, i32* %1
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %21, %41
%27 = phi i32 [ %43, %41 ], [ %24, %21 ]
%28 = phi i32 [ %42, %41 ], [ 0, %21 ]
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %8, i64 %29
%31 = load float, float* %30
%32 = call i32 @qnt_ap(float* %8, i32 %27, float %31)
%33 = icmp eq i32 %32, 2
%34 = load float, float* %30
%35 = fpext float %34 to double
br i1 %33, label %36, label %38
36: ; preds = %26
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), double %35, i32 1)
br label %41
38: ; preds = %26
%39 = add nsw i32 %32, -1
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %35, i32 %39)
br label %41
41: ; preds = %38, %36
%42 = add i32 %32, %28
%43 = load i32, i32* %1
%44 = icmp slt i32 %42, %43
br i1 %44, label %26, label %45
45: ; preds = %41, %21
ret i32 0
}