#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);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int a, b, c, d, i;
  char aa;
  scanf("%d", &c);
  for (i = 0; i < c; i++) {
    scanf("%d %c%d", &a, &aa, &b);
    if (a == b) {
      printf("%d\n", b * a);
    } else if (aa >= 'A' && aa <= 'Z') {
      printf("%d\n", b - a);
    } else if (aa >= 'a' && aa <= 'z') {
      printf("%d\n", a + b);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecf(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120c <main+0xec>
lea    0xea5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x19(%rbp),%rdx
lea    -0xc(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1192 <main+0x72>
mov    -0xc(%rbp),%esi
imul   -0x8(%rbp),%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    11f9 <main+0xd9>
movsbl -0x19(%rbp),%eax
cmp    $0x41,%eax
jl     11c3 <main+0xa3>
movsbl -0x19(%rbp),%eax
cmp    $0x5a,%eax
jg     11c3 <main+0xa3>
mov    -0xc(%rbp),%esi
sub    -0x8(%rbp),%esi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
jmp    11f4 <main+0xd4>
movsbl -0x19(%rbp),%eax
cmp    $0x61,%eax
jl     11ef <main+0xcf>
movsbl -0x19(%rbp),%eax
cmp    $0x7a,%eax
jg     11ef <main+0xcf>
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
jmp    11f4 <main+0xd4>
jmp    11f9 <main+0xd9>
jmp    11fe <main+0xde>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <main+0x28>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11c3 <main+0xa3>
lea    0xeb1(%rip),%r14
lea    0x14(%rsp),%r15
lea    0xb(%rsp),%r12
lea    0x10(%rsp),%rbx
lea    0xea3(%rip),%r13
xor    %ebp,%ebp
jmp    1186 <main+0x66>
nopl   0x0(%rax)
imul   %eax,%eax
mov    %eax,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    11c3 <main+0xa3>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
mov    %ecx,%esi
sub    %eax,%esi
je     1170 <main+0x50>
movzbl 0xb(%rsp),%edx
lea    -0x41(%rdx),%edi
cmp    $0x19,%dil
jbe    1175 <main+0x55>
add    $0x9f,%dl
cmp    $0x19,%dl
ja     117d <main+0x5d>
add    %eax,%ecx
mov    %ecx,%esi
jmp    1175 <main+0x55>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [8 x i8] c"%d %c%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %6
br label %9
9: ; preds = %52, %0
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %55
13: ; preds = %9
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %2, i8* %7, i32* %3)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = mul nsw i32 %19, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %51
23: ; preds = %13
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 65
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 90
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32, i32* %3
%33 = load i32, i32* %2
%34 = sub nsw i32 %32, %33
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %50
36: ; preds = %27, %23
%37 = load i8, i8* %7
%38 = sext i8 %37 to i32
%39 = icmp sge i32 %38, 97
br i1 %39, label %40, label %49
40: ; preds = %36
%41 = load i8, i8* %7
%42 = sext i8 %41 to i32
%43 = icmp sle i32 %42, 122
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* %2
%46 = load i32, i32* %3
%47 = add nsw i32 %45, %46
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %44, %40, %36
br label %50
50: ; preds = %49, %31
br label %51
51: ; preds = %50, %18
br label %52
52: ; preds = %51
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %9
55: ; preds = %9
ret i32 0
}

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