#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 num, i = 0, k, temp;
  printf("Num=");
  scanf("%d", &num);
  for (i = 0; i < 10; i++) {
    k = 0;
    temp = num;
    while (temp != 0) {
      if (temp % 10 == i)
        k++;
      temp = temp / 10;
    }
    if (k > 1)
      printf("The Number %d is met %d times\n", i, k);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11dd <main+0xbd>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11ac <main+0x8c>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    -0xc(%rbp),%edx
jne    1199 <main+0x79>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    1172 <main+0x52>
cmpl   $0x1,-0x10(%rbp)
jle    11ca <main+0xaa>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cf <main+0xaf>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
xor    %eax,%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    0xecd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xebf(%rip),%rbx
xor    %ebp,%ebp
jmp    1158 <main+0x38>
nopl   (%rax)
add    $0x1,%ebp
cmp    $0xa,%ebp
je     11b6 <main+0x96>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1150 <main+0x30>
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     1170 <main+0x50>
cmp    $0x2,%edx
jb     1150 <main+0x30>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"Num=\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"The Number %d is met %d times\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 ([5 x i8], [5 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, %23
%6 = phi i32 [ 0, %0 ], [ %24, %23 ]
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %5, %9
%10 = phi i32 [ %16, %9 ], [ %7, %5 ]
%11 = phi i32 [ %15, %9 ], [ 0, %5 ]
%12 = srem i32 %10, 10
%13 = icmp eq i32 %12, %6
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %11, %14
%16 = sdiv i32 %10, 10
%17 = add i32 %10, 9
%18 = icmp ult i32 %17, 19
br i1 %18, label %19, label %9
19: ; preds = %9
%20 = icmp ugt i32 %15, 1
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = 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 %23
23: ; preds = %5, %19, %21
%24 = add nuw nsw i32 %6, 1
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %5
26: ; preds = %23
ret i32 0
}