#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 *, char *);
int scanf(char *, int *);
int main() {
  int dec, i;
  char oct[5 + 1] = {0};
  if (scanf("%d", &dec) == 1)
    if (0 <= dec && dec <= 32767) {
      for (i = 5; i > 0; i--) {
        oct[i - 1] = dec % 8 + '0';
        dec /= 8;
      }
      printf("%s\n", oct);
    }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x12(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11de <main+0xae>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jg     11d9 <main+0xa9>
cmpl   $0x7fff,-0x8(%rbp)
jg     11d9 <main+0xa9>
movl   $0x5,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11c9 <main+0x99>
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1187 <main+0x57>
lea    -0x12(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    11de <main+0xae>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movb   $0x0,0x13(%rsp)
lea    0xed0(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11ad <main+0x8d>
mov    0x14(%rsp),%eax
cmp    $0x7fff,%eax
ja     11ad <main+0x8d>
mov    %eax,%ecx
and    $0x7,%cl
or     $0x30,%cl
mov    %cl,0x12(%rsp)
mov    %eax,%ecx
shr    $0x3,%cl
and    $0x7,%cl
or     $0x30,%cl
mov    %cl,0x11(%rsp)
mov    %eax,%ecx
shr    $0x6,%ecx
and    $0x7,%cl
or     $0x30,%cl
mov    %cl,0x10(%rsp)
mov    %eax,%ecx
shr    $0x9,%ecx
and    $0x7,%cl
or     $0x30,%cl
mov    %cl,0xf(%rsp)
mov    %eax,%ecx
shr    $0xc,%ecx
and    $0x7,%cl
or     $0x30,%cl
mov    %cl,0xe(%rsp)
shr    $0xf,%eax
and    $0x1,%eax
mov    %eax,0x14(%rsp)
lea    0xe60(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 5
store i8 0, i8* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = icmp eq i32 %6, 1
%8 = load i32, i32* %1
%9 = icmp ult i32 %8, 32768
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %40
11: ; preds = %0
%12 = trunc i32 %8 to i8
%13 = and i8 %12, 7
%14 = or i8 %13, 48
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 4
store i8 %14, i8* %15
%16 = trunc i32 %8 to i8
%17 = lshr i8 %16, 3
%18 = and i8 %17, 7
%19 = or i8 %18, 48
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 3
store i8 %19, i8* %20
%21 = lshr i32 %8, 6
%22 = trunc i32 %21 to i8
%23 = and i8 %22, 7
%24 = or i8 %23, 48
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 2
store i8 %24, i8* %25
%26 = trunc i32 %8 to i16
%27 = lshr i16 %26, 9
%28 = trunc i16 %27 to i8
%29 = and i8 %28, 7
%30 = or i8 %29, 48
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 1
store i8 %30, i8* %31
%32 = trunc i32 %8 to i16
%33 = lshr i16 %32, 12
%34 = trunc i16 %33 to i8
%35 = and i8 %34, 7
%36 = or i8 %35, 48
store i8 %36, i8* %4
%37 = lshr i32 %8, 15
%38 = and i32 %37, 1
store i32 %38, i32* %1
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %40
40: ; preds = %11, %0
ret i32 0
}