#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
main() {
  FILE *fin = fopen("ride.in", "r");
  FILE *fout = fopen("ride.out", "w");
  int i = 0, j = 0, re1 = 1, re2 = 1, x;
  char comet[7], group[7];
  fscanf(fin, "%s %s", comet, group);
  while (comet[i]) {
    x = comet[i] - 64;
    re1 *= x;
    ++i;
  }
  while (group[j]) {
    x = group[j] - 64;
    re2 *= x;
    ++j;
  }
  if (((re2) % 47) == ((re1) % 47)) {
    fprintf(fout, "%s\n", "GO");
  } else {
    fprintf(fout, "%s\n", "STAY");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x33(%rbp),%rdx
lea    -0x3a(%rbp),%rcx
lea    0xe69(%rip),%rsi
call   1030 <fscanf@plt>
movslq -0x1c(%rbp),%rax
cmpb   $0x0,-0x33(%rbp,%rax,1)
je     11e7 <main+0xa7>
movslq -0x1c(%rbp),%rax
movsbl -0x33(%rbp,%rax,1),%eax
sub    $0x40,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b1 <main+0x71>
jmp    11ec <main+0xac>
movslq -0x20(%rbp),%rax
cmpb   $0x0,-0x3a(%rbp,%rax,1)
je     1222 <main+0xe2>
movslq -0x20(%rbp),%rax
movsbl -0x3a(%rbp,%rax,1),%eax
sub    $0x40,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ec <main+0xac>
mov    -0x28(%rbp),%eax
mov    $0x2f,%ecx
cltd
idiv   %ecx
mov    %edx,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2f,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x40(%rbp),%edx
cmp    %eax,%edx
jne    1264 <main+0x124>
mov    -0x18(%rbp),%rdi
lea    0xdc8(%rip),%rsi
lea    0xdc5(%rip),%rdx
call   1040 <fprintf@plt>
jmp    127b <main+0x13b>
mov    -0x18(%rbp),%rdi
lea    0xdac(%rip),%rsi
lea    0xdac(%rip),%rdx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb2(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xea6(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xe9b(%rip),%rsi
lea    0x11(%rsp),%rdx
lea    0xa(%rsp),%rcx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
mov    0x11(%rsp),%dl
mov    $0x1,%eax
mov    $0x1,%ecx
test   %dl,%dl
je     11e3 <main+0xa3>
lea    0x12(%rsp),%rsi
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
movsbl %dl,%edx
add    $0xffffffc0,%edx
imul   %edx,%ecx
movzbl (%rsi),%edx
add    $0x1,%rsi
test   %dl,%dl
jne    11b0 <main+0x70>
movslq %ecx,%rcx
imul   $0xffffffffae4c415d,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0x2f,%edx,%edx
sub    %edx,%ecx
mov    0xa(%rsp),%dl
test   %dl,%dl
je     1232 <main+0xf2>
lea    0xb(%rsp),%rsi
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %dl,%edx
add    $0xffffffc0,%edx
imul   %edx,%eax
movzbl (%rsi),%edx
add    $0x1,%rsi
test   %dl,%dl
jne    1200 <main+0xc0>
cltq
imul   $0xffffffffae4c415d,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0x2f,%edx,%edx
sub    %edx,%eax
cmp    %ecx,%eax
lea    0xde4(%rip),%rax
lea    0xde0(%rip),%rdx
cmove  %rax,%rdx
lea    0xdce(%rip),%rsi
mov    %r14,%rdi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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 = [6 x i8] c"%s %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 i32
%8 = alloca i32
%9 = alloca [7 x i8]
%10 = alloca [7 x i8]
store i32 0, i32* %1
%11 = 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* %11, i32** %2
%12 = 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* %12, i32** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
store i32 1, i32* %7
%13 = load i32*, i32** %2
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %10, i64 0, i64 0
%16 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %14, i8* %15)
br label %17
17: ; preds = %23, %0
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %17
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = sub nsw i32 %28, 64
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = mul nsw i32 %31, %30
store i32 %32, i32* %6
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %17
35: ; preds = %17
br label %36
36: ; preds = %42, %35
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [7 x i8], [7 x i8]* %10, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %42, label %54
42: ; preds = %36
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [7 x i8], [7 x i8]* %10, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = sub nsw i32 %47, 64
store i32 %48, i32* %8
%49 = load i32, i32* %8
%50 = load i32, i32* %7
%51 = mul nsw i32 %50, %49
store i32 %51, i32* %7
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %36
54: ; preds = %36
%55 = load i32, i32* %7
%56 = srem i32 %55, 47
%57 = load i32, i32* %6
%58 = srem i32 %57, 47
%59 = icmp eq i32 %56, %58
br i1 %59, label %60, label %63
60: ; preds = %54
%61 = load i32*, i32** %3
%62 = call i32 @fprintf(i32* %61, 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 %66
63: ; preds = %54
%64 = load i32*, i32** %3
%65 = call i32 @fprintf(i32* %64, 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 %66
66: ; preds = %63, %60
%67 = call i32 @exit(i32 0)
unreachable
}

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 = [6 x i8] c"%s %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 ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* %6)
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %16
10: ; preds = %16
%11 = srem i32 %22, 47
br label %12
12: ; preds = %10, %0
%13 = phi i32 [ 1, %0 ], [ %11, %10 ]
%14 = load i8, i8* %6
%15 = icmp eq i8 %14, 0
br i1 %15, label %40, label %27
16: ; preds = %0, %16
%17 = phi i64 [ %23, %16 ], [ 0, %0 ]
%18 = phi i8 [ %25, %16 ], [ %8, %0 ]
%19 = phi i32 [ %22, %16 ], [ 1, %0 ]
%20 = sext i8 %18 to i32
%21 = add nsw i32 %20, -64
%22 = mul nsw i32 %21, %19
%23 = add nuw nsw i64 %17, 1
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %10, label %16
27: ; preds = %12, %27
%28 = phi i64 [ %34, %27 ], [ 0, %12 ]
%29 = phi i8 [ %36, %27 ], [ %14, %12 ]
%30 = phi i32 [ %33, %27 ], [ 1, %12 ]
%31 = sext i8 %29 to i32
%32 = add nsw i32 %31, -64
%33 = mul nsw i32 %32, %30
%34 = add nuw nsw i64 %28, 1
%35 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %38, label %27
38: ; preds = %27
%39 = srem i32 %33, 47
br label %40
40: ; preds = %38, %12
%41 = phi i32 [ 1, %12 ], [ %39, %38 ]
%42 = icmp eq i32 %41, %13
%43 = select i1 %42, 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)
%44 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 0)
unreachable
}