#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 *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long long *);
int main() {
  unsigned long long N, T;
  scanf("%Lu", &T);
  while (T--) {
    unsigned long long i = 1;
    unsigned long long s1 = 1, s2 = 1;
    unsigned long long total = 0;
    scanf("%Lu", &N);
    while (s1 < N) {
      if (s1 % 2 == 0) {
        total += s1;
      }
      s1 ^= s2;
      s2 ^= s1;
      s1 ^= s2;
      s1 += s2;
    }
    printf("%Lu\n", total);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     11fe <main+0xde>
movq   $0x1,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xe81(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11e9 <main+0xc9>
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    11b4 <main+0x94>
mov    -0x28(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
xor    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
xor    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
xor    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1188 <main+0x68>
mov    -0x38(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jae    114b <main+0x2b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xeae(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xea6(%rip),%rbx
jmp    1171 <main+0x51>
xor    %esi,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jb     113f <main+0x1f>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
cmp    $0x2,%rax
jb     1160 <main+0x40>
mov    $0x1,%ecx
xor    %esi,%esi
mov    $0x1,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   $0x1,%dl
mov    $0x0,%edi
cmove  %rdx,%rdi
add    %rdi,%rsi
mov    %rcx,%rdi
add    %rdx,%rdi
mov    %rdx,%rcx
mov    %rdi,%rdx
cmp    %rax,%rdi
jb     11a0 <main+0x80>
jmp    1162 <main+0x42>

LLVM IR (-O0):
@.str = [4 x i8] c"%Lu\00"
@.str.1 = [5 x i8] c"%Lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
br label %9
9: ; preds = %40, %0
%10 = load i64, i64* %3
%11 = add i64 %10, -1
store i64 %11, i64* %3
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %43
13: ; preds = %9
store i64 1, i64* %4
store i64 1, i64* %5
store i64 1, i64* %6
store i64 0, i64* %7
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %15
15: ; preds = %27, %13
%16 = load i64, i64* %5
%17 = load i64, i64* %2
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = load i64, i64* %5
%21 = urem i64 %20, 2
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i64, i64* %5
%25 = load i64, i64* %7
%26 = add i64 %25, %24
store i64 %26, i64* %7
br label %27
27: ; preds = %23, %19
%28 = load i64, i64* %6
%29 = load i64, i64* %5
%30 = xor i64 %29, %28
store i64 %30, i64* %5
%31 = load i64, i64* %5
%32 = load i64, i64* %6
%33 = xor i64 %32, %31
store i64 %33, i64* %6
%34 = load i64, i64* %6
%35 = load i64, i64* %5
%36 = xor i64 %35, %34
store i64 %36, i64* %5
%37 = load i64, i64* %6
%38 = load i64, i64* %5
%39 = add i64 %38, %37
store i64 %39, i64* %5
br label %15
40: ; preds = %15
%41 = load i64, i64* %7
%42 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %41)
br label %9
43: ; preds = %9
ret i32 0
}

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