// File: IncredibleHannes[P]QMUL-ChessGame/src/Model/Chessman/Knight.cpp
// Function: Knight::getPossibleMoves[abi:cxx11](Board const&) const
std::list<Move> Knight::getPossibleMoves(const Board &board) const {
  std::list<Move> moves;
  if (!isCaptured()) {
    int x = this->getCurrentPosition().getX();
    int y = this->getCurrentPosition().getY();
    std::list<Position> positions = {
      Position(x + 2, y - 1), Position(x + 1, y - 2), Position(x + 2, y + 1),
      Position(x + 1, y + 2), Position(x - 2, y - 1), Position(x - 1, y - 2),
      Position(x - 2, y + 1),  Position(x - 1, y + 2)
    };

    for (Position p : positions) {
      if (p.isValid())
      { moves.push_back(Move(Position(x, y), p)); }
    }
  }
  return moves;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x128(%rbp)
movq %rdi, %rax
movq %rax, -0x120(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x3220
movq -0x118(%rbp), %rdi
callq 0x57d0
movb %al, -0x109(%rbp)
jmp 0x3790
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x3a85
jmp 0x37a0
movq -0x118(%rbp), %rdi
callq 0x5910
movq %rax, -0x130(%rbp)
jmp 0x37b5
movq -0x130(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2ee0
movl %eax, -0x134(%rbp)
jmp 0x37d1
movq -0x118(%rbp), %rdi
movl -0x134(%rbp), %eax
movl %eax, -0x30(%rbp)
callq 0x5910
movq %rax, -0x140(%rbp)
jmp 0x37ef
movq -0x140(%rbp), %rax
movq %rax, -0x44(%rbp)
leaq -0x44(%rbp), %rdi
callq 0x2ef0
movl %eax, -0x144(%rbp)
jmp 0x380b
movl -0x144(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x30(%rbp), %esi
addl $0x2, %esi
movl -0x3c(%rbp), %edx
decl %edx
leaq -0xb0(%rbp), %rdi
callq 0x2e50
jmp 0x382d
leaq -0xa8(%rbp), %rdi
movl -0x30(%rbp), %esi
incl %esi
movl -0x3c(%rbp), %edx
addl $-0x2, %edx
callq 0x2e50
jmp 0x3846
leaq -0xa0(%rbp), %rdi
movl -0x30(%rbp), %esi
addl $0x2, %esi
movl -0x3c(%rbp), %edx
incl %edx
callq 0x2e50
jmp 0x385f
leaq -0x98(%rbp), %rdi
movl -0x30(%rbp), %esi
incl %esi
movl -0x3c(%rbp), %edx
addl $0x2, %edx
callq 0x2e50
jmp 0x3878
leaq -0x90(%rbp), %rdi
movl -0x30(%rbp), %esi
addl $-0x2, %esi
movl -0x3c(%rbp), %edx
decl %edx
callq 0x2e50
jmp 0x3891
leaq -0x88(%rbp), %rdi
movl -0x30(%rbp), %esi
decl %esi
movl -0x3c(%rbp), %edx
addl $-0x2, %edx
callq 0x2e50
jmp 0x38aa
leaq -0x80(%rbp), %rdi
movl -0x30(%rbp), %esi
addl $-0x2, %esi
movl -0x3c(%rbp), %edx
incl %edx
callq 0x2e50
jmp 0x38c0
leaq -0x78(%rbp), %rdi
movl -0x30(%rbp), %esi
decl %esi
movl -0x3c(%rbp), %edx
addl $0x2, %edx
callq 0x2e50
jmp 0x38d6
leaq -0xb0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x8, -0x68(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3b00
movq -0x150(%rbp), %rcx
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x3b20
jmp 0x3916
leaq -0xb1(%rbp), %rdi
callq 0x3bd0
leaq -0x60(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x3bf0
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x3c20
movq %rax, -0xd0(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3c50
testb $0x1, %al
jne 0x396f
jmp 0x3a6f
leaq -0xc8(%rbp), %rdi
callq 0x3c80
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x2f10
movb %al, -0x151(%rbp)
jmp 0x3999
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x39a8
jmp 0x3a5c
movl -0x30(%rbp), %esi
movl -0x3c(%rbp), %edx
leaq -0x100(%rbp), %rdi
callq 0x2e50
jmp 0x39bc
movq -0xd8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rsi
movq -0x108(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
callq 0x68b0
jmp 0x39e6
movq -0x128(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3ca0
jmp 0x39fb
leaq -0xf8(%rbp), %rdi
callq 0x69d0
jmp 0x3a5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x3aab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xb1(%rbp), %rdi
callq 0x3bd0
jmp 0x3aab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x3a7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x69d0
jmp 0x3a7a
jmp 0x3a5e
leaq -0xc8(%rbp), %rdi
callq 0x3ce0
jmp 0x3953
leaq -0x60(%rbp), %rdi
callq 0x3d00
jmp 0x3a85
leaq -0x60(%rbp), %rdi
callq 0x3d00
jmp 0x3aab
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x3a9b
movq -0x128(%rbp), %rdi
callq 0x3240
movq -0x120(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x128(%rbp), %rdi
callq 0x3240
movq -0x28(%rbp), %rdi
callq 0x2260