#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 number, check, counter, digit;
  printf("Number: ");
  scanf("%d", &number);
  if (number < 0)
    number = number * -1;
  else if (number == 0)
    printf("\nDigit 0: 1 time");
  for (digit = 0; digit < 10; digit++) {
    counter = 0;
    for (check = number; check != 0;) {
      if (check % 10 == digit)
        counter++;
      check = check / 10;
    }
    if (counter > 0)
      printf("\nDigit %d: %d time(s)", digit, counter);
  }
}


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    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1163 <main+0x43>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x60>
cmpl   $0x0,-0x8(%rbp)
jne    117b <main+0x5b>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x60>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1209 <main+0xe9>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d8 <main+0xb8>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    -0x14(%rbp),%edx
jne    11c5 <main+0xa5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    119e <main+0x7e>
cmpl   $0x0,-0x10(%rbp)
jle    11f6 <main+0xd6>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fb <main+0xdb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <main+0x67>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     115c <main+0x3c>
jne    1162 <main+0x42>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1162 <main+0x42>
neg    %eax
mov    %eax,0x4(%rsp)
lea    0xeb4(%rip),%rbx
xor    %ebp,%ebp
jmp    1178 <main+0x58>
nopl   (%rax)
add    $0x1,%ebp
cmp    $0xa,%ebp
je     11d5 <main+0xb5>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1170 <main+0x50>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rax
add    %esi,%eax
lea    (%rax,%rax,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %ecx,%edi
sub    %esi,%edi
xor    %esi,%esi
cmp    %ebp,%edi
sete   %sil
add    %esi,%edx
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     1190 <main+0x70>
test   %edx,%edx
je     1170 <main+0x50>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"Number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\0ADigit 0: 1 time\00"
@.str.3 = [22 x i8] c"\0ADigit %d: %d time(s)\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 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)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = sub nsw i32 0, %5
store i32 %8, i32* %1
br label %13
9: ; preds = %0
%10 = icmp eq i32 %5, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %9, %11, %7
br label %14
14: ; preds = %13, %32
%15 = phi i32 [ %33, %32 ], [ 0, %13 ]
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %32, label %18
18: ; preds = %14, %18
%19 = phi i32 [ %24, %18 ], [ 0, %14 ]
%20 = phi i32 [ %25, %18 ], [ %16, %14 ]
%21 = srem i32 %20, 10
%22 = icmp eq i32 %21, %15
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %19, %23
%25 = sdiv i32 %20, 10
%26 = add i32 %20, 9
%27 = icmp ult i32 %26, 19
br i1 %27, label %28, label %18
28: ; preds = %18
%29 = icmp eq i32 %24, 0
br i1 %29, label %32, label %30
30: ; preds = %28
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %24)
br label %32
32: ; preds = %14, %28, %30
%33 = add nuw nsw i32 %15, 1
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %14
35: ; preds = %32
ret i32 0
}