#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 */
char getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int table[26] = {4, 1, 2, 2, 2, 2, 4, 2, 3, 1, 2, 6, 1,
                   2, 1, 4, 2, 6, 6, 4, 1, 4, 1, 1, 2, 1};
  char a;
  int total = 3;
  a = getchar();
  while (a != '\n') {
    total = (table[a - 65] * total) % 1000000;
    a = getchar();
  }
  printf("%d\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x68,%edx
call   1050 <memcpy@plt>
movl   $0x3,-0x78(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x71(%rbp)
movsbl -0x71(%rbp),%eax
cmp    $0xa,%eax
je     11a0 <main+0x70>
movsbl -0x71(%rbp),%eax
sub    $0x41,%eax
cltq
mov    -0x70(%rbp,%rax,4),%eax
imul   -0x78(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,-0x78(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x71(%rbp)
jmp    1168 <main+0x38>
mov    -0x78(%rbp),%esi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x3,%ebx
cmp    $0xa,%al
je     1177 <main+0x57>
mov    $0x3,%ebx
lea    0xec0(%rip),%r14
movsbq %al,%rax
imul   -0x104(%r14,%rax,4),%ebx
ff ff
movslq %ebx,%rbx
imul   $0x431bde83,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
imul   $0xf4240,%eax,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1140 <main+0x20>
lea    0xeea(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.table = [26 x i32] [i32 4, i32 1, i32 2, i32 2, i32 2, i32 2, i32 4, i32 2, i32 3, i32 1, i32 2, i32 6, i32 1, i32 2, i32 1, i32 4, i32 2, i32 6, i32 6, i32 4, i32 1, i32 4, i32 1, i32 1, i32 2, i32 1]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [26 x i32]
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [26 x i32]* %2 to i8*
store i32 3, i32* %4
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %3
br label %7
7: ; preds = %11, %0
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 65
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = load i32, i32* %4
%19 = mul nsw i32 %17, %18
%20 = srem i32 %19, 1000000
store i32 %20, i32* %4
%21 = call signext i8 (...) @getchar()
store i8 %21, i8* %3
br label %7
22: ; preds = %7
%23 = load i32, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@__const.main.table = [26 x i32] [i32 4, i32 1, i32 2, i32 2, i32 2, i32 2, i32 4, i32 2, i32 3, i32 1, i32 2, i32 6, i32 1, i32 2, i32 1, i32 4, i32 2, i32 6, i32 6, i32 4, i32 1, i32 4, i32 1, i32 1, i32 2, i32 1]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = icmp eq i8 %1, 10
br i1 %2, label %14, label %3
3: ; preds = %0, %3
%4 = phi i32 [ %11, %3 ], [ 3, %0 ]
%5 = phi i8 [ %12, %3 ], [ %1, %0 ]
%6 = sext i8 %5 to i64
%7 = add nsw i64 %6, -65
%8 = getelementptr inbounds [26 x i32], [26 x i32]* @__const.main.table, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = mul nsw i32 %9, %4
%11 = srem i32 %10, 1000000
%12 = tail call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %3
14: ; preds = %3, %0
%15 = phi i32 [ 3, %0 ], [ %11, %3 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 0
}