// File: /workspace/github_cpp_makefile_star2_O1/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 -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x5cb7(%rip), %rbx      # 0x8fe0
leaq -0x48(%rbp), %r14
leaq 0x2f59(%rip), %r13      # 0x628d
movl %r12d, %r15d
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3532
movq -0x48(%rbp), %rax
cmpb $0x7e, (%rax)
jne 0x3390
movq %r14, %rdi
leaq 0x2f02(%rip), %rsi      # 0x6280
callq 0x2050
testl %eax, %eax
jne 0x347b
jmp 0x352c
movq %r14, %rdi
leaq 0x2f0f(%rip), %rsi      # 0x62a9
callq 0x2050
movl $0x45, %r15d
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2ef4(%rip), %rsi      # 0x62ab
callq 0x2050
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2ee1(%rip), %rsi      # 0x62af
callq 0x2050
movl $0x320, %r15d           # imm = 0x320
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2ecb(%rip), %rsi      # 0x62b6
callq 0x2050
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2ebb(%rip), %rsi      # 0x62bd
callq 0x2050
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2eab(%rip), %rsi      # 0x62c4
callq 0x2050
movl $0x321, %r15d           # imm = 0x321
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2e98(%rip), %rsi      # 0x62ce
callq 0x2050
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2e8b(%rip), %rsi      # 0x62d8
callq 0x2050
testl %eax, %eax
je 0x3532
movq %r14, %rdi
leaq 0x2e7e(%rip), %rsi      # 0x62e2
callq 0x2050
testl %eax, %eax
je 0x3532
cmpq $0x2, -0x40(%rbp)
movl %r12d, %r15d
je 0x3494
movl $0x1b, %edx
movq 0x5b49(%rip), %rdi      # 0x8fd0
movq %r13, %rsi
callq 0x2120
jmp 0x3337
movq -0x48(%rbp), %rax
movb (%rax), %cl
addb $-0x61, %cl
cmpb $0x8, %cl
jae 0x34cb
shlb $0x3, %cl
movzbl %cl, %r15d
movzbl 0x1(%rax), %eax
addl $-0x31, %eax
cmpl $0x7, %eax
ja 0x3514
leaq 0x2d84(%rip), %rcx      # 0x6240
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
orl $0x1, %r15d
jmp 0x3505
movl $0x1b, %edx
movq 0x5af9(%rip), %rdi      # 0x8fd0
movq %r13, %rsi
callq 0x2120
movb $0x1, %al
jmp 0x3507
orl $0x4, %r15d
jmp 0x3505
orl $0x2, %r15d
jmp 0x3505
orl $0x3, %r15d
jmp 0x3505
orl $0x7, %r15d
jmp 0x3505
orl $0x5, %r15d
jmp 0x3505
orl $0x6, %r15d
xorl %eax, %eax
movl %r15d, %r12d
testb %al, %al
jne 0x3334
jmp 0x3532
movl $0x1b, %edx
movq 0x5ab0(%rip), %rdi      # 0x8fd0
movq %r13, %rsi
callq 0x2120
movb $0x1, %al
jmp 0x3507
movl $0x3e8, %r15d           # imm = 0x3E8
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3544
callq 0x20f0
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x355a
jmp 0x355a
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x356f
callq 0x20f0
movq %rbx, %rdi
callq 0x21c0