#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 u, v, i, j, t, k = 0;
  unsigned long long cornerTri, value, cornerTriRank;
  scanf("%llu", &t);
  while (k++ < t) {
    u = v = 0;
    scanf("%llu %llu", &u, &v);
    cornerTri = u + v;
    value = 0;
    value = (1 + cornerTri) * cornerTri;
    value /= 2;
    cornerTriRank = value;
    i = 0, j = cornerTri;
    cornerTriRank += u;
    printf("%llu\n", cornerTriRank + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
cmp    -0x30(%rbp),%rax
jae    11f6 <main+0xd6>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe87(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
imul   -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
add    $0x1,%rsi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
jmp    1149 <main+0x29>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
je     11c9 <main+0xa9>
lea    0xead(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xea6(%rip),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
movq   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x18(%rsp),%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,1),%rdx
add    $0x1,%rdx
add    %rax,%rcx
imul   %rdx,%rcx
shr    %rcx
lea    (%rax,%rcx,1),%rsi
add    $0x1,%rsi
mov    %r13,%rdi
call   1030 <printf@plt>
cmp    0x8(%rsp),%rbx
jb     1170 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [10 x i8] c"%llu %llu\00"
@.str.2 = [6 x i8] c"%llu\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
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %7
%11 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %6)
br label %12
12: ; preds = %17, %0
%13 = load i64, i64* %7
%14 = add i64 %13, 1
store i64 %14, i64* %7
%15 = load i64, i64* %6
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %36
17: ; preds = %12
store i64 0, i64* %3
store i64 0, i64* %2
%18 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%19 = load i64, i64* %2
%20 = load i64, i64* %3
%21 = add i64 %19, %20
store i64 %21, i64* %8
store i64 0, i64* %9
%22 = load i64, i64* %8
%23 = add i64 1, %22
%24 = load i64, i64* %8
%25 = mul i64 %23, %24
store i64 %25, i64* %9
%26 = load i64, i64* %9
%27 = udiv i64 %26, 2
store i64 %27, i64* %9
%28 = load i64, i64* %9
store i64 %28, i64* %10
store i64 0, i64* %4
%29 = load i64, i64* %8
store i64 %29, i64* %5
%30 = load i64, i64* %2
%31 = load i64, i64* %10
%32 = add i64 %31, %30
store i64 %32, i64* %10
%33 = load i64, i64* %10
%34 = add i64 %33, 1
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %34)
br label %12
36: ; preds = %12
ret i32 0
}

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