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


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    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     118e <main+0x6e>
movsbl -0x5(%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    11c4 <main+0xa4>
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1195 <main+0x75>
xor    %eax,%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    $0x0,%ecx
mov    $0x0,%esi
mov    $0x0,%edi
mov    $0x0,%ebp
mov    $0x0,%ebx
mov    $0x0,%r15d
mov    $0x0,%r12d
mov    $0x0,%r13d
mov    $0x0,%edx
cmp    $0xa,%al
je     11d3 <main+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbq %al,%rax
addl   $0x1,-0xb0(%rsp,%rax,4)
01
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1190 <main+0x70>
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%r13d
mov    0x18(%rsp),%r12d
mov    0x1c(%rsp),%r15d
mov    0x20(%rsp),%ebx
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    0xe16(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
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    %ebx,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebp,%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):
@.str = [9 x i8] c"%d : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%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 = %20, %15
%17 = call signext i8 (...) @getchar()
store i8 %17, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 48
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
br label %16
28: ; preds = %16
store i32 0, i32* %3
br label %29
29: ; preds = %39, %28
%30 = load i32, i32* %3
%31 = icmp slt i32 %30, 10
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i32, i32* %3
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %33, i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %29
42: ; preds = %29
ret i32 0
}

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