// File: /workspace/github_cpp_makefile_star2_O2/IncredibleHannes[P]QMUL-ChessGame/src/Model/Board.cpp
// Function: Board::applyPromotion(Move*, Chessman::FigureType)
void Board::applyPromotion(Move *move, Chessman::FigureType type) {
    Chessman *currentChessman = getChessman(move->getTarget());
    move->addType(Move::Promotion);
    int x = move->getTarget().getX();
    int y = move->getTarget().getY();
    switch(type) {
      case Chessman::Queen :
        board[x][y] = new Queen(currentChessman->getColour(), Position(x,y));
        break;
      case Chessman::Rook :
        board[x][y] = new Rook(currentChessman->getColour(), Position(x,y));
        break;
      case Chessman::Bishop :
        board[x][y] = new Bishop(currentChessman->getColour(), Position(x,y));
        break;
      case Chessman::Knight :
        board[x][y] = new Knight(currentChessman->getColour(), Position(x,y));
        break;
      default:
        break;
    }
    Move *m = previousMoves.back();
    previousMoves.pop_back();
    delete m;
    previousMoves.push_back(new Move(*move));
    capturedChessmen.push_back(currentChessman);
    delete move;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x4092
movq %r14, %rdi
movq %rax, %rsi
callq 0x4a86
movq %rax, %r15
movq %rax, -0x60(%rbp)
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x409c
movq %rbx, %rdi
callq 0x4092
leaq -0x38(%rbp), %r12
movq %rax, (%r12)
movq %r12, %rdi
callq 0x28a6
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
callq 0x4092
movq %rax, (%r12)
leaq -0x38(%rbp), %rdi
callq 0x28ae
decl %r13d
cmpl $0x4, %r13d
ja 0x51c0
movl %eax, %r12d
leaq 0x1f98(%rip), %rax      # 0x7060
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
jmpq *%rcx
pushq $0x18
popq %rdi
callq 0x2110
movq %rax, %r13
movq %r15, %rdi
callq 0x379a
movl %eax, %r15d
leaq -0x58(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl %r12d, %edx
callq 0x286e
movq -0x58(%rbp), %rdx
movzbl %r15b, %esi
movq %r13, %rdi
callq 0x3e14
jmp 0x51ae
pushq $0x18
popq %rdi
callq 0x2110
movq %rax, %r13
movq %r15, %rdi
callq 0x379a
movl %eax, %r15d
leaq -0x50(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl %r12d, %edx
callq 0x286e
movq -0x50(%rbp), %rdx
movzbl %r15b, %esi
movq %r13, %rdi
callq 0x3624
jmp 0x51ae
pushq $0x18
popq %rdi
callq 0x2110
movq %rax, %r13
movq %r15, %rdi
callq 0x379a
movl %eax, %r15d
leaq -0x40(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl %r12d, %edx
callq 0x286e
movq -0x40(%rbp), %rdx
movzbl %r15b, %esi
movq %r13, %rdi
callq 0x2a7c
jmp 0x51ae
pushq $0x18
popq %rdi
callq 0x2110
movq %rax, %r13
movq %r15, %rdi
callq 0x379a
movl %eax, %r15d
leaq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl %r12d, %edx
callq 0x286e
movq -0x48(%rbp), %rdx
movzbl %r15b, %esi
movq %r13, %rdi
callq 0x28e4
movq (%r14), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq %r12d, %rcx
movq %r13, (%rax,%rcx,8)
leaq 0x28(%r14), %r15
movq 0x30(%r14), %rax
movq 0x10(%rax), %r12
movq %r15, %rdi
callq 0x551e
testq %r12, %r12
je 0x51e1
movq %r12, %rdi
callq 0x4072
movq %r12, %rdi
callq 0x20f0
pushq $0x20
popq %rdi
callq 0x2110
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4028
leaq -0x38(%rbp), %rsi
movq %r12, (%rsi)
movq %r15, %rdi
callq 0x5492
addq $0x10, %r14
leaq -0x60(%rbp), %rsi
movq %r14, %rdi
callq 0x550e
movq %rbx, %rdi
callq 0x4072
movq %rbx, %rdi
callq 0x20f0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5243
jmp 0x5243
jmp 0x5243
movq %rax, %rbx
movq %r13, %rdi
jmp 0x5251
movq %rax, %rbx
movq %r12, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x21d0