// File: jswaff[P]prophet3/src/bitboards.cpp
// Function: init_knight_moves()
void init_knight_moves() {

    for (int i=0;i<64;i++) {
        square_t sq = (square_t)i;
        bb_knight_moves[sq] = 0;
        rank_t r = get_rank(sq);
        file_t f = get_file(sq);
        if (f > FILE_A) {
            if (r > RANK_7) {
                bb_knight_moves[sq] |= bb_squares[north(northwest(sq))];
            }
            if (r < RANK_2) {
                bb_knight_moves[sq] |= bb_squares[south(southwest(sq))];
            }
        }
        if (f > FILE_B) {
            if (r > RANK_8) {
                bb_knight_moves[sq] |= bb_squares[northwest(west(sq))];
            }
            if (r < RANK_1) {
                bb_knight_moves[sq] |= bb_squares[southwest(west(sq))];
            }
        }
        if (f < FILE_G) {
            if (r > RANK_8) {
                bb_knight_moves[sq] |= bb_squares[northeast(east(sq))];
            }
            if (r < RANK_1) {
                bb_knight_moves[sq] |= bb_squares[southeast(east(sq))];
            }
        }
        if (f < FILE_H) {
            if (r > RANK_7) {
                bb_knight_moves[sq] |= bb_squares[north(northeast(sq))];
            }
            if (r < RANK_2) {
                bb_knight_moves[sq] |= bb_squares[south(southeast(sq))];
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x40, -0x4(%rbp)
jge 0x4e01
movl -0x4(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100cc5(%rip), %rax    # 0x105870
movq $0x0, (%rax,%rcx,8)
movl -0x8(%rbp), %edi
callq 0x120d0
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %edi
callq 0x12070
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jle 0x4c53
cmpl $0x1, -0xc(%rbp)
jle 0x4c12
movl -0x8(%rbp), %edi
callq 0x127c0
movl %eax, %edi
callq 0x12410
movl %eax, %eax
movl %eax, %ecx
leaq 0x100a7d(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100c6d(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100c62(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
cmpl $0x6, -0xc(%rbp)
jge 0x4c51
movl -0x8(%rbp), %edi
callq 0x12730
movl %eax, %edi
callq 0x12490
movl %eax, %eax
movl %eax, %ecx
leaq 0x100a3e(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100c2e(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100c23(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
jmp 0x4c53
cmpl $0x1, -0x10(%rbp)
jle 0x4cdd
cmpl $0x0, -0xc(%rbp)
jle 0x4c9c
movl -0x8(%rbp), %edi
callq 0x12590
movl %eax, %edi
callq 0x127c0
movl %eax, %eax
movl %eax, %ecx
leaq 0x1009f3(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100be3(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100bd8(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
cmpl $0x7, -0xc(%rbp)
jge 0x4cdb
movl -0x8(%rbp), %edi
callq 0x12590
movl %eax, %edi
callq 0x12730
movl %eax, %eax
movl %eax, %ecx
leaq 0x1009b4(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100ba4(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100b99(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
jmp 0x4cdd
cmpl $0x6, -0x10(%rbp)
jge 0x4d67
cmpl $0x0, -0xc(%rbp)
jle 0x4d26
movl -0x8(%rbp), %edi
callq 0x12510
movl %eax, %edi
callq 0x12610
movl %eax, %eax
movl %eax, %ecx
leaq 0x100969(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100b59(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100b4e(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
cmpl $0x7, -0xc(%rbp)
jge 0x4d65
movl -0x8(%rbp), %edi
callq 0x12510
movl %eax, %edi
callq 0x126a0
movl %eax, %eax
movl %eax, %ecx
leaq 0x10092a(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100b1a(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100b0f(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
jmp 0x4d67
cmpl $0x7, -0x10(%rbp)
jge 0x4df1
cmpl $0x1, -0xc(%rbp)
jle 0x4db0
movl -0x8(%rbp), %edi
callq 0x12610
movl %eax, %edi
callq 0x12410
movl %eax, %eax
movl %eax, %ecx
leaq 0x1008df(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100acf(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100ac4(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
cmpl $0x6, -0xc(%rbp)
jge 0x4def
movl -0x8(%rbp), %edi
callq 0x126a0
movl %eax, %edi
callq 0x12490
movl %eax, %eax
movl %eax, %ecx
leaq 0x1008a0(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100a90(%rip), %rax    # 0x105870
orq (%rax,%rcx,8), %rdx
leaq 0x100a85(%rip), %rax    # 0x105870
movq %rdx, (%rax,%rcx,8)
jmp 0x4df1
jmp 0x4df3
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x4b8f
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)