#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 */
unsigned int charToInt(char);
unsigned int myPow(int, int);
unsigned int getFirstIndex(char board[7][6]) {
  unsigned int index = 0;
  for (int x = 0; x < 7; x++) {
    for (int y = 0; y < 6; y++) {
      index += charToInt(board[x][y]) * myPow(3, ((x + y * 7) % 18));
    }
  }
  index = index % 20000000;
  return index;
}


x86 assembly (clang, -O0):
<getFirstIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x7,-0x10(%rbp)
jge    11c0 <getFirstIndex+0xa0>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11ad <getFirstIndex+0x8d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x6,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <charToInt@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
imul   $0x7,-0x14(%rbp),%ecx
add    %ecx,%eax
mov    $0x12,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    $0x3,%edi
call   1040 <myPow@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <getFirstIndex+0x2b>
jmp    11b2 <getFirstIndex+0x92>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <getFirstIndex+0x1a>
mov    -0xc(%rbp),%eax
mov    $0x1312d00,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFirstIndex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
add    $0x5,%r14
xor    %r15d,%r15d
mov    $0x23,%eax
mov    $0x1c,%ecx
mov    $0x15,%edx
mov    $0xe,%esi
mov    $0x7,%edi
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edi,0x8(%rsp)
mov    %esi,0xc(%rsp)
mov    %edx,0x10(%rsp)
mov    %ecx,0x14(%rsp)
mov    %eax,0x4(%rsp)
mov    0x4(%rsp),%eax
imul   $0x38e38e39,%rax,%rax
shr    $0x22,%rax
add    %eax,%eax
lea    (%rax,%rax,8),%eax
mov    %rax,0x30(%rsp)
mov    %ecx,%eax
imul   $0x38e38e39,%rax,%rax
shr    $0x22,%rax
add    %eax,%eax
lea    (%rax,%rax,8),%eax
mov    %rax,0x28(%rsp)
mov    %edx,%eax
imul   $0x38e38e39,%rax,%rax
shr    $0x22,%rax
add    %eax,%eax
lea    (%rax,%rax,8),%eax
mov    %rax,0x20(%rsp)
mov    %esi,%eax
imul   $0x38e38e39,%rax,%rax
shr    $0x22,%rax
add    %eax,%eax
lea    (%rax,%rax,8),%eax
mov    %rax,0x18(%rsp)
mov    %edi,%eax
imul   $0x38e38e39,%rax,%rax
shr    $0x22,%rax
add    %eax,%eax
lea    (%rax,%rax,8),%r13d
movsbl -0x5(%r14),%edi
call   1030 <charToInt@plt>
mov    %eax,%r12d
mov    $0x3,%edi
mov    %r15d,%esi
call   1040 <myPow@plt>
mov    %eax,%ebx
imul   %r12d,%ebx
add    %ebp,%ebx
movsbl -0x4(%r14),%edi
call   1030 <charToInt@plt>
mov    %eax,%r12d
neg    %r13d
lea    (%r15,%r13,1),%esi
add    $0x7,%esi
mov    $0x3,%edi
call   1040 <myPow@plt>
mov    %eax,%ebp
imul   %r12d,%ebp
add    %ebx,%ebp
movsbl -0x3(%r14),%edi
call   1030 <charToInt@plt>
mov    %eax,%r12d
mov    0x18(%rsp),%rax
neg    %eax
lea    (%r15,%rax,1),%esi
add    $0xe,%esi
mov    $0x3,%edi
call   1040 <myPow@plt>
mov    %eax,%ebx
imul   %r12d,%ebx
add    %ebp,%ebx
movsbl -0x2(%r14),%edi
call   1030 <charToInt@plt>
mov    %eax,%r12d
mov    0x20(%rsp),%rax
neg    %eax
lea    (%r15,%rax,1),%esi
add    $0x15,%esi
mov    $0x3,%edi
call   1040 <myPow@plt>
mov    %eax,%ebp
imul   %r12d,%ebp
add    %ebx,%ebp
movsbl -0x1(%r14),%edi
call   1030 <charToInt@plt>
mov    %eax,%r12d
mov    0x28(%rsp),%rax
neg    %eax
lea    (%r15,%rax,1),%esi
add    $0x1c,%esi
mov    $0x3,%edi
call   1040 <myPow@plt>
mov    %eax,%ebx
imul   %r12d,%ebx
add    %ebp,%ebx
movsbl (%r14),%edi
call   1030 <charToInt@plt>
mov    %eax,%r12d
mov    0x30(%rsp),%rax
neg    %eax
lea    (%r15,%rax,1),%esi
add    $0x23,%esi
mov    $0x3,%edi
call   1040 <myPow@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    %eax,%ebp
mov    0x4(%rsp),%eax
imul   %r12d,%ebp
add    %ebx,%ebp
add    $0x1,%r15
add    $0x1,%eax
add    $0x1,%ecx
add    $0x1,%edx
add    $0x1,%esi
add    $0x1,%edi
add    $0x6,%r14
cmp    $0x7,%r15
jne    1160 <getFirstIndex+0x40>
mov    %ebp,%eax
imul   $0x6b5fca6b,%rax,%rax
shr    $0x37,%rax
imul   $0x1312d00,%eax,%eax
sub    %eax,%ebp
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getFirstIndex([6 x i8]* %0) {
%2 = alloca [6 x i8]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store [6 x i8]* %0, [6 x i8]** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %36, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 7
br i1 %8, label %9, label %39
9: ; preds = %6
store i32 0, i32* %5
br label %10
10: ; preds = %32, %9
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 6
br i1 %12, label %13, label %35
13: ; preds = %10
%14 = load [6 x i8]*, [6 x i8]** %2
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 %16
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %17, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @charToInt(i8 signext %21)
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = mul nsw i32 %24, 7
%26 = add nsw i32 %23, %25
%27 = srem i32 %26, 18
%28 = call i32 @myPow(i32 3, i32 %27)
%29 = mul i32 %22, %28
%30 = load i32, i32* %3
%31 = add i32 %30, %29
store i32 %31, i32* %3
br label %32
32: ; preds = %13
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %10
35: ; preds = %10
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %6
39: ; preds = %6
%40 = load i32, i32* %3
%41 = urem i32 %40, 20000000
store i32 %41, i32* %3
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @getFirstIndex([6 x i8]* nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %57, %2 ]
%4 = phi i32 [ 0, %1 ], [ %56, %2 ]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %3, i64 0
%6 = load i8, i8* %5
%7 = tail call i32 @charToInt(i8 signext %6)
%8 = trunc i64 %3 to i32
%9 = tail call i32 @myPow(i32 3, i32 %8)
%10 = mul i32 %9, %7
%11 = add i32 %10, %4
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %3, i64 1
%13 = load i8, i8* %12
%14 = tail call i32 @charToInt(i8 signext %13)
%15 = trunc i64 %3 to i32
%16 = add i32 %15, 7
%17 = urem i32 %16, 18
%18 = tail call i32 @myPow(i32 3, i32 %17)
%19 = mul i32 %18, %14
%20 = add i32 %19, %11
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %3, i64 2
%22 = load i8, i8* %21
%23 = tail call i32 @charToInt(i8 signext %22)
%24 = trunc i64 %3 to i32
%25 = add i32 %24, 14
%26 = urem i32 %25, 18
%27 = tail call i32 @myPow(i32 3, i32 %26)
%28 = mul i32 %27, %23
%29 = add i32 %28, %20
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %3, i64 3
%31 = load i8, i8* %30
%32 = tail call i32 @charToInt(i8 signext %31)
%33 = trunc i64 %3 to i32
%34 = add i32 %33, 21
%35 = urem i32 %34, 18
%36 = tail call i32 @myPow(i32 3, i32 %35)
%37 = mul i32 %36, %32
%38 = add i32 %37, %29
%39 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %3, i64 4
%40 = load i8, i8* %39
%41 = tail call i32 @charToInt(i8 signext %40)
%42 = trunc i64 %3 to i32
%43 = add i32 %42, 28
%44 = urem i32 %43, 18
%45 = tail call i32 @myPow(i32 3, i32 %44)
%46 = mul i32 %45, %41
%47 = add i32 %46, %38
%48 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %3, i64 5
%49 = load i8, i8* %48
%50 = tail call i32 @charToInt(i8 signext %49)
%51 = trunc i64 %3 to i32
%52 = add i32 %51, 35
%53 = urem i32 %52, 18
%54 = tail call i32 @myPow(i32 3, i32 %53)
%55 = mul i32 %54, %50
%56 = add i32 %55, %47
%57 = add nuw nsw i64 %3, 1
%58 = icmp eq i64 %57, 7
br i1 %58, label %59, label %2
59: ; preds = %2
%60 = urem i32 %56, 20000000
ret i32 %60
}