#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main(void) {
  int n;
  char ans[32];
  int len;
  while (scanf("%d", &n) != EOF) {
    len = 0;
    while (n) {
      int num = n % 8;
      ans[len] = num + '0';
      n /= 8;
      ++len;
    }
    if (len > 0) {
      for (int i = len - 1; i >= 0; --i) {
        printf("%c", ans[i]);
      }
      printf("\n");
    } else {
      printf("0\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%rax
je     1202 <main+0xe2>
movl   $0x0,-0x34(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     119a <main+0x7a>
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1156 <main+0x36>
cmpl   $0x0,-0x34(%rbp)
jle    11ef <main+0xcf>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     11dc <main+0xbc>
movslq -0x3c(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ad <main+0x8d>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <main+0xdd>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e93(%rip),%r13
cmp    0x0(%r13),%rax
jne    116b <main+0x3b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe91(%rip),%r14
lea    0xe87(%rip),%r15
lea    0xc(%rsp),%r12
jmp    1199 <main+0x69>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    0x0(%r13),%rax
je     115b <main+0x2b>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     1180 <main+0x50>
mov    $0x1,%esi
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    %esi,%edx
lea    0x7(%rcx),%edi
test   %ecx,%ecx
mov    %ecx,%ebx
cmovs  %edi,%ebx
mov    %ebx,%esi
and    $0xfffffff8,%esi
sub    %esi,%ecx
add    $0x30,%cl
mov    %cl,0x10(%rsp,%rax,1)
mov    %ebx,%ecx
sar    $0x3,%ecx
add    $0x1,%rax
lea    0x1(%rdx),%esi
cmp    $0xe,%edi
ja     11b0 <main+0x80>
mov    %ecx,0xc(%rsp)
test   %eax,%eax
je     1180 <main+0x50>
test   %eax,%eax
jle    1207 <main+0xd7>
mov    %edx,%ebx
add    $0x1,%rbx
nopl   (%rax)
lea    -0x2(%rbx),%eax
movsbl 0x10(%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11f0 <main+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1188 <main+0x58>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@str = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %46, label %8
8: ; preds = %0, %42
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %40, label %11
11: ; preds = %8, %11
%12 = phi i64 [ %19, %11 ], [ 0, %8 ]
%13 = phi i32 [ %18, %11 ], [ %9, %8 ]
%14 = srem i32 %13, 8
%15 = trunc i32 %14 to i8
%16 = add nsw i8 %15, 48
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 %12
store i8 %16, i8* %17
%18 = sdiv i32 %13, 8
%19 = add nuw i64 %12, 1
%20 = add i32 %13, 7
%21 = icmp ult i32 %20, 15
br i1 %21, label %22, label %11
22: ; preds = %11
%23 = trunc i64 %19 to i32
store i32 %18, i32* %1
%24 = icmp eq i32 %23, 0
br i1 %24, label %40, label %25
25: ; preds = %22
%26 = icmp sgt i32 %23, 0
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = and i64 %19, 4294967295
br label %31
29: ; preds = %31, %25
%30 = call i32 @putchar(i32 10)
br label %42
31: ; preds = %27, %31
%32 = phi i64 [ %28, %27 ], [ %33, %31 ]
%33 = add nsw i64 %32, -1
%34 = and i64 %33, 4294967295
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i32 @putchar(i32 %37)
%39 = icmp ugt i64 %32, 1
br i1 %39, label %31, label %29
40: ; preds = %8, %22
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %40, %29
%43 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%44 = load i64, i64* @EOF
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %8
46: ; preds = %42, %0
ret i32 0
}