#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 *, unsigned int, ...);
int rand();
int main() {
  unsigned int ocurrencias[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  float porcentajes[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int azar;
  unsigned int vuelta;
  printf("Voy a buscar %d numeros aleatorios entre 0 y 9, y contar su "
         "ocurrencia\n\n",
         100000000);
  for (vuelta = 0; vuelta < 100000000; vuelta++) {
    azar = rand() % 10;
    ocurrencias[azar]++;
  }
  for (vuelta = 0; vuelta < 10; vuelta++) {
    porcentajes[vuelta] = (float)ocurrencias[vuelta] * 100 / 100000000;
    printf("El numero %d ocurrio %d veces, representando %f %% del total\n",
           vuelta, ocurrencias[vuelta], porcentajes[vuelta]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xea2(%rip),%rdi
mov    $0x5f5e100,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x68(%rbp)
cmpl   $0x5f5e100,-0x68(%rbp)
jae    11b5 <main+0x85>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x64(%rbp)
movslq -0x64(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1179 <main+0x49>
movl   $0x0,-0x68(%rbp)
cmpl   $0xa,-0x68(%rbp)
jae    1226 <main+0xf6>
mov    -0x68(%rbp),%eax
mov    -0x30(%rbp,%rax,4),%eax
cvtsi2ss %rax,%xmm0
movss  0xe2a(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe1a(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x68(%rbp),%eax
movss  %xmm0,-0x60(%rbp,%rax,4)
mov    -0x68(%rbp),%esi
mov    -0x68(%rbp),%eax
mov    -0x30(%rbp,%rax,4),%edx
mov    -0x68(%rbp),%eax
movss  -0x60(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11bc <main+0x8c>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xec7(%rip),%rdi
mov    $0x5f5e100,%ebx
mov    $0x5f5e100,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cltq
addl   $0x1,(%rsp,%rax,4)
add    $0xffffffff,%ebx
jne    1160 <main+0x40>
mov    (%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xe5e(%rip),%xmm0
divss  0xe5a(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9c(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xe2b(%rip),%xmm0
divss  0xe27(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xdfc(%rip),%xmm0
divss  0xdf8(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xdcd(%rip),%xmm0
divss  0xdc9(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xd9e(%rip),%xmm0
divss  0xd9a(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xd6f(%rip),%xmm0
divss  0xd6b(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x18(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xd40(%rip),%xmm0
divss  0xd3c(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x1c(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xd11(%rip),%xmm0
divss  0xd0d(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x20(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xce2(%rip),%xmm0
divss  0xcde(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x24(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %rdx,%xmm0
mulss  0xcb3(%rip),%xmm0
divss  0xcaf(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [73 x i8] c"Voy a buscar %d numeros aleatorios entre 0 y 9, y contar su ocurrencia\0A\0A\00"
@.str.1 = [62 x i8] c"El numero %d ocurrio %d veces, representando %f %% del total\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [10 x float]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %2 to i8*
%7 = bitcast [10 x float]* %3 to i8*
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 100000000)
store i32 0, i32* %5
br label %9
9: ; preds = %20, %0
%10 = load i32, i32* %5
%11 = icmp ult i32 %10, 100000000
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 10
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = add i32 %18, 1
store i32 %19, i32* %17
br label %20
20: ; preds = %12
%21 = load i32, i32* %5
%22 = add i32 %21, 1
store i32 %22, i32* %5
br label %9
23: ; preds = %9
store i32 0, i32* %5
br label %24
24: ; preds = %49, %23
%25 = load i32, i32* %5
%26 = icmp ult i32 %25, 10
br i1 %26, label %27, label %52
27: ; preds = %24
%28 = load i32, i32* %5
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = uitofp i32 %31 to float
%33 = fmul float %32, 1.000000e+02
%34 = fdiv float %33, 1.000000e+08
%35 = load i32, i32* %5
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 %36
store float %34, float* %37
%38 = load i32, i32* %5
%39 = load i32, i32* %5
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = load i32, i32* %5
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 %44
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %42, double %47)
br label %49
49: ; preds = %27
%50 = load i32, i32* %5
%51 = add i32 %50, 1
store i32 %51, i32* %5
br label %24
52: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@.str = [73 x i8] c"Voy a buscar %d numeros aleatorios entre 0 y 9, y contar su ocurrencia\0A\0A\00"
@.str.1 = [62 x i8] c"El numero %d ocurrio %d veces, representando %f %% del total\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 100000000)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %12, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 10
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = add i32 %10, 1
store i32 %11, i32* %9
%12 = add nuw nsw i32 %5, 1
%13 = icmp eq i32 %12, 100000000
br i1 %13, label %14, label %4
14: ; preds = %4
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%16 = load i32, i32* %15
%17 = uitofp i32 %16 to float
%18 = fmul float %17, 1.000000e+02
%19 = fdiv float %18, 1.000000e+08
%20 = fpext float %19 to double
%21 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %16, double %20)
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%23 = load i32, i32* %22
%24 = uitofp i32 %23 to float
%25 = fmul float %24, 1.000000e+02
%26 = fdiv float %25, 1.000000e+08
%27 = fpext float %26 to double
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %23, double %27)
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%30 = load i32, i32* %29
%31 = uitofp i32 %30 to float
%32 = fmul float %31, 1.000000e+02
%33 = fdiv float %32, 1.000000e+08
%34 = fpext float %33 to double
%35 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %30, double %34)
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%37 = load i32, i32* %36
%38 = uitofp i32 %37 to float
%39 = fmul float %38, 1.000000e+02
%40 = fdiv float %39, 1.000000e+08
%41 = fpext float %40 to double
%42 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %37, double %41)
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%44 = load i32, i32* %43
%45 = uitofp i32 %44 to float
%46 = fmul float %45, 1.000000e+02
%47 = fdiv float %46, 1.000000e+08
%48 = fpext float %47 to double
%49 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %44, double %48)
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%51 = load i32, i32* %50
%52 = uitofp i32 %51 to float
%53 = fmul float %52, 1.000000e+02
%54 = fdiv float %53, 1.000000e+08
%55 = fpext float %54 to double
%56 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %51, double %55)
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%58 = load i32, i32* %57
%59 = uitofp i32 %58 to float
%60 = fmul float %59, 1.000000e+02
%61 = fdiv float %60, 1.000000e+08
%62 = fpext float %61 to double
%63 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %58, double %62)
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%65 = load i32, i32* %64
%66 = uitofp i32 %65 to float
%67 = fmul float %66, 1.000000e+02
%68 = fdiv float %67, 1.000000e+08
%69 = fpext float %68 to double
%70 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %65, double %69)
%71 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%72 = load i32, i32* %71
%73 = uitofp i32 %72 to float
%74 = fmul float %73, 1.000000e+02
%75 = fdiv float %74, 1.000000e+08
%76 = fpext float %75 to double
%77 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %72, double %76)
%78 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%79 = load i32, i32* %78
%80 = uitofp i32 %79 to float
%81 = fmul float %80, 1.000000e+02
%82 = fdiv float %81, 1.000000e+08
%83 = fpext float %82 to double
%84 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 %79, double %83)
ret i32 0
}