#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int strlen(char *);
int main(void) {
  int i;
  int comet_product = 1;
  int group_product = 1;
  FILE *fin = fopen("ride.in", "r");
  FILE *fout = fopen("ride.out", "w");
  char comet_name[7] = "";
  char group_name[7] = "";
  fscanf(fin, "%s", comet_name);
  fscanf(fin, "%s", group_name);
  for (i = 0; i < strlen(comet_name); ++i) {
    comet_product *= ((int)comet_name[i] - 'A' + 1);
    comet_product %= 47;
  }
  for (i = 0; i < strlen(group_name); ++i) {
    group_product *= ((int)group_name[i] - 'A' + 1);
    group_product %= 47;
  }
  if (comet_product == group_product) {
    fprintf(fout, "%s\n", "GO");
  } else {
    fprintf(fout, "%s\n", "STAY");
  }
  fclose("ride.in");
  fclose("ride.out");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xe7c(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe6f(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x27(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
lea    -0x2e(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
lea    -0x27(%rbp),%rdx
lea    0xe3b(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x2e(%rbp),%rdx
lea    0xe27(%rip),%rsi
call   1060 <fscanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x27(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1248 <main+0xe8>
movslq -0x8(%rbp),%rax
movsbl -0x27(%rbp,%rax,1),%eax
sub    $0x41,%eax
add    $0x1,%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2f,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11fa <main+0x9a>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x2e(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    129d <main+0x13d>
movslq -0x8(%rbp),%rax
movsbl -0x2e(%rbp,%rax,1),%eax
sub    $0x41,%eax
add    $0x1,%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2f,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124f <main+0xef>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    12c5 <main+0x165>
mov    -0x20(%rbp),%rdi
lea    0xd64(%rip),%rsi
lea    0xd61(%rip),%rdx
call   1070 <fprintf@plt>
jmp    12dc <main+0x17c>
mov    -0x20(%rbp),%rdi
lea    0xd48(%rip),%rsi
lea    0xd48(%rip),%rdx
call   1070 <fprintf@plt>
lea    0xd1d(%rip),%rdi
call   1030 <fclose@plt>
lea    0xd1b(%rip),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe90(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
movl   $0x0,0xb(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x3(%rsp)
movl   $0x0,(%rsp)
lea    0xe66(%rip),%r15
lea    0x8(%rsp),%r12
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fscanf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    $0x1,%r12d
mov    $0x1,%r13d
test   %eax,%eax
jle    1240 <main+0xf0>
mov    $0x1,%r13d
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x8(%rsp,%rbx,1),%eax
add    $0xffffffc0,%eax
imul   %r13d,%eax
movslq %eax,%r13
imul   $0xffffffffae4c415d,%r13,%rax
shr    $0x20,%rax
add    %r13d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x2f,%eax,%eax
sub    %eax,%r13d
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1200 <main+0xb0>
mov    %rsp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    129f <main+0x14f>
mov    $0x1,%r12d
xor    %ebx,%ebx
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%eax
add    $0xffffffc0,%eax
imul   %r12d,%eax
movslq %eax,%r12
imul   $0xffffffffae4c415d,%r12,%rax
shr    $0x20,%rax
add    %r12d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x2f,%eax,%eax
sub    %eax,%r12d
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1260 <main+0x110>
cmp    %r12d,%r13d
lea    0xd73(%rip),%rax
lea    0xd6f(%rip),%rdx
cmove  %rax,%rdx
lea    0xd5d(%rip),%rsi
mov    %r14,%rdi
call   1060 <fprintf@plt>
lea    0xd36(%rip),%rdi
call   1030 <fclose@plt>
lea    0xd34(%rip),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"ride.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"ride.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [3 x i8] c"GO\00"
@.str.7 = [5 x i8] c"STAY\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [7 x i8]
%8 = alloca [7 x i8]
store i32 0, i32* %1
store i32 1, i32* %3
store i32 1, i32* %4
%9 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %5
%10 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %10, i32** %6
%11 = bitcast [7 x i8]* %7 to i8*
%12 = bitcast [7 x i8]* %8 to i8*
%13 = load i32*, i32** %5
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 0
%15 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = load i32*, i32** %5
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%18 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %17)
store i32 0, i32* %2
br label %19
19: ; preds = %36, %0
%20 = load i32, i32* %2
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %39
24: ; preds = %19
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %29, 65
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %3
%33 = mul nsw i32 %32, %31
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = srem i32 %34, 47
store i32 %35, i32* %3
br label %36
36: ; preds = %24
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %19
39: ; preds = %19
store i32 0, i32* %2
br label %40
40: ; preds = %57, %39
%41 = load i32, i32* %2
%42 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = icmp slt i32 %41, %43
br i1 %44, label %45, label %60
45: ; preds = %40
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = sub nsw i32 %50, 65
%52 = add nsw i32 %51, 1
%53 = load i32, i32* %4
%54 = mul nsw i32 %53, %52
store i32 %54, i32* %4
%55 = load i32, i32* %4
%56 = srem i32 %55, 47
store i32 %56, i32* %4
br label %57
57: ; preds = %45
%58 = load i32, i32* %2
%59 = add nsw i32 %58, 1
store i32 %59, i32* %2
br label %40
60: ; preds = %40
%61 = load i32, i32* %3
%62 = load i32, i32* %4
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i32*, i32** %6
%66 = call i32 @fprintf(i32* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %70
67: ; preds = %60
%68 = load i32*, i32** %6
%69 = call i32 @fprintf(i32* %68, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %70
70: ; preds = %67, %64
%71 = call i32 @fclose(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%72 = call i32 @fclose(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"ride.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"ride.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [3 x i8] c"GO\00"
@.str.7 = [5 x i8] c"STAY\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = alloca [7 x i8]
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%7 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%8 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%9 = call i32 @strlen(i8* %5)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %15, %0
%12 = phi i32 [ 1, %0 ], [ %23, %15 ]
%13 = call i32 @strlen(i8* %6)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %28, label %41
15: ; preds = %0, %15
%16 = phi i64 [ %24, %15 ], [ 0, %0 ]
%17 = phi i32 [ %23, %15 ], [ 1, %0 ]
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %16
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add nsw i32 %20, -64
%22 = mul nsw i32 %21, %17
%23 = srem i32 %22, 47
%24 = add nuw nsw i64 %16, 1
%25 = call i32 @strlen(i8* %5)
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %15, label %11
28: ; preds = %11, %28
%29 = phi i64 [ %37, %28 ], [ 0, %11 ]
%30 = phi i32 [ %36, %28 ], [ 1, %11 ]
%31 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %29
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = add nsw i32 %33, -64
%35 = mul nsw i32 %34, %30
%36 = srem i32 %35, 47
%37 = add nuw nsw i64 %29, 1
%38 = call i32 @strlen(i8* %6)
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %37, %39
br i1 %40, label %28, label %41
41: ; preds = %28, %11
%42 = phi i32 [ 1, %11 ], [ %36, %28 ]
%43 = icmp eq i32 %12, %42
%44 = select i1 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0)
%45 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%46 = call i32 @fclose(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @fclose(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}