// File: 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
subq $0x80, %rsp
leaq -0x28(%rbp), %rdi
callq 0x21d0
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movb $0x1, -0x2d(%rbp)
xorl %eax, %eax
testb $0x1, -0x2d(%rbp)
movb %al, -0x43(%rbp)
je 0x3ce0
movq 0xb32f(%rip), %rdi      # 0xefe0
leaq -0x28(%rbp), %rsi
callq 0x2050
movq %rax, -0x50(%rbp)
jmp 0x3cc0
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2190
movb %al, -0x51(%rbp)
jmp 0x3cd8
movb -0x51(%rbp), %al
movb %al, -0x43(%rbp)
jmp 0x3ce0
movb -0x43(%rbp), %al
testb $0x1, %al
jne 0x3cec
jmp 0x4036
xorl %eax, %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdi
callq 0x22a0
movq %rax, -0x60(%rbp)
jmp 0x3cff
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7e, %eax
jne 0x3d6b
leaq -0x28(%rbp), %rdi
leaq 0x662a(%rip), %rsi      # 0xa340
callq 0x2070
cmpl $0x0, %eax
jne 0x3d4d
movl $0x3e8, -0x4(%rbp)      # imm = 0x3E8
movl $0x1, -0x40(%rbp)
jmp 0x4043
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x20e0
jmp 0x4058
movq 0xb27c(%rip), %rdi      # 0xefd0
leaq 0x65f2(%rip), %rsi      # 0xa34d
callq 0x2140
jmp 0x3d62
movb $0x1, -0x2d(%rbp)
jmp 0x3c9f
leaq -0x28(%rbp), %rdi
leaq 0x65f3(%rip), %rsi      # 0xa369
callq 0x2070
cmpl $0x0, %eax
je 0x3d95
leaq -0x28(%rbp), %rdi
leaq 0x65e0(%rip), %rsi      # 0xa36b
callq 0x2070
cmpl $0x0, %eax
jne 0x3da8
movl $0x45, -0x4(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x4043
leaq -0x28(%rbp), %rdi
leaq 0x65bc(%rip), %rsi      # 0xa36f
callq 0x2070
cmpl $0x0, %eax
je 0x3de7
leaq -0x28(%rbp), %rdi
leaq 0x65ae(%rip), %rsi      # 0xa376
callq 0x2070
cmpl $0x0, %eax
je 0x3de7
leaq -0x28(%rbp), %rdi
leaq 0x65a0(%rip), %rsi      # 0xa37d
callq 0x2070
cmpl $0x0, %eax
jne 0x3dfa
movl $0x320, -0x4(%rbp)      # imm = 0x320
movl $0x1, -0x40(%rbp)
jmp 0x4043
leaq -0x28(%rbp), %rdi
leaq 0x657f(%rip), %rsi      # 0xa384
callq 0x2070
cmpl $0x0, %eax
je 0x3e4e
leaq -0x28(%rbp), %rdi
leaq 0x6574(%rip), %rsi      # 0xa38e
callq 0x2070
cmpl $0x0, %eax
je 0x3e4e
leaq -0x28(%rbp), %rdi
leaq 0x6569(%rip), %rsi      # 0xa398
callq 0x2070
cmpl $0x0, %eax
je 0x3e4e
leaq -0x28(%rbp), %rdi
leaq 0x655e(%rip), %rsi      # 0xa3a2
callq 0x2070
cmpl $0x0, %eax
jne 0x3e61
movl $0x321, -0x4(%rbp)      # imm = 0x321
movl $0x1, -0x40(%rbp)
jmp 0x4043
leaq -0x28(%rbp), %rdi
callq 0x2200
cmpq $0x2, %rax
je 0x3e8e
movq 0xb159(%rip), %rdi      # 0xefd0
leaq 0x64cf(%rip), %rsi      # 0xa34d
callq 0x2140
jmp 0x3e85
movb $0x1, -0x2d(%rbp)
jmp 0x3c9f
xorl %eax, %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdi
callq 0x22a0
movq %rax, -0x68(%rbp)
jmp 0x3ea1
movq -0x68(%rbp), %rax
movb (%rax), %al
movb %al, -0x41(%rbp)
movsbl -0x41(%rbp), %eax
addl $-0x61, %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x7, %eax
ja 0x3f38
movq -0x70(%rbp), %rax
leaq 0x6419(%rip), %rcx      # 0xa2e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movl $0x8, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movl $0x10, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movl $0x18, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movl $0x20, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movl $0x28, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movl $0x30, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movl $0x38, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x3f56
movq 0xb091(%rip), %rdi      # 0xefd0
leaq 0x6407(%rip), %rsi      # 0xa34d
callq 0x2140
jmp 0x3f4d
movb $0x1, -0x2d(%rbp)
jmp 0x3c9f
leaq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x22a0
movq %rax, -0x78(%rbp)
jmp 0x3f6a
movq -0x78(%rbp), %rax
movb (%rax), %al
movb %al, -0x42(%rbp)
movsbl -0x42(%rbp), %eax
addl $-0x31, %eax
movl %eax, %ecx
movq %rcx, -0x80(%rbp)
subl $0x7, %eax
ja 0x4018
movq -0x80(%rbp), %rax
leaq 0x636c(%rip), %rcx      # 0xa300
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x2c(%rbp), %eax
addl $0x0, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movl -0x2c(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movl -0x2c(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movl -0x2c(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movl -0x2c(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
jmp 0x4031
movq 0xafb1(%rip), %rdi      # 0xefd0
leaq 0x6327(%rip), %rsi      # 0xa34d
callq 0x2140
jmp 0x402d
movb $0x1, -0x2d(%rbp)
jmp 0x3c9f
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x40(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x20e0
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x2270
nopw %cs:(%rax,%rax)