#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 /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[10], i, n;
  scanf("%d", &n);
  for (i = 0; i < 10; i++) {
    a[i] = 0;
  }
  while (n % 10 > 0) {
    i = n % 10;
    a[i]++;
    n = n / 10;
  }
  for (i = 0; i < 10; i++) {
    if (a[i] > 0)
      printf("%d %d\n", i, a[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    116a <main+0x4a>
movslq -0x34(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1146 <main+0x26>
jmp    116f <main+0x4f>
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jle    11b3 <main+0x93>
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    116f <main+0x4f>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11fd <main+0xdd>
movslq -0x34(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
jle    11ea <main+0xca>
mov    -0x34(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
jmp    11ef <main+0xcf>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ba <main+0x9a>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xed5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%edx
mov    %eax,%ecx
sub    %edx,%ecx
test   %ecx,%ecx
jle    11d9 <main+0xb9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ecx,%ecx
addl   $0x1,0x10(%rsp,%rcx,4)
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
test   %ecx,%ecx
jg     1180 <main+0x60>
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%edx
test   %edx,%edx
jle    11d9 <main+0xb9>
lea    0xe31(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
test   %edx,%edx
jle    11f2 <main+0xd2>
lea    0xe1b(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    0x18(%rsp),%edx
test   %edx,%edx
jle    120b <main+0xeb>
lea    0xe02(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    0x1c(%rsp),%edx
test   %edx,%edx
jle    1224 <main+0x104>
lea    0xde9(%rip),%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    0x20(%rsp),%edx
test   %edx,%edx
jle    123d <main+0x11d>
lea    0xdd0(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    0x24(%rsp),%edx
test   %edx,%edx
jle    1256 <main+0x136>
lea    0xdb7(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
mov    0x28(%rsp),%edx
test   %edx,%edx
jle    126f <main+0x14f>
lea    0xd9e(%rip),%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
mov    0x2c(%rsp),%edx
test   %edx,%edx
jle    1288 <main+0x168>
lea    0xd85(%rip),%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
mov    0x30(%rsp),%edx
test   %edx,%edx
jle    12a1 <main+0x181>
lea    0xd6c(%rip),%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
mov    0x34(%rsp),%edx
test   %edx,%edx
jle    12ba <main+0x19a>
lea    0xd53(%rip),%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = srem i32 %6, 10
%8 = icmp sgt i32 %7, 0
br i1 %8, label %13, label %25
9: ; preds = %13
store i32 %20, i32* %3
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %23, label %25
13: ; preds = %0, %13
%14 = phi i32 [ %21, %13 ], [ %7, %0 ]
%15 = phi i32 [ %20, %13 ], [ %6, %0 ]
%16 = zext i32 %14 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1
store i32 %19, i32* %17
%20 = sdiv i32 %15, 10
%21 = srem i32 %20, 10
%22 = icmp sgt i32 %21, 0
br i1 %22, label %13, label %9
23: ; preds = %9
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %11)
br label %25
25: ; preds = %0, %9, %23
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %27)
br label %31
31: ; preds = %29, %25
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%33 = load i32, i32* %32
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %33)
br label %37
37: ; preds = %35, %31
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%39 = load i32, i32* %38
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %39)
br label %43
43: ; preds = %41, %37
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%45 = load i32, i32* %44
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %45)
br label %49
49: ; preds = %47, %43
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%51 = load i32, i32* %50
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %51)
br label %55
55: ; preds = %53, %49
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%57 = load i32, i32* %56
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %57)
br label %61
61: ; preds = %59, %55
%62 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%63 = load i32, i32* %62
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %63)
br label %67
67: ; preds = %65, %61
%68 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%69 = load i32, i32* %68
%70 = icmp sgt i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %69)
br label %73
73: ; preds = %71, %67
%74 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%75 = load i32, i32* %74
%76 = icmp sgt i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 %75)
br label %79
79: ; preds = %77, %73
ret i32 0
}