#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 *, long *);
int main(void) {
  bool seen[10] = {false};
  int digit;
  long n;
  printf("enter a number: ");
  scanf("%ld", &n);
  printf("repeated digit(s): ");
  while (n > 0) {
    digit = n % 10;
    if (seen[digit])
      printf(" %d", digit);
    seen[digit] = true;
    n /= 10;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%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    -0x40(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x40(%rbp)
jle    11dc <main+0xac>
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
je     11b9 <main+0x89>
mov    -0x34(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x34(%rbp),%rax
movl   $0x1,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
jmp    117b <main+0x4b>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
jle    120c <main+0xdc>
movabs $0xcccccccccccccccd,%r15
cc cc cc
movabs $0x6666666666666667,%r12
66 66 66
lea    0xe82(%rip),%r14
jmp    11da <main+0xaa>
nopl   0x0(%rax)
movl   $0x1,0x10(%rsp,%rbx,4)
mov    %rcx,%rax
imul   %r12
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
mov    %rdx,0x8(%rsp)
cmp    $0x9,%rcx
mov    %rdx,%rcx
jle    120c <main+0xdc>
mov    %rcx,%rax
mul    %r15
shr    $0x2,%rdx
and    $0xfffffffffffffffe,%rdx
lea    (%rdx,%rdx,4),%rax
mov    %rcx,%rbx
sub    %rax,%rbx
cmpl   $0x0,0x10(%rsp,%rbx,4)
je     11b0 <main+0x80>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rcx
jmp    11b0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"enter a number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [20 x i8] c"repeated digit(s): \00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i64
store i32 0, i32* %1
%5 = bitcast [10 x i32]* %2 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %24, %0
%10 = load i64, i64* %4
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i64, i64* %4
%14 = srem i64 %13, 10
%15 = trunc i64 %14 to i32
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %12
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21, %12
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %26
store i32 1, i32* %27
%28 = load i64, i64* %4
%29 = sdiv i64 %28, 10
store i64 %29, i64* %4
br label %9
30: ; preds = %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"enter a number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [20 x i8] c"repeated digit(s): \00"
@.str.3 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i64
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = load i64, i64* %2
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %0, %20
%11 = phi i64 [ %22, %20 ], [ %8, %0 ]
%12 = urem i64 %11, 10
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = trunc i64 %12 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i64, i64* %2
br label %20
20: ; preds = %16, %10
%21 = phi i64 [ %19, %16 ], [ %11, %10 ]
store i32 1, i32* %13
%22 = sdiv i64 %21, 10
store i64 %22, i64* %2
%23 = icmp sgt i64 %21, 9
br i1 %23, label %10, label %24
24: ; preds = %20, %0
%25 = call i32 @putchar(i32 10)
ret i32 0
}