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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11d4 <main+0xb4>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11ab <main+0x8b>
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11a6 <main+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <main+0x4b>
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0xcccccccd,%ebx
lea    0xeb0(%rip),%r14
xor    %ebp,%ebp
jmp    1174 <main+0x54>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    $0xa,%ebp
je     11b7 <main+0x97>
mov    0xc(%rsp),%eax
mov    $0x0,%edx
test   %eax,%eax
jle    1160 <main+0x40>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%ecx
imul   %rbx,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %eax,%edi
sub    %esi,%edi
xor    %esi,%esi
cmp    %edi,%ebp
sete   %sil
add    %esi,%edx
cmp    $0x9,%eax
mov    %ecx,%eax
ja     1190 <main+0x70>
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"n=\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [8 x i8] c"\0A %d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
5: ; preds = %0, %18
%6 = phi i32 [ 0, %0 ], [ %21, %18 ]
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %5, %9
%10 = phi i32 [ %13, %9 ], [ %7, %5 ]
%11 = phi i32 [ %16, %9 ], [ 0, %5 ]
%12 = urem i32 %10, 10
%13 = udiv i32 %10, 10
%14 = icmp eq i32 %6, %12
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %11, %15
%17 = icmp ult i32 %10, 10
br i1 %17, label %18, label %9
18: ; preds = %9, %5
%19 = phi i32 [ 0, %5 ], [ %16, %9 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %19)
%21 = add nuw nsw i32 %6, 1
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %5
23: ; preds = %18
ret i32 0
}