#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 *, long *);
int main(void) {
  int occurance[10] = {0};
  int digit, i;
  long n;
  printf("enter the number: ");
  scanf("%ld", &n);
  while (n > 0) {
    digit = n % 10;
    occurance[digit] += 1;
    n /= 10;
  }
  for (i = 0; i < 10; i++) {
    printf("%d  ", occurance[i]);
  }
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <scanf@plt>
cmpq   $0x0,-0x40(%rbp)
jle    11b1 <main+0x81>
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
jmp    116d <main+0x3d>
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    11e6 <main+0xb6>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b8 <main+0x88>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    $0x48,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x40(%rsp)
lea    0xea5(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
lea    0x18(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x18(%rsp),%rdx
mov    $0x0,%edi
mov    $0x0,%eax
mov    $0x0,%ebx
mov    $0x0,%r13d
mov    $0x0,%r14d
mov    $0x0,%r15d
mov    $0x0,%r12d
mov    $0x0,%esi
test   %rdx,%rdx
jle    1213 <main+0xe3>
movabs $0xcccccccccccccccd,%rsi
cc cc cc
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rdx,%rcx
mov    %rdx,%rax
mul    %rsi
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
mov    %rcx,%rdi
sub    %rax,%rdi
addl   $0x1,0x20(%rsp,%rdi,4)
cmp    $0xa,%rcx
jae    11c0 <main+0x90>
mov    %rdx,0x18(%rsp)
mov    0x20(%rsp),%esi
mov    0x24(%rsp),%r12d
mov    0x28(%rsp),%r15d
mov    0x2c(%rsp),%r14d
mov    0x30(%rsp),%r13d
mov    0x34(%rsp),%ebx
mov    0x38(%rsp),%eax
mov    0x3c(%rsp),%edi
mov    0x40(%rsp),%ebp
mov    %eax,0xc(%rsp)
mov    %edi,0x10(%rsp)
mov    %ebp,0x14(%rsp)
lea    0xdf1(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x44(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd6d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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