// File: tlaloc1313[P]chess-project/decodeEncode.cpp
// Function: encode[abi:cxx11](int)
string encode(int code){
  string takeString = "";

  //Special Case: CASTLING
  if (code == 69) {
    return "O-O";
  }
  if (code == 70) {
    return "O-O-O";
  }

  //If the move took a piece
  if (code>199 && code <264) {
    takeString = "x";
    code -= 200;
  }

  int row = code%8; //gets an integer for the row
  int column = (code-row)/8; //gets an integer for the column
  string rowString = to_string(row+1); //Converts to a string for concatenation
  string columnString;

  //Assigns a letter based on the row
  switch (column) {
    case 0:
      columnString = "a";
    break;
    case 1:
      columnString = "b";
    break;
    case 2:
      columnString = "c";
    break;
    case 3:
      columnString = "d";
    break;
    case 4:
      columnString = "e";
    break;
    case 5:
      columnString = "f";
    break;
    case 6:
      columnString = "g";
    break;
    case 7:
      columnString = "h";
    break;
    default:
      return "Undefined";
  }
  //Concatenates the column and row
  string output = takeString + columnString + rowString;
  return output;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xd8(%rbp)
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x2280
movq -0xc8(%rbp), %rdx
leaq 0x5ffd(%rip), %rsi      # 0xa0ae
leaq -0x30(%rbp), %rdi
callq 0x21c0
jmp 0x40bc
leaq -0x31(%rbp), %rdi
callq 0x2170
cmpl $0x45, -0xc(%rbp)
jne 0x4140
leaq -0x45(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x2280
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x627b(%rip), %rsi      # 0xa36b
callq 0x21c0
jmp 0x40f7
leaq -0x45(%rbp), %rdi
callq 0x2170
movl $0x1, -0x4c(%rbp)
jmp 0x444c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x2170
jmp 0x446e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x45(%rbp), %rdi
callq 0x2170
jmp 0x4465
cmpl $0x46, -0xc(%rbp)
jne 0x41a1
leaq -0x4d(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x2280
movq -0xd8(%rbp), %rdi
movq -0xe8(%rbp), %rdx
leaq 0x61fe(%rip), %rsi      # 0xa369
callq 0x21c0
jmp 0x4172
leaq -0x4d(%rbp), %rdi
callq 0x2170
movl $0x1, -0x4c(%rbp)
jmp 0x444c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x4d(%rbp), %rdi
callq 0x2170
jmp 0x4465
cmpl $0xc7, -0xc(%rbp)
jle 0x41e3
cmpl $0x108, -0xc(%rbp)      # imm = 0x108
jge 0x41e3
leaq 0x61f2(%rip), %rsi      # 0xa3ac
leaq -0x30(%rbp), %rdi
callq 0x21b0
jmp 0x41c5
movl -0xc(%rbp), %eax
subl $0xc8, %eax
movl %eax, -0xc(%rbp)
jmp 0x41e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4465
movl -0xc(%rbp), %eax
movl %eax, %edx
addl $0x7, %edx
testl %eax, %eax
movl %eax, %ecx
cmovsl %edx, %ecx
andl $-0x8, %ecx
subl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0xc(%rbp), %eax
movl -0x54(%rbp), %ecx
subl %ecx, %eax
movl %eax, %ecx
addl $0x7, %ecx
testl %eax, %eax
cmovsl %ecx, %eax
sarl $0x3, %eax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %esi
incl %esi
leaq -0x78(%rbp), %rdi
callq 0x4480
jmp 0x4222
leaq -0x98(%rbp), %rdi
callq 0x21d0
movl -0x58(%rbp), %eax
movq %rax, -0xf0(%rbp)
subq $0x7, %rax
ja 0x4334
movq -0xf0(%rbp), %rax
leaq 0x60d0(%rip), %rcx      # 0xa320
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x6068(%rip), %rsi      # 0xa2c8
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x426e
jmp 0x4398
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4435
leaq 0x603f(%rip), %rsi      # 0xa2ca
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x4299
jmp 0x4398
leaq 0x6027(%rip), %rsi      # 0xa2cc
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x42b3
jmp 0x4398
leaq 0x60f7(%rip), %rsi      # 0xa3b6
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x42cd
jmp 0x4398
leaq 0x5ff5(%rip), %rsi      # 0xa2ce
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x42e7
jmp 0x4398
leaq 0x5fdd(%rip), %rsi      # 0xa2d0
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x4301
jmp 0x4398
leaq 0x5fc5(%rip), %rsi      # 0xa2d2
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x431b
jmp 0x4398
leaq 0x5fb5(%rip), %rsi      # 0xa2d9
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x4332
jmp 0x4398
leaq -0x99(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x2280
movq -0xd8(%rbp), %rdi
movq -0xf8(%rbp), %rdx
leaq 0x6052(%rip), %rsi      # 0xa3ae
callq 0x21c0
jmp 0x4363
leaq -0x99(%rbp), %rdi
callq 0x2170
movl $0x1, -0x4c(%rbp)
jmp 0x441e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x2170
jmp 0x4435
movb $0x0, -0x9a(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0x45f0
jmp 0x43b8
movq -0xd8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x45a0
jmp 0x43d1
leaq -0xc0(%rbp), %rdi
callq 0x20e0
movb $0x1, -0x9a(%rbp)
movl $0x1, -0x4c(%rbp)
testb $0x1, -0x9a(%rbp)
jne 0x441c
jmp 0x4410
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x20e0
jmp 0x4435
movq -0xd8(%rbp), %rdi
callq 0x20e0
jmp 0x441e
leaq -0x98(%rbp), %rdi
callq 0x20e0
leaq -0x78(%rbp), %rdi
callq 0x20e0
jmp 0x444c
leaq -0x98(%rbp), %rdi
callq 0x20e0
leaq -0x78(%rbp), %rdi
callq 0x20e0
jmp 0x4465
leaq -0x30(%rbp), %rdi
callq 0x20e0
movq -0xd0(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x20e0
movq -0x40(%rbp), %rdi
callq 0x2270
nopw (%rax,%rax)