#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 seq_stack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
struct seq_stack *init_stack(int);
int pop(struct seq_stack *, int *);
int /*<<< orphan*/ printf(char *, ...);
int push(int, struct seq_stack *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  struct seq_stack *s = init_stack(10);
  int n;
  scanf("%d", &n);
  while (n > 0) {
    if (push(n % 8, s) == false) {
      printf("push() failed");
      exit(1);
    }
    n /= 8;
  }
  printf("0");
  int m;
  while (1) {
    if (pop(s, &m) == false) {
      break;
    }
    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    $0xa,%edi
call   1060 <init_stack@plt>
mov    %rax,-0x18(%rbp)
lea    0xe75(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x1c(%rbp)
jle    11e8 <main+0x88>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0x18(%rbp),%rsi
call   1070 <push@plt>
cmp    $0x0,%eax
jne    11d5 <main+0x75>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
jmp    1194 <main+0x34>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <pop@plt>
cmp    $0x0,%eax
jne    1211 <main+0xb1>
jmp    1227 <main+0xc7>
mov    -0x20(%rbp),%esi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f6 <main+0x96>
lea    0xde5(%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
mov    $0xa,%edi
call   1070 <init_stack@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%edi
test   %edi,%edi
jle    11c7 <main+0x57>
nop
and    $0x7,%edi
mov    %rbx,%rsi
call   1080 <push@plt>
test   %eax,%eax
je     1223 <main+0xb3>
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>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <pop@plt>
test   %eax,%eax
je     120d <main+0x9d>
lea    0xe17(%rip),%r14
lea    0xc(%rsp),%r15
xchg   %ax,%ax
mov    0xc(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <pop@plt>
test   %eax,%eax
jne    11f0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdd9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.seq_stack = type { i32 }
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"push() failed\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [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.seq_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.seq_stack* @init_stack(i32 10)
store %struct.seq_stack* %9, %struct.seq_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 = %23, %2
%12 = load i32, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i32, i32* %7
%16 = srem i32 %15, 8
%17 = load %struct.seq_stack*, %struct.seq_stack** %6
%18 = call i32 @push(i32 %16, %struct.seq_stack* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %14
%24 = load i32, i32* %7
%25 = sdiv i32 %24, 8
store i32 %25, i32* %7
br label %11
26: ; preds = %11
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %33
%29 = load %struct.seq_stack*, %struct.seq_stack** %6
%30 = call i32 @pop(%struct.seq_stack* %29, i32* %8)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
br label %36
33: ; preds = %28
%34 = load i32, i32* %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %28
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

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