#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stdin;
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int ac, char *av[]) {
  int count, i, n, _n, types[10];
  char buf[1024];
  while (fgets(buf, 1024, stdin)) {
    n = strtol(buf, NULL, 10);
    for (i = 0; i < 10; i++)
      types[i] = 0;
    _n = n;
    while (_n != 0) {
      types[_n % 10]++;
      _n /= 10;
    }
    count = 0;
    for (i = 0; i < 10; i++)
      if (types[i] != 0)
        count++;
    printf("%d %d\n", n, count);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x450(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1246 <main+0x116>
lea    -0x450(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    11b0 <main+0x80>
movslq -0x18(%rbp),%rax
movl   $0x0,-0x50(%rbp,%rax,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118c <main+0x5c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11ec <main+0xbc>
mov    -0x20(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x50(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
jmp    11b6 <main+0x86>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    122f <main+0xff>
movslq -0x18(%rbp),%rax
cmpl   $0x0,-0x50(%rbp,%rax,4)
je     121c <main+0xec>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1221 <main+0xf1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fa <main+0xca>
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xdc4(%rip),%rdi
call   1030 <printf@plt>
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    0x2ea3(%rip),%r15
mov    (%r15),%edx
lea    0x30(%rsp),%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1278 <main+0x148>
lea    0x30(%rsp),%r12
lea    0xe94(%rip),%r14
jmp    11ec <main+0xbc>
xchg   %ax,%ax
xor    %esi,%esi
pxor   %xmm0,%xmm0
pxor   %xmm1,%xmm1
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm3,%xmm3
pxor   %xmm3,%xmm0
pcmpeqd %xmm2,%xmm1
pxor   %xmm3,%xmm1
packssdw %xmm1,%xmm0
packsswb %xmm0,%xmm0
pmovmskb %xmm0,%edx
mov    %edx,%ecx
shr    %cl
and    $0x55,%cl
sub    %cl,%dl
mov    %edx,%ecx
and    $0x33,%cl
shr    $0x2,%dl
and    $0x33,%dl
add    %cl,%dl
mov    %edx,%ecx
shr    $0x4,%cl
add    %dl,%cl
and    $0xf,%cl
movzbl %cl,%edx
cmp    $0x1,%esi
sbb    $0xffffffff,%edx
cmp    $0x1,%ebx
sbb    $0xffffffff,%edx
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    (%r15),%edx
mov    %r12,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1278 <main+0x148>
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
pxor   %xmm0,%xmm0
movdqa %xmm0,(%rsp)
movdqa %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
mov    %eax,%ecx
test   %eax,%eax
pxor   %xmm2,%xmm2
je     1170 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %ecx,%rdx
imul   $0x66666667,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rcx
add    %esi,%ecx
lea    (%rcx,%rcx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%edi
sub    %esi,%edi
movslq %edi,%rsi
addl   $0x1,(%rsp,%rsi,4)
add    $0x9,%edx
cmp    $0x13,%edx
jae    1230 <main+0x100>
movdqa (%rsp),%xmm0
movdqa 0x10(%rsp),%xmm1
mov    0x20(%rsp),%esi
mov    0x24(%rsp),%ebx
jmp    117a <main+0x4a>
xor    %eax,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [10 x i32]
%11 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %12
12: ; preds = %61, %2
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i64 @fgets(i8* %13, i32 1024, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %65
17: ; preds = %12
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%19 = call i32 @strtol(i8* %18, i32* null, i32 10)
store i32 %19, i32* %8
store i32 0, i32* %7
br label %20
20: ; preds = %27, %17
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i64 0, i64 %25
store i32 0, i32* %26
br label %27
27: ; preds = %23
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %20
30: ; preds = %20
%31 = load i32, i32* %8
store i32 %31, i32* %9
br label %32
32: ; preds = %35, %30
%33 = load i32, i32* %9
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %44
35: ; preds = %32
%36 = load i32, i32* %9
%37 = srem i32 %36, 10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
%42 = load i32, i32* %9
%43 = sdiv i32 %42, 10
store i32 %43, i32* %9
br label %32
44: ; preds = %32
store i32 0, i32* %6
store i32 0, i32* %7
br label %45
45: ; preds = %58, %44
%46 = load i32, i32* %7
%47 = icmp slt i32 %46, 10
br i1 %47, label %48, label %61
48: ; preds = %45
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %48
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %57
57: ; preds = %54, %48
br label %58
58: ; preds = %57
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %45
61: ; preds = %45
%62 = load i32, i32* %8
%63 = load i32, i32* %6
%64 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %62, i32 %63)
br label %12
65: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 1024, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %49, label %10
10: ; preds = %2
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
%13 = bitcast [10 x i32]* %3 to <8 x i32>*
br label %14
14: ; preds = %10, %21
%15 = call i32 @strtol(i8* nocapture %6, i32* null, i32 10)
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %39
17: ; preds = %39
%18 = load <8 x i32>, <8 x i32>* %13
%19 = load i32, i32* %11
%20 = load i32, i32* %12
br label %21
21: ; preds = %17, %14
%22 = phi i32 [ %20, %17 ], [ 0, %14 ]
%23 = phi i32 [ %19, %17 ], [ 0, %14 ]
%24 = phi <8 x i32> [ %18, %17 ], [ zeroinitializer, %14 ]
%25 = icmp ne <8 x i32> %24, zeroinitializer
%26 = icmp ne i32 %23, 0
%27 = zext i1 %26 to i32
%28 = icmp ne i32 %22, 0
%29 = zext i1 %28 to i32
%30 = bitcast <8 x i1> %25 to i8
%31 = call i8 @llvm.ctpop.i8(i8 %30)
%32 = zext i8 %31 to i32
%33 = add nuw nsw i32 %32, %27
%34 = add nuw nsw i32 %33, %29
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %34)
%36 = load i32, i32* @stdin
%37 = call i64 @fgets(i8* %6, i32 1024, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %49, label %14
39: ; preds = %14, %39
%40 = phi i32 [ %46, %39 ], [ %15, %14 ]
%41 = srem i32 %40, 10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
store i32 %45, i32* %43
%46 = sdiv i32 %40, 10
%47 = add i32 %40, 9
%48 = icmp ult i32 %47, 19
br i1 %48, label %17, label %39
49: ; preds = %21, %2
ret i32 0
}