#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 *, char *);
int strlen(char *);
int main(void) {
  char str[1000001];
  int len;
  int i, num, dig = 1;
  scanf("%s", str);
  len = strlen(str);
  for (i = 0; i < (len - 1) % 3; i++) {
    dig *= 2;
  }
  for (i = 0, num = 0; i < len; i++) {
    if (dig == 0) {
      printf("%d", num);
      num = 0;
      dig = 4;
    }
    num += (str[i] - '0') * dig;
    dig /= 2;
  }
  printf("%d", num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4270,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xf4260(%rbp)
lea    -0xf4250(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xf4250(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xf4254(%rbp)
movl   $0x0,-0xf4258(%rbp)
mov    -0xf4258(%rbp),%eax
mov    %eax,-0xf4264(%rbp)
mov    -0xf4254(%rbp),%eax
sub    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0xf4264(%rbp),%eax
cmp    %edx,%eax
jge    11c9 <main+0x99>
mov    -0xf4260(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xf4260(%rbp)
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
jmp    117b <main+0x4b>
movl   $0x0,-0xf4258(%rbp)
movl   $0x0,-0xf425c(%rbp)
mov    -0xf4258(%rbp),%eax
cmp    -0xf4254(%rbp),%eax
jge    126f <main+0x13f>
cmpl   $0x0,-0xf4260(%rbp)
jne    1222 <main+0xf2>
mov    -0xf425c(%rbp),%esi
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xf425c(%rbp)
movl   $0x4,-0xf4260(%rbp)
movslq -0xf4258(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
imul   -0xf4260(%rbp),%eax
add    -0xf425c(%rbp),%eax
mov    %eax,-0xf425c(%rbp)
mov    -0xf4260(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xf4260(%rbp)
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
jmp    11dd <main+0xad>
mov    -0xf425c(%rbp),%esi
lea    0xd87(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xf4270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf4250,%rsp
lea    0xebd(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    -0x1(%rax),%ecx
movslq %ecx,%rcx
imul   $0x55555556,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
add    %eax,%ecx
add    $0xffffffff,%ecx
xor    %edx,%edx
cmp    $0x2,%ecx
setne  %dl
lea    0x4(,%rdx,4),%edx
cmp    $0x1,%ecx
mov    $0x2,%esi
cmovne %edx,%esi
mov    $0x1,%ecx
cmovge %esi,%ecx
test   %eax,%eax
jle    11e5 <main+0xb5>
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0xe57(%rip),%r14
xor    %esi,%esi
jmp    11d0 <main+0xa0>
movsbl (%rsp,%rbx,1),%eax
add    $0xffffffd0,%eax
imul   %ecx,%eax
add    %eax,%esi
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
add    $0x1,%rbx
mov    %eax,%ecx
cmp    %rbx,%r15
je     11e7 <main+0xb7>
test   %ecx,%ecx
jne    11b0 <main+0x80>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    $0x4,%ecx
xor    %esi,%esi
jmp    11b0 <main+0x80>
xor    %esi,%esi
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4250,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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