// File: tlaloc1313[P]chess-project/Board.cpp
// Function: Board::addPiece(char, int, int)
int Board::addPiece(char type, int startSpace, int isWhite){
  if (activeArray[startSpace] == 1) { //If the space is taken
    return -1;
  }
  activeArray[startSpace] = 1; //Activates the space before placing the piece
  switch (type){
    case 'b':
      pieceArray[startSpace] = new Bishop(startSpace, isWhite);
      break;
    case 'n':
      pieceArray[startSpace] = new Knight(startSpace, isWhite);
      break;
    case 'p':
      pieceArray[startSpace] = new Pawn(startSpace, isWhite);
      break;
    case 'k':
      pieceArray[startSpace] = new King(startSpace, isWhite);
      break;
    case 'q':
      pieceArray[startSpace] = new Queen(startSpace, isWhite);
      break;
    case 'r':
      pieceArray[startSpace] = new Rook(startSpace, isWhite);
      break;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movslq -0x18(%rbp), %rcx
movb 0x208(%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x4b41
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d5c
movq -0x38(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, 0x208(%rax,%rcx)
movsbl -0x11(%rbp), %eax
addl $-0x62, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x10, %eax
ja 0x4d55
movq -0x40(%rbp), %rax
leaq 0x591a(%rip), %rcx      # 0xa48c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x18, %edi
callq 0x2150
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x48(%rbp)
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x8be0
jmp 0x4b9c
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rdx
movslq -0x18(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x4d55
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x2130
jmp 0x4d65
movl $0x18, %edi
callq 0x2150
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x8ee0
jmp 0x4bed
movq -0x38(%rbp), %rax
movq -0x50(%rbp), %rdx
movslq -0x18(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x4d55
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x2130
jmp 0x4d65
movl $0x18, %edi
callq 0x2150
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x58(%rbp)
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x9080
jmp 0x4c3e
movq -0x38(%rbp), %rax
movq -0x58(%rbp), %rdx
movslq -0x18(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x4d55
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x2130
jmp 0x4d65
movl $0x18, %edi
callq 0x2150
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x8d50
jmp 0x4c8f
movq -0x38(%rbp), %rax
movq -0x60(%rbp), %rdx
movslq -0x18(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x4d55
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x2130
jmp 0x4d65
movl $0x18, %edi
callq 0x2150
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x68(%rbp)
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x9940
jmp 0x4ce0
movq -0x38(%rbp), %rax
movq -0x68(%rbp), %rdx
movslq -0x18(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x4d55
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x2130
jmp 0x4d65
movl $0x18, %edi
callq 0x2150
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x9b70
jmp 0x4d2b
movq -0x38(%rbp), %rax
movq -0x70(%rbp), %rdx
movslq -0x18(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x4d55
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x2130
jmp 0x4d65
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x2270
nop