#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 */
long long callEvenFunc(long long, int);
long long callOddFunc(long long, int);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int testCases, k;
  long long n;
  long long value;
  scanf("%d", &testCases);
  while (testCases--) {
    scanf("%lld%d", &n, &k);
    if (k % 2 == 0) {
      value = callEvenFunc(n, k);
    } else {
      value = callOddFunc(n, k);
    }
    printf("%lld\n", value);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11d9 <main+0x99>
lea    0xe84(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b4 <main+0x74>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <callEvenFunc@plt>
mov    %rax,-0x20(%rbp)
jmp    11c4 <main+0x84>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <callOddFunc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
jmp    1161 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb2(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0x8(%rsp)
jae    1173 <main+0x33>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe86(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xe7c(%rip),%rbx
jmp    11a7 <main+0x67>
nopl   (%rax)
call   1050 <callOddFunc@plt>
mov    %rax,%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0x8(%rsp)
jb     1165 <main+0x25>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%rdi
test   $0x1,%sil
jne    1190 <main+0x50>
call   1040 <callEvenFunc@plt>
jmp    1195 <main+0x55>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%lld%d\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %2
%9 = add nsw i32 %8, -1
store i32 %9, i32* %2
%10 = icmp ne i32 %8, 0
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %4, i32* %3)
%13 = load i32, i32* %3
%14 = srem i32 %13, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i64, i64* %4
%18 = load i32, i32* %3
%19 = call i64 @callEvenFunc(i64 %17, i32 %18)
store i64 %19, i64* %5
br label %24
20: ; preds = %11
%21 = load i64, i64* %4
%22 = load i32, i32* %3
%23 = call i64 @callOddFunc(i64 %21, i32 %22)
store i64 %23, i64* %5
br label %24
24: ; preds = %20, %16
%25 = load i64, i64* %5
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %25)
br label %7
27: ; preds = %7
ret i32 0
}

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