#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 cifra, chislo, neshto, broi;
  printf("Chislo:");
  scanf("%d", &chislo);
  for (cifra = 0; cifra < 10; cifra++) {
    broi = 0;
    neshto = chislo;
    while (neshto >= 1) {
      if (neshto % 10 == cifra)
        broi++;
      neshto /= 10;
    }
    if (broi != 0)
      printf("Cifrata %d e napisana %d puti\n", cifra, broi);
  }
}


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    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11d6 <main+0xb6>
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11a5 <main+0x85>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    -0x8(%rbp),%edx
jne    1192 <main+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    116b <main+0x4b>
cmpl   $0x0,-0x14(%rbp)
je     11c3 <main+0xa3>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c8 <main+0xa8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
mov    -0x4(%rbp),%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    0xeb8(%rip),%r14
xor    %ebp,%ebp
jmp    1168 <main+0x48>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0xa,%ebp
je     11b7 <main+0x97>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1160 <main+0x40>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%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    %ebp,%edi
sete   %sil
add    %esi,%edx
cmp    $0x9,%eax
mov    %ecx,%eax
ja     1180 <main+0x60>
test   %edx,%edx
je     1160 <main+0x40>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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