// File: /workspace/github_cpp_makefile_star2_O3/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 $0x8d8, %rsp            # imm = 0x8D8
movq %rdi, %rbx
leaq -0x8f0(%rbp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x7c57
leaq -0x8ec(%rbp), %rsi
movq %rbx, -0x38(%rbp)
movq %rbx, %rdi
callq 0x5d4e
leaq -0x3c(%rbp), %r15
movl %eax, (%r15)
leaq 0x78f2(%rip), %rdi      # 0xc843
movl %eax, %esi
xorl %eax, %eax
callq 0x3040
movq %r14, %rdi
movq %r15, %rsi
callq 0x78de
testl %eax, %eax
je 0x529a
movl %eax, %r15d
leaq -0x80(%rbp), %r14
movq -0x38(%rbp), %rax
leaq 0x50(%rax), %r13
leaq -0xd0(%rbp), %r12
leaq -0x8f0(%rbp), %rbx
movl $0x0, -0x2c(%rbp)
movl $0xa, %ecx
movq %r12, %rdi
movq -0x38(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
movq %r13, %rsi
callq 0x5300
movq %r12, %rdi
movl %r15d, %esi
callq 0x47a0
movq -0xa8(%rbp), %rax
movq -0x98(%rbp), %rdx
movq %rdx, %rcx
andq %rax, %rcx
je 0x52ac
bsfq %rcx, %rdi
movq -0xa0(%rbp), %rcx
orq %rcx, %rdx
leal (,%rdi,8), %esi
movq -0xd0(%rbp), %r9
movq -0xc8(%rbp), %r8
leaq 0xc1c6(%rip), %r10      # 0x111c0
andq 0x200(%r10,%rsi), %r9
leaq 0xc5b7(%rip), %r10      # 0x115c0
andq (%r10,%rsi), %r8
leaq 0x748c(%rip), %r10      # 0xc4a0
movq (%r10,%rsi), %r10
andq %rdx, %r10
leaq 0x727e(%rip), %r11      # 0xc2a0
imulq (%r11,%rsi), %r10
orq %r9, %r8
shrq $0x37, %r10
movl %edi, %r9d
shll $0xc, %r9d
addq 0xbf74(%rip), %r9       # 0x10fb0
movq (%r9,%r10,8), %r9
movq -0xc0(%rbp), %r10
andq %r9, %r10
leaq 0x6f4f(%rip), %r11      # 0xbfa0
andq (%r11,%rsi), %rdx
leaq 0x6d44(%rip), %r11      # 0xbda0
imulq (%r11,%rsi), %rdx
orq %r8, %r10
shrq $0x34, %rdx
shll $0xf, %edi
addq 0xbf26(%rip), %rdi      # 0x10f98
movq (%rdi,%rdx,8), %rdx
movq -0xb8(%rbp), %rdi
andq %rdx, %rdi
orq %r10, %rdi
orq %r9, %rdx
leaq 0xc733(%rip), %r8       # 0x117c0
andq (%r8,%rsi), %rax
orq %rdi, %rax
andq -0xb0(%rbp), %rdx
orq %rdx, %rax
testq %rcx, %rax
jne 0x5275
movq %r13, %rbx
movq %r14, %r13
movl %r15d, %r14d
andl $0x3ffff, %r14d         # imm = 0x3FFFF
xorl $0xe38, %r14d           # imm = 0xE38
movq -0x38(%rbp), %rax
cmpb $0x0, 0x41(%rax)
cmovel %r15d, %r14d
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %r15
movq %r15, %rdi
leaq 0x77f2(%rip), %rdx      # 0xc8d2
movq %rdx, %rsi
callq 0x539e
movl %r14d, %eax
shrl $0xc, %eax
andl $0x7, %eax
movq -0x60(%rbp), %rdx
leaq 0x7664(%rip), %rsi      # 0xc760
movslq (%rsi,%rax,4), %rcx
addq %rsi, %rcx
leaq 0x7676(%rip), %rsi      # 0xc780
movq (%rsi,%rax,8), %r8
movq %r15, %rdi
xorl %esi, %esi
callq 0x3270
leaq -0x42(%rbp), %rdi
movl %r14d, %esi
callq 0x4bc6
movq %r12, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x7398
movl %eax, %r14d
movq %r15, %rdi
callq 0x73e8
movq -0xa8(%rbp), %rcx
movq -0xa0(%rbp), %rsi
movq %rsi, %rdx
andq %rcx, %rdx
je 0x52ac
bsfq %rdx, %r8
movq -0x98(%rbp), %rdx
orq %rdx, %rsi
leal (,%r8,8), %edi
movq -0xd0(%rbp), %r9
movq -0xc8(%rbp), %r10
leaq 0xc03f(%rip), %r11      # 0x111c0
andq (%r11,%rdi), %r9
leaq 0xc434(%rip), %r11      # 0x115c0
andq (%r11,%rdi), %r10
orq %r9, %r10
leaq 0x7306(%rip), %r9       # 0xc4a0
movq (%r9,%rdi), %r9
andq %rsi, %r9
leaq 0x70f8(%rip), %r11      # 0xc2a0
imulq (%r11,%rdi), %r9
shrq $0x37, %r9
movl %r8d, %r11d
shll $0xc, %r11d
addq 0xbdf1(%rip), %r11      # 0x10fb0
movq (%r11,%r9,8), %r9
movq -0xc0(%rbp), %r11
andq %r9, %r11
leaq 0x6dcc(%rip), %r15      # 0xbfa0
andq (%r15,%rdi), %rsi
orq %r10, %r11
leaq 0x6bbe(%rip), %r10      # 0xbda0
imulq (%r10,%rdi), %rsi
shrq $0x34, %rsi
shll $0xf, %r8d
addq 0xbda2(%rip), %r8       # 0x10f98
movq (%r8,%rsi,8), %r15
movq -0xb8(%rbp), %r8
andq %r15, %r8
orq %r11, %r8
leaq 0xc5b2(%rip), %r10      # 0x117c0
andq (%r10,%rdi), %rcx
orq %r9, %r15
orq %r8, %rcx
andq -0xb0(%rbp), %r15
movl -0x2c(%rbp), %esi
incl %esi
orq %r15, %rcx
xorl %r9d, %r9d
testq %rdx, %rcx
movzbl %r14b, %ecx
setne %r9b
movzbl %al, %r8d
movq -0x68(%rbp), %rax
movq %rax, (%rsp)
leaq 0x764b(%rip), %rdi      # 0xc893
movl %esi, -0x2c(%rbp)
leaq -0x42(%rbp), %rdx
xorl %eax, %eax
callq 0x3040
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x5268
callq 0x31a0
movq %r13, %r14
movq %rbx, %r13
leaq -0x8f0(%rbp), %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x5283
callq 0x31a0
movq %rbx, %rdi
leaq -0x3c(%rbp), %rsi
callq 0x78de
movl %eax, %r15d
testl %eax, %eax
jne 0x4f91
addq $0x8d8, %rsp            # imm = 0x8D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x699d(%rip), %rdi      # 0xbc50
leaq 0x6999(%rip), %rsi      # 0xbc53
leaq 0x69a1(%rip), %rcx      # 0xbc62
movl $0x3e, %edx
callq 0x3100
jmp 0x52cf
jmp 0x52e6
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x52e9
callq 0x31a0
jmp 0x52e9
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x52f7
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
nop