// File: /workspace/github_cpp_makefile_star2_O1/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, %r12d
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x40f8
leaq -0x40(%rbp), %r15
movq %rax, (%r15)
movq (%r14), %r13
movq %r15, %rdi
callq 0x2956
cltq
movq (%r13,%rax,8), %r13
movq %r15, %rdi
callq 0x295e
cltq
movq (%r13,%rax,8), %rax
movq %rax, -0x38(%rbp)
movq %rbx, %rdi
movl $0x4, %esi
callq 0x4102
movq %rbx, %rdi
callq 0x40f8
movq %rax, (%r15)
movq %r15, %rdi
callq 0x2956
movl %eax, %r13d
movq %rbx, %rdi
callq 0x40f8
movq %rax, (%r15)
leaq -0x40(%rbp), %rdi
callq 0x295e
decl %r12d
cmpl $0x4, %r12d
ja 0x5439
movl %eax, %r15d
leaq 0x1d2a(%rip), %rax      # 0x7060
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x18, %edi
callq 0x2120
movq %rax, %r12
movq -0x38(%rbp), %rdi
callq 0x37b2
movb %al, -0x29(%rbp)
leaq -0x60(%rbp), %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0x291e
movq -0x60(%rbp), %rdx
movzbl -0x29(%rbp), %esi
movq %r12, %rdi
callq 0x3e60
jmp 0x5428
movl $0x18, %edi
callq 0x2120
movq %rax, %r12
movq -0x38(%rbp), %rdi
callq 0x37b2
movb %al, -0x29(%rbp)
leaq -0x58(%rbp), %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0x291e
movq -0x58(%rbp), %rdx
movzbl -0x29(%rbp), %esi
movq %r12, %rdi
callq 0x362c
jmp 0x5428
movl $0x18, %edi
callq 0x2120
movq %rax, %r12
movq -0x38(%rbp), %rdi
callq 0x37b2
movb %al, -0x29(%rbp)
leaq -0x48(%rbp), %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0x291e
movq -0x48(%rbp), %rdx
movzbl -0x29(%rbp), %esi
movq %r12, %rdi
callq 0x2b3c
jmp 0x5428
movl $0x18, %edi
callq 0x2120
movq %rax, %r12
movq -0x38(%rbp), %rdi
callq 0x37b2
movb %al, -0x29(%rbp)
leaq -0x50(%rbp), %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0x291e
movq -0x50(%rbp), %rdx
movzbl -0x29(%rbp), %esi
movq %r12, %rdi
callq 0x2994
movq (%r14), %rax
movslq %r13d, %rcx
movq (%rax,%rcx,8), %rax
movslq %r15d, %rcx
movq %r12, (%rax,%rcx,8)
movq 0x30(%r14), %r12
movq 0x10(%r12), %r15
decq 0x38(%r14)
movq %r12, %rdi
callq 0x21b0
movq %r12, %rdi
callq 0x2100
testq %r15, %r15
je 0x546b
movq %r15, %rdi
callq 0x40d8
movq %r15, %rdi
callq 0x2100
movl $0x20, %edi
callq 0x2120
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x408c
leaq 0x28(%r14), %r15
movl $0x18, %edi
callq 0x2120
movq %r12, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2050
incq 0x38(%r14)
leaq 0x10(%r14), %r15
movl $0x18, %edi
callq 0x2120
movq -0x38(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2050
incq 0x20(%r14)
movq %rbx, %rdi
callq 0x40d8
movq %rbx, %rdi
callq 0x2100
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x54f0
jmp 0x54f0
jmp 0x54f0
jmp 0x54f0
movq %rax, %rbx
movq %r12, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x21d0
nop