#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 /*<<< orphan*/ scanf(char *, ...);
size_t strlen(char *);
int main() {
  int map[10] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};
  int n;
  scanf("%d", &n);
  while (n--) {
    char num[101];
    scanf("%s", num);
    size_t len = strlen(num);
    int sum = 0;
    for (int i = len - 2; i >= 0; i -= 2)
      sum += map[num[i] - '0'];
    for (int i = len - 1; i >= 0; i -= 2)
      sum += num[i] - '0';
    printf(sum % 10 ? "FAIL\n" : "PASS\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    0xeba(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x34(%rbp)
cmp    $0x0,%eax
je     1292 <main+0x152>
lea    -0xa0(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
mov    -0xa8(%rbp),%rax
sub    $0x2,%rax
mov    %eax,-0xb0(%rbp)
cmpl   $0x0,-0xb0(%rbp)
jl     1215 <main+0xd5>
movslq -0xb0(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
add    -0xac(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0xb0(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0xb0(%rbp)
jmp    11d0 <main+0x90>
mov    -0xa8(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     1265 <main+0x125>
movslq -0xb4(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
add    -0xac(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0xb4(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0xb4(%rbp)
jmp    1226 <main+0xe6>
mov    -0xac(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
lea    0xdba(%rip),%rdi
lea    0xdad(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%rdi
call   1040 <printf@plt>
jmp    1179 <main+0x39>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xee3(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1169 <main+0x39>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xebb(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe84(%rip),%rbx
lea    0xeb1(%rip),%r12
lea    0xea4(%rip),%r13
jmp    11b5 <main+0x85>
nopl   0x0(%rax)
imul   $0xcccccccd,%ebp,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999999,%eax
mov    %r13,%rdi
cmovb  %r12,%rdi
call   1040 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1158 <main+0x28>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
add    $0xfffffffe,%ecx
js     11f5 <main+0xc5>
xor    %ebp,%ebp
mov    %eax,%ecx
nopw   0x0(%rax,%rax,1)
add    $0xfffffffe,%ecx
movsbq 0x10(%rsp,%rcx,1),%rdx
add    -0xc0(%rbx,%rdx,4),%ebp
cmp    $0x1,%ecx
jg     11e0 <main+0xb0>
mov    %eax,%ecx
add    $0xffffffff,%ecx
js     1190 <main+0x60>
add    $0x1,%eax
mov    %ecx,%ecx
add    %rsp,%rcx
add    $0x10,%rcx
nopl   0x0(%rax,%rax,1)
movsbl (%rcx),%edx
add    %edx,%ebp
add    $0xffffffd0,%ebp
add    $0xfffffffe,%eax
add    $0xfffffffffffffffe,%rcx
cmp    $0x1,%eax
ja     1210 <main+0xe0>
jmp    1190 <main+0x60>

LLVM IR (-O0):
@__const.main.map = [10 x i32] [i32 0, i32 2, i32 4, i32 6, i32 8, i32 1, i32 3, i32 5, i32 7, i32 9]
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [6 x i8] c"FAIL\0A\00"
@.str.3 = [6 x i8] c"PASS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca [101 x i8]
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [10 x i32]* %2 to i8*
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %11
11: ; preds = %60, %0
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %67
15: ; preds = %11
%16 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%19 = call i64 @strlen(i8* %18)
store i64 %19, i64* %5
store i32 0, i32* %6
%20 = load i64, i64* %5
%21 = sub i64 %20, 2
%22 = trunc i64 %21 to i32
store i32 %22, i32* %7
br label %23
23: ; preds = %38, %15
%24 = load i32, i32* %7
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %41
26: ; preds = %23
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = sub nsw i32 %31, 48
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, %35
store i32 %37, i32* %6
br label %38
38: ; preds = %26
%39 = load i32, i32* %7
%40 = sub nsw i32 %39, 2
store i32 %40, i32* %7
br label %23
41: ; preds = %23
%42 = load i64, i64* %5
%43 = sub i64 %42, 1
%44 = trunc i64 %43 to i32
store i32 %44, i32* %8
br label %45
45: ; preds = %57, %41
%46 = load i32, i32* %8
%47 = icmp sge i32 %46, 0
br i1 %47, label %48, label %60
48: ; preds = %45
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = sub nsw i32 %53, 48
%55 = load i32, i32* %6
%56 = add nsw i32 %55, %54
store i32 %56, i32* %6
br label %57
57: ; preds = %48
%58 = load i32, i32* %8
%59 = sub nsw i32 %58, 2
store i32 %59, i32* %8
br label %45
60: ; preds = %45
%61 = load i32, i32* %6
%62 = srem i32 %61, 10
%63 = icmp ne i32 %62, 0
%64 = zext i1 %63 to i64
%65 = select i1 %63, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%66 = call i32 @printf(i8* %65)
br label %11
67: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.map = [10 x i32] [i32 0, i32 2, i32 4, i32 6, i32 8, i32 1, i32 3, i32 5, i32 7, i32 9]
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [6 x i8] c"FAIL\0A\00"
@.str.3 = [6 x i8] c"PASS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [101 x i8]
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = add nsw i32 %5, -1
store i32 %6, i32* %1
%7 = icmp eq i32 %5, 0
br i1 %7, label %53, label %8
8: ; preds = %0
%9 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
br label %10
10: ; preds = %8, %33
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%12 = call i64 @strlen(i8* %9)
%13 = trunc i64 %12 to i32
%14 = add i32 %13, -2
%15 = icmp sgt i32 %14, -1
br i1 %15, label %20, label %16
16: ; preds = %20, %10
%17 = phi i32 [ 0, %10 ], [ %30, %20 ]
%18 = add i32 %13, -1
%19 = icmp sgt i32 %18, -1
br i1 %19, label %42, label %33
20: ; preds = %10, %20
%21 = phi i32 [ %31, %20 ], [ %14, %10 ]
%22 = phi i32 [ %30, %20 ], [ 0, %10 ]
%23 = zext i32 %21 to i64
%24 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i64
%27 = add nsw i64 %26, -48
%28 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.main.map, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, %22
%31 = add nsw i32 %21, -2
%32 = icmp sgt i32 %21, 1
br i1 %32, label %20, label %16
33: ; preds = %42, %16
%34 = phi i32 [ %17, %16 ], [ %50, %42 ]
%35 = srem i32 %34, 10
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%38 = call i32 @printf(i8* dereferenceable(1) %37)
%39 = load i32, i32* %1
%40 = add nsw i32 %39, -1
store i32 %40, i32* %1
%41 = icmp eq i32 %39, 0
br i1 %41, label %53, label %10
42: ; preds = %16, %42
%43 = phi i32 [ %51, %42 ], [ %18, %16 ]
%44 = phi i32 [ %50, %42 ], [ %17, %16 ]
%45 = zext i32 %43 to i64
%46 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = add i32 %44, -48
%50 = add i32 %49, %48
%51 = add nsw i32 %43, -2
%52 = icmp ugt i32 %43, 1
br i1 %52, label %42, label %33
53: ; preds = %33, %0
ret i32 0
}