#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 digit_seen[10] = {false};
  int digit;
  long n;
  while (1) {
    printf("Enter a number: ");
    scanf("%ld", &n);
    if (n <= 0) {
      printf("Error: the value of number is invailded.\n");
      break;
    }
    while (n > 0) {
      digit = n % 10;
      if (digit_seen[digit])
        break;
      digit_seen[digit] = true;
      n /= 10;
    }
    if (n > 0)
      printf("Repeated digit\n");
    else
      printf("No repeated digit\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
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <scanf@plt>
cmpq   $0x0,-0x40(%rbp)
jg     1187 <main+0x57>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    120e <main+0xde>
jmp    118c <main+0x5c>
cmpq   $0x0,-0x40(%rbp)
jle    11e1 <main+0xb1>
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     11be <main+0x8e>
jmp    11e1 <main+0xb1>
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    118c <main+0x5c>
cmpq   $0x0,-0x40(%rbp)
jle    11fd <main+0xcd>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
jmp    1209 <main+0xd9>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
jle    120f <main+0xdf>
movabs $0xcccccccccccccccd,%r13
cc cc cc
lea    0xe97(%rip),%rbx
lea    0xe7e(%rip),%rbp
lea    0xe62(%rip),%r14
lea    0xe6c(%rip),%r15
lea    0x8(%rsp),%r12
jmp    11d2 <main+0xa2>
nopl   0x0(%rax)
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
jle    120f <main+0xdf>
mov    %rcx,%rax
mul    %r13
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rsi
mov    %rcx,%rax
sub    %rsi,%rax
cmpl   $0x0,0x10(%rsp,%rax,4)
mov    %rbx,%rdi
jne    11b0 <main+0x80>
movl   $0x1,0x10(%rsp,%rax,4)
mov    %rdx,0x8(%rsp)
mov    %rbp,%rdi
cmp    $0x9,%rcx
mov    %rdx,%rcx
ja     11d2 <main+0xa2>
jmp    11b0 <main+0x80>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [42 x i8] c"Error: the value of number is invailded.\0A\00"
@.str.3 = [16 x i8] c"Repeated digit\0A\00"
@.str.4 = [19 x i8] c"No repeated digit\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*
br label %6
6: ; preds = %0, %40
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%9 = load i64, i64* %4
%10 = icmp sle i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %41
13: ; preds = %6
br label %14
14: ; preds = %27, %13
%15 = load i64, i64* %4
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = load i64, i64* %4
%19 = srem i64 %18, 10
%20 = trunc i64 %19 to i32
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %17
br label %33
27: ; preds = %17
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %29
store i32 1, i32* %30
%31 = load i64, i64* %4
%32 = sdiv i64 %31, 10
store i64 %32, i64* %4
br label %14
33: ; preds = %26, %14
%34 = load i64, i64* %4
%35 = icmp sgt i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %40
38: ; preds = %33
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %6
41: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@str = [18 x i8] c"No repeated digit\00"
@str.5 = [15 x i8] c"Repeated digit\00"
@str.6 = [41 x i8] c"Error: the value of number is invailded.\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 = call i32 @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 = load i64, i64* %2
%8 = icmp slt i64 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %22, %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.6, i64 0, i64 0))
ret i32 0
11: ; preds = %0, %20
%12 = phi i64 [ %21, %20 ], [ %7, %0 ]
%13 = urem i64 %12, 10
%14 = udiv i64 %12, 10
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %13
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %11
store i32 1, i32* %15
store i64 %14, i64* %2
%19 = icmp ult i64 %12, 10
br i1 %19, label %22, label %20
20: ; preds = %18, %22
%21 = phi i64 [ %14, %18 ], [ %27, %22 ]
br label %11
22: ; preds = %18, %11
%23 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0), %18 ]
%24 = call i32 @puts(i8* dereferenceable(1) %23)
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%27 = load i64, i64* %2
%28 = icmp slt i64 %27, 1
br i1 %28, label %9, label %20
}