#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 determineChoice(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int colorValArr[5], numQuestion, i, choiceId, q;
  while (1) {
    scanf("%d", &numQuestion);
    if (!numQuestion)
      break;
    for (q = 0; q < numQuestion; q++) {
      for (i = 0; i < 5; i++)
        scanf("%d", &colorValArr[i]);
      choiceId = determineChoice(colorValArr);
      if (choiceId < 0)
        printf("*\n");
      else
        printf("%c\n", choiceId + 'A');
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x24(%rbp)
jne    115e <main+0x2e>
jmp    1200 <main+0xd0>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11fb <main+0xcb>
movl   $0x0,-0x28(%rbp)
cmpl   $0x5,-0x28(%rbp)
jge    11ab <main+0x7b>
movslq -0x28(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe68(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1178 <main+0x48>
lea    -0x20(%rbp),%rdi
call   1050 <determineChoice@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11d4 <main+0xa4>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <main+0xb8>
mov    -0x2c(%rbp),%esi
add    $0x41,%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <main+0xbd>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1165 <main+0x35>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1221 <main+0xe1>
lea    0x18(%rsp),%r15
lea    0x1c(%rsp),%r12
lea    0x20(%rsp),%r13
lea    0xe7f(%rip),%rbx
lea    0x10(%rsp),%rbp
jmp    11a5 <main+0x65>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1221 <main+0xe1>
test   %eax,%eax
jle    1190 <main+0x50>
xor    %r14d,%r14d
jmp    11ce <main+0x8e>
xchg   %ax,%ax
add    $0x41,%eax
lea    0xe49(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jge    1190 <main+0x50>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
call   1060 <determineChoice@plt>
test   %eax,%eax
jns    11b0 <main+0x70>
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
jmp    11c3 <main+0x83>
xor    %eax,%eax
add    $0x28,%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 = [3 x i8] c"*\0A\00"
@.str.2 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %0, %44
%8 = call 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 ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7
br label %45
12: ; preds = %7
store i32 0, i32* %6
br label %13
13: ; preds = %41, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %44
17: ; preds = %13
store i32 0, i32* %4
br label %18
18: ; preds = %26, %17
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %21
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %18
29: ; preds = %18
%30 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%31 = call i32 @determineChoice(i32* %30)
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %40
36: ; preds = %29
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 65
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %36, %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %13
44: ; preds = %13
br label %7
45: ; preds = %11
ret i32 0
}

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