#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  scanf("%d", &num);
  int octal[100];
  int i = 0, j;
  while (num != 0) {
    octal[i] = num % 8;
    num = num / 8;
    i++;
  }
  for (j = i - 1; j >= 0; j--)
    printf("%d", octal[j]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1191 <main+0x71>
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
movslq -0x1a4(%rbp),%rax
mov    %edx,-0x1a0(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    114c <main+0x2c>
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
cmpl   $0x0,-0x1a8(%rbp)
jl     11db <main+0xbb>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1a8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11a0 <main+0x80>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0xecf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     11a9 <main+0x89>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x7(%rcx),%edx
test   %ecx,%ecx
mov    %ecx,%esi
cmovs  %edx,%esi
mov    %esi,%edi
and    $0xfffffff8,%edi
sub    %edi,%ecx
mov    %ecx,0x10(%rsp,%rax,4)
mov    %esi,%ecx
sar    $0x3,%ecx
add    $0x1,%rax
cmp    $0xf,%edx
jae    1150 <main+0x30>
mov    %ecx,0xc(%rsp)
test   %eax,%eax
jle    11a9 <main+0x89>
mov    %eax,%ebx
add    $0x1,%rbx
lea    0xe78(%rip),%r14
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1190 <main+0x70>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 8
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %14
store i32 %12, i32* %15
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 8
store i32 %17, i32* %2
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %7
20: ; preds = %7
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
store i32 %22, i32* %5
br label %23
23: ; preds = %32, %20
%24 = load i32, i32* %5
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %5
%34 = add nsw i32 %33, -1
store i32 %34, i32* %5
br label %23
35: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = bitcast [100 x i32]* %2 to i8*
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %30, label %13
8: ; preds = %13
%9 = trunc i64 %19 to i32
store i32 %18, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = and i64 %19, 4294967295
br label %22
13: ; preds = %0, %13
%14 = phi i64 [ %19, %13 ], [ 0, %0 ]
%15 = phi i32 [ %18, %13 ], [ %6, %0 ]
%16 = srem i32 %15, 8
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %14
store i32 %16, i32* %17
%18 = sdiv i32 %15, 8
%19 = add nuw i64 %14, 1
%20 = add i32 %15, 7
%21 = icmp ult i32 %20, 15
br i1 %21, label %8, label %13
22: ; preds = %11, %22
%23 = phi i64 [ %12, %11 ], [ %24, %22 ]
%24 = add nsw i64 %23, -1
%25 = and i64 %24, 4294967295
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = icmp ugt i64 %23, 1
br i1 %29, label %22, label %30
30: ; preds = %22, %0, %8
ret i32 0
}