// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8c8, %rsp            # imm = 0x8C8
movq %rdi, %rbx
leaq -0x8e0(%rbp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x61c7
leaq -0x8dc(%rbp), %rsi
movq %rbx, -0x40(%rbp)
movq %rbx, %rdi
callq 0x49ae
leaq -0x30(%rbp), %rbx
movl %eax, (%rbx)
leaq 0x691e(%rip), %rdi      # 0xa803
movl %eax, %esi
xorl %eax, %eax
callq 0x2030
leaq -0x78(%rbp), %r12
movl $0x0, -0x2c(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5fa6
testl %eax, %eax
je 0x400d
movl %eax, %r15d
leaq -0xc8(%rbp), %r13
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x40d2
movq %r13, %rdi
movl %r15d, %esi
callq 0x3988
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0x40fd
testb %al, %al
jne 0x4000
movl %r15d, %r12d
andl $0x3ffff, %r12d         # imm = 0x3FFFF
xorl $0xe38, %r12d           # imm = 0xE38
movq -0x40(%rbp), %rax
cmpb $0x0, 0x41(%rax)
cmovel %r15d, %r12d
leaq -0x60(%rbp), %r15
movq %r15, %rdi
leaq 0x6927(%rip), %rsi      # 0xa892
leaq -0x36(%rbp), %rdx
callq 0x2090
movl %r12d, %eax
shrl $0xa, %eax
andl $0x1c, %eax
leaq 0x67dc(%rip), %rcx      # 0xa760
movslq (%rax,%rcx), %rsi
addq %rcx, %rsi
movq %r15, %rdi
callq 0x22c0
leaq -0x36(%rbp), %rdi
movl %r12d, %esi
callq 0x3baa
movq %r13, %rdi
xorl %esi, %esi
callq 0x5a91
movl %eax, %r15d
movq %r13, %rdi
callq 0x5ab9
movl %eax, %r12d
movq %r13, %rdi
xorl %esi, %esi
callq 0x40fd
movl -0x2c(%rbp), %esi
incl %esi
movzbl %r15b, %ecx
movzbl %r12b, %r8d
movzbl %al, %r9d
movq -0x60(%rbp), %rax
movq %rax, (%rsp)
leaq 0x6872(%rip), %rdi      # 0xa853
movl %esi, -0x2c(%rbp)
leaq -0x36(%rbp), %rdx
xorl %eax, %eax
callq 0x2030
leaq -0x60(%rbp), %rdi
callq 0x20a0
leaq -0x78(%rbp), %r12
leaq -0x30(%rbp), %rbx
movq %r12, %rdi
callq 0x41a8
jmp 0x3ef9
addq $0x8c8, %rsp            # imm = 0x8C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4026
movq %rax, %r14
jmp 0x4032
movq %rax, %r14
leaq -0x60(%rbp), %rdi
callq 0x20a0
leaq -0x78(%rbp), %r12
jmp 0x403b
movq %rax, %r14
movq %r12, %rdi
callq 0x41a8
movq %r14, %rdi
callq 0x2290