#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, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, tmp, cnt = 0, i = 0;
  scanf("%d", &num);
  while (i < 10) {
    tmp = num;
    cnt = 0;
    while (tmp > 0) {
      if (i == tmp % 10)
        cnt++;
      tmp /= 10;
    }
    if (cnt >= 2) {
      printf("%d is met exactly %d times\n", i, cnt);
    }
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xa,-0x14(%rbp)
jge    11d0 <main+0xb0>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11a6 <main+0x86>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
cmp    %edx,%eax
jne    1193 <main+0x73>
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    1164 <main+0x44>
cmpl   $0x2,-0x10(%rbp)
jl     11c2 <main+0xa2>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
xor    %ebx,%ebx
mov    $0xcccccccd,%r15d
lea    0xeba(%rip),%r14
jmp    1158 <main+0x38>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0xa,%ebx
je     11a6 <main+0x86>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1150 <main+0x30>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ecx
imul   %r15,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %eax,%edi
sub    %esi,%edi
xor    %esi,%esi
cmp    %edi,%ebx
sete   %sil
add    %esi,%edx
cmp    $0x9,%eax
mov    %ecx,%eax
ja     1170 <main+0x50>
cmp    $0x2,%edx
jb     1150 <main+0x30>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [28 x i8] c"%d is met exactly %d times\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %4
4: ; preds = %0, %21
%5 = phi i32 [ 0, %0 ], [ %22, %21 ]
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %4, %8
%9 = phi i32 [ %14, %8 ], [ 0, %4 ]
%10 = phi i32 [ %15, %8 ], [ %6, %4 ]
%11 = urem i32 %10, 10
%12 = icmp eq i32 %5, %11
%13 = zext i1 %12 to i32
%14 = add nuw nsw i32 %9, %13
%15 = udiv i32 %10, 10
%16 = icmp ult i32 %10, 10
br i1 %16, label %17, label %8
17: ; preds = %8
%18 = icmp ugt i32 %14, 1
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %14)
br label %21
21: ; preds = %4, %19, %17
%22 = add nuw nsw i32 %5, 1
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %4
24: ; preds = %21
ret i32 0
}