#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 get_index(char *);
char get_result(int, int);
char *get_result_str(char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int N, i, index_f, index_e;
  char F[4], E[4], result;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%s %s", F, E);
    index_f = get_index(F);
    index_e = get_index(E);
    result = get_result(index_f, index_e);
    printf("%s\n", get_result_str(result));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e6 <main+0x96>
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x18(%rbp),%rdi
call   1040 <get_index@plt>
mov    %eax,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <get_index@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <get_result@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%edi
call   1060 <get_result_str@plt>
mov    %rax,%rsi
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <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    0xe9b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11e7 <main+0x97>
lea    0xe84(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r13
lea    0xe79(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r15,%rdi
call   1040 <get_index@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1040 <get_index@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <get_result@plt>
movsbl %al,%edi
call   1060 <get_result_str@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
jl     11a0 <main+0x50>
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 = [6 x i8] c"%s %s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4 x i8]
%7 = alloca [4 x i8]
%8 = alloca i8
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %10
10: ; preds = %28, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%19 = call i32 @get_index(i8* %18)
store i32 %19, i32* %4
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%21 = call i32 @get_index(i8* %20)
store i32 %21, i32* %5
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call signext i8 @get_result(i32 %22, i32 %23)
store i8 %24, i8* %8
%25 = load i8, i8* %8
%26 = call i8* @get_result_str(i8 signext %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %14
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %10
31: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%s %s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [4 x i8]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%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 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %0, %10
%11 = phi i32 [ %18, %10 ], [ 0, %0 ]
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %6)
%13 = call i32 @get_index(i8* %5)
%14 = call i32 @get_index(i8* %6)
%15 = call signext i8 @get_result(i32 %13, i32 %14)
%16 = call i8* @get_result_str(i8 signext %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = add nuw nsw i32 %11, 1
%19 = load i32, i32* %1
%20 = icmp slt i32 %18, %19
br i1 %20, label %10, label %21
21: ; preds = %10, %0
ret i32 0
}