#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 /*<<< orphan*/ scanf(char *, int *);
int utopiantree(void) {
  int numCases;
  scanf("%d", &numCases);
  while (numCases--) {
    int cycles;
    scanf("%d", &cycles);
    int isEven = (cycles % 2 == 0);
    if (cycles == 0) {
      printf("1\n");
      continue;
    }
    if (isEven) {
      cycles--;
    }
    int treeHeight = 1 << ((cycles / 2) + 2);
    if (isEven) {
      treeHeight -= 1;
    } else {
      treeHeight -= 2;
    }
    printf("%d\n", treeHeight);
  }
  return 0;
}


x86 assembly (clang, -O0):
<utopiantree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     11f6 <utopiantree+0xd6>
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1192 <utopiantree+0x72>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1138 <utopiantree+0x18>
cmpl   $0x0,-0xc(%rbp)
je     11a5 <utopiantree+0x85>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x2,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d7 <utopiantree+0xb7>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e0 <utopiantree+0xc0>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1138 <utopiantree+0x18>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utopiantree>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
subl   $0x1,0x4(%rsp)
jb     11c6 <utopiantree+0x96>
lea    0xea9(%rip),%r14
mov    %rsp,%rbx
lea    0xea6(%rip),%r15
lea    0xe9b(%rip),%r12
jmp    117f <utopiantree+0x4f>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
subl   $0x1,0x4(%rsp)
jb     11c6 <utopiantree+0x96>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     1170 <utopiantree+0x40>
mov    %eax,%esi
and    $0x1,%esi
jne    119e <utopiantree+0x6e>
add    $0xffffffff,%eax
mov    %eax,(%rsp)
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
shr    %ecx
add    $0x2,%cl
mov    $0x1,%eax
shl    %cl,%eax
not    %esi
add    %eax,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
subl   $0x1,0x4(%rsp)
jae    117f <utopiantree+0x4f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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