#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 betoFn(int, int);
int carlosFn(int, int);
int /*<<< orphan*/ printf(char *);
int rafaelFn(int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int casos, x, y, rafaelResult, betoResult, carlosResult;
  scanf("%d", &casos);
  for (; casos > 0; casos--) {
    scanf("%d %d", &x, &y);
    rafaelResult = rafaelFn(x, y);
    betoResult = betoFn(x, y);
    carlosResult = carlosFn(x, y);
    if (rafaelResult > betoResult && rafaelResult > carlosResult) {
      printf("Rafael ganhou\n");
    } else if (betoResult > rafaelResult && betoResult > carlosResult) {
      printf("Beto ganhou\n");
    } else {
      printf("Carlos ganhou\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9d(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1231 <main+0xe1>
lea    0xe7e(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <rafaelFn@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <betoFn@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <carlosFn@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11e4 <main+0x94>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11e4 <main+0x94>
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
jmp    121e <main+0xce>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    120d <main+0xbd>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    120d <main+0xbd>
lea    0xe12(%rip),%rdi
call   1030 <printf@plt>
jmp    1219 <main+0xc9>
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
jmp    121e <main+0xce>
jmp    1223 <main+0xd3>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1171 <main+0x21>
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    0xe9e(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
jle    1217 <main+0xc7>
lea    0xc(%rsp),%r12
lea    0xe8c(%rip),%r13
lea    0xe77(%rip),%r14
lea    0xe8a(%rip),%r15
jmp    11ca <main+0x7a>
nopl   0x0(%rax,%rax,1)
cmp    %ebp,%ebx
cmovle %r14,%rcx
cmp    %eax,%ebp
mov    %rcx,%rdi
cmovg  %r15,%rdi
cmp    %ebx,%ebp
cmovle %rcx,%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x14(%rsp)
cmp    $0x1,%eax
jle    1217 <main+0xc7>
lea    0xe2f(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1040 <rafaelFn@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1050 <betoFn@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1060 <carlosFn@plt>
mov    %r13,%rcx
cmp    %eax,%ebx
jg     11a0 <main+0x50>
mov    %r14,%rcx
jmp    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"%d %d\00"
@.str.2 = [15 x i8] c"Rafael ganhou\0A\00"
@.str.3 = [13 x i8] c"Beto ganhou\0A\00"
@.str.4 = [15 x i8] c"Carlos ganhou\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 i32
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* %2)
br label %9
9: ; preds = %46, %0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %49
12: ; preds = %9
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i32 @rafaelFn(i32 %14, i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 @betoFn(i32 %17, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @carlosFn(i32 %20, i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %12
%27 = load i32, i32* %5
%28 = load i32, i32* %7
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %45
32: ; preds = %26, %12
%33 = load i32, i32* %6
%34 = load i32, i32* %5
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %44
42: ; preds = %36, %32
%43 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
br label %45
45: ; preds = %44, %30
br label %46
46: ; preds = %45
%47 = load i32, i32* %2
%48 = add nsw i32 %47, -1
store i32 %48, i32* %2
br label %9
49: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@str = [14 x i8] c"Carlos ganhou\00"
@str.5 = [12 x i8] c"Beto ganhou\00"
@str.6 = [14 x i8] c"Rafael ganhou\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, i32*, ...) @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 %33
10: ; preds = %0, %10
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @rafaelFn(i32 %12, i32 %13)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @betoFn(i32 %15, i32 %16)
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @carlosFn(i32 %18, i32 %19)
%21 = icmp sgt i32 %14, %17
%22 = icmp sgt i32 %14, %20
%23 = select i1 %21, i1 %22, i1 false
%24 = icmp sgt i32 %17, %14
%25 = icmp sgt i32 %17, %20
%26 = select i1 %24, i1 %25, i1 false
%27 = select i1 %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0)
%28 = select i1 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0), i8* %27
%29 = call i32 @puts(i8* dereferenceable(1) %28)
%30 = load i32, i32* %1
%31 = add nsw i32 %30, -1
store i32 %31, i32* %1
%32 = icmp sgt i32 %30, 1
br i1 %32, label %10, label %33
33: ; preds = %10, %0
ret i32 0
}