#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*/ aleatorio(int *, int);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  int i, op;
  int N = 3;
  int vector[100];
  int *contador;
  contador = (int *)calloc(N, sizeof(int));
  if (contador == NULL) {
    printf("No se ha podido asignar la memoria.\n");
  } else {
    aleatorio(vector, 100);
    for (i = 0; i < 100; i++) {
      op = vector[i];
      *(contador + op) += 1;
    }
    for (i = 0; i < N; i++) {
      printf("%i ", *(contador + i));
    }
  }
  free(contador);
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x1a8(%rbp)
cmpq   $0x0,-0x1a8(%rbp)
jne    119e <main+0x4e>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1232 <main+0xe2>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1070 <aleatorio@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11f0 <main+0xa0>
movslq -0x8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0xc(%rbp)
mov    -0x1a8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b6 <main+0x66>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    122d <main+0xdd>
mov    -0x1a8(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f7 <main+0xa7>
jmp    1232 <main+0xe2>
mov    -0x1a8(%rbp),%rdi
call   1030 <free@plt>
lea    0xde4(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
mov    $0x3,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11fc <main+0x9c>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1080 <aleatorio@plt>
mov    $0x3,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq -0xc(%rsp,%rax,4),%rcx
addl   $0x1,(%rbx,%rcx,4)
movslq -0x8(%rsp,%rax,4),%rcx
addl   $0x1,(%rbx,%rcx,4)
movslq -0x4(%rsp,%rax,4),%rcx
addl   $0x1,(%rbx,%rcx,4)
movslq (%rsp,%rax,4),%rcx
addl   $0x1,(%rbx,%rcx,4)
add    $0x4,%rax
cmp    $0x67,%rax
jne    11a0 <main+0x40>
mov    (%rbx),%esi
lea    0xe2a(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1208 <main+0xa8>
lea    0xe07(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xded(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"No se ha podido asignar la memoria.\0A\00"
@.str.1 = [4 x i8] c"%i \00"
@.str.2 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i32]
%6 = alloca i32*
store i32 0, i32* %1
store i32 3, i32* %4
%7 = load i32, i32* %4
%8 = call i64 @calloc(i32 %7, i32 4)
%9 = inttoptr i64 %8 to i32*
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %50
14: ; preds = %0
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%16 = call i32 @aleatorio(i32* %15, i32 100)
store i32 0, i32* %2
br label %17
17: ; preds = %31, %14
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 100
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %22
%24 = load i32, i32* %23
store i32 %24, i32* %3
%25 = load i32*, i32** %6
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %31
31: ; preds = %20
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %17
34: ; preds = %17
store i32 0, i32* %2
br label %35
35: ; preds = %46, %34
%36 = load i32, i32* %2
%37 = load i32, i32* %4
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = load i32*, i32** %6
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %39
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %35
49: ; preds = %35
br label %50
50: ; preds = %49, %12
%51 = load i32*, i32** %6
%52 = call i32 @free(i32* %51)
%53 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%i \00"
@.str.2 = [6 x i8] c"pause\00"
@str = [36 x i8] c"No se ha podido asignar la memoria.\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i64 @calloc(i32 3, i32 4)
%4 = inttoptr i64 %3 to i32*
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %51
8: ; preds = %0
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%10 = call i32 @aleatorio(i32* %9, i32 100)
br label %11
11: ; preds = %11, %8
%12 = phi i64 [ 0, %8 ], [ %40, %11 ]
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %4, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
%19 = or i64 %12, 1
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %4, i64 %22
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %23
%26 = or i64 %12, 2
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %4, i64 %29
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
%33 = or i64 %12, 3
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %4, i64 %36
%38 = load i32, i32* %37
%39 = add nsw i32 %38, 1
store i32 %39, i32* %37
%40 = add nuw nsw i64 %12, 4
%41 = icmp eq i64 %40, 100
br i1 %41, label %42, label %11
42: ; preds = %11
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds i32, i32* %4, i64 1
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds i32, i32* %4, i64 2
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %42, %6
%52 = call i32 @free(i32* %4)
%53 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}