// File: /workspace/github_cpp_makefile_star2_O3/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)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movq 0x5cc2(%rip), %rbx      # 0x8fe0
leaq -0x50(%rbp), %r14
movq 0x5ca7(%rip), %r12      # 0x8fd0
leaq 0x2f5d(%rip), %r13      # 0x628d
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 0x34eb
movq -0x50(%rbp), %rax
cmpb $0x7e, (%rax)
jne 0x3389
movq %r14, %rdi
leaq 0x2f09(%rip), %rsi      # 0x6280
callq 0x2050
testl %eax, %eax
jne 0x3471
jmp 0x34d3
movq %r14, %rdi
leaq 0x2f16(%rip), %rsi      # 0x62a9
callq 0x2050
movl $0x45, %r15d
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2efb(%rip), %rsi      # 0x62ab
callq 0x2050
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2ee8(%rip), %rsi      # 0x62af
callq 0x2050
movl $0x320, %r15d           # imm = 0x320
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2ed2(%rip), %rsi      # 0x62b6
callq 0x2050
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2ec2(%rip), %rsi      # 0x62bd
callq 0x2050
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2eb2(%rip), %rsi      # 0x62c4
callq 0x2050
movl $0x321, %r15d           # imm = 0x321
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2e9f(%rip), %rsi      # 0x62ce
callq 0x2050
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2e92(%rip), %rsi      # 0x62d8
callq 0x2050
testl %eax, %eax
je 0x34ef
movq %r14, %rdi
leaq 0x2e85(%rip), %rsi      # 0x62e2
callq 0x2050
testl %eax, %eax
je 0x34ef
cmpq $0x2, -0x48(%rbp)
je 0x3486
movl $0x1b, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2120
jmp 0x3330
movq -0x50(%rbp), %rax
movb (%rax), %cl
addb $-0x61, %cl
cmpb $0x8, %cl
jb 0x34a9
movl $0x1b, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2120
jmp 0x3330
shlb $0x3, %cl
movzbl %cl, %ecx
movl %ecx, -0x2c(%rbp)
movzbl 0x1(%rax), %eax
addl $-0x31, %eax
cmpl $0x7, %eax
jbe 0x34db
movl $0x1b, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2120
jmp 0x3330
movl $0x3e8, %r15d           # imm = 0x3E8
jmp 0x34ef
leaq 0x2d5e(%rip), %rcx      # 0x6240
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x2c(%rbp), %r15d
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3501
callq 0x20f0
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x2c(%rbp), %r15d
orl $0x4, %r15d
jmp 0x34ef
movl -0x2c(%rbp), %r15d
orl $0x2, %r15d
jmp 0x34ef
movl -0x2c(%rbp), %r15d
orl $0x3, %r15d
jmp 0x34ef
movl -0x2c(%rbp), %r15d
orl $0x7, %r15d
jmp 0x34ef
movl -0x2c(%rbp), %r15d
orl $0x1, %r15d
jmp 0x34ef
movl -0x2c(%rbp), %r15d
orl $0x5, %r15d
jmp 0x34ef
movl -0x2c(%rbp), %r15d
orl $0x6, %r15d
jmp 0x34ef
jmp 0x355d
jmp 0x355d
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3572
callq 0x20f0
movq %rbx, %rdi
callq 0x21c0