// File: cpirc[P]Monochrome/src/move.cpp
// Function: print_moves(Position const&)
void print_moves(const Position& pos) {
    SearchStack ss[1];
    clear_ss(ss, 1);

    int movecount;
    movecount = generate(pos, ss->ml);
    printf("Move count: %i\n", movecount);
    int i = 0;

    Move move;
    while ((move = next_move(ss, movecount))) {
        Position npos = pos;

        make_move(npos, move);
        if (is_checked(npos, THEM)) {
            continue;
        }

        if (pos.flipped) {
            move = flip_move(move);
        }

        std::string mtypestr = "";
        switch (move_type(move)) {
            case NORMAL:
                mtypestr = "normal";
                break;
            case CAPTURE:
                mtypestr = "capture";
                break;
            case CASTLE:
                mtypestr = "castle";
                break;
            case ENPASSANT:
                mtypestr = "enpassant";
                break;
            case PROMOTION:
                mtypestr = "promotion";
                break;
            case DOUBLE_PUSH:
                mtypestr = "double pawn";
                break;
            case PROM_CAPTURE:
                mtypestr = "promotion capture";
                break;
            default:
                mtypestr = "ERROR";
                break;
        }

        char mstr[6];
        move_to_lan(mstr, move);
        printf(
            "%i)  %s  (3-fold: %i)  (50-moves: %i)  (Check: %i)  (Type: %s)\n",
            i + 1, mstr, is_threefold(npos), is_fifty_moves(npos),
            is_checked(npos, US), mtypestr.c_str());
        i++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x920, %rsp            # imm = 0x920
movq %rdi, -0x8(%rbp)
leaq -0x820(%rbp), %rdi
movl $0x1, %esi
callq 0xb540
movq -0x8(%rbp), %rdi
leaq -0x820(%rbp), %rsi
addq $0x4, %rsi
callq 0x8b20
movl %eax, -0x824(%rbp)
movl -0x824(%rbp), %esi
leaq 0xd68c(%rip), %rdi      # 0x13933
movb $0x0, %al
callq 0x3030
movl $0x0, -0x828(%rbp)
leaq -0x820(%rbp), %rdi
leaq -0x824(%rbp), %rsi
callq 0xb1c0
movl %eax, -0x82c(%rbp)
cmpl $0x0, %eax
je 0x6691
movq -0x8(%rbp), %rsi
leaq -0x898(%rbp), %rdi
movq %rdi, -0x8d8(%rbp)
callq 0x6a30
movq -0x8d8(%rbp), %rdi
movl -0x82c(%rbp), %esi
callq 0x5900
jmp 0x6305
leaq -0x898(%rbp), %rdi
movl $0x1, %esi
callq 0x6b80
movb %al, -0x8d9(%rbp)
jmp 0x631e
movb -0x8d9(%rbp), %al
testb $0x1, %al
jne 0x632a
jmp 0x6350
movl $0x2, -0x8a8(%rbp)
jmp 0x6661
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x8a0(%rbp)
movl %eax, -0x8a4(%rbp)
jmp 0x6683
movq -0x8(%rbp), %rax
testb $0x1, 0x41(%rax)
je 0x6379
movl -0x82c(%rbp), %edi
callq 0x69d0
movl %eax, -0x8e0(%rbp)
jmp 0x636d
movl -0x8e0(%rbp), %eax
movl %eax, -0x82c(%rbp)
leaq -0x8c9(%rbp), %rdi
movq %rdi, -0x8e8(%rbp)
callq 0x3360
movq -0x8e8(%rbp), %rdx
leaq 0xd628(%rip), %rsi      # 0x139c2
leaq -0x8c8(%rbp), %rdi
callq 0x3280
jmp 0x63a8
leaq -0x8c9(%rbp), %rdi
callq 0x3210
movl -0x82c(%rbp), %edi
callq 0x66e0
movl %eax, -0x8ec(%rbp)
jmp 0x63c7
movl -0x8ec(%rbp), %eax
testl %eax, %eax
je 0x6492
jmp 0x63d7
movl -0x8ec(%rbp), %eax
subl $0x1000, %eax           # imm = 0x1000
je 0x64c6
jmp 0x63ea
movl -0x8ec(%rbp), %eax
subl $0x2000, %eax           # imm = 0x2000
je 0x64ac
jmp 0x63fd
movl -0x8ec(%rbp), %eax
subl $0x3000, %eax           # imm = 0x3000
je 0x64dd
jmp 0x6410
movl -0x8ec(%rbp), %eax
subl $0x4000, %eax           # imm = 0x4000
je 0x64f4
jmp 0x6423
movl -0x8ec(%rbp), %eax
subl $0x5000, %eax           # imm = 0x5000
je 0x650b
jmp 0x6436
movl -0x8ec(%rbp), %eax
subl $0x6000, %eax           # imm = 0x6000
je 0x6522
jmp 0x6539
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x8a0(%rbp)
movl %eax, -0x8a4(%rbp)
leaq -0x8c9(%rbp), %rdi
callq 0x3210
jmp 0x6683
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x8a0(%rbp)
movl %eax, -0x8a4(%rbp)
leaq -0x8c8(%rbp), %rdi
callq 0x3120
jmp 0x6683
leaq 0xd4aa(%rip), %rsi      # 0x13943
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x64a7
jmp 0x6550
leaq 0xd4c8(%rip), %rsi      # 0x1397b
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x64c1
jmp 0x6550
leaq 0xd47d(%rip), %rsi      # 0x1394a
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x64db
jmp 0x6550
leaq 0xd46d(%rip), %rsi      # 0x13951
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x64f2
jmp 0x6550
leaq 0xd460(%rip), %rsi      # 0x1395b
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x6509
jmp 0x6550
leaq 0xd453(%rip), %rsi      # 0x13965
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x6520
jmp 0x6550
leaq 0xd448(%rip), %rsi      # 0x13971
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x6537
jmp 0x6550
leaq 0xd37a(%rip), %rsi      # 0x138ba
leaq -0x8c8(%rbp), %rdi
callq 0x3270
jmp 0x654e
jmp 0x6550
movl -0x82c(%rbp), %esi
leaq -0x8cf(%rbp), %rdi
callq 0x5ca0
jmp 0x6564
movl -0x828(%rbp), %eax
incl %eax
movl %eax, -0x8fc(%rbp)
leaq -0x8cf(%rbp), %rax
movq %rax, -0x8f8(%rbp)
leaq -0x898(%rbp), %rdi
xorl %esi, %esi
callq 0xa6f0
movb %al, -0x8ed(%rbp)
jmp 0x6596
movb -0x8ed(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
movl %eax, -0x904(%rbp)
leaq -0x898(%rbp), %rdi
callq 0xa740
movb %al, -0x8fd(%rbp)
jmp 0x65bc
movb -0x8fd(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
movl %eax, -0x90c(%rbp)
leaq -0x898(%rbp), %rdi
xorl %esi, %esi
callq 0x6b80
movb %al, -0x905(%rbp)
jmp 0x65e4
movb -0x905(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
movl %eax, -0x910(%rbp)
leaq -0x8c8(%rbp), %rdi
callq 0x30c0
movl -0x8fc(%rbp), %esi
movq -0x8f8(%rbp), %rdx
movl -0x904(%rbp), %ecx
movl -0x90c(%rbp), %r8d
movl -0x910(%rbp), %r9d
movq %rax, %rdi
movq %rsp, %rax
movq %rdi, (%rax)
leaq 0xd350(%rip), %rdi      # 0x13983
xorl %eax, %eax
callq 0x3030
jmp 0x663c
movl -0x828(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x828(%rbp)
leaq -0x8c8(%rbp), %rdi
callq 0x3120
movl $0x0, -0x8a8(%rbp)
leaq -0x898(%rbp), %rdi
callq 0x6b60
movl -0x8a8(%rbp), %eax
testl %eax, %eax
je 0x667e
jmp 0x6679
jmp 0x62b8
jmp 0x62b8
leaq -0x898(%rbp), %rdi
callq 0x6b60
jmp 0x669a
addq $0x920, %rsp            # imm = 0x920
popq %rbp
retq
movq -0x8a0(%rbp), %rdi
callq 0x3350
nopw %cs:(%rax,%rax)