#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(int /*<<< orphan*/ *);
char *flStr(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int length(char *);
int main(void) {
  FILE *fin = fopen("ride.in", "r");
  FILE *fout = fopen("ride.out", "w");
  int group_val = 1;
  int comet_val = 1;
  char *group = flStr(fin);
  char *comet = flStr(fin);
  int i;
  for (i = 0; i < length(group); i++) {
    group_val *= (int)*(group + i) - 64;
  }
  for (i = 0; i < length(comet); i++) {
    comet_val *= (int)*(comet + i) - 64;
  }
  if ((comet_val % 47) == (group_val % 47)) {
    fprintf(fout, "GO\n");
    fclose(fin);
  } else {
    fprintf(fout, "STAY\n");
    fclose(fin);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <flStr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <flStr@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    11fc <main+0xac>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x40,%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11bc <main+0x6c>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    1243 <main+0xf3>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x40,%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1203 <main+0xb3>
mov    -0x20(%rbp),%eax
mov    $0x2f,%ecx
cltd
idiv   %ecx
mov    %edx,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2f,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x40(%rbp),%edx
cmp    %eax,%edx
jne    1287 <main+0x137>
mov    -0x18(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12a0 <main+0x150>
mov    -0x18(%rbp),%rdi
lea    0xd87(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xe92(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,(%rsp)
mov    %r15,%rdi
call   1050 <flStr@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <flStr@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <length@plt>
mov    $0x1,%r13d
mov    $0x1,%r14d
test   %eax,%eax
jle    11ff <main+0xaf>
mov    $0x1,%ebp
xor    %r14d,%r14d
xchg   %ax,%ax
movsbl (%rbx,%r14,1),%eax
add    $0xffffffc0,%eax
imul   %eax,%ebp
add    $0x1,%r14
mov    %rbx,%rdi
call   1030 <length@plt>
cltq
cmp    %rax,%r14
jl     11c0 <main+0x70>
movslq %ebp,%r14
imul   $0xffffffffae4c415d,%r14,%rax
shr    $0x20,%rax
add    %r14d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x2f,%eax,%eax
sub    %eax,%r14d
mov    %r12,%rdi
call   1030 <length@plt>
test   %eax,%eax
jle    125f <main+0x10f>
mov    $0x1,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%r12,%rbp,1),%eax
add    $0xffffffc0,%eax
imul   %eax,%ebx
add    $0x1,%rbp
mov    %r12,%rdi
call   1030 <length@plt>
cltq
cmp    %rax,%rbp
jl     1220 <main+0xd0>
movslq %ebx,%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
cmp    %r14d,%r13d
jne    1272 <main+0x122>
lea    0xdaa(%rip),%rdi
mov    $0x3,%esi
jmp    127e <main+0x12e>
lea    0xda0(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    (%rsp),%rcx
call   1070 <fwrite@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 = [4 x i8] c"GO\0A\00"
@.str.5 = [6 x i8] c"STAY\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %1
%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** %2
%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** %3
store i32 1, i32* %4
store i32 1, i32* %5
%11 = load i32*, i32** %2
%12 = call i8* @flStr(i32* %11)
store i8* %12, i8** %6
%13 = load i32*, i32** %2
%14 = call i8* @flStr(i32* %13)
store i8* %14, i8** %7
store i32 0, i32* %8
br label %15
15: ; preds = %30, %0
%16 = load i32, i32* %8
%17 = load i8*, i8** %6
%18 = call i32 @length(i8* %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %33
20: ; preds = %15
%21 = load i8*, i8** %6
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 64
%28 = load i32, i32* %4
%29 = mul nsw i32 %28, %27
store i32 %29, i32* %4
br label %30
30: ; preds = %20
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %15
33: ; preds = %15
store i32 0, i32* %8
br label %34
34: ; preds = %49, %33
%35 = load i32, i32* %8
%36 = load i8*, i8** %7
%37 = call i32 @length(i8* %36)
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %52
39: ; preds = %34
%40 = load i8*, i8** %7
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %45, 64
%47 = load i32, i32* %5
%48 = mul nsw i32 %47, %46
store i32 %48, i32* %5
br label %49
49: ; preds = %39
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %34
52: ; preds = %34
%53 = load i32, i32* %5
%54 = srem i32 %53, 47
%55 = load i32, i32* %4
%56 = srem i32 %55, 47
%57 = icmp eq i32 %54, %56
br i1 %57, label %58, label %63
58: ; preds = %52
%59 = load i32*, i32** %3
%60 = call i32 @fprintf(i32* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%61 = load i32*, i32** %2
%62 = call i32 @fclose(i32* %61)
br label %68
63: ; preds = %52
%64 = load i32*, i32** %3
%65 = call i32 @fprintf(i32* %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%66 = load i32*, i32** %2
%67 = call i32 @fclose(i32* %66)
br label %68
68: ; preds = %63, %58
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 = [4 x i8] c"GO\0A\00"
@.str.5 = [6 x i8] c"STAY\0A\00"
define i32 @main() {
%1 = 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))
%2 = 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))
%3 = tail call i8* @flStr(i32* %1)
%4 = tail call i8* @flStr(i32* %1)
%5 = tail call i32 @length(i8* %3)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %13, label %9
7: ; preds = %13
%8 = srem i32 %20, 47
br label %9
9: ; preds = %7, %0
%10 = phi i32 [ 1, %0 ], [ %8, %7 ]
%11 = tail call i32 @length(i8* %4)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %25, label %39
13: ; preds = %0, %13
%14 = phi i64 [ %21, %13 ], [ 0, %0 ]
%15 = phi i32 [ %20, %13 ], [ 1, %0 ]
%16 = getelementptr inbounds i8, i8* %3, i64 %14
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = add nsw i32 %18, -64
%20 = mul nsw i32 %19, %15
%21 = add nuw nsw i64 %14, 1
%22 = tail call i32 @length(i8* %3)
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %13, label %7
25: ; preds = %9, %25
%26 = phi i64 [ %33, %25 ], [ 0, %9 ]
%27 = phi i32 [ %32, %25 ], [ 1, %9 ]
%28 = getelementptr inbounds i8, i8* %4, i64 %26
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = add nsw i32 %30, -64
%32 = mul nsw i32 %31, %27
%33 = add nuw nsw i64 %26, 1
%34 = tail call i32 @length(i8* %4)
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %25, label %37
37: ; preds = %25
%38 = srem i32 %32, 47
br label %39
39: ; preds = %37, %9
%40 = phi i32 [ 1, %9 ], [ %38, %37 ]
%41 = icmp eq i32 %40, %10
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 3, i64 1, i32* %2)
br label %46
44: ; preds = %39
%45 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 5, i64 1, i32* %2)
br label %46
46: ; preds = %44, %42
%47 = tail call i32 @fclose(i32* %1)
ret i32 0
}