#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) {
  int digit;
  bool digit_repeated[10] = {false}, first_rep = true, repeated = false;
  long n;
  printf("enter a digit:\n");
  scanf("%ld", &n);
  while (n > 0) {
    digit = n % 10;
    n = n / 10;
    if (!digit_repeated[digit]) {
      digit_repeated[digit] = true;
    } else {
      repeated = true;
      if (first_rep) {
        printf("repeated digit: %d ", digit);
        first_rep = false;
      } else {
        printf("%d ", digit);
      }
    }
  }
  if (!repeated) {
    printf("no repeated digit\n");
  } else {
    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>
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <scanf@plt>
cmpq   $0x0,-0x40(%rbp)
jle    1214 <main+0xe4>
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
jne    11cb <main+0x9b>
movslq -0x8(%rbp),%rax
movl   $0x1,-0x30(%rbp,%rax,4)
jmp    120f <main+0xdf>
movl   $0x1,-0x38(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11f9 <main+0xc9>
mov    -0x8(%rbp),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
jmp    120a <main+0xda>
mov    -0x8(%rbp),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120f <main+0xdf>
jmp    117b <main+0x4b>
cmpl   $0x0,-0x38(%rbp)
jne    1231 <main+0x101>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <main+0x10f>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8d(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
jle    1213 <main+0xd3>
mov    $0x1,%ebp
xor    %ecx,%ecx
movabs $0xcccccccccccccccd,%rbx
cc cc cc
lea    0xe71(%rip),%r15
lea    0xe5a(%rip),%r14
jmp    11c2 <main+0x82>
nopl   0x0(%rax)
movl   $0x1,0x10(%rsp,%rsi,4)
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
jle    1203 <main+0xc3>
mov    %rsi,%rax
mul    %rbx
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
sub    %rax,%rsi
mov    %rdx,0x8(%rsp)
cmpl   $0x0,0x10(%rsp,%rsi,4)
je     11b0 <main+0x70>
test   %ebp,%ebp
jne    11f0 <main+0xb0>
xor    %ebp,%ebp
mov    %r15,%rdi
jmp    11f5 <main+0xb5>
xchg   %ax,%ax
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ecx
jmp    11b8 <main+0x78>
test   %ecx,%ecx
je     1213 <main+0xd3>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    121f <main+0xdf>
lea    0xe0d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [20 x i8] c"repeated digit: %d \00"
@.str.3 = [4 x i8] c"%d \00"
@str = [15 x i8] c"enter a digit:\00"
@str.6 = [18 x i8] c"no repeated digit\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 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 = load i64, i64* %2
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %0, %26
%10 = phi i64 [ %29, %26 ], [ %7, %0 ]
%11 = phi i32 [ %28, %26 ], [ 0, %0 ]
%12 = phi i32 [ %27, %26 ], [ 1, %0 ]
%13 = urem i64 %10, 10
%14 = trunc i64 %13 to i32
%15 = udiv i64 %10, 10
store i64 %15, i64* %2
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %13
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %9
store i32 1, i32* %16
br label %26
20: ; preds = %9
%21 = icmp eq i32 %12, 0
br i1 %21, label %24, label %22
22: ; preds = %20
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %26
26: ; preds = %22, %24, %19
%27 = phi i32 [ 0, %22 ], [ 0, %24 ], [ %12, %19 ]
%28 = phi i32 [ 1, %22 ], [ 1, %24 ], [ %11, %19 ]
%29 = load i64, i64* %2
%30 = icmp sgt i64 %29, 0
br i1 %30, label %9, label %31
31: ; preds = %26
%32 = icmp eq i32 %28, 0
br i1 %32, label %33, label %35
33: ; preds = %0, %31
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %37
35: ; preds = %31
%36 = call i32 @putchar(i32 10)
br label %37
37: ; preds = %35, %33
ret i32 0
}