#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  const int tam = 20;
  int numero, vetor[20] = {0}, cont;
  do {
    printf("Digite um numero entre 1 e 20: ");
    scanf(" %d", &numero);
    if (numero >= 1 && numero <= tam) {
      vetor[numero - 1]++;
    } else {
      printf("Erro: numero errado.\n");
    }
  } while (numero != 0);
  for (cont = 0; cont < tam; cont++) {
    printf("\nO numero %d foi digitado %d veze(s)", cont + 1, vetor[cont]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jl     11a0 <main+0x70>
cmpl   $0x14,-0xc(%rbp)
jg     11a0 <main+0x70>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x60(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x60(%rbp,%rax,4)
jmp    11ae <main+0x7e>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b3 <main+0x83>
cmpl   $0x0,-0xc(%rbp)
jne    1156 <main+0x26>
movl   $0x0,-0x64(%rbp)
cmpl   $0x14,-0x64(%rbp)
jge    11f8 <main+0xc8>
mov    -0x64(%rbp),%esi
add    $0x1,%esi
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%edx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11c4 <main+0x94>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xea2(%rip),%r14
lea    0xebb(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xed8(%rip),%r12
jmp    1190 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11bc <main+0x8c>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x13,%ecx
ja     1180 <main+0x50>
mov    %ecx,%ecx
addl   $0x1,0x10(%rsp,%rcx,4)
test   %eax,%eax
jne    1190 <main+0x60>
mov    0x10(%rsp),%edx
lea    0xe5d(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%edx
mov    %rbx,%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x3c(%rsp),%edx
mov    %rbx,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x40(%rsp),%edx
mov    %rbx,%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x44(%rsp),%edx
mov    %rbx,%rdi
mov    $0xe,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x48(%rsp),%edx
mov    %rbx,%rdi
mov    $0xf,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x50(%rsp),%edx
mov    %rbx,%rdi
mov    $0x11,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x54(%rsp),%edx
mov    %rbx,%rdi
mov    $0x12,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x58(%rsp),%edx
mov    %rbx,%rdi
mov    $0x13,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x5c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Digite um numero entre 1 e 20: \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [22 x i8] c"Erro: numero errado.\0A\00"
@.str.3 = [37 x i8] c"\0AO numero %d foi digitado %d veze(s)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i32 20, i32* %2
%6 = bitcast [20 x i32]* %4 to i8*
br label %7
7: ; preds = %25, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 1
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i32, i32* %3
%14 = icmp sle i32 %13, 20
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
br label %24
22: ; preds = %12, %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %15
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %7, label %28
28: ; preds = %25
store i32 0, i32* %5
br label %29
29: ; preds = %40, %28
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 20
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %38)
br label %40
40: ; preds = %32
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %29
43: ; preds = %29
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [32 x i8] c"Digite um numero entre 1 e 20: \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.3 = [37 x i8] c"\0AO numero %d foi digitado %d veze(s)\00"
@str = [21 x i8] c"Erro: numero errado.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [20 x i32]* %2 to i8*
br label %5
5: ; preds = %19, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add i32 %8, -1
%10 = icmp ult i32 %9, 20
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = zext i32 %9 to i64
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %13
br label %19
16: ; preds = %5
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%18 = load i32, i32* %1
br label %19
19: ; preds = %11, %16
%20 = phi i32 [ %8, %11 ], [ %18, %16 ]
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %5
22: ; preds = %19
%23 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %24)
%26 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %27)
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 2
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %30)
%32 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 3
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %33)
%35 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 4
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %36)
%38 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 5
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %39)
%41 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 6
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 %42)
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 7
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 8, i32 %45)
%47 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 8
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 9, i32 %48)
%50 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 9
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 10, i32 %51)
%53 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 10
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 11, i32 %54)
%56 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 11
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 12, i32 %57)
%59 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 12
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 13, i32 %60)
%62 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 13
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 14, i32 %63)
%65 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 14
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 15, i32 %66)
%68 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 15
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 16, i32 %69)
%71 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 16
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 17, i32 %72)
%74 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 17
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 18, i32 %75)
%77 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 18
%78 = load i32, i32* %77
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 19, i32 %78)
%80 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 19
%81 = load i32, i32* %80
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 20, i32 %81)
ret i32 0
}