// File: /workspace/github_cpp_makefile_star2_O2/tlaloc1313[P]chess-project/decodeEncode.cpp
// Function: inputFunc()
int inputFunc(void) {
  string input;
  int square = -1;
	bool invInput = true;

	//Loops until a valid input is entered
	while (invInput && getline(cin, input)) {

		//Tilde signifies that a cheat code is following
		if (input[0] == '~') {
			if (input.compare("~UUDDLRLRBAS") == 0) {
				return 1000;
			}
			cout << INVSQUARE;
			invInput = true;
			continue;
		}

    //Checks for either of the  castling sequences
    if ( (input.compare("O-O-O") == 0) || (input.compare("O-O") == 0)) {
      return 69;
    }

    //Checks for resignation
    if ( (input.compare("resign") == 0) || (input.compare("Resign")) == 0 || (input.compare("RESIGN")) == 0 ) {
      return 800;
    }

    if ( (input.compare("offerdraw") == 0) || (input.compare("Offerdraw")) == 0 || (input.compare("OfferDraw")) == 0 || (input.compare("OFFERDRAW")) == 0 ) {
      return 801;
    }

		//Checks that the input is the correct length
		if (input.length() != 2) {
			cout << INVSQUARE;
			invInput = true;
			continue;
		}

		//Sets the starting number based on the column
	  char letter = input[0];
	  switch (letter) {
		  case 'a':
				square = 0;
				invInput = false;
				break;
			case 'b':
				square = 8;
				invInput = false;
				break;
			case 'c':
				square = 16;
				invInput = false;
				break;
			case 'd':
				square = 24;
				invInput = false;
				break;
			case 'e':
				square = 32;
				invInput = false;
				break;
			case 'f':
				square = 40;
				invInput = false;
				break;
			case 'g':
				square = 48;
				invInput = false;
				break;
			case 'h':
				square = 56;
				invInput = false;
				break;
			//Returns to start of loop if invalid input
			default:
				cout << INVSQUARE;
				invInput = true;
				continue;
	  }

		//Adds on the row
		char number = input[1];
	  switch (number) {
		  case '1':
				square += 0;
				invInput = false;
				break;
			case '2':
				square += 1;
				invInput = false;
				break;
			case '3':
				square += 2;
				invInput = false;
				break;
			case '4':
				square += 3;
				invInput = false;
				break;
			case '5':
				square += 4;
				invInput = false;
				break;
			case '6':
				square += 5;
				invInput = false;
				break;
			case '7':
				square += 6;
				invInput = false;
				break;
			case '8':
				square += 7;
				invInput = false;
				break;
			//Returns to start of loop if invalid input
			default:
				cout << INVSQUARE;
				invInput = true;
	  }
	}

  return square;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
pushq $-0x1
popq %rax
movl %eax, -0x2c(%rbp)
movb $0x1, %al
movq 0x5fc4(%rip), %rbx      # 0x8fe0
leaq -0x50(%rbp), %r14
movq 0x5fa9(%rip), %r12      # 0x8fd0
leaq 0x325f(%rip), %r13      # 0x628d
testb $0x1, %al
je 0x3210
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2040
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3210
movq -0x50(%rbp), %rax
cmpb $0x7e, (%rax)
jne 0x3078
movq %r14, %rdi
leaq 0x321a(%rip), %rsi      # 0x6280
callq 0x2050
testl %eax, %eax
jne 0x315a
jmp 0x321c
movq %r14, %rdi
leaq 0x3227(%rip), %rsi      # 0x62a9
callq 0x2050
testl %eax, %eax
je 0x3216
movq %r14, %rdi
leaq 0x3212(%rip), %rsi      # 0x62ab
callq 0x2050
testl %eax, %eax
je 0x3216
movq %r14, %rdi
leaq 0x31ff(%rip), %rsi      # 0x62af
callq 0x2050
movl $0x320, %r15d           # imm = 0x320
testl %eax, %eax
je 0x3222
movq %r14, %rdi
leaq 0x31e9(%rip), %rsi      # 0x62b6
callq 0x2050
testl %eax, %eax
je 0x3222
movq %r14, %rdi
leaq 0x31d9(%rip), %rsi      # 0x62bd
callq 0x2050
testl %eax, %eax
je 0x3222
movq %r14, %rdi
leaq 0x31c9(%rip), %rsi      # 0x62c4
callq 0x2050
movl $0x321, %r15d           # imm = 0x321
testl %eax, %eax
je 0x3222
movq %r14, %rdi
leaq 0x31b6(%rip), %rsi      # 0x62ce
callq 0x2050
testl %eax, %eax
je 0x3222
movq %r14, %rdi
leaq 0x31a9(%rip), %rsi      # 0x62d8
callq 0x2050
testl %eax, %eax
je 0x3222
movq %r14, %rdi
leaq 0x319c(%rip), %rsi      # 0x62e2
callq 0x2050
testl %eax, %eax
je 0x3222
cmpq $0x2, -0x48(%rbp)
je 0x316a
movq %r12, %rdi
movq %r13, %rsi
callq 0x20f0
jmp 0x3036
movq -0x50(%rbp), %rax
movb (%rax), %cl
addb $-0x61, %cl
cmpb $0x8, %cl
jae 0x31aa
shlb $0x3, %cl
movzbl %cl, %ecx
movl %ecx, -0x2c(%rbp)
movzbl 0x1(%rax), %ecx
addl $-0x31, %ecx
cmpl $0x7, %ecx
ja 0x31fe
xorl %eax, %eax
leaq 0x30aa(%rip), %rdx      # 0x6240
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
orl $0x1, -0x2c(%rbp)
xorl %eax, %eax
jmp 0x302e
movq %r12, %rdi
movq %r13, %rsi
callq 0x20f0
movb $0x1, %al
jmp 0x302e
orl $0x5, -0x2c(%rbp)
xorl %eax, %eax
jmp 0x302e
orl $0x3, -0x2c(%rbp)
xorl %eax, %eax
jmp 0x302e
orl $0x4, -0x2c(%rbp)
xorl %eax, %eax
jmp 0x302e
orl $0x2, -0x2c(%rbp)
xorl %eax, %eax
jmp 0x302e
orl $0x6, -0x2c(%rbp)
xorl %eax, %eax
jmp 0x302e
orl $0x7, -0x2c(%rbp)
xorl %eax, %eax
jmp 0x302e
movq %r12, %rdi
movq %r13, %rsi
callq 0x20f0
movb $0x1, %al
jmp 0x302e
movl -0x2c(%rbp), %r15d
jmp 0x3222
pushq $0x45
popq %r15
jmp 0x3222
movl $0x3e8, %r15d           # imm = 0x3E8
leaq -0x50(%rbp), %rdi
callq 0x2080
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3241
jmp 0x3241
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x21b0