#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int c, i;
  int ndigit[10];
  for (i = 0; i < 10; i = i + 1) {
    ndigit[i] = 0;
  }
  while ((c = getchar()) != EOF) {
    if (c >= '0' && c <= '9') {
      ++ndigit[c - '0'];
    }
  }
  for (i = 0; i < 10; i = i + 1) {
    printf("%d -> %d\n", i, ndigit[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    115a <main+0x3a>
movslq -0xc(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1136 <main+0x16>
jmp    115f <main+0x3f>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
je     11a4 <main+0x84>
cmpl   $0x30,-0x8(%rbp)
jl     119f <main+0x7f>
cmpl   $0x39,-0x8(%rbp)
jg     119f <main+0x7f>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
cltq
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    115f <main+0x3f>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11da <main+0xba>
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ab <main+0x8b>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e93(%rip),%rbx
mov    $0x0,%ecx
mov    $0x0,%esi
mov    $0x0,%edi
mov    $0x0,%ebp
mov    $0x0,%r8d
mov    $0x0,%r15d
mov    $0x0,%r12d
mov    $0x0,%r13d
mov    $0x0,%edx
cmp    (%rbx),%eax
jne    119b <main+0x7b>
jmp    11d9 <main+0xb9>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     11ac <main+0x8c>
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     1190 <main+0x70>
mov    %eax,%eax
addl   $0x1,0x10(%rsp,%rax,4)
jmp    1190 <main+0x70>
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%r13d
mov    0x18(%rsp),%r12d
mov    0x1c(%rsp),%r15d
mov    0x20(%rsp),%r8d
mov    0x24(%rsp),%ebp
mov    0x28(%rsp),%edi
mov    0x2c(%rsp),%esi
mov    0x30(%rsp),%ecx
mov    0x34(%rsp),%r14d
mov    %edi,(%rsp)
mov    %esi,0x4(%rsp)
mov    %ecx,0x8(%rsp)
mov    %r14d,0xc(%rsp)
lea    0xe10(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebp,%ebx
mov    %r8d,%ebp
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %r12d,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %r15d,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    (%rsp),%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    0x4(%rsp),%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    0x8(%rsp),%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x9,%esi
mov    0xc(%rsp),%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [10 x i8] c"%d -> %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %27, label %48
6: ; preds = %57
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%18 = load i32, i32* %17
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%20 = load i32, i32* %19
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%22 = load i32, i32* %21
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%24 = load i32, i32* %23
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%26 = load i32, i32* %25
br label %27
27: ; preds = %6, %0
%28 = phi i32 [ %26, %6 ], [ 0, %0 ]
%29 = phi i32 [ %24, %6 ], [ 0, %0 ]
%30 = phi i32 [ %22, %6 ], [ 0, %0 ]
%31 = phi i32 [ %20, %6 ], [ 0, %0 ]
%32 = phi i32 [ %18, %6 ], [ 0, %0 ]
%33 = phi i32 [ %16, %6 ], [ 0, %0 ]
%34 = phi i32 [ %14, %6 ], [ 0, %0 ]
%35 = phi i32 [ %12, %6 ], [ 0, %0 ]
%36 = phi i32 [ %10, %6 ], [ 0, %0 ]
%37 = phi i32 [ %8, %6 ], [ 0, %0 ]
%38 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0, i32 %37)
%39 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 1, i32 %36)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 2, i32 %35)
%41 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 3, i32 %34)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 4, i32 %33)
%43 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 5, i32 %32)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 6, i32 %31)
%45 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 7, i32 %30)
%46 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 8, i32 %29)
%47 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9, i32 %28)
ret i32 0
48: ; preds = %0, %57
%49 = phi i32 [ %58, %57 ], [ %3, %0 ]
%50 = add i32 %49, -48
%51 = icmp ult i32 %50, 10
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = zext i32 %50 to i64
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = add nsw i32 %55, 1
store i32 %56, i32* %54
br label %57
57: ; preds = %52, %48
%58 = tail call i32 (...) @getchar()
%59 = load i32, i32* @EOF
%60 = icmp eq i32 %58, %59
br i1 %60, label %6, label %48
}