#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 index_of(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n;
  int q;
  int r;
  int m;
  int t, u;
  int d[100];
  int s[100];
  int i;
  scanf("%d", &n);
  r = 10;
  m = 0;
  while (1) {
    q = r / n;
    r = (r % n) * 10;
    if (r == 0 && q == 0) {
      t = u = -1;
      break;
    }
    t = index_of(d, q, m);
    u = index_of(s, r, m);
    if (t != -1 && u != -1)
      break;
    d[m] = q;
    s[m] = r;
    m++;
  }
  printf("0.");
  for (i = 0; i < m; i++) {
    if (i == t) {
      printf("'");
    }
    printf("%d", d[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0xa,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x8(%rbp)
imul   $0xa,%edx,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    119e <main+0x6e>
cmpl   $0x0,-0xc(%rbp)
jne    119e <main+0x6e>
movl   $0xffffffff,-0x1c(%rbp)
movl   $0xffffffff,-0x18(%rbp)
jmp    120b <main+0xdb>
lea    -0x1b0(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <index_of@plt>
mov    %eax,-0x18(%rbp)
lea    -0x340(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <index_of@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     11e1 <main+0xb1>
cmpl   $0xffffffff,-0x1c(%rbp)
je     11e1 <main+0xb1>
jmp    120b <main+0xdb>
mov    -0xc(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x1b0(%rbp,%rax,4)
mov    -0x10(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <main+0x30>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x344(%rbp)
mov    -0x344(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    127f <main+0x14f>
mov    -0x344(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    124f <main+0x11f>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x344(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    1223 <main+0xf3>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x338,%rsp
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%eax
xor    %edx,%edx
idivl  0xc(%rsp)
mov    %eax,%ebp
mov    %edx,%eax
or     %ebp,%eax
je     11df <main+0x9f>
xor    %ebx,%ebx
lea    0x10(%rsp),%r14
lea    0x1a0(%rsp),%r15
jmp    11b0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,0x10(%rsp,%rbx,4)
mov    %r13d,0x1a0(%rsp,%rbx,4)
mov    %r13d,%eax
cltd
idivl  0xc(%rsp)
add    $0x1,%rbx
mov    %edx,%ecx
mov    %eax,%ebp
or     %eax,%ecx
je     11ef <main+0xaf>
add    %edx,%edx
lea    (%rdx,%rdx,4),%r13d
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <index_of@plt>
mov    %eax,%r12d
mov    %r15,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1040 <index_of@plt>
cmp    $0xffffffff,%r12d
je     1190 <main+0x50>
cmp    $0xffffffff,%eax
je     1190 <main+0x50>
jmp    11f5 <main+0xb5>
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1248 <main+0x108>
mov    $0xffffffff,%r12d
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
je     1248 <main+0x108>
mov    %r12d,%r15d
mov    %ebx,%ebx
lea    0xded(%rip),%r14
xor    %ebp,%ebp
jmp    1237 <main+0xf7>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1248 <main+0x108>
cmp    %rbp,%r15
jne    1220 <main+0xe0>
mov    $0x27,%edi
call   1030 <putchar@plt>
jmp    1220 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x338,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"0.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca [100 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast [100 x i32]* %2 to i8*
%6 = bitcast [100 x i32]* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = sdiv i32 10, %8
%10 = srem i32 10, %8
%11 = or i32 %10, %9
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %58
15: ; preds = %0
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
br label %18
18: ; preds = %15, %29
%19 = phi i64 [ 0, %15 ], [ %32, %29 ]
%20 = phi i32 [ %10, %15 ], [ %35, %29 ]
%21 = phi i32 [ %9, %15 ], [ %34, %29 ]
%22 = mul nsw i32 %20, 10
%23 = trunc i64 %19 to i32
%24 = call i32 @index_of(i32* %16, i32 %21, i32 %23)
%25 = call i32 @index_of(i32* %17, i32 %22, i32 %23)
%26 = icmp ne i32 %24, -1
%27 = icmp ne i32 %25, -1
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %38, label %29
29: ; preds = %18
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %19
store i32 %21, i32* %30
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %19
store i32 %22, i32* %31
%32 = add nuw i64 %19, 1
%33 = load i32, i32* %1
%34 = sdiv i32 %22, %33
%35 = srem i32 %22, %33
%36 = or i32 %35, %34
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %18
38: ; preds = %29, %18
%39 = phi i64 [ %19, %18 ], [ %32, %29 ]
%40 = phi i32 [ %24, %18 ], [ -1, %29 ]
%41 = trunc i64 %39 to i32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%43 = icmp eq i32 %41, 0
br i1 %43, label %58, label %44
44: ; preds = %38
%45 = zext i32 %40 to i64
%46 = and i64 %39, 4294967295
br label %47
47: ; preds = %44, %52
%48 = phi i64 [ 0, %44 ], [ %56, %52 ]
%49 = icmp eq i64 %48, %45
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @putchar(i32 39)
br label %52
52: ; preds = %50, %47
%53 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %48
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %54)
%56 = add nuw nsw i64 %48, 1
%57 = icmp eq i64 %56, %46
br i1 %57, label %58, label %47
58: ; preds = %52, %13, %38
%59 = call i32 @putchar(i32 10)
ret i32 0
}