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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x41(%rbp)
movsbl -0x41(%rbp),%eax
mov    0x2e7d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11b3 <main+0x83>
movsbl -0x41(%rbp),%eax
cmp    $0x30,%eax
jl     11a4 <main+0x74>
movsbl -0x41(%rbp),%eax
cmp    $0x39,%eax
jg     11a4 <main+0x74>
movsbl -0x41(%rbp),%eax
sub    $0x30,%eax
cltq
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x41(%rbp)
jmp    1160 <main+0x30>
jmp    11b8 <main+0x88>
cmpl   $0xa,-0x48(%rbp)
jge    11ea <main+0xba>
mov    -0x48(%rbp),%esi
add    $0x30,%esi
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11b8 <main+0x88>
xor    %eax,%eax
add    $0x50,%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)
xor    %eax,%eax
call   1030 <getchar@plt>
mov    0x2eb0(%rip),%rbx
jmp    1147 <main+0x37>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    (%rbx),%al
je     115f <main+0x4f>
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1140 <main+0x30>
movzbl %al,%eax
add    $0xffffffd0,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    1140 <main+0x30>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@EOF = global i8 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = tail call signext i8 (...) @getchar()
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %23, label %8
8: ; preds = %2, %19
%9 = phi i8 [ %20, %19 ], [ %5, %2 ]
%10 = add i8 %9, -48
%11 = icmp ult i8 %10, 10
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = zext i8 %9 to i64
%14 = add nuw nsw i64 %13, 4294967248
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
br label %19
19: ; preds = %12, %8
%20 = tail call signext i8 (...) @getchar()
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %23, label %8
23: ; preds = %19, %2
ret i32 0
}