#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;
  int d[10] = {0};
  printf("Enter a number:\n");
  scanf("%d", &n);
  if (n == 0)
    d[0]++;
  while (n > 0) {
    d[n % 10]++;
    n = n / 10;
  }
  for (i = 0; i < 10; i++) {
    if (d[i] != 0) {
      printf("\nDigit %d = %d times", i, d[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1180 <main+0x50>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1185 <main+0x55>
cmpl   $0x0,-0x8(%rbp)
jle    11bb <main+0x8b>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1185 <main+0x55>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1207 <main+0xd7>
movslq -0xc(%rbp),%rax
cmpl   $0x0,-0x40(%rbp,%rax,4)
je     11f4 <main+0xc4>
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <main+0xc9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c2 <main+0x92>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11ae <main+0x7e>
jle    11cb <main+0x9b>
mov    $0xcccccccd,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%edx
mov    %eax,%eax
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%edi
sub    %esi,%edi
addl   $0x1,0x10(%rsp,%rdi,4)
cmp    $0xa,%edx
jae    1180 <main+0x50>
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%edx
test   %edx,%edx
jne    11bb <main+0x8b>
jmp    11cb <main+0x9b>
movl   $0x1,0x10(%rsp)
mov    $0x1,%edx
lea    0xe41(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%edx
test   %edx,%edx
je     11e6 <main+0xb6>
lea    0xe29(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
test   %edx,%edx
je     1201 <main+0xd1>
lea    0xe0e(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
test   %edx,%edx
je     121c <main+0xec>
lea    0xdf3(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%edx
test   %edx,%edx
je     1237 <main+0x107>
lea    0xdd8(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%edx
test   %edx,%edx
je     1252 <main+0x122>
lea    0xdbd(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%edx
test   %edx,%edx
je     126d <main+0x13d>
lea    0xda2(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%edx
test   %edx,%edx
je     1288 <main+0x158>
lea    0xd87(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%edx
test   %edx,%edx
je     12a3 <main+0x173>
lea    0xd6c(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%edx
test   %edx,%edx
je     12be <main+0x18e>
lea    0xd51(%rip),%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

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

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