#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_repeated[10] = {false};
  int digit;
  long n;
  while (1) {
    printf("enter a number:\n");
    scanf("%ld", &n);
    if (n != 0) {
      while (n > 0) {
        digit = n % 10;
        if (digit_repeated[digit]) {
          break;
        }
        digit_repeated[digit] = true;
        n = n / 10;
      }
      if (n > 0) {
        printf("repeated digit\n");
      } else {
        printf("no repeated digit\n");
      }
      for (int i = 0; i < 10; i++) {
        digit_repeated[i] = false;
      }
    } else {
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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)
je     1228 <main+0xf8>
jmp    117b <main+0x4b>
cmpq   $0x0,-0x40(%rbp)
jle    11d0 <main+0xa0>
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     11ad <main+0x7d>
jmp    11d0 <main+0xa0>
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>
cmpq   $0x0,-0x40(%rbp)
jle    11ec <main+0xbc>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
jmp    11f8 <main+0xc8>
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    1223 <main+0xf3>
movslq -0x44(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11ff <main+0xcf>
jmp    122d <main+0xfd>
jmp    1232 <main+0x102>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x50,%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    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     122d <main+0x10d>
lea    0xe9e(%rip),%r13
movabs $0xcccccccccccccccd,%rbx
cc cc cc
lea    0xe90(%rip),%rbp
lea    0xe76(%rip),%r14
lea    0xe6b(%rip),%r15
lea    0x8(%rsp),%r12
jmp    11db <main+0xbb>
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     122d <main+0x10d>
mov    %r13,%rdi
test   %rcx,%rcx
jle    11a3 <main+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rcx,%rax
mul    %rbx
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)
jne    11a0 <main+0x80>
movl   $0x1,0x10(%rsp,%rax,4)
mov    %rdx,0x8(%rsp)
cmp    $0x9,%rcx
mov    %rdx,%rcx
ja     11f0 <main+0xd0>
mov    %r13,%rdi
jmp    11a3 <main+0x83>
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:\0A\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [16 x i8] c"repeated digit\0A\00"
@.str.3 = [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
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %2 to i8*
br label %7
7: ; preds = %0, %52
%8 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 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* %4)
%10 = load i64, i64* %4
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %51
12: ; preds = %7
br label %13
13: ; preds = %26, %12
%14 = load i64, i64* %4
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %13
%17 = load i64, i64* %4
%18 = srem i64 %17, 10
%19 = trunc i64 %18 to i32
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %16
br label %32
26: ; preds = %16
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %28
store i32 1, i32* %29
%30 = load i64, i64* %4
%31 = sdiv i64 %30, 10
store i64 %31, i64* %4
br label %13
32: ; preds = %25, %13
%33 = load i64, i64* %4
%34 = icmp sgt i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %39
37: ; preds = %32
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
store i32 0, i32* %5
br label %40
40: ; preds = %47, %39
%41 = load i32, i32* %5
%42 = icmp slt i32 %41, 10
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %45
store i32 0, i32* %46
br label %47
47: ; preds = %43
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %40
50: ; preds = %40
br label %52
51: ; preds = %7
br label %53
52: ; preds = %50
br label %7
53: ; preds = %51
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%ld\00"
@str = [16 x i8] c"enter a number:\00"
@str.4 = [18 x i8] c"no repeated digit\00"
@str.5 = [15 x i8] c"repeated digit\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 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* %3)
%7 = load i64, i64* %3
%8 = icmp eq i64 %7, 0
br i1 %8, label %28, label %9
9: ; preds = %0, %21
%10 = phi i64 [ %26, %21 ], [ %7, %0 ]
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %9, %19
%13 = phi i64 [ %15, %19 ], [ %10, %9 ]
%14 = urem i64 %13, 10
%15 = udiv i64 %13, 10
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %14
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
store i32 1, i32* %16
store i64 %15, i64* %3
%20 = icmp ult i64 %13, 10
br i1 %20, label %21, label %12
21: ; preds = %19, %12, %9
%22 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0), %19 ]
%23 = call i32 @puts(i8* dereferenceable(1) %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%26 = load i64, i64* %3
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %9
28: ; preds = %21, %0
ret i32 0
}