#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*/ horizontal(int *, int);
int /*<<< orphan*/ vertical(int *, int);
int main(void) {
  int i = 0, ch = 0;
  int cnt[10] = {0};
  while ((ch = getchar()) != EOF) {
    if (ch >= '0' && ch <= '9') {
      cnt[ch - '0']++;
    }
  }
  horizontal(cnt, 10);
  vertical(cnt, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%eax
je     11b2 <main+0x72>
cmpl   $0x30,-0xc(%rbp)
jl     11ad <main+0x6d>
cmpl   $0x39,-0xc(%rbp)
jg     11ad <main+0x6d>
mov    -0xc(%rbp),%eax
sub    $0x30,%eax
cltq
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    116d <main+0x2d>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1060 <horizontal@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1030 <vertical@plt>
xor    %eax,%eax
add    $0x40,%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   1040 <getchar@plt>
mov    0x2e90(%rip),%rbx
jmp    1167 <main+0x37>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     117b <main+0x4b>
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     1160 <main+0x30>
mov    %eax,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    1160 <main+0x30>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <horizontal@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <vertical@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
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* %2
store i32 0, i32* %3
%5 = bitcast [10 x i32]* %4 to i8*
br label %6
6: ; preds = %23, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load i32, i32* %3
%12 = icmp sge i32 %11, 48
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp sle i32 %14, 57
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 48
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
br label %23
23: ; preds = %16, %13, %10
br label %6
24: ; preds = %6
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%26 = call i32 @horizontal(i32* %25, i32 10)
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%28 = call i32 @vertical(i32* %27, i32 10)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
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 %19, label %6
6: ; preds = %0, %15
%7 = phi i32 [ %16, %15 ], [ %3, %0 ]
%8 = add i32 %7, -48
%9 = icmp ult i32 %8, 10
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = zext i32 %8 to i64
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
store i32 %14, i32* %12
br label %15
15: ; preds = %10, %6
%16 = tail call i32 (...) @getchar()
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %6
19: ; preds = %15, %0
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%21 = call i32 @horizontal(i32* %20, i32 10)
%22 = call i32 @vertical(i32* %20, i32 10)
ret i32 0
}