#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
void main() {
  char *p, s[6];
  int n;
  p = s;
  gets(p);
  n = 0;
  while (*p != '\0') {
    n = n * 8 + *p - '0';
    p++;
  }
  printf("%d\n", n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0xe(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1176 <main+0x56>
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1140 <main+0x20>
mov    -0x14(%rbp),%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0x2(%rsp),%rdi
call   1040 <gets@plt>
mov    0x2(%rsp),%cl
test   %cl,%cl
je     1156 <main+0x36>
lea    0x3(%rsp),%rax
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movsbl %cl,%ecx
lea    (%rcx,%rsi,8),%esi
add    $0xffffffd0,%esi
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1140 <main+0x20>
jmp    1158 <main+0x38>
xor    %esi,%esi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i8*
%2 = alloca [6 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
store i8* %4, i8** %1
%5 = load i8*, i8** %1
%6 = call i32 @gets(i8* %5)
store i32 0, i32* %3
br label %7
7: ; preds = %12, %0
%8 = load i8*, i8** %1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i32, i32* %3
%14 = mul nsw i32 %13, 8
%15 = load i8*, i8** %1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = add nsw i32 %14, %17
%19 = sub nsw i32 %18, 48
store i32 %19, i32* %3
%20 = load i8*, i8** %1
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %1
br label %7
22: ; preds = %7
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
ret void
}

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