#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 decimal;
  int base = 1;
  while (num) {
    int x = num % 10;
    num = num / 10;
    decimal += x * base;
    base = base * 8;
  }
  printf("%d", decimal);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1187 <main+0x67>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <main+0x26>
mov    -0xc(%rbp),%esi
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%eax
mov    0x4(%rsp),%ecx
nopl   0x0(%rax,%rax,1)
movslq %ecx,%rdx
imul   $0x66666667,%rdx,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rcx
add    %edi,%ecx
lea    (%rcx,%rcx,1),%edi
lea    (%rdi,%rdi,4),%r8d
mov    %edx,%edi
sub    %r8d,%edi
imul   %eax,%edi
add    %edi,%esi
shl    $0x3,%eax
add    $0x9,%edx
cmp    $0x12,%edx
ja     1140 <main+0x20>
mov    %ecx,0x4(%rsp)
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca 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 1, 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 %22
10: ; preds = %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 10
store i32 %12, i32* %5
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 10
store i32 %14, i32* %2
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = mul nsw i32 %15, %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, %17
store i32 %19, i32* %3
%20 = load i32, i32* %4
%21 = mul nsw i32 %20, 8
store i32 %21, i32* %4
br label %7
22: ; preds = %7
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ %13, %6 ], [ undef, %0 ]
%8 = phi i32 [ %14, %6 ], [ 1, %0 ]
%9 = phi i32 [ %11, %6 ], [ %4, %0 ]
%10 = srem i32 %9, 10
%11 = sdiv i32 %9, 10
%12 = mul nsw i32 %10, %8
%13 = add nsw i32 %7, %12
%14 = shl nsw i32 %8, 3
%15 = add i32 %9, 9
%16 = icmp ult i32 %15, 19
br i1 %16, label %17, label %6
17: ; preds = %6
store i32 %11, i32* %1
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
ret i32 0
}