// File: IncredibleHannes[P]QMUL-ChessGame/src/Model/Board.cpp
// Function: Board::move(Move*)
void Board::move(Move *move) {

  Position origin = move->getOrigin();
  Position target = move->getTarget();
  Chessman *currentChessman = this->board[origin.getX()][origin.getY()];
  this->board[origin.getX()][origin.getY()] = nullptr;

  Chessman *targetChessman = this->board[target.getX()][target.getY()];
  if (targetChessman != nullptr) {
    targetChessman->capture();
    move->setCaptureMove(targetChessman);
    capturedChessmen.push_back(targetChessman);
  }
  this->board[target.getX()][target.getY()] = currentChessman;
  currentChessman->setCurrentPosition(target);
  this->previousMoves.push_back(new Move(*move));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6a10
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6a30
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq (%rax), %rax
movq %rax, -0x88(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x2ee0
movl %eax, %ecx
movq -0x88(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x2ef0
movq -0x80(%rbp), %rcx
movl %eax, %edx
movq -0x68(%rbp), %rax
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x28(%rbp)
movq (%rax), %rax
movq %rax, -0x78(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x2ee0
movl %eax, %ecx
movq -0x78(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x2ef0
movq -0x70(%rbp), %rcx
movl %eax, %edx
movq -0x68(%rbp), %rax
movslq %edx, %rdx
movq $0x0, (%rcx,%rdx,8)
movq (%rax), %rax
movq %rax, -0x60(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2ee0
movl %eax, %ecx
movq -0x60(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2ef0
movl %eax, %ecx
movq -0x58(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x8539
movq -0x30(%rbp), %rdi
callq 0x57b0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6a90
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
leaq -0x30(%rbp), %rsi
callq 0x97e0
movq -0x68(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
leaq -0x20(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x2ee0
movq -0xb8(%rbp), %rdi
movl %eax, %ecx
movq -0xb0(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa0(%rbp)
callq 0x2ef0
movq -0xa8(%rbp), %rdx
movl %eax, %ecx
movq -0xa0(%rbp), %rax
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
callq 0x5930
movq -0x68(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x98(%rbp)
movl $0x20, %edi
callq 0x2160
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rsi
callq 0x6930
jmp 0x85e2
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rsi
callq 0x9400
addq $0xc0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x2140
movq -0x48(%rbp), %rdi
callq 0x2260
nopw (%rax,%rax)