// File: jswaff[P]prophet3/src/bitboards.cpp
// Function: init_king_moves()
void init_king_moves() {
    for (int i=0;i<64;i++) {
        square_t sq = (square_t)i;
        bb_king_moves[sq] = 0;
        rank_t r = get_rank(sq);
        file_t f = get_file(sq);
        if (r > RANK_8) {
            if (f > FILE_A) {
                bb_king_moves[sq] |= bb_squares[northwest(sq)];
            }
            bb_king_moves[sq] |= bb_squares[north(sq)];
            if (f < FILE_H) {
                bb_king_moves[sq] |= bb_squares[northeast(sq)];
            }
        }
        if (f < FILE_H) {
            bb_king_moves[sq] |= bb_squares[east(sq)];
        }
        if (r < RANK_1) {
            if (f < FILE_H) {
                bb_king_moves[sq] |= bb_squares[southeast(sq)];
            }
            bb_king_moves[sq] |= bb_squares[south(sq)];
            if (f > FILE_A) {
                bb_king_moves[sq] |= bb_squares[southwest(sq)];
            }
        }
        if (f > FILE_A) {
            bb_king_moves[sq] |= bb_squares[west(sq)];
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x40, -0x4(%rbp)
jge 0x5035
movl -0x4(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100c35(%rip), %rax    # 0x105a70
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, -0xc(%rbp)
jle 0x4f07
cmpl $0x0, -0x10(%rbp)
jle 0x4e9b
movl -0x8(%rbp), %edi
callq 0x127c0
movl %eax, %eax
movl %eax, %ecx
leaq 0x1007f4(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100be4(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100bd9(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
movl -0x8(%rbp), %edi
callq 0x12410
movl %eax, %eax
movl %eax, %ecx
leaq 0x1007c2(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100bb2(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100ba7(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
cmpl $0x7, -0x10(%rbp)
jge 0x4f05
movl -0x8(%rbp), %edi
callq 0x12610
movl %eax, %eax
movl %eax, %ecx
leaq 0x10078a(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100b7a(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100b6f(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
jmp 0x4f07
cmpl $0x7, -0x10(%rbp)
jge 0x4f3f
movl -0x8(%rbp), %edi
callq 0x12510
movl %eax, %eax
movl %eax, %ecx
leaq 0x100750(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100b40(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100b35(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
cmpl $0x7, -0xc(%rbp)
jge 0x4fed
cmpl $0x7, -0x10(%rbp)
jge 0x4f81
movl -0x8(%rbp), %edi
callq 0x126a0
movl %eax, %eax
movl %eax, %ecx
leaq 0x10070e(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100afe(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100af3(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
movl -0x8(%rbp), %edi
callq 0x12490
movl %eax, %eax
movl %eax, %ecx
leaq 0x1006dc(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100acc(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100ac1(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
cmpl $0x0, -0x10(%rbp)
jle 0x4feb
movl -0x8(%rbp), %edi
callq 0x12730
movl %eax, %eax
movl %eax, %ecx
leaq 0x1006a4(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100a94(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100a89(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
jmp 0x4fed
cmpl $0x0, -0x10(%rbp)
jle 0x5025
movl -0x8(%rbp), %edi
callq 0x12590
movl %eax, %eax
movl %eax, %ecx
leaq 0x10066a(%rip), %rax    # 0x105670
movq (%rax,%rcx,8), %rdx
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x100a5a(%rip), %rax    # 0x105a70
orq (%rax,%rcx,8), %rdx
leaq 0x100a4f(%rip), %rax    # 0x105a70
movq %rdx, (%rax,%rcx,8)
jmp 0x5027
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x4e1f
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)