#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, cifri[20] = {0}, y;
  printf("Vuvedi chislo: ");
  scanf("%d", &n);
  while (n != 0) {
    cifri[n % 10]++;
    n /= 10;
  }
  y = 0;
  while (y < 10) {
    if (cifri[y] != 0) {
      printf("Cifrata %d se sreshta %d puti \n", y, cifri[y]);
    }
    y++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11a3 <main+0x73>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x60(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x3d>
movl   $0x0,-0x64(%rbp)
cmpl   $0xa,-0x64(%rbp)
jge    11ea <main+0xba>
movslq -0x64(%rbp),%rax
cmpl   $0x0,-0x60(%rbp,%rax,4)
je     11dc <main+0xac>
mov    -0x64(%rbp),%esi
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%edx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11aa <main+0x7a>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11bd <main+0x9d>
nopw   0x0(%rax,%rax,1)
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
movslq %esi,%rdx
addl   $0x1,0x10(%rsp,%rdx,4)
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    1170 <main+0x50>
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%edx
test   %edx,%edx
je     11bd <main+0x9d>
lea    0xe5f(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
test   %edx,%edx
je     11d8 <main+0xb8>
lea    0xe47(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%edx
test   %edx,%edx
je     11f3 <main+0xd3>
lea    0xe2c(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%edx
test   %edx,%edx
je     120e <main+0xee>
lea    0xe11(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%edx
test   %edx,%edx
je     1229 <main+0x109>
lea    0xdf6(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%edx
test   %edx,%edx
je     1244 <main+0x124>
lea    0xddb(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%edx
test   %edx,%edx
je     125f <main+0x13f>
lea    0xdc0(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2c(%rsp),%edx
test   %edx,%edx
je     127a <main+0x15a>
lea    0xda5(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x30(%rsp),%edx
test   %edx,%edx
je     1295 <main+0x175>
lea    0xd8a(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x34(%rsp),%edx
test   %edx,%edx
je     12b0 <main+0x190>
lea    0xd6f(%rip),%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

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

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