#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, unsigned long);
scalar_t__ scanf(char *, unsigned long *);
int main(void) {
  unsigned long n, a = 0;
  while (scanf("%lu", &n) != EOF) {
    n = ((n & 0x55555555UL) << 33) | (n & 0xAAAAAAAAUL);
    a += (n - (a & n) * 3) / 2;
  }
  printf("%lu\n", (a & 0xAAAAAAAAUL) | (a >> 33));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%rax
je     119e <main+0x7e>
mov    -0x10(%rbp),%rax
and    $0x55555555,%rax
shl    $0x21,%rax
movabs $0xaaaaaaaa,%rcx
and    -0x10(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
and    -0x10(%rbp),%rcx
imul   $0x3,%rcx,%rcx
sub    %rcx,%rax
shr    $0x1,%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <main+0x17>
movabs $0xaaaaaaaa,%rsi
and    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
shr    $0x21,%rax
or     %rax,%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    0x2eaa(%rip),%r12
cmp    (%r12),%rax
jne    1148 <main+0x28>
xor    %ebx,%ebx
jmp    11a0 <main+0x80>
xor    %ebx,%ebx
lea    0xeaf(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rsp),%rax
mov    %eax,%ecx
and    $0x55555555,%ecx
shl    $0x21,%rcx
and    $0xaaaaaaaa,%eax
or     %rcx,%rax
mov    %rax,(%rsp)
mov    %rax,%rcx
and    %rbx,%rcx
lea    (%rcx,%rcx,2),%rcx
sub    %rcx,%rax
shr    %rax
add    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmp    (%r12),%rax
jne    1160 <main+0x40>
mov    %ebx,%eax
and    $0xaaaaaaaa,%eax
shr    $0x21,%rbx
or     %rax,%rbx
lea    0xe4f(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lu\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"%lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %3
br label %4
4: ; preds = %8, %0
%5 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%6 = load i64, i64* @EOF
%7 = icmp ne i64 %5, %6
br i1 %7, label %8, label %24
8: ; preds = %4
%9 = load i64, i64* %2
%10 = and i64 %9, 1431655765
%11 = shl i64 %10, 33
%12 = load i64, i64* %2
%13 = and i64 %12, 2863311530
%14 = or i64 %11, %13
store i64 %14, i64* %2
%15 = load i64, i64* %2
%16 = load i64, i64* %3
%17 = load i64, i64* %2
%18 = and i64 %16, %17
%19 = mul i64 %18, 3
%20 = sub i64 %15, %19
%21 = udiv i64 %20, 2
%22 = load i64, i64* %3
%23 = add i64 %22, %21
store i64 %23, i64* %3
br label %4
24: ; preds = %4
%25 = load i64, i64* %3
%26 = and i64 %25, 2863311530
%27 = load i64, i64* %3
%28 = lshr i64 %27, 33
%29 = or i64 %26, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lu\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"%lu\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %21, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %17, %6 ], [ 0, %0 ]
%8 = load i64, i64* %1
%9 = shl i64 %8, 33
%10 = and i64 %9, -6148914694099828736
%11 = and i64 %8, 2863311530
%12 = or i64 %10, %11
store i64 %12, i64* %1
%13 = and i64 %12, %7
%14 = mul i64 %13, -3
%15 = add i64 %14, %12
%16 = lshr exact i64 %15, 1
%17 = add i64 %16, %7
%18 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %6
21: ; preds = %6, %0
%22 = phi i64 [ 0, %0 ], [ %17, %6 ]
%23 = and i64 %22, 2863311530
%24 = lshr i64 %22, 33
%25 = or i64 %23, %24
%26 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %25)
ret i32 0
}