#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};
  int i = 0;
  char ch = getchar();
  while (ch != EOF) {
    if (ch >= '0' && ch <= '9') {
      counters[ch - '0']++;
    }
    ch = getchar();
  }
  while (i < 10) {
    printf("%c: %d\n", i + '0', 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>
movl   $0x0,-0x44(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x45(%rbp)
movsbl -0x45(%rbp),%eax
mov    0x2e76(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ba <main+0x8a>
movsbl -0x45(%rbp),%eax
cmp    $0x30,%eax
jl     11ab <main+0x7b>
movsbl -0x45(%rbp),%eax
cmp    $0x39,%eax
jg     11ab <main+0x7b>
movsbl -0x45(%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,-0x45(%rbp)
jmp    1167 <main+0x37>
jmp    11bf <main+0x8f>
cmpl   $0xa,-0x44(%rbp)
jge    11f1 <main+0xc1>
mov    -0x44(%rbp),%esi
add    $0x30,%esi
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11bf <main+0x8f>
xor    %eax,%eax
add    $0x50,%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),%al
jne    119b <main+0x7b>
jmp    11dd <main+0xbd>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%al
je     11b0 <main+0x90>
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1190 <main+0x70>
movzbl %al,%eax
add    $0xffffffd0,%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    0xe0c(%rip),%r14
mov    %r14,%rdi
mov    $0x30,%esi
mov    %ebp,%ebx
mov    %r8d,%ebp
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x31,%esi
mov    %r13d,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x32,%esi
mov    %r12d,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x33,%esi
mov    %r15d,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x34,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x35,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x36,%esi
mov    (%rsp),%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x37,%esi
mov    0x4(%rsp),%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x38,%esi
mov    0x8(%rsp),%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x39,%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 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 i32
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [10 x i32]* %6 to i8*
store i32 0, i32* %7
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %8
br label %11
11: ; preds = %33, %2
%12 = load i8, i8* %8
%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* %8
%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* %8
%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* %8
%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* %8
br label %11
35: ; preds = %11
br label %36
36: ; preds = %39, %35
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 10
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 48
%42 = load i32, i32* %7
%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* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %36
49: ; preds = %36
ret i32 0
}

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