#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*/ fgets(char *, int, int /*<<< orphan*/);
int power(int, size_t);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ stdin;
size_t strlen(char *);
int main() {
  char line[65];
  fgets(line, 65, stdin);
  size_t length = strlen(line);
  if (line[length - 1] == '\n') {
    line[length - 1] = '\0';
  }
  length = strlen(line);
  int i;
  long long sum = 0;
  for (i = length - 1; i >= 0; i--) {
    int coeff = line[i] - '0';
    sum += coeff * power(2, length - i - 1);
  }
  printf("%lld\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
mov    $0x41,%esi
call   1060 <fgets@plt>
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
sub    $0x1,%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    1196 <main+0x56>
mov    -0x58(%rbp),%rax
sub    $0x1,%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x68(%rbp)
mov    -0x58(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jl     120e <main+0xce>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
sub    $0x30,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x58(%rbp),%rsi
movslq -0x5c(%rbp),%rax
sub    %rax,%rsi
sub    $0x1,%rsi
mov    $0x2,%edi
call   1030 <power@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%eax
imul   %ecx,%eax
cltq
add    -0x68(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
jmp    11b6 <main+0x76>
mov    -0x68(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x41,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    117a <main+0x3a>
movb   $0x0,-0x1(%rsp,%rax,1)
mov    %rsp,%rdi
call   1040 <strlen@plt>
mov    %rax,%r15
add    $0xffffffff,%eax
js     11d2 <main+0x92>
mov    %eax,%r13d
lea    (%rsp,%r13,1),%r12
not    %r13
add    %r15,%r13
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movsbq (%r12),%rbx
add    $0xffffffffffffffd0,%rbx
mov    $0x2,%edi
mov    %r13,%rsi
call   1030 <power@plt>
cltq
imul   %rbx,%rax
add    %rax,%r14
add    $0xffffffff,%r15d
add    $0xffffffffffffffff,%r12
add    $0x1,%r13
test   %r15d,%r15d
jg     11a0 <main+0x60>
jmp    11d5 <main+0x95>
xor    %r14d,%r14d
lea    0xe24(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [65 x i8]
%3 = alloca i64
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 65, i32 %8)
%10 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %3
%12 = load i64, i64* %3
%13 = sub i64 %12, 1
%14 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %22
18: ; preds = %0
%19 = load i64, i64* %3
%20 = sub i64 %19, 1
%21 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %18, %0
%23 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
%24 = call i64 @strlen(i8* %23)
store i64 %24, i64* %3
store i64 0, i64* %5
%25 = load i64, i64* %3
%26 = sub i64 %25, 1
%27 = trunc i64 %26 to i32
store i32 %27, i32* %4
br label %28
28: ; preds = %49, %22
%29 = load i32, i32* %4
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %52
31: ; preds = %28
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = sub nsw i32 %36, 48
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = load i64, i64* %3
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = sub i64 %39, %41
%43 = sub i64 %42, 1
%44 = call i32 @power(i32 2, i64 %43)
%45 = mul nsw i32 %38, %44
%46 = sext i32 %45 to i64
%47 = load i64, i64* %5
%48 = add nsw i64 %47, %46
store i64 %48, i64* %5
br label %49
49: ; preds = %31
%50 = load i32, i32* %4
%51 = add nsw i32 %50, -1
store i32 %51, i32* %4
br label %28
52: ; preds = %28
%53 = load i64, i64* %5
%54 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %53)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca [65 x i8]
%2 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 65, i32 %3)
%5 = call i64 @strlen(i8* %2)
%6 = add i64 %5, -1
%7 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 10
br i1 %9, label %10, label %11
10: ; preds = %0
store i8 0, i8* %7
br label %11
11: ; preds = %10, %0
%12 = call i64 @strlen(i8* %2)
%13 = trunc i64 %12 to i32
%14 = add i32 %13, -1
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %32
16: ; preds = %11, %16
%17 = phi i32 [ %30, %16 ], [ %14, %11 ]
%18 = phi i64 [ %29, %16 ], [ 0, %11 ]
%19 = zext i32 %17 to i64
%20 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = add nsw i32 %22, -48
%24 = xor i64 %19, -1
%25 = add i64 %12, %24
%26 = call i32 @power(i32 2, i64 %25)
%27 = mul nsw i32 %23, %26
%28 = sext i32 %27 to i64
%29 = add nsw i64 %18, %28
%30 = add nsw i32 %17, -1
%31 = icmp sgt i32 %17, 0
br i1 %31, label %16, label %32
32: ; preds = %16, %11
%33 = phi i64 [ 0, %11 ], [ %29, %16 ]
%34 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %33)
ret i32 0
}