#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 */
struct stack {
  int dummy;
};

/* Variables and functions */
struct stack *init_stack();
scalar_t__ is_empty(struct stack *);
int /*<<< orphan*/ pop(struct stack *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int, struct stack *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  struct stack *s = init_stack();
  int n;
  scanf("%d", &n);
  while (n > 0) {
    push(n % 8, s);
    n /= 8;
  }
  int m;
  printf("0");
  while (1) {
    if (is_empty(s))
      break;
    pop(s, &m);
    printf("%d", m);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <init_stack@plt>
mov    %rax,-0x18(%rbp)
lea    0xe78(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x1c(%rbp)
jle    11c4 <main+0x64>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0x18(%rbp),%rsi
call   1080 <push@plt>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
jmp    1191 <main+0x31>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <is_empty@plt>
cmp    $0x0,%rax
je     11ea <main+0x8a>
jmp    120d <main+0xad>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <pop@plt>
mov    -0x20(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <main+0x72>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1080 <init_stack@plt>
mov    %rax,%rbx
lea    0xe76(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%edi
test   %edi,%edi
jle    11c3 <main+0x53>
nopl   0x0(%rax)
and    $0x7,%edi
mov    %rbx,%rsi
call   1090 <push@plt>
mov    0x8(%rsp),%eax
lea    0x7(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x3,%edi
mov    %edi,0x8(%rsp)
cmp    $0x7,%eax
jg     11a0 <main+0x30>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <is_empty@plt>
test   %rax,%rax
jne    1216 <main+0xa6>
lea    0xc(%rsp),%r14
lea    0xe1a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <pop@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <is_empty@plt>
test   %rax,%rax
je     11f0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.stack = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = tail call %struct.stack* (...) @init_stack()
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2, %10
%11 = phi i32 [ %15, %10 ], [ %8, %2 ]
%12 = and i32 %11, 7
%13 = call i32 @push(i32 %12, %struct.stack* %5)
%14 = load i32, i32* %3
%15 = sdiv i32 %14, 8
store i32 %15, i32* %3
%16 = icmp sgt i32 %14, 7
br i1 %16, label %10, label %17
17: ; preds = %10, %2
%18 = bitcast i32* %4 to i8*
%19 = call i32 @putchar(i32 48)
%20 = call i64 @is_empty(%struct.stack* %5)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %17, %22
%23 = call i32 @pop(%struct.stack* %5, i32* %4)
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = call i64 @is_empty(%struct.stack* %5)
%27 = icmp eq i64 %26, 0
br i1 %27, label %22, label %28
28: ; preds = %22, %17
%29 = call i32 @putchar(i32 10)
ret i32 0
}