LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/move.cpp
// Function: move_to_lan(char*, unsigned int)
void move_to_lan(char* lan_str, const Move move) {
    assert(lan_str);

    Square from = from_square(move), to = to_square(move);

    lan_str[0] = square_str[(std::size_t)from][0];
    lan_str[1] = square_str[(std::size_t)from][1];

    lan_str[2] = square_str[(std::size_t)to][0];
    lan_str[3] = square_str[(std::size_t)to][1];

    if (promotion_type(move)) {
        switch (promotion_type(move)) {
            case KNIGHT:
                lan_str[4] = 'n';
                break;
            case BISHOP:
                lan_str[4] = 'b';
                break;
            case ROOK:
                lan_str[4] = 'r';
                break;
            case QUEEN:
                lan_str[4] = 'q';
                break;
            default:
                break;
        }
        lan_str[5] = '\0';
    } else
        lan_str[4] = '\0';
}

// Assembly:
testq %rdi, %rdi
je 0x4f60
movl %esi, %eax
andl $0x3f, %eax
leaq 0xbc49(%rip), %rcx      # 0x10b40
movq (%rcx,%rax,8), %rax
movb (%rax), %dl
movb %dl, (%rdi)
movb 0x1(%rax), %al
movb %al, 0x1(%rdi)
movl %esi, %eax
shrl $0x3, %eax
andl $0x1f8, %eax            # imm = 0x1F8
movq (%rax,%rcx), %rax
movb (%rax), %cl
movb %cl, 0x2(%rdi)
movb 0x1(%rax), %al
movb %al, 0x3(%rdi)
shrl $0xf, %esi
movl %esi, %ecx
andb $0x7, %cl
movl $0x5, %eax
cmpb $0x4, %cl
ja 0x4f5b
andl $0x7, %esi
leaq 0x78c6(%rip), %rcx      # 0xc800
movslq (%rcx,%rsi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl $0x4, %eax
jmp 0x4f5b
movb $0x71, %cl
jmp 0x4f58
movb $0x62, %cl
jmp 0x4f58
movb $0x72, %cl
jmp 0x4f58
movb $0x6e, %cl
movb %cl, 0x4(%rdi)
movb $0x0, (%rdi,%rax)
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x7925(%rip), %rdi      # 0xc890
leaq 0x7926(%rip), %rsi      # 0xc898
leaq 0x792c(%rip), %rcx      # 0xc8a5
movl $0x7a, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/move.cpp
// Function: run_move_to_lan_tests()
void run_move_to_lan_tests(void) {
    char str[6];

    move_to_lan(str, get_move(H2, H1, PROMOTION, TO_ROOK));
    printf("%s\n", str);
    move_to_lan(str, get_move(A5, C7, NORMAL));
    printf("%s\n", str);
    move_to_lan(str, get_move(G7, G8, PROMOTION, TO_BISHOP));
    printf("%s\n", str);
    move_to_lan(str, get_move(E7, E8, PROMOTION, TO_QUEEN));
    printf("%s\n", str);
    move_to_lan(str, get_move(F2, F1, PROMOTION, TO_KNIGHT));
    printf("%s\n", str);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq -0xe(%rbp), %rbx
movl $0x31683268, (%rbx)     # imm = 0x31683268
movw $0x72, 0x4(%rbx)
movq %rbx, %rdi
callq 0x3260
movl $0x37633561, (%rbx)     # imm = 0x37633561
movb $0x0, 0x4(%rbx)
movq %rbx, %rdi
callq 0x3260
movl $0x38673767, (%rbx)     # imm = 0x38673767
movw $0x62, 0x4(%rbx)
movq %rbx, %rdi
callq 0x3260
movl $0x38653765, (%rbx)     # imm = 0x38653765
movw $0x71, 0x4(%rbx)
movq %rbx, %rdi
callq 0x3260
movl $0x31663266, (%rbx)     # imm = 0x31663266
movw $0x6e, 0x4(%rbx)
movq %rbx, %rdi
callq 0x3260
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/move.cpp
// Function: pv_verify(Position const&, std::vector<unsigned int, std::allocator<unsigned int>>&)
bool pv_verify(const Position& pos, PV& pv) {
    Position npos = pos;
    Move moves[256];

    for (const auto& pv_move : pv) {
        bool found = false;

        int movecount = generate(npos, moves);
        for (int i = 0; i < movecount; i++) {
            if (pv_move == moves[i]) {
                make_move(npos, pv_move);
                found = true;
                break;
            }
        }

        if (!found) {
            return false;
        }
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %rsi, %rbx
movq %rdi, %rax
leaq -0x90(%rbp), %rdi
movl $0xa, %ecx
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x40(%rbp), %rdi
addq $0x50, %rax
movq %rax, %rsi
callq 0x5692
movq (%rbx), %r12
movq 0x8(%rbx), %r13
cmpq %r13, %r12
sete %bl
je 0x51ed
leaq -0x90(%rbp), %r14
leaq -0x490(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x608e
testl %eax, %eax
jle 0x51ed
movl (%r12), %esi
movl %eax, %eax
xorl %ecx, %ecx
cmpl -0x490(%rbp,%rcx,4), %esi
je 0x51d9
incq %rcx
cmpq %rcx, %rax
jne 0x51c6
jmp 0x51ed
movq %r14, %rdi
callq 0x4ac0
addq $0x4, %r12
cmpq %r13, %r12
sete %bl
jne 0x51af
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x51fb
callq 0x31a0
andb $0x1, %bl
movl %ebx, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5214
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x5225
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/move_gen.cpp
// Function: void add_moves<false, (Piece)0>(Position const&, unsigned int*, int&)
void add_moves<false, PAWN>(const Position& pos, Move* ml, int& idx) {
    std::uint64_t pawns = get_piece(pos, PAWN, US);
    std::uint64_t empty = ~get_occupancy(pos);
    std::uint64_t singles, doubles;

    // Single push
    singles = (pawns << 8) & empty;

    // Separate promotions
    singles &= ~rank_mask[RANK_8];

    while (singles) {
        Square dest = lsb(singles);

        ml[idx] = get_move(dest - 8, dest, NORMAL);
        idx++;

        singles &= singles - 1;
    }

    // Double push
    singles = ((pawns & rank_mask[RANK_2]) << 8) & empty;
    doubles = (singles << 8) & empty;

    while (doubles) {
        Square dest = lsb(doubles);

        ml[idx] = get_move(dest - 16, dest, DOUBLE_PUSH);
        idx++;

        doubles &= doubles - 1;
    }

    // Promotions
    singles = ((pawns & rank_mask[RANK_7]) << 8) & empty;

    while (singles) {
        Square dest = lsb(singles);

        ml[idx] = get_move(dest - 8, dest, PROMOTION, TO_KNIGHT);
        idx++;

        ml[idx] = get_move(dest - 8, dest, PROMOTION, TO_BISHOP);
        idx++;

        ml[idx] = get_move(dest - 8, dest, PROMOTION, TO_ROOK);
        idx++;

        ml[idx] = get_move(dest - 8, dest, PROMOTION, TO_QUEEN);
        idx++;

        singles &= singles - 1;
    }

    add_moves<false, KNIGHT>(pos, ml, idx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x30(%rdi), %r8
movq (%rdi), %rcx
andq %r8, %rcx
orq 0x38(%rdi), %r8
notq %r8
shlq $0x8, %rcx
movq %rcx, %rax
andq %r8, %rax
movabsq $0xffffffffffff00, %r9  # imm = 0xFFFFFFFFFFFF00
andq %rax, %r9
je 0x593e
bsfq %r9, %r10
leal 0xf8(%r10), %r11d
movzbl %r11b, %r11d
shll $0x6, %r10d
orl %r11d, %r10d
movslq (%rdx), %r11
movl %r10d, (%rsi,%r11,4)
incl (%rdx)
leaq -0x1(%r9), %r10
andq %r10, %r9
jne 0x5916
andl %r8d, %ecx
shll $0x8, %ecx
andl %r8d, %ecx
andl $0xff000000, %ecx       # imm = 0xFF000000
je 0x597e
bsfq %rcx, %r8
leal 0xf0(%r8), %r9d
movzbl %r9b, %r9d
shll $0x6, %r8d
orl %r9d, %r8d
orl $0x5000, %r8d           # imm = 0x5000
movslq (%rdx), %r9
movl %r8d, (%rsi,%r9,4)
incl (%rdx)
leaq -0x1(%rcx), %r8
andq %r8, %rcx
jne 0x594f
movabsq $-0x100000000000000, %rcx # imm = 0xFF00000000000000
andq %rcx, %rax
je 0x59f9
bsfq %rax, %rcx
leal 0xf8(%rcx), %r8d
movzbl %r8b, %r8d
shll $0x6, %ecx
orl %r8d, %ecx
leal 0xc000(%rcx), %r8d
movslq (%rdx), %r9
movl %r8d, (%rsi,%r9,4)
movslq (%rdx), %r8
leaq 0x1(%r8), %r9
movl %r9d, (%rdx)
leal 0x14000(%rcx), %r9d
movl %r9d, 0x4(%rsi,%r8,4)
movslq (%rdx), %r8
leaq 0x1(%r8), %r9
movl %r9d, (%rdx)
leal 0x1c000(%rcx), %r9d
movl %r9d, 0x4(%rsi,%r8,4)
movslq (%rdx), %r8
leaq 0x1(%r8), %r9
movl %r9d, (%rdx)
orl $0x24000, %ecx          # imm = 0x24000
movl %ecx, 0x4(%rsi,%r8,4)
incl (%rdx)
leaq -0x1(%rax), %rcx
jmp 0x5988
popq %rbp
jmp 0x60ee
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/move_gen.cpp
// Function: generate(Position const&, unsigned int*)
int generate(const Position& pos, Move* ml) {
    int idx = 0;

    add_moves<true>(pos, ml, idx);
    add_moves<false>(pos, ml, idx);

    return idx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x1c(%rbp), %r15
movl $0x0, (%r15)
movq %r15, %rdx
callq 0x59ff
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x58e8
movl (%r15), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/move_gen.cpp
// Function: void add_moves<false, (Piece)4>(Position const&, unsigned int*, int&)
void add_moves(const Position& pos, Move* ml, int& idx) {
    std::uint64_t pieces = get_piece(pos, pc, US);
    std::uint64_t occ = get_occupancy(pos);
    std::uint64_t capturemask = (captures) ? get_colour(pos, THEM) : ~occ;
    MoveType mt = captures ? CAPTURE : NORMAL;

    while (pieces) {
        Square from = lsb(pieces);

        std::uint64_t attack_bb = attacks<pc>(from, occ) & capturemask;

        while (attack_bb) {
            Square dest = lsb(attack_bb);

            ml[idx] = get_move(from, dest, mt);
            idx++;

            attack_bb &= attack_bb - 1;
        }

        pieces &= pieces - 1;
    }

    add_moves<captures, pc + 1>(pos, ml, idx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x30(%rdi), %rax
movq %rdi, -0x30(%rbp)
movq 0x20(%rdi), %rcx
andq %rax, %rcx
je 0x63b0
movq -0x30(%rbp), %rdi
orq 0x38(%rdi), %rax
movq %rax, %r8
notq %r8
leaq 0x5f84(%rip), %r10      # 0xc2a0
leaq 0xca2d(%rip), %r11      # 0x12d50
leaq 0x5c76(%rip), %rbx      # 0xbfa0
leaq 0x5a6f(%rip), %r14      # 0xbda0
leaq 0x4ca18(%rip), %r15     # 0x52d50
bsfq %rcx, %r12
leal (,%r12,8), %r9d
leaq 0x6155(%rip), %rdi      # 0xc4a0
movq (%rdi,%r9), %r13
andq %rax, %r13
imulq (%r10,%r9), %r13
movq (%rbx,%r9), %rdi
andq %rax, %rdi
imulq (%r14,%r9), %rdi
shrq $0x37, %r13
shrq $0x34, %rdi
movl %r12d, %r9d
shll $0xf, %r9d
addq %r15, %r9
movq (%r9,%rdi,8), %r9
movl %r12d, %edi
shll $0xc, %edi
addq %r11, %rdi
orq (%rdi,%r13,8), %r9
andq %r8, %r9
je 0x63a7
bsfq %r9, %rdi
shll $0x6, %edi
orl %r12d, %edi
movslq (%rdx), %r13
movl %edi, (%rsi,%r13,4)
incl (%rdx)
leaq -0x1(%r9), %rdi
andq %rdi, %r9
jne 0x638b
leaq -0x1(%rcx), %rdi
andq %rdi, %rcx
jne 0x6338
movq -0x30(%rbp), %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5be4
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/perft.cpp
// Function: perft(Position const&, int)
std::uint64_t perft(const Position& pos, const int depth) {
    if (depth == 0) {
        return 1;
    }

    uint64_t nodes = 0;
    Move moves[256];
    int movecount = generate(pos, moves);

    for (int i = 0; i < movecount; i++) {
        Position npos = pos;

        make_move(npos, moves[i]);
        if (is_checked(npos, THEM)) continue;

        nodes += perft(npos, depth - 1);
    }

    return nodes;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movl %esi, -0x2c(%rbp)
testl %esi, %esi
je 0x6770
movq %rdi, %r14
leaq -0x4a0(%rbp), %rsi
callq 0x608e
testl %eax, %eax
jle 0x6777
leaq 0x50(%r14), %r12
decl -0x2c(%rbp)
movl %eax, %ebx
xorl %r13d, %r13d
leaq -0xa0(%rbp), %r15
movq $0x0, -0x38(%rbp)
movl $0xa, %ecx
movq %r15, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x5692
movl -0x4a0(%rbp,%r13,4), %esi
movq %r15, %rdi
callq 0x4ac0
movq -0x78(%rbp), %rax
movq -0x68(%rbp), %rcx
andq %rax, %rcx
je 0x6795
bsfq %rcx, %rsi
movq -0x70(%rbp), %rcx
movq -0x68(%rbp), %rdi
orq %rcx, %rdi
leal (,%rsi,8), %edx
movq -0xa0(%rbp), %r9
movq -0x98(%rbp), %r8
leaq 0xab21(%rip), %r10      # 0x111c0
andq 0x200(%r10,%rdx), %r9
leaq 0xaf12(%rip), %r10      # 0x115c0
andq (%r10,%rdx), %r8
leaq 0x5de7(%rip), %r10      # 0xc4a0
movq (%r10,%rdx), %r10
andq %rdi, %r10
leaq 0x5bd9(%rip), %r11      # 0xc2a0
imulq (%r11,%rdx), %r10
orq %r9, %r8
shrq $0x37, %r10
movl %esi, %r9d
shll $0xc, %r9d
addq 0xa8cf(%rip), %r9       # 0x10fb0
movq (%r9,%r10,8), %r9
movq -0x90(%rbp), %r10
andq %r9, %r10
leaq 0x58aa(%rip), %r11      # 0xbfa0
andq (%r11,%rdx), %rdi
leaq 0x569f(%rip), %r11      # 0xbda0
imulq (%r11,%rdx), %rdi
orq %r8, %r10
shrq $0x34, %rdi
shll $0xf, %esi
addq 0xa881(%rip), %rsi      # 0x10f98
movq (%rsi,%rdi,8), %rsi
movq -0x88(%rbp), %rdi
andq %rsi, %rdi
orq %r10, %rdi
orq %r9, %rsi
leaq 0xb08e(%rip), %r8       # 0x117c0
andq (%r8,%rdx), %rax
orq %rdi, %rax
andq -0x80(%rbp), %rsi
orq %rsi, %rax
testq %rcx, %rax
jne 0x6754
movq %r15, %rdi
movl -0x2c(%rbp), %esi
callq 0x65e8
addq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x6762
callq 0x31a0
incq %r13
cmpq %r13, %rbx
jne 0x6639
jmp 0x677f
movl $0x1, %eax
jmp 0x6783
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x54b4(%rip), %rdi      # 0xbc50
leaq 0x54b0(%rip), %rsi      # 0xbc53
leaq 0x54b8(%rip), %rcx      # 0xbc62
movl $0x3e, %edx
callq 0x3100
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x67c5
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/perft.cpp
// Function: run_perft_tests()
void run_perft_tests() {
    Position pos;
    parse_fen_to_position((const char*)"r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1", pos);
    for (int i = 1; i <= 6; i++) {
        std::printf("Perft(%d) = %" PRIu64 "\n", i, perft(pos, i));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
xorps %xmm0, %xmm0
leaq -0x80(%rbp), %rsi
movups %xmm0, 0x50(%rsi)
movq $0x0, 0x60(%rsi)
leaq 0x60cc(%rip), %rdi      # 0xcb4f
callq 0x6de8
movl $0x1, %ebx
leaq -0x80(%rbp), %r14
leaq 0x60f8(%rip), %r15      # 0xcb90
movq %r14, %rdi
movl %ebx, %esi
callq 0x65e8
movq %r15, %rdi
movl %ebx, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3040
incl %ebx
cmpl $0x7, %ebx
jne 0x6a98
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6ac6
callq 0x31a0
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6ad3
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6ae4
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/position.cpp
// Function: init_keys()
void init_keys() {
    int i, j;
    for (i = 0; i < 16; ++i) {
        castle_keys[i] = get_rand64();
    }
    for (i = 0; i < 6; ++i) {
        for (j = 0; j < 64; ++j) {
            piece_sq_keys[i][j] = get_rand64();
        }
    }
    for (i = 0; i < 8; i++) {
        ep_keys[i] = get_rand64();
    }
    flip_key = get_rand64();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %r15d, %r15d
leaq 0x25107c(%rip), %rbx    # 0x257b80
leaq 0x2530cd(%rip), %r14    # 0x259bd8
leaq 0x252ffe(%rip), %r12    # 0x259b10
movb 0x2530d0(%rip), %al     # 0x259be8
testb %al, %al
je 0x6b3e
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7726
testq %rax, %rax
je 0x6b1c
movq %rax, (%r12,%r15,8)
incq %r15
cmpq $0x10, %r15
jne 0x6b12
jmp 0x6b45
callq 0x3358
jmp 0x6b1c
xorl %r15d, %r15d
leaq 0x251031(%rip), %rbx    # 0x257b80
leaq 0x253082(%rip), %r14    # 0x259bd8
movq %r15, %r13
shlq $0x9, %r13
leaq 0x2523ac(%rip), %rax    # 0x258f10
addq %rax, %r13
xorl %r12d, %r12d
movb 0x253078(%rip), %al     # 0x259be8
testb %al, %al
je 0x6b97
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7726
testq %rax, %rax
je 0x6b74
movq %rax, (%r13,%r12,8)
incq %r12
cmpq $0x40, %r12
jne 0x6b6a
jmp 0x6b9e
callq 0x338b
jmp 0x6b74
incq %r15
cmpq $0x6, %r15
jne 0x6b56
xorl %r15d, %r15d
leaq 0x250fcf(%rip), %rbx    # 0x257b80
leaq 0x253020(%rip), %r14    # 0x259bd8
leaq 0x252fd1(%rip), %r12    # 0x259b90
movb 0x253023(%rip), %al     # 0x259be8
testb %al, %al
je 0x6beb
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7726
testq %rax, %rax
je 0x6bc9
movq %rax, (%r12,%r15,8)
incq %r15
cmpq $0x8, %r15
jne 0x6bbf
jmp 0x6bf2
callq 0x33be
jmp 0x6bc9
movb 0x252ff0(%rip), %al     # 0x259be8
testb %al, %al
je 0x6c33
leaq 0x250f7d(%rip), %rbx    # 0x257b80
leaq 0x252fce(%rip), %r14    # 0x259bd8
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7726
testq %rax, %rax
je 0x6c0a
movq %rax, 0x252fac(%rip)    # 0x259bd0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x33f1
jmp 0x6bfc
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/position.cpp
// Function: calculate_key(Position&)
void calculate_key(Position &pos) {
    std::uint64_t pieces;

    pos.hash_key = 0;
    pieces = get_colour(pos, US);

    while (pieces) {
        Square sq = lsb(pieces);
        Piece pc = get_piece_on_square(pos, sq);

        pos.hash_key ^= piece_sq_keys[pc][sq];

        pieces &= pieces - 1;
    }

    pieces = get_colour(pos, THEM);

    while (pieces) {
        Square sq = lsb(pieces);
        Piece pc = get_piece_on_square(pos, sq);

        pos.hash_key ^= bswap(piece_sq_keys[pc][sq]);

        pieces &= pieces - 1;
    }

    pos.hash_key ^= castle_keys[pos.castle];

    if (pos.epsq != INVALID_SQUARE) {
        pos.hash_key ^= ep_keys[pos.epsq & 7];
    }

    if (pos.flipped) pos.hash_key ^= flip_key;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq $0x0, 0x48(%rdi)
movq 0x30(%rdi), %rax
testq %rax, %rax
je 0x6cf1
movq 0x48(%rdi), %rdx
movq (%rdi), %rsi
movq 0x8(%rdi), %r8
movq 0x10(%rdi), %r9
movq 0x18(%rdi), %r10
movq 0x20(%rdi), %r11
movq 0x28(%rdi), %rbx
movl $0x4, %r14d
leaq 0x25228c(%rip), %r15    # 0x258f10
bsfq %rax, %rcx
movl $0x1, %r12d
shlq %cl, %r12
btq %rcx, %rsi
jae 0x6c9c
xorl %r13d, %r13d
jmp 0x6cd8
movl $0x1, %r13d
testq %r12, %r8
jne 0x6cd8
movl $0x2, %r13d
testq %r12, %r9
jne 0x6cd8
movl $0x3, %r13d
testq %r12, %r10
jne 0x6cd8
movq %rbx, %r13
andq %r12, %r13
cmpq $0x1, %r13
movl $0x0, %r13d
adcq $0x5, %r13
testq %r12, %r11
cmovneq %r14, %r13
shlq $0x9, %r13
addq %r15, %r13
xorq (%r13,%rcx,8), %rdx
movq %rdx, 0x48(%rdi)
leaq -0x1(%rax), %rcx
andq %rcx, %rax
jne 0x6c84
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x6d99
movq 0x48(%rdi), %rdx
movq (%rdi), %rsi
movq 0x8(%rdi), %r8
movq 0x10(%rdi), %r9
movq 0x18(%rdi), %r10
movq 0x20(%rdi), %r11
movq 0x28(%rdi), %rbx
movl $0x4, %r14d
leaq 0x2521ea(%rip), %r15    # 0x258f10
bsfq %rax, %rcx
movl $0x1, %r12d
shlq %cl, %r12
btq %rcx, %rsi
jae 0x6d3e
xorl %r13d, %r13d
jmp 0x6d7a
movl $0x1, %r13d
testq %r12, %r8
jne 0x6d7a
movl $0x2, %r13d
testq %r12, %r9
jne 0x6d7a
movl $0x3, %r13d
testq %r12, %r10
jne 0x6d7a
movq %rbx, %r13
andq %r12, %r13
cmpq $0x1, %r13
movl $0x0, %r13d
adcq $0x5, %r13
testq %r12, %r11
cmovneq %r14, %r13
shlq $0x9, %r13
addq %r15, %r13
movq (%r13,%rcx,8), %rcx
bswapq %rcx
xorq %rcx, %rdx
movq %rdx, 0x48(%rdi)
leaq -0x1(%rax), %rcx
andq %rcx, %rax
jne 0x6d26
movzbl 0x40(%rdi), %ecx
leaq 0x252d6c(%rip), %rdx    # 0x259b10
movq 0x48(%rdi), %rax
xorq (%rdx,%rcx,8), %rax
movq %rax, 0x48(%rdi)
movzbl 0x42(%rdi), %ecx
cmpq $0x40, %rcx
je 0x6dcc
andl $0x7, %ecx
leaq 0x252dcc(%rip), %rdx    # 0x259b90
xorq (%rdx,%rcx,8), %rax
movq %rax, 0x48(%rdi)
cmpb $0x1, 0x41(%rdi)
jne 0x6ddd
movq 0x252df7(%rip), %rax    # 0x259bd0
xorq %rax, 0x48(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/position.cpp
// Function: run_fen_parser_tests()
void run_fen_parser_tests() {
    Position tmp;

    init_keys();
    parse_fen_to_position((const char*)"rnbqkbnr//pppppppp//8//8//8//8//PPPPPPPP//RNBQKBNR w KQkq - 0 1", tmp);
    print_position_struct(tmp);
    parse_fen_to_position((const char*)"rnbqkbnr//pppppppp//8///8//4P3//8//PPPP1PPP//RNBQKBNR b KQkq e3 0 1", tmp);
    print_position_struct(tmp);
    parse_fen_to_position((const char*)"rnbqkbnr//pp1ppppp//8//2p5//4P3//8//PPPP1PPP//RNBQKBNR w KQkq c6 0 2", tmp);
    print_position_struct(tmp);
    parse_fen_to_position((const char*)"rnbqkbnr//pp1ppppp//8//2p5//4P3//5N2//PPPP1PPP//RNBQKB1R b Qkq - 1 2", tmp);
    print_position_struct(tmp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x68, %rsp
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rbp)
movq $0x0, -0x10(%rbp)
callq 0x6aec
leaq 0x5a17(%rip), %rdi      # 0xcd5a
leaq -0x70(%rbp), %rsi
callq 0x6de8
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x7165
leaq 0x5a3b(%rip), %rdi      # 0xcd9a
movq %rbx, %rsi
callq 0x6de8
movq %rbx, %rdi
callq 0x7165
leaq 0x5a68(%rip), %rdi      # 0xcdde
movq %rbx, %rsi
callq 0x6de8
movq %rbx, %rdi
callq 0x7165
leaq 0x5a96(%rip), %rdi      # 0xce23
movq %rbx, %rsi
callq 0x6de8
movq %rbx, %rdi
callq 0x7165
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x73ab
callq 0x31a0
addq $0x68, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x73c3
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/search.cpp
// Function: score_moves(Position const&, SearchStack*, int, unsigned int)
void score_moves(const Position& pos, SearchStack* ss, int size,
                 Move hash_move) {
    assert(ss);

    for (int i = 0; i < size; i++) {
        Move move = ss->ml[i];

        if (move == hash_move) {
            ss->score[i] = 20000;
            continue;
        }

        int mt = move_type(move);
        if (mt == CAPTURE)
            ss->score[i] = 9000 + mvv_lva(pos, move);
        else if (mt == PROM_CAPTURE)
            ss->score[i] = 9000 + mvv_lva(pos, move) +
                           piecevals[OPENING][promotion_type(move)];
        else if (mt == ENPASSANT)
            ss->score[i] = 9000 + piecevals[OPENING][PAWN] - PAWN + 10;
        else if (ss->killers[0] == move)
            ss->score[i] = 7000;
        else if (ss->killers[1] == move)
            ss->score[i] = 6000;
        else
            ss->score[i] = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, -0x38(%rbp)
testq %rsi, %rsi
je 0x7b40
testl %edx, %edx
jle 0x7b31
movl %ecx, %ebx
movq %rsi, %r14
leaq 0x359e(%rip), %rax      # 0xb010
movl (%rax), %eax
addl $0x32, %eax
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
movl %edx, %r15d
xorl %r13d, %r13d
movl 0x4(%r14,%r13,4), %r12d
movl $0x4e20, %eax           # imm = 0x4E20
cmpl %ebx, %r12d
jne 0x7aa7
movl %eax, 0x404(%r14,%r13,4)
incq %r13
cmpq %r13, %r15
jne 0x7a83
jmp 0x7b31
movl %r12d, %ecx
andl $0x7000, %ecx           # imm = 0x7000
cmpl $0x6000, %ecx           # imm = 0x6000
je 0x7ade
movl -0x2c(%rbp), %eax
cmpl $0x3000, %ecx           # imm = 0x3000
je 0x7a92
cmpl $0x2000, %ecx           # imm = 0x2000
jne 0x7b06
movq -0x38(%rbp), %rdi
movl %r12d, %esi
callq 0x7980
addl $0x2328, %eax           # imm = 0x2328
jmp 0x7a92
movq -0x38(%rbp), %rdi
movl %r12d, %esi
callq 0x7980
shrl $0xd, %r12d
andl $0x1c, %r12d
leaq 0x3517(%rip), %rcx      # 0xb010
movl (%rcx,%r12), %ecx
addl %ecx, %eax
addl $0x2328, %eax           # imm = 0x2328
jmp 0x7a92
movl $0x1b58, %eax           # imm = 0x1B58
cmpl %r12d, 0x804(%r14)
je 0x7a92
cmpl %r12d, 0x808(%r14)
movl $0x0, %eax
movl $0x1770, %ecx           # imm = 0x1770
cmovel %ecx, %eax
jmp 0x7a92
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5439(%rip), %rdi      # 0xcf80
leaq 0x5435(%rip), %rsi      # 0xcf83
leaq 0x543d(%rip), %rcx      # 0xcf92
movl $0x30, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/search.cpp
// Function: next_move(SearchStack*, int&)
Move next_move(SearchStack* ss, int& size) {
    assert(ss);

    if (!size) return 0;

    // Find best move index
    int best_index = 0;
    for (int i = 1; i < size; ++i) {
        if (ss->score[i] > ss->score[best_index]) {
            best_index = i;
        }
    }

    // Store the best move to return
    Move best_move = ss->ml[best_index];

    // Reduce ml/score size
    --size;

    // Bring the last move to current index
    ss->ml[best_index] = ss->ml[size];
    ss->score[best_index] = ss->score[size];

    return best_move;
}

// Assembly:
testq %rdi, %rdi
je 0x7bcb
movl (%rsi), %eax
testq %rax, %rax
je 0x7bc8
movslq %eax, %rcx
xorl %edx, %edx
cmpl $0x2, %eax
jl 0x7ba4
decq %rax
xorl %r8d, %r8d
movl 0x408(%rdi,%r8,4), %r10d
movslq %edx, %r11
incq %r8
movl %r8d, %r9d
cmpl 0x404(%rdi,%r11,4), %r10d
jg 0x7b99
movl %edx, %r9d
movl %r9d, %edx
cmpq %r8, %rax
jne 0x7b7b
movslq %r9d, %rdx
movl 0x4(%rdi,%rdx,4), %eax
leaq -0x1(%rcx), %r8
movl %r8d, (%rsi)
movl (%rdi,%rcx,4), %ecx
movl %ecx, 0x4(%rdi,%rdx,4)
movslq (%rsi), %rcx
movl 0x404(%rdi,%rcx,4), %ecx
movl %ecx, 0x404(%rdi,%rdx,4)
retq
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x53aa(%rip), %rdi      # 0xcf80
leaq 0x53a6(%rip), %rsi      # 0xcf83
leaq 0x53eb(%rip), %rcx      # 0xcfcf
movl $0x4d, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/search.cpp
// Function: clear_ss(SearchStack*, int)
void clear_ss(SearchStack* ss, int size) {
    assert(ss);
    assert(size >= 0);

    for (std::uint8_t i = 0; i < size; ++i, ++ss) {
        ss->ply = i;
        ss->killers[0] = ss->killers[1] = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
je 0x7f09
testl %esi, %esi
js 0x7f28
je 0x7f07
xorl %eax, %eax
movb %al, (%rdi)
movq $0x0, 0x804(%rdi)
incb %al
addq $0x818, %rdi            # imm = 0x818
movzbl %al, %ecx
cmpl %esi, %ecx
jl 0x7eea
popq %rbp
retq
leaq 0x5070(%rip), %rdi      # 0xcf80
leaq 0x506c(%rip), %rsi      # 0xcf83
leaq 0x511b(%rip), %rcx      # 0xd039
movl $0x133, %edx            # imm = 0x133
callq 0x3100
leaq 0x512c(%rip), %rdi      # 0xd05b
leaq 0x504d(%rip), %rsi      # 0xcf83
leaq 0x50fc(%rip), %rcx      # 0xd039
movl $0x134, %edx            # imm = 0x134
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/search.cpp
// Function: set_stats(SearchStack*, Stats&)
void set_stats(SearchStack* ss, Stats& stats) {
    assert(ss);

    SearchStack* end = ss - ss->ply + MAX_PLY;
    for (; ss < end; ++ss) {
        ss->stats = &stats;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
je 0x7f80
movzbl (%rdi), %eax
negq %rax
imulq $0x818, %rax, %rax      # imm = 0x818
addq %rdi, %rax
addq $0x20600, %rax          # imm = 0x20600
cmpq %rdi, %rax
jbe 0x7f7e
movq %rsi, 0x810(%rdi)
addq $0x818, %rdi            # imm = 0x818
cmpq %rax, %rdi
jb 0x7f6b
popq %rbp
retq
leaq 0x4ff9(%rip), %rdi      # 0xcf80
leaq 0x4ff5(%rip), %rsi      # 0xcf83
leaq 0x50d0(%rip), %rcx      # 0xd065
movl $0x13e, %edx            # imm = 0x13E
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.h
// Function: tt_eval(unsigned long)
inline int tt_eval(const std::uint64_t data) {
    int eval = (data >> TT_EVAL_SHIFT) & TT_EVAL_MASK;
    assert(eval <= INF + MAX_PLY);
    assert(eval >= -INF - MAX_PLY);
    // assert(eval <= INF);
    // assert(eval >= -INF);
    return eval;

    // return (data >> TT_EVAL_SHIFT) & TT_EVAL_MASK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
shrq $0x7, %rdi
cmpl $0x7571, %edi           # imm = 0x7571
jge 0x935a
cmpl $0xffff8a8f, %edi       # imm = 0xFFFF8A8F
jle 0x9379
movl %edi, %eax
popq %rbp
retq
leaq 0x3ee9(%rip), %rdi      # 0xd24a
leaq 0x3839(%rip), %rsi      # 0xcba1
leaq 0x3ef1(%rip), %rcx      # 0xd260
movl $0x6d, %edx
callq 0x3100
leaq 0x3f01(%rip), %rdi      # 0xd281
leaq 0x381a(%rip), %rsi      # 0xcba1
leaq 0x3ed2(%rip), %rcx      # 0xd260
movl $0x6e, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.h
// Function: tt_flag(unsigned long)
inline int tt_flag(const std::uint64_t data) {
    int flag = (data >> TT_FLAG_SHIFT) & TT_FLAG_MASK;
    assert(flag == TT_EXACT || flag == TT_LOWER || flag == TT_UPPER);
    return flag;

    // return (data >> TT_FLAG_SHIFT) & TT_FLAG_MASK;
}

// Assembly:
movq %rdi, %rax
shrq $0x27, %rax
andl $0x3, %eax
btq $0x27, %rdi
setae %cl
cmpl $0x1, %eax
sete %dl
orb %cl, %dl
je 0x93b5
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x3ed8(%rip), %rdi      # 0xd298
leaq 0x37da(%rip), %rsi      # 0xcba1
leaq 0x3f03(%rip), %rcx      # 0xd2d1
movl $0x79, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.cpp
// Function: tt_create(TT*, unsigned int)
bool tt_create(TT* tt, const std::uint32_t megabytes) {
    assert(tt);

    if (megabytes <= 0) {
        return false;
    } else if (megabytes > 512) {
        return false;
    }

    int num_entries = 1024 * 1024 * megabytes / sizeof(TTEntry);

    assert(num_entries * sizeof(TTEntry) <= 1024 * 1024 * megabytes);

    tt->data = (TTEntry*)malloc(num_entries * sizeof(TTEntry));

    if (tt->data) {
        tt->size = num_entries;
        return true;
    }

    tt->size = 0;
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x974e
leal -0x201(%rsi), %eax
xorl %r14d, %r14d
cmpl $0xfffffe00, %eax       # imm = 0xFFFFFE00
jb 0x9740
movq %rdi, %rbx
movl %esi, %r15d
shll $0x10, %r15d
shll $0x14, %esi
movq %rsi, %rdi
callq 0x3210
movq %rax, 0x8(%rbx)
testq %rax, %rax
setne %al
cmovnel %r15d, %r14d
movl %r14d, (%rbx)
movl %eax, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x33af(%rip), %rdi      # 0xcb04
leaq 0x3be1(%rip), %rsi      # 0xd33d
leaq 0x3be5(%rip), %rcx      # 0xd348
movl $0x21, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.cpp
// Function: tt_poll(TT*, unsigned long)
TTEntry tt_poll(TT* tt, const std::uint64_t key) {
    assert(tt);
    assert(tt->size);
    assert(tt->data);

    int index = key % tt->size;

    assert(index < tt->size);

    return tt->data[index];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
je 0x97a6
movslq (%rdi), %r8
testq %r8, %r8
je 0x97c5
movq 0x8(%rdi), %rcx
testq %rcx, %rcx
je 0x97e4
movq %rsi, %rax
xorl %edx, %edx
divq %r8
cmpl %edx, %r8d
jle 0x9803
movslq %edx, %rdx
shlq $0x4, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rdx
popq %rbp
retq
leaq 0x3357(%rip), %rdi      # 0xcb04
leaq 0x3b89(%rip), %rsi      # 0xd33d
leaq 0x3bb7(%rip), %rcx      # 0xd372
movl $0x39, %edx
callq 0x3100
leaq 0x3be2(%rip), %rdi      # 0xd3ae
leaq 0x3b6a(%rip), %rsi      # 0xd33d
leaq 0x3b98(%rip), %rcx      # 0xd372
movl $0x3a, %edx
callq 0x3100
leaq 0x3bb2(%rip), %rdi      # 0xd39d
leaq 0x3b4b(%rip), %rsi      # 0xd33d
leaq 0x3b79(%rip), %rcx      # 0xd372
movl $0x3b, %edx
callq 0x3100
leaq 0x3b9c(%rip), %rdi      # 0xd3a6
leaq 0x3b2c(%rip), %rsi      # 0xd33d
leaq 0x3b5a(%rip), %rcx      # 0xd372
movl $0x3f, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.cpp
// Function: tt_clear(TT*)
bool tt_clear(TT* tt) {
    assert(tt);

    if (!tt->data) {
        return false;
    }

    memset(tt->data, 0, tt->size * sizeof(TTEntry));
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x9854
movq 0x8(%rdi), %rbx
testq %rbx, %rbx
je 0x9847
movslq (%rdi), %rdx
shlq $0x4, %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x30d0
testq %rbx, %rbx
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x32a9(%rip), %rdi      # 0xcb04
leaq 0x3adb(%rip), %rsi      # 0xd33d
leaq 0x3b4e(%rip), %rcx      # 0xd3b7
movl $0x45, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.cpp
// Function: tt_free(TT*)
bool tt_free(TT* tt) {
    assert(tt);

    if (!tt->data) {
        return false;
    }

    tt->size = 0;
    free(tt->data);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x98a2
movq 0x8(%rdi), %rbx
testq %rbx, %rbx
je 0x9895
movl $0x0, (%rdi)
movq %rbx, %rdi
callq 0x31f0
testq %rbx, %rbx
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x325b(%rip), %rdi      # 0xcb04
leaq 0x3a8d(%rip), %rsi      # 0xd33d
leaq 0x3b14(%rip), %rcx      # 0xd3cb
movl $0x50, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.cpp
// Function: tt_add(TT*, unsigned long, int, int, int, int)
bool tt_add(TT* tt, const std::uint64_t hash_key, const int move,
            const int depth, const int flag, const int eval) {
    assert(tt);
    assert(move != 0);
    assert(depth >= 0);
    assert(flag == TT_EXACT || flag == TT_LOWER || flag == TT_UPPER);

    if (!tt->data) {
        return false;
    }

    int index = hash_key % tt->size;

    TTEntry entry;
    entry.data = 0ULL;
    entry.hash_key = hash_key;

    entry.data = ((std::uint64_t)(move & TT_MOVE_MASK) << TT_MOVE_SHIFT) |
                 ((std::uint64_t)(depth & TT_DEPTH_MASK) << TT_DEPTH_SHIFT) |
                 ((std::uint64_t)(flag & TT_FLAG_MASK) << TT_FLAG_SHIFT) |
                 ((std::uint64_t)(eval & TT_EVAL_MASK) << TT_EVAL_SHIFT);

    tt->data[index] = entry;

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
je 0x9931
movl %edx, %r10d
testl %edx, %edx
je 0x9950
testl %ecx, %ecx
js 0x996f
cmpl $0x3, %r8d
jae 0x998e
movq 0x8(%rdi), %r11
testq %r11, %r11
je 0x9929
movslq (%rdi), %rdi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
andl $0x3ffff, %r10d         # imm = 0x3FFFF
shlq $0x29, %r10
andl $0x7f, %ecx
orq %r10, %rcx
shlq $0x27, %r8
orq %rcx, %r8
movl %r9d, %eax
shlq $0x7, %rax
orq %r8, %rax
movslq %edx, %rcx
shlq $0x4, %rcx
movq %rax, (%r11,%rcx)
movq %rsi, 0x8(%r11,%rcx)
testq %r11, %r11
setne %al
popq %rbp
retq
leaq 0x31cc(%rip), %rdi      # 0xcb04
leaq 0x39fe(%rip), %rsi      # 0xd33d
leaq 0x3a98(%rip), %rcx      # 0xd3de
movl $0x5d, %edx
callq 0x3100
leaq 0x3ada(%rip), %rdi      # 0xd431
leaq 0x39df(%rip), %rsi      # 0xd33d
leaq 0x3a79(%rip), %rcx      # 0xd3de
movl $0x5e, %edx
callq 0x3100
leaq 0x3ac5(%rip), %rdi      # 0xd43b
leaq 0x39c0(%rip), %rsi      # 0xd33d
leaq 0x3a5a(%rip), %rcx      # 0xd3de
movl $0x5f, %edx
callq 0x3100
leaq 0x3903(%rip), %rdi      # 0xd298
leaq 0x39a1(%rip), %rsi      # 0xd33d
leaq 0x3a3b(%rip), %rcx      # 0xd3de
movl $0x60, %edx
callq 0x3100
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/tt.cpp
// Function: tt_add_perft(TT*, unsigned long, int, unsigned long)
bool tt_add_perft(TT* tt, const std::uint64_t hash_key, const int depth,
                  const uint64_t nodes) {
    assert(tt);
    assert(depth != 0);

    if (!tt->data) {
        return false;
    }

    int index = hash_key % tt->size;

    TTEntry entry;
    entry.data = 0ULL;
    entry.hash_key = hash_key;

    entry.data = ((std::uint64_t)(depth & TT_DEPTH_MASK) << TT_DEPTH_SHIFT) |
                 ((std::uint64_t)(nodes & TT_NODES_MASK) << TT_NODES_SHIFT);

    tt->data[index] = entry;

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
je 0x99f4
movl %edx, %r8d
testl %edx, %edx
je 0x9a13
movq 0x8(%rdi), %r9
testq %r9, %r9
je 0x99ec
movslq (%rdi), %rdi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
andl $0x7f, %r8d
shlq $0x7, %rcx
orq %r8, %rcx
movslq %edx, %rax
shlq $0x4, %rax
movq %rcx, (%r9,%rax)
movq %rsi, 0x8(%r9,%rax)
testq %r9, %r9
setne %al
popq %rbp
retq
leaq 0x3109(%rip), %rdi      # 0xcb04
leaq 0x393b(%rip), %rsi      # 0xd33d
leaq 0x3a3d(%rip), %rcx      # 0xd446
movl $0x78, %edx
callq 0x3100
leaq 0x3a74(%rip), %rdi      # 0xd48e
leaq 0x391c(%rip), %rsi      # 0xd33d
leaq 0x3a1e(%rip), %rcx      # 0xd446
movl $0x79, %edx
callq 0x3100
nop
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/uci.cpp
// Function: UCI::Extension::perft(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&)
void perft(std::stringstream& ss) {
    int depth = 0;
    ss >> depth;
    if (depth < 1) {
        depth = 1;
    }

    std::uint64_t nodes = 0ULL;
    for (int i = 1; i <= depth; ++i) {
        auto start = std::chrono::high_resolution_clock::now();
        nodes = perft(sc.pos, i);
        auto finish = std::chrono::high_resolution_clock::now();
        std::chrono::duration<double> elapsed = finish - start;

        std::cout << "info"
                  << " depth " << i << " nodes " << nodes << " time "
                  << static_cast<int>(elapsed.count() * 1000) << " nps "
                  << static_cast<int>(nodes / elapsed.count()) << std::endl;
    }

    std::cout << "nodes " << nodes << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq -0x2c(%rbp), %rbx
movl $0x0, (%rbx)
movq %rbx, %rsi
callq 0x30e0
cmpl $0x0, (%rbx)
jg 0x9a74
movl $0x1, -0x2c(%rbp)
xorl %ebx, %ebx
cmpl $0x0, -0x2c(%rbp)
jle 0x9bc5
movq 0x7541(%rip), %r15      # 0x10fc8
leaq 0x3a5e(%rip), %r13      # 0xd4ec
incl %ebx
callq 0x3050
movq %rax, %r12
leaq 0x253bf1(%rip), %rdi    # 0x25d690
movl %ebx, %esi
callq 0x65e8
movq %rax, %r14
callq 0x3050
subq %r12, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x39df(%rip), %xmm0     # 0xd4a0
movsd %xmm0, -0x38(%rbp)
movl $0x4, %edx
movq %r15, %rdi
leaq 0x39fb(%rip), %rsi      # 0xd4d0
callq 0x31e0
movl $0x7, %edx
movq %r15, %rdi
leaq 0x39ec(%rip), %rsi      # 0xd4d5
callq 0x31e0
movq %r15, %rdi
movl %ebx, %esi
callq 0x32a0
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
leaq 0x39d3(%rip), %rsi      # 0xd4dd
callq 0x31e0
movq %r12, %rdi
movq %r14, %rsi
callq 0x3120
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x39b9(%rip), %rsi      # 0xd4e5
callq 0x31e0
movsd -0x38(%rbp), %xmm0
mulsd 0x396a(%rip), %xmm0     # 0xd4a8
cvttsd2si %xmm0, %esi
movq %r12, %rdi
callq 0x32a0
movq %rax, %r12
movl $0x5, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x31e0
movq %r14, %xmm0
punpckldq 0x3946(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x394e(%rip), %xmm0     # 0xd4c0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd -0x38(%rbp), %xmm1
cvttsd2si %xmm1, %esi
movq %r12, %rdi
callq 0x32a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
cmpl -0x2c(%rbp), %ebx
jl 0x9a8e
movq %r14, %rbx
movq 0x73fc(%rip), %r14      # 0x10fc8
leaq 0x390b(%rip), %rsi      # 0xd4de
movl $0x6, %edx
movq %r14, %rdi
callq 0x31e0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3120
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/uci.cpp
// Function: UCI::setoption(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&)
void setoption(std::stringstream& ss) {
    std::string word;
    std::string name = "";
    std::string value = "";

    if (ss >> word && word != "name") {
        return;
    }

    // Collect the name
    while (ss >> word && word != "value") {
        if (name != "") {
            name += " ";
        }
        name += word;
    }

    // Collect the value
    while (ss >> word) {
        if (value != "") {
            value += " ";
        }
        value += word;
    }

    // Set the option
    if (name != "" && value != "") {
        // TODO:
        // Set the option if found
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
leaq -0x70(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x2ae1(%rip), %rdx      # 0xc992
leaq -0x80(%rbp), %rdi
movq %rdx, %rsi
callq 0x5730
leaq -0x50(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x2ac5(%rip), %rdx      # 0xc992
leaq -0x60(%rbp), %rdi
movq %rdx, %rsi
callq 0x5730
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x3200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x9fd5
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x3200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x9f95
leaq 0x361c(%rip), %rsi      # 0xd538
leaq -0x40(%rbp), %rdi
callq 0x3070
testl %eax, %eax
je 0x9f95
leaq 0x2a62(%rip), %rsi      # 0xc992
leaq -0x80(%rbp), %rdi
callq 0x3070
testl %eax, %eax
je 0x9f4d
leaq 0x2ddf(%rip), %rsi      # 0xcd23
leaq -0x80(%rbp), %rdi
callq 0x3310
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x3080
jmp 0x9ef7
leaq 0x2a2b(%rip), %rsi      # 0xc992
leaq -0x60(%rbp), %rdi
callq 0x3070
testl %eax, %eax
je 0x9f84
leaq 0x2da8(%rip), %rsi      # 0xcd23
leaq -0x60(%rbp), %rdi
callq 0x3310
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x3080
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x3200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x9f60
leaq 0x29dc(%rip), %rsi      # 0xc992
leaq -0x80(%rbp), %rdi
callq 0x3070
testl %eax, %eax
je 0x9fed
leaq 0x29c8(%rip), %rsi      # 0xc992
leaq -0x60(%rbp), %rdi
callq 0x3070
jmp 0x9fed
leaq 0x3557(%rip), %rsi      # 0xd533
leaq -0x40(%rbp), %rdi
callq 0x3070
testl %eax, %eax
je 0x9ef7
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x9ffb
callq 0x31a0
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0xa009
callq 0x31a0
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xa017
callq 0x31a0
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa032
movq %rax, %rbx
jmp 0xa043
movq %rax, %rbx
jmp 0xa051
jmp 0xa032
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0xa043
callq 0x31a0
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0xa051
callq 0x31a0
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xa05f
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/uci.cpp
// Function: UCI::moves(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&)
void moves(std::stringstream& ss) {
    std::string word;
    while (ss >> word) {
        Move move;
        if (!lan_to_move(sc.pos, word.c_str(), move)) {
            return;
        }

        char move_str[5];
        move_to_lan(move_str, move);

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

        make_move(sc.pos, move);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x50(%rbp), %r14
leaq 0x2533e1(%rip), %r15    # 0x25d690
leaq -0x2c(%rbp), %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xa319
movq -0x50(%rbp), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x4ff6
movl %eax, %r13d
testb %al, %al
je 0xa319
movl -0x2c(%rbp), %esi
leaq -0x55(%rbp), %rdi
callq 0x4ee6
cmpb $0x1, 0x2533dc(%rip)    # 0x25d6d1
jne 0xa309
movl -0x2c(%rbp), %eax
movl $0x3ffff, %ecx          # imm = 0x3FFFF
andl %ecx, %eax
xorl $0xe38, %eax            # imm = 0xE38
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %esi
movq %r15, %rdi
callq 0x4ac0
testb %r13b, %r13b
jne 0xa2b3
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xa32b
callq 0x31a0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa33e
jmp 0xa33e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xa353
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/uci.cpp
// Function: UCI::position(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&)
void position(std::stringstream& ss) {
    std::string fen = "";

    std::string word;
    while (ss >> word && word != "moves") {
        if (word == "startpos") {
            fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
        } else if (word != "fen") {
            if (fen != "") {
                fen += " ";
            }
            fen += word;
        }
    }

    if (fen != "") {
        parse_fen_to_position(fen.c_str(), sc.pos);
    }

    moves(ss);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2614(%rip), %rdx      # 0xc992
leaq -0x48(%rbp), %r15
movq %r15, %rdi
movq %rdx, %rsi
callq 0x5730
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x68(%rbp), %r12
leaq 0x31c2(%rip), %r13      # 0xd56d
leaq 0x31c1(%rip), %r14      # 0xd573
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xa457
movq %r12, %rdi
movq %r13, %rsi
callq 0x3070
testl %eax, %eax
je 0xa457
movq %r12, %rdi
movq %r14, %rsi
callq 0x3070
testl %eax, %eax
je 0xa437
movq %r12, %rdi
leaq 0x3185(%rip), %rsi      # 0xd57c
callq 0x3070
testl %eax, %eax
je 0xa3b2
movq %r15, %rdi
leaq 0x2588(%rip), %rsi      # 0xc992
callq 0x3070
testl %eax, %eax
je 0xa422
movq %r15, %rdi
leaq 0x2906(%rip), %rsi      # 0xcd23
callq 0x3310
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0x3080
jmp 0xa3b2
movq -0x40(%rbp), %rdx
movl $0x38, %r8d
movq %r15, %rdi
xorl %esi, %esi
leaq 0x30a5(%rip), %rcx      # 0xd4f2
callq 0x3270
jmp 0xa3b2
leaq 0x2534(%rip), %rsi      # 0xc992
leaq -0x48(%rbp), %rdi
callq 0x3070
testl %eax, %eax
je 0xa47b
movq -0x48(%rbp), %rdi
leaq 0x25321a(%rip), %rsi    # 0x25d690
callq 0x6de8
movq %rbx, %rdi
callq 0xa27d
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xa495
callq 0x31a0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xa4a7
callq 0x31a0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa4b8
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xa4cd
callq 0x31a0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xa4df
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0
// File: /workspace/github_cpp_makefile_star2_O1/olly-larkin[P]mips-parser/src/main.cpp
// Function: formatName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string formatName(std::string str) {
	std::size_t dotIndex = str.size();
	std::size_t slashIndex = -1;
	for(int i = str.size()-1; i >= 0; --i) {
		if (str[i] == '.' && dotIndex == str.size())
			dotIndex = i;
		if (str[i] == '/' && slashIndex == -1)
			slashIndex = i;
	}
	return str.substr(slashIndex+1, (dotIndex - slashIndex - 1)) + ".bin";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq 0x8(%rsi), %rax
movl %eax, %ecx
decl %ecx
js 0x3f20
movq (%rsi), %rdx
movl %ecx, %r8d
movq $-0x1, %r9
movq %rax, %r10
movq %rax, %rdi
movq %r9, %rcx
cmpq %rax, %r10
cmoveq %r8, %rdi
movb (%rdx,%r8), %r11b
cmpb $0x2e, %r11b
cmovneq %r10, %rdi
cmpq $-0x1, %r9
cmoveq %r8, %rcx
cmpb $0x2f, %r11b
cmovneq %r9, %rcx
leaq -0x1(%r8), %r11
movq %rdi, %r10
movq %rcx, %r9
testq %r8, %r8
movq %r11, %r8
jg 0x3ee9
jmp 0x3f2a
movq $-0x1, %rcx
movq %rax, %rdi
leaq 0x1(%rcx), %rdx
notq %rcx
addq %rdi, %rcx
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x2220
leaq 0x7199(%rip), %rsi      # 0xb0e0
movq %r14, %rdi
callq 0x23b0
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x3f71
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x3f77
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x20(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3fa0
callq 0x21f0
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x20(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3fc1
callq 0x21f0
movq %rbx, %rdi
callq 0x2370