#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 input = 0, i = 0, digit = 0, freq[10] = {0};
  printf("Please enter a number.\n");
  scanf("%d", &input);
  while (input > 0) {
    digit = input % 10;
    freq[digit]++;
    input = input / 10;
  }
  for (i = 0; i < 10; i++) {
    if (freq[i] != 0)
      printf("%d is present %d times.\n", i, freq[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11bc <main+0x8c>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
movslq -0x10(%rbp),%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    1182 <main+0x52>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1208 <main+0xd8>
movslq -0xc(%rbp),%rax
cmpl   $0x0,-0x40(%rbp,%rax,4)
je     11f5 <main+0xc5>
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fa <main+0xca>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c3 <main+0x93>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11bc <main+0x8c>
mov    $0xcccccccd,%ecx
nopl   0x0(%rax)
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
je     11bc <main+0x8c>
lea    0xe50(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%edx
test   %edx,%edx
je     11d7 <main+0xa7>
lea    0xe38(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
test   %edx,%edx
je     11f2 <main+0xc2>
lea    0xe1d(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
test   %edx,%edx
je     120d <main+0xdd>
lea    0xe02(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%edx
test   %edx,%edx
je     1228 <main+0xf8>
lea    0xde7(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%edx
test   %edx,%edx
je     1243 <main+0x113>
lea    0xdcc(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%edx
test   %edx,%edx
je     125e <main+0x12e>
lea    0xdb1(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%edx
test   %edx,%edx
je     1279 <main+0x149>
lea    0xd96(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%edx
test   %edx,%edx
je     1294 <main+0x164>
lea    0xd7b(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%edx
test   %edx,%edx
je     12af <main+0x17f>
lea    0xd60(%rip),%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

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

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