LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/bitboards.cpp
// Function: init_knight_moves()
void init_knight_moves() {

    for (int i=0;i<64;i++) {
        square_t sq = (square_t)i;
        bb_knight_moves[sq] = 0;
        rank_t r = get_rank(sq);
        file_t f = get_file(sq);
        if (f > FILE_A) {
            if (r > RANK_7) {
                bb_knight_moves[sq] |= bb_squares[north(northwest(sq))];
            }
            if (r < RANK_2) {
                bb_knight_moves[sq] |= bb_squares[south(southwest(sq))];
            }
        }
        if (f > FILE_B) {
            if (r > RANK_8) {
                bb_knight_moves[sq] |= bb_squares[northwest(west(sq))];
            }
            if (r < RANK_1) {
                bb_knight_moves[sq] |= bb_squares[southwest(west(sq))];
            }
        }
        if (f < FILE_G) {
            if (r > RANK_8) {
                bb_knight_moves[sq] |= bb_squares[northeast(east(sq))];
            }
            if (r < RANK_1) {
                bb_knight_moves[sq] |= bb_squares[southeast(east(sq))];
            }
        }
        if (f < FILE_H) {
            if (r > RANK_7) {
                bb_knight_moves[sq] |= bb_squares[north(northeast(sq))];
            }
            if (r < RANK_2) {
                bb_knight_moves[sq] |= bb_squares[south(southeast(sq))];
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %ebx, %ebx
leaq 0xf9bb9(%rip), %r15     # 0xfd6b0
leaq 0xf99b2(%rip), %r12     # 0xfd4b0
cmpq $0x40, %rbx
je 0x3c2a
andq $0x0, (%r15,%rbx,8)
movl %ebx, %edi
callq 0xc001
movl %eax, %ebp
movl %ebx, %edi
callq 0xbfd8
testl %eax, %eax
jle 0x3ba7
movl %eax, %r14d
cmpl $0x2, %ebp
jl 0x3b4a
movl %ebx, %edi
callq 0xc3ac
movl %eax, %edi
callq 0xc19d
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x5, %ebp
ja 0x3b62
movl %ebx, %edi
callq 0xc356
movl %eax, %edi
callq 0xc1e0
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x1, %r14d
je 0x3ba7
testl %ebp, %ebp
jle 0x3b89
movl %ebx, %edi
callq 0xc267
movl %eax, %edi
callq 0xc3ac
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x6, %ebp
ja 0x3ba1
movl %ebx, %edi
callq 0xc267
movl %eax, %edi
callq 0xc356
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x5, %r14d
ja 0x3c22
testl %ebp, %ebp
jle 0x3bc8
movl %ebx, %edi
callq 0xc224
movl %eax, %edi
callq 0xc2a9
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x6, %ebp
ja 0x3be5
movl %ebx, %edi
callq 0xc224
movl %eax, %edi
callq 0xc2ff
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x2, %ebp
jl 0x3c02
movl %ebx, %edi
callq 0xc2a9
movl %eax, %edi
callq 0xc19d
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x5, %ebp
ja 0x3c1a
movl %ebx, %edi
callq 0xc2ff
movl %eax, %edi
callq 0xc1e0
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
incq %rbx
jmp 0x3afe
cmpl $0x6, %r14d
je 0x3be0
jmp 0x3c1a
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %ebx, %ebx
leaq 0xf9c6c(%rip), %r15     # 0xfd8b0
leaq 0xf9865(%rip), %r12     # 0xfd4b0
cmpq $0x40, %rbx
je 0x3d2a
andq $0x0, (%r15,%rbx,8)
movl %ebx, %edi
callq 0xc001
movl %eax, %r14d
movl %ebx, %edi
callq 0xbfd8
movl %eax, %ebp
testl %r14d, %r14d
jle 0x3cb0
testl %ebp, %ebp
jle 0x3c87
movl %ebx, %edi
callq 0xc3ac
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
movl %ebx, %edi
callq 0xc19d
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x6, %ebp
jg 0x3cdf
movl %ebx, %edi
callq 0xc2a9
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
jmp 0x3cb5
cmpl $0x6, %ebp
jg 0x3ce5
movl %ebx, %edi
callq 0xc224
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
cmpl $0x7, %r14d
jge 0x3d0d
movl %ebx, %edi
callq 0xc2ff
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
jmp 0x3ce5
cmpl $0x7, %r14d
jae 0x3d11
movl %ebx, %edi
callq 0xc1e0
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
testl %ebp, %ebp
jle 0x3d22
movl %ebx, %edi
callq 0xc356
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
jmp 0x3d11
testl %ebp, %ebp
jle 0x3d22
movl %ebx, %edi
callq 0xc267
movl %eax, %eax
movq (%r12,%rax,8), %rax
orq %rax, (%r15,%rbx,8)
incq %rbx
jmp 0x3c4b
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/bitboards.cpp
// Function: init_pawn_attacks()
void init_pawn_attacks() {
    for (int i=0;i<64;i++) {
        square_t sq = (square_t)i;
        file_t file_i = get_file(sq);
        rank_t rank_i = get_rank(sq);

        bb_pawn_attacks[i][BLACK] = bb_pawn_attacks[i][WHITE] = 0;
        if (rank_i != RANK_1 && rank_i != RANK_8) {
            if (file_i > FILE_A) {
                bb_pawn_attacks[i][WHITE] |= bb_squares[northwest(sq)];
                bb_pawn_attacks[i][BLACK] |= bb_squares[southwest(sq)];
            }
            if (file_i < FILE_H) {
                bb_pawn_attacks[i][WHITE] |= bb_squares[northeast(sq)];
                bb_pawn_attacks[i][BLACK] |= bb_squares[southeast(sq)];
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0xf9bea(%rip), %r14     # 0xfdab0
xorl %ebx, %ebx
leaq 0xf95e1(%rip), %r15     # 0xfd4b0
cmpq $0x40, %rbx
je 0x3f49
movl %ebx, %edi
callq 0xbfd8
movl %eax, %ebp
movl %ebx, %edi
callq 0xc001
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
testl %eax, %eax
je 0x3f40
cmpl $0x7, %eax
je 0x3f40
testl %ebp, %ebp
jle 0x3f1f
movl %ebx, %edi
callq 0xc3ac
movl %eax, %eax
movq (%r15,%rax,8), %rax
orq %rax, 0x8(%r14)
movl %ebx, %edi
callq 0xc356
movl %eax, %eax
movq (%r15,%rax,8), %rax
orq %rax, (%r14)
cmpl $0x6, %ebp
ja 0x3f40
movl %ebx, %edi
callq 0xc2a9
movl %eax, %eax
movq (%r15,%rax,8), %rax
orq %rax, 0x8(%r14)
movl %ebx, %edi
callq 0xc2ff
movl %eax, %eax
movq (%r15,%rax,8), %rax
orq %rax, (%r14)
incq %rbx
addq $0x10, %r14
jmp 0x3ecf
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/bitboards.cpp
// Function: init_bitboards()
void init_bitboards() {

    for (int i=0;i<64;i++) {
        bb_squares[i] = ((uint64)1) << i;
    }

    for (int i=0;i<8;i++) {
        bb_ranks[i] = 0;
        bb_files[i] = 0;
    }

    for (int i=0;i<64;i++) {
        bb_ranks[get_rank((square_t)i)] |= bb_squares[i];
        bb_files[get_file((square_t)i)] |= bb_squares[i];
    }

    lsb[0] = 0; msb[0] = 0;
    for (uint32 i=1;i<65536;i++) {
        lsb[i] = get_lsb_slow(i);
        msb[i] = get_msb_slow(i);
    }

    init_knight_moves();
    init_king_moves();
    init_pawn_attacks();
    init_rays();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ecx, %ecx
pushq $0x1
popq %rbx
leaq 0xf9545(%rip), %r15     # 0xfd4b0
cmpq $0x40, %rcx
je 0x3f80
movq %rbx, %rax
shlq %cl, %rax
movq %rax, (%r15,%rcx,8)
incq %rcx
jmp 0x3f6b
xorl %eax, %eax
leaq 0xf94e7(%rip), %r12     # 0xfd470
leaq 0xf94a0(%rip), %r13     # 0xfd430
cmpq $0x8, %rax
je 0x3fa6
andq $0x0, (%r12,%rax,8)
andq $0x0, (%r13,%rax,8)
incq %rax
jmp 0x3f90
xorl %r14d, %r14d
cmpq $0x40, %r14
je 0x3fd9
movq (%r15,%r14,8), %rbp
movl %r14d, %edi
callq 0xc001
movl %eax, %eax
orq %rbp, (%r12,%rax,8)
movq (%r15,%r14,8), %rbp
movl %r14d, %edi
callq 0xbfd8
movl %eax, %eax
orq %rbp, (%r13,%rax,8)
incq %r14
jmp 0x3fa9
andl $0x0, 0x414c0(%rip)     # 0x454a0
andl $0x0, 0x814b9(%rip)     # 0x854a0
leaq 0x414b2(%rip), %r14     # 0x454a0
leaq 0x814ab(%rip), %r15     # 0x854a0
cmpq $0x10000, %rbx          # imm = 0x10000
je 0x401b
movq %rbx, %rdi
callq 0x393b
movl %eax, (%r14,%rbx,4)
movq %rbx, %rdi
callq 0x39fa
movl %eax, (%r15,%rbx,4)
incq %rbx
jmp 0x3ff5
callq 0x3ae6
callq 0x3c33
callq 0x3eb8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3d33
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/book.cpp
// Function: load_zkeys()
void load_zkeys() {
    printd("loading zkeys from book...\n");

    char* sql = "select key from zobrist_keys order by id";
    char *err_msg = 0;
    int num_keys = 0;

    int rc = sqlite3_exec(book_db,sql,load_zkeys_callback,(void*)&num_keys,&err_msg);
    if( rc != SQLITE_OK ){
        error("SQL error: %s\n",err_msg);
        sqlite3_free(err_msg);
    }
    printd("loaded %d keys\n",num_keys);
}

// Assembly:
subq $0x18, %rsp
leaq 0x2332d(%rip), %rdi     # 0x27378
xorl %eax, %eax
callq 0x60fd
leaq 0x10(%rsp), %r8
andq $0x0, (%r8)
leaq 0xc(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0xc38ae(%rip), %rax     # 0xc7918
movq (%rax), %rdi
leaq 0x23320(%rip), %rsi     # 0x27394
leaq 0x3d(%rip), %rdx        # 0x40b8
callq 0x2250
testl %eax, %eax
je 0x40a1
movq 0x10(%rsp), %rsi
leaq 0x2332d(%rip), %rdi     # 0x273bd
xorl %eax, %eax
callq 0x622a
movq 0x10(%rsp), %rdi
callq 0x2200
movl 0xc(%rsp), %esi
leaq 0x23320(%rip), %rdi     # 0x273cc
xorl %eax, %eax
callq 0x60fd
addq $0x18, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/book.cpp
// Function: open_book_db(char*)
int32 open_book_db(char *path) {

    int rc = sqlite3_open(path, &book_db);
    if (rc){
        error("Can't open database: %s\n", sqlite3_errmsg(book_db));
        sqlite3_close(book_db);
        book_db = 0;
        return 0;
    }

    char* sql = "select count(*) from book_moves";
    char *err_msg = 0;
    int num_moves = 0;

    rc = sqlite3_exec(book_db,sql,num_moves_callback,(void*)&num_moves,&err_msg);
    if( rc != SQLITE_OK ){
        error("SQL error: %s\n",err_msg);
        sqlite3_free(err_msg);
    }

    load_zkeys();

    return num_moves;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
leaq 0xc365d(%rip), %rbx     # 0xc7918
movq %rbx, %rsi
callq 0x22e0
testl %eax, %eax
je 0x42f0
movq (%rbx), %rdi
callq 0x2150
leaq 0x23106(%rip), %rdi     # 0x273dc
xorl %ebp, %ebp
movq %rax, %rsi
xorl %eax, %eax
callq 0x622a
movq (%rbx), %rdi
callq 0x20a0
andq $0x0, (%rbx)
jmp 0x4341
leaq 0x10(%rsp), %r8
andq $0x0, (%r8)
leaq 0xc(%rsp), %rcx
andl $0x0, (%rcx)
movq (%rbx), %rdi
leaq 0x230ea(%rip), %rsi     # 0x273f5
leaq 0x38(%rip), %rdx        # 0x434a
callq 0x2250
testl %eax, %eax
je 0x4338
movq 0x10(%rsp), %rsi
leaq 0x23096(%rip), %rdi     # 0x273bd
xorl %eax, %eax
callq 0x622a
movq 0x10(%rsp), %rdi
callq 0x2200
callq 0x4040
movl 0xc(%rsp), %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/book.cpp
// Function: num_moves_callback(void*, int, char**, char**)
static int num_moves_callback(void *data, int argc, char **argv, char **azColName){

    int* num_moves = (int*)data;

    if (argc==1 && argv[0]) {
        *num_moves = atoi(argv[0]);
    }

    printd("num moves: %d\n",*num_moves);

    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x1, %esi
jne 0x4362
movq (%rdx), %rdi
testq %rdi, %rdi
je 0x4362
callq 0x22b0
movl %eax, (%rbx)
movl (%rbx), %esi
leaq 0x231df(%rip), %rdi     # 0x2754a
xorl %eax, %eax
callq 0x60fd
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/book.cpp
// Function: build_book_key(position*)
int64 build_book_key(position *p) {
    int64 key = 0;

    for (int32 sq=0;sq<64;sq++) {
        if (p->piece[sq] != NO_PIECE) {
            int32 pc = p->piece[sq];
            int32 ptm = WHITE;
            if (pc < 0) {
                pc = -pc;
                ptm = BLACK;
            }
            key ^= bk_pieces[pc][ptm][sq];
        }
    }

    if (p->castling_rights & 1) {
        key ^= bk_castling_rights[bk_cr_wk];
    }
    if (p->castling_rights & 2) {
        key ^= bk_castling_rights[bk_cr_wq];
    }
    if (p->castling_rights & 4) {
        key ^= bk_castling_rights[bk_cr_bk];
    }
    if (p->castling_rights & 8) {
        key ^= bk_castling_rights[bk_cr_bq];
    }

    if (p->ep_sq != NO_SQUARE) {
        key ^= bk_ep[p->ep_sq];
    }

    key ^= bk_ptm[p->player];

    return key;
}

// Assembly:
xorl %eax, %eax
leaq 0xc1131(%rip), %rdx     # 0xc54b0
movq %rdi, %rsi
xorl %ecx, %ecx
cmpq $0x200, %rax            # imm = 0x200
je 0x43c4
movl (%rsi), %r8d
testl %r8d, %r8d
je 0x43ba
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
shlq $0xa, %r9
notl %r8d
shrl $0x16, %r8d
andl $0x200, %r8d            # imm = 0x200
orq %r9, %r8
addq %rax, %r8
xorq (%rdx,%r8), %rcx
addq $0x8, %rax
addq $0x4, %rsi
jmp 0x4384
movd 0x140(%rdi), %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pand 0x22f87(%rip), %xmm0    # 0x27360
pxor %xmm1, %xmm1
pcmpeqd %xmm0, %xmm1
pshufd $0x50, %xmm1, %xmm0     # xmm0 = xmm1[0,0,1,1]
pshufd $0xfa, %xmm1, %xmm1     # xmm1 = xmm1[2,2,3,3]
pandn 0xc2cdd(%rip), %xmm1    # 0xc70d0
pandn 0xc2cc5(%rip), %xmm0    # 0xc70c0
pxor %xmm1, %xmm0
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
pxor %xmm0, %xmm1
movq %xmm1, %rax
xorq %rcx, %rax
movl 0x13c(%rdi), %ecx
cmpq $0x40, %rcx
je 0x4427
leaq 0xc2cbd(%rip), %rdx     # 0xc70e0
xorq (%rdx,%rcx,8), %rax
movl 0x138(%rdi), %ecx
leaq 0xc2c7c(%rip), %rdx     # 0xc70b0
xorq (%rdx,%rcx,8), %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/book.cpp
// Function: probe_book(position*)
move probe_book(position *p) {
    move_freq_pair mfp[300];
    int32 num_book_moves = get_book_moves(mfp,p);

    // get the total frequency of all book moves
    int32 total_freq=0;
    char move_buffer[8];
    for (int i=0;i<num_book_moves;i++) {
        if (mfp[i].freq > 0) {
            move_to_str(mfp[i].mv,move_buffer);
            printd("# book move: %s, freq: %d\n",move_buffer,mfp[i].freq);
            total_freq += mfp[i].freq;
        }
    }
    printd("# total freq: %d\n",total_freq);
    if (total_freq==0) {
        return 0;
    }

    // do a weighted random selection
    srand(time(NULL));
    double g = rand() / ((double) RAND_MAX); // [0-1]
    double random_weight = g * total_freq;
    printd("# random weight: %f\n",random_weight);

    int sum_freq = 0;
    move selected_mv = 0;
    for (int i=0;i<num_book_moves;i++) {
        if (mfp[i].freq > 0) {
            sum_freq += mfp[i].freq;
            if (sum_freq >= random_weight) {
                selected_mv = mfp[i].mv;
                move_to_str(selected_mv,move_buffer);
                printd("# selected move %s with sum_freq=%d\n",move_buffer,sum_freq);
                break;
            }
        }
    }

    return selected_mv;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x12d0, %rsp           # imm = 0x12D0
movq %rdi, %rsi
leaq 0x10(%rsp), %rdi
callq 0x455e
movl %eax, %ebx
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
shlq $0x4, %rbx
leaq 0x8(%rsp), %r14
leaq 0x22fa7(%rip), %r15     # 0x27415
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpq %r12, %rbx
je 0x44aa
cmpl $0x0, 0x18(%rsp,%r12)
jle 0x44a4
movq 0x10(%rsp,%r12), %rdi
movq %r14, %rsi
callq 0xd5f6
movl 0x18(%rsp,%r12), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x60fd
addl 0x18(%rsp,%r12), %ebp
addq $0x10, %r12
jmp 0x4473
leaq 0x22f7f(%rip), %rdi     # 0x27430
xorl %r14d, %r14d
movl %ebp, %esi
xorl %eax, %eax
callq 0x60fd
testl %ebp, %ebp
je 0x454b
xorl %edi, %edi
callq 0x2130
movl %eax, %edi
callq 0x2140
callq 0x2060
cvtsi2sd %eax, %xmm1
divsd 0x22e8c(%rip), %xmm1    # 0x27370
cvtsi2sd %ebp, %xmm0
mulsd %xmm1, %xmm0
leaq 0x22f4f(%rip), %rdi     # 0x27442
movsd %xmm0, (%rsp)
movb $0x1, %al
callq 0x60fd
xorl %eax, %eax
xorl %ebp, %ebp
cmpq %rax, %rbx
je 0x454b
movl 0x18(%rsp,%rax), %ecx
testl %ecx, %ecx
jle 0x451d
addl %ecx, %ebp
cvtsi2sd %ebp, %xmm0
ucomisd (%rsp), %xmm0
jae 0x4523
addq $0x10, %rax
jmp 0x4503
movq 0x10(%rsp,%rax), %r14
leaq 0x8(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd5f6
leaq 0x22f18(%rip), %rdi     # 0x27457
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x60fd
movq %r14, %rax
addq $0x12d0, %rsp           # imm = 0x12D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/book.cpp
// Function: get_book_moves(move_freq_pair*, position*)
int32 get_book_moves(move_freq_pair *mfp,position *p) {
    if (book_db==0) {
        printd("# can't probe - no book database\n");
        return 0;
    }

    printd("# probing book...\n");

    long long key = build_book_key(p);

    char sql[128];
    sprintf(sql,"select fromsq,tosq,frequency,wins,losses,draws from book_moves where key=%lld",key);

    char *err_msg = 0;

    move moves[300],*endp;
    endp = gen_legal_moves(moves,p,true,true);

    int mv_ind=0;
    for (move *mp=moves;mp<endp;mp++) {
        if (*mp) {
            mfp[mv_ind].mv=*mp;
            mfp[mv_ind].freq=0;
            mv_ind++;
        }
    }
    assert(mv_ind<300);

    mfpn_type mfpn;
    mfpn.mfp = &mfp[0];
    mfpn.n = mv_ind;
    int rc = sqlite3_exec(book_db,sql,get_moves_callback,(void*)&mfpn,&err_msg);
    if( rc != SQLITE_OK ){
        error("SQL error: %s\n",err_msg);
        sqlite3_free(err_msg);
    }

    return mv_ind;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa00, %rsp            # imm = 0xA00
leaq 0xc33a3(%rip), %r13     # 0xc7918
cmpq $0x0, (%r13)
je 0x4648
movq %rsi, %r12
movq %rdi, %r14
leaq 0x22f11(%rip), %rdi     # 0x2749e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x60fd
movq %r12, %rdi
callq 0x4376
leaq 0x22f0c(%rip), %rsi     # 0x274b1
leaq 0x20(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2040
andq $0x0, 0x8(%rsp)
leaq 0xa0(%rsp), %r15
pushq $0x1
popq %rcx
movq %r15, %rdi
movq %r12, %rsi
movl %ecx, %edx
callq 0x73f8
cmpq %rax, %r15
jae 0x45f8
movq (%r15), %rcx
testq %rcx, %rcx
je 0x45f2
movslq %ebx, %rdx
shlq $0x4, %rdx
movq %rcx, (%r14,%rdx)
andl $0x0, 0x8(%r14,%rdx)
incl %ebx
addq $0x8, %r15
jmp 0x45d2
cmpl $0x12c, %ebx            # imm = 0x12C
jge 0x466b
leaq 0x10(%rsp), %rcx
movq %r14, (%rcx)
movl %ebx, 0x8(%rcx)
movq (%r13), %rdi
leaq 0x74(%rip), %rdx        # 0x468a
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %r8
callq 0x2250
testl %eax, %eax
je 0x4658
movq 0x8(%rsp), %rsi
leaq 0x22d88(%rip), %rdi     # 0x273bd
xorl %eax, %eax
callq 0x622a
movq 0x8(%rsp), %rdi
callq 0x2200
jmp 0x4658
leaq 0x22e2d(%rip), %rdi     # 0x2747c
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x60fd
movl %ebx, %eax
addq $0xa00, %rsp            # imm = 0xA00
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x22e8d(%rip), %rdi     # 0x274ff
leaq 0x22e91(%rip), %rsi     # 0x2750a
leaq 0x22e97(%rip), %rcx     # 0x27517
movl $0x104, %edx            # imm = 0x104
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/book.cpp
// Function: get_moves_callback(void*, int, char**, char**)
static int get_moves_callback(void *data,int argc,char **argv,char **azColName) {

    mfpn_type* mfpn = (mfpn_type*)data;

    int fromsq = atoi(argv[0]);
    int tosq = atoi(argv[1]);
    int freq = atoi(argv[2]);

    for (int i=0;i<mfpn->n;i++) {
        if (get_from_sq(mfpn->mfp[i].mv)==fromsq && get_to_sq(mfpn->mfp[i].mv)==tosq) {
            mfpn->mfp[i].freq += freq;
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rdi, %rbx
movq (%rdx), %rdi
callq 0x22b0
movl %eax, %ebp
movq 0x8(%r15), %rdi
callq 0x22b0
movl %eax, %r14d
movq 0x10(%r15), %rdi
callq 0x22b0
movl %eax, %r15d
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq 0x8(%rbx), %rax
cmpq %rax, %r13
jge 0x46fe
movq (%rbx), %rax
movq (%rax,%r12), %rdi
callq 0x736b
cmpl %ebp, %eax
jne 0x46f5
movq (%rbx), %rax
movq (%rax,%r12), %rdi
callq 0x7372
cmpl %r14d, %eax
jne 0x46f5
movq (%rbx), %rax
addl %r15d, 0x8(%rax,%r12)
incq %r13
addq $0x10, %r12
jmp 0x46c3
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/draw.cpp
// Function: is_lack_of_mating_material(position*)
bool is_lack_of_mating_material(position *pos) {
    assert(pos);

    int num_knights=0,num_white_sq_bishops=0,num_black_sq_bishops=0;

    for (int sq=0;sq<64;sq++) {
        switch(pos->piece[sq]) {
            // any position with a pawn, rook, or queen is not drawn by lack of mating material
            case PAWN:
            case -PAWN:
            case ROOK:
            case -ROOK:
            case QUEEN:
            case -QUEEN:
                return false;

            // a position with more than one knight is not drawn by lack of mating material
            case KNIGHT:
            case -KNIGHT:
                num_knights++;
                if (num_knights>1) return false;
                if (num_white_sq_bishops>0 || num_black_sq_bishops>0) return false;
                break;

            // a position with bishops on opposite colors is not drawn
            case BISHOP:
            case -BISHOP:
                if (is_light_sq((square_t)sq)) {
                    num_white_sq_bishops++;
                } else {
                    num_black_sq_bishops++;
                }
                if (num_white_sq_bishops>0 && num_black_sq_bishops>0) return false;
                if (num_knights>0) return false;
                break;
        }
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x47cb
movq %rdi, %rbx
xorl %r14d, %r14d
movl $0x88, %ebp
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq $0x40, %r14
je 0x47b5
movl (%rbx,%r14,4), %eax
addl $0x5, %eax
cmpl $0xa, %eax
ja 0x47b0
btl %eax, %ebp
jb 0x4791
movl $0x104, %ecx            # imm = 0x104
btl %eax, %ecx
jae 0x47a6
movl %r14d, %edi
callq 0xc401
movzbl %al, %eax
movl %eax, %ecx
andl $0x1, %ecx
notb %al
movzbl %al, %eax
andl $0x1, %eax
addl %eax, %r15d
addl %ecx, %r13d
setg %al
testl %r15d, %r15d
setg %cl
testb %cl, %al
jne 0x47b5
testl %r12d, %r12d
movl $0x0, %r12d
jle 0x47b0
jmp 0x47b5
testl %r12d, %r12d
jg 0x47b5
testl %r13d, %r13d
jg 0x47b5
pushq $0x1
popq %r12
testl %r15d, %r15d
jle 0x47b0
jmp 0x47b5
movl $0x653, %ecx            # imm = 0x653
btl %eax, %ecx
jb 0x47b5
incq %r14
jmp 0x4738
cmpq $0x40, %r14
setae %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22d87(%rip), %rdi     # 0x27559
leaq 0x22d84(%rip), %rsi     # 0x2755d
leaq 0x22d8a(%rip), %rcx     # 0x2756a
pushq $0x18
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/draw.cpp
// Function: is_draw_by_rep(position*, undo*)
bool is_draw_by_rep(position *pos,undo *undo_stack) {
    assert(pos);
    assert(pos->move_counter >= 0 && pos->move_counter < MAX_MOVES_PER_GAME);
    assert(pos->fifty_counter >= 0 && pos->fifty_counter <= pos->move_counter);
    assert(pos->hash_key==build_hash_key(pos));
    assert(undo_stack);

    uint32 reps = 0;
    for (uint32 i=(pos->move_counter-pos->fifty_counter);i<pos->move_counter;i++) {
        if ((undo_stack+i)->hash_key==pos->hash_key) {
            reps++;
        }
    }

    return reps >= 2;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x4889
movq %rdi, %rbx
movl 0x144(%rdi), %eax
cmpl $0x173c, %eax           # imm = 0x173C
jae 0x48a2
cmpl %eax, 0x148(%rbx)
ja 0x48bb
movq %rsi, %r14
movq 0x1b8(%rbx), %r15
movq %rbx, %rdi
callq 0x5a50
cmpq %rax, %r15
jne 0x48d4
testq %r14, %r14
je 0x48ed
movl 0x144(%rbx), %eax
movl 0x148(%rbx), %edx
movl %eax, %ecx
subl %edx, %ecx
movq %rcx, %rdx
shlq $0x5, %rdx
leaq (%rdx,%r14), %rsi
addq $0x8, %rsi
xorl %edx, %edx
cmpq %rax, %rcx
jae 0x487d
movq (%rsi), %rdi
xorl %r8d, %r8d
cmpq 0x1b8(%rbx), %rdi
sete %r8b
addl %r8d, %edx
incq %rcx
addq $0x20, %rsi
jmp 0x485b
cmpl $0x2, %edx
setae %al
popq %rbx
popq %r14
popq %r15
retq
leaq 0x22cc9(%rip), %rdi     # 0x27559
leaq 0x22cc6(%rip), %rsi     # 0x2755d
leaq 0x22cf8(%rip), %rcx     # 0x27596
pushq $0x41
jmp 0x4904
leaq 0x22d15(%rip), %rdi     # 0x275be
leaq 0x22cad(%rip), %rsi     # 0x2755d
leaq 0x22cdf(%rip), %rcx     # 0x27596
pushq $0x42
jmp 0x4904
leaq 0x22d3d(%rip), %rdi     # 0x275ff
leaq 0x22c94(%rip), %rsi     # 0x2755d
leaq 0x22cc6(%rip), %rcx     # 0x27596
pushq $0x43
jmp 0x4904
leaq 0x22d67(%rip), %rdi     # 0x27642
leaq 0x22c7b(%rip), %rsi     # 0x2755d
leaq 0x22cad(%rip), %rcx     # 0x27596
pushq $0x44
jmp 0x4904
leaq 0x2283c(%rip), %rdi     # 0x27130
leaq 0x22c62(%rip), %rsi     # 0x2755d
leaq 0x22c94(%rip), %rcx     # 0x27596
pushq $0x45
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/drawboard.cpp
// Function: draw_bitboard(unsigned long long)
void draw_bitboard(uint64 bb) {
    char text[100];
    strcpy(text,"");

    for (int i=0;i<64;i++) {
        if (bb & bb_squares[i]) {
            strcat(text,"1");
        } else {
            strcat(text,"0");
        }
        if (get_file((square_t)i)==FILE_H) {
            strcat(text,"\n");
        }
    }

    strcat(text,"\n");
    print(text);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
movq %rsp, %r14
movb $0x0, (%r14)
xorl %r15d, %r15d
leaq 0xf8882(%rip), %r12     # 0xfd4b0
cmpq $0x40, %r15
je 0x4c73
movq (%r12,%r15,8), %r13
andq %rbx, %r13
movq %r14, %rdi
callq 0x2080
cmpq $0x1, %r13
movw $0x31, %cx
sbbw $0x0, %cx
movw %cx, (%rsp,%rax)
movl %r15d, %edi
callq 0xbfd8
cmpl $0x7, %eax
jne 0x4c6e
movq %r14, %rdi
callq 0x2080
movw $0xa, (%rsp,%rax)
incq %r15
jmp 0x4c2e
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x2080
movw $0xa, (%rsp,%rax)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5fdd
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_major_on_7th(position*, square_t, bool)
int32 eval_major_on_7th(position *pos,square_t sq,bool wtm) {
    int32 score = 0;

    if (wtm) {
        if (get_rank(sq)==RANK_7 && get_rank(pos->black_king)==RANK_8) {
            score += rook_on_7th;
            score += eval_connected_major_on_7th(pos,sq,wtm);
        }
    } else {
        if (get_rank(sq)==RANK_2 && get_rank(pos->white_king)==RANK_1) {
            score += rook_on_7th;
            score += eval_connected_major_on_7th(pos,sq,wtm);
        }
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %edi
callq 0xc001
xorl %r15d, %r15d
testl %ebp, %ebp
je 0x4d27
cmpl $0x1, %eax
jne 0x4d52
movl 0x150(%r14), %edi
callq 0xc001
testl %eax, %eax
jne 0x4d52
jmp 0x4d3d
cmpl $0x6, %eax
jne 0x4d52
movl 0x14c(%r14), %edi
callq 0xc001
cmpl $0x7, %eax
jne 0x4d52
movzbl %bpl, %edx
movq %r14, %rdi
movl %ebx, %esi
callq 0x4cab
movl %eax, %r15d
addl $0x32, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_knights(position*)
int32 eval_knights(position *p) {
    int32 score = 0;

    uint64 pmap = p->white_knights;
    while (pmap) {
        square_t sq = (square_t)get_msb(pmap);
        score += eval_knight(p,sq,true);
        pmap ^= bb_squares[sq];
    }

    pmap = p->black_knights;
    while (pmap) {
        square_t sq = (square_t)get_lsb(pmap);
        score -= eval_knight(p,sq,false);
        pmap ^= bb_squares[sq];
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x168(%rdi), %r14
xorl %ebp, %ebp
pushq $0x1
popq %r15
leaq 0xf872e(%rip), %r13     # 0xfd4b0
testq %r14, %r14
je 0x4dab
movq %r14, %rdi
callq 0x3a44
movl %eax, %r12d
movq %rbx, %rdi
movl %eax, %esi
movl %r15d, %edx
callq 0x4deb
addl %eax, %ebp
movl %r12d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x4d82
movq 0x170(%rbx), %r14
testq %r14, %r14
je 0x4dda
movq %r14, %rdi
callq 0x397d
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x4deb
subl %eax, %ebp
movl %r15d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x4db2
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_knight(position*, square_t, bool)
int32 eval_knight(position *p,square_t sq,bool wtm) {
    int score;
    if (wtm) {
        score = knight_pst[sq];
        score += knight_tropism * distance(sq,p->black_king);
    } else {
        score = knight_pst[fliprank[sq]];
        score += knight_tropism * distance(sq,p->white_king);
    }
    return score;
}

// Assembly:
movl %esi, %eax
movl %esi, %ecx
movl $0x150, %esi            # imm = 0x150
testl %edx, %edx
jne 0x4e08
leaq 0x22ab1(%rip), %rdx     # 0x278b0
movslq (%rdx,%rcx,4), %rcx
movl $0x14c, %esi            # imm = 0x14C
pushq %rbx
leaq 0x229a0(%rip), %rdx     # 0x277b0
movl (%rdx,%rcx,4), %ebx
movl (%rdi,%rsi), %esi
movl %eax, %edi
callq 0xc136
addl %eax, %eax
subl %eax, %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_bishops(position*)
int32 eval_bishops(position *p) {
    int32 score = 0;

    uint64 pmap = p->white_bishops;
    while (pmap) {
        square_t sq = (square_t)get_msb(pmap);
        score += eval_bishop(p,sq,true);
        pmap ^= bb_squares[sq];
    }

    pmap = p->black_bishops;
    while (pmap) {
        square_t sq = (square_t)get_lsb(pmap);
        score -= eval_bishop(p,sq,false);
        pmap ^= bb_squares[sq];
    }

    return score;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movq 0x178(%rdi), %r15
xorl %ebx, %ebx
leaq 0x22d6f(%rip), %r12     # 0x27bb0
leaq 0xf8668(%rip), %r13     # 0xfd4b0
testq %r15, %r15
je 0x4e62
movq %r15, %rdi
callq 0x3a44
movl %eax, %eax
addl (%r12,%rax,4), %ebx
xorq (%r13,%rax,8), %r15
jmp 0x4e48
movq 0x180(%r14), %r14
leaq 0x22a40(%rip), %r15     # 0x278b0
testq %r14, %r14
je 0x4e8e
movq %r14, %rdi
callq 0x397d
movl %eax, %eax
movslq (%r15,%rax,4), %rcx
subl (%r12,%rcx,4), %ebx
xorq (%r13,%rax,8), %r14
jmp 0x4e70
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_rook_open_file(position*, square_t, bool)
int32 eval_rook_open_file(position *p,square_t sq,bool wtm) {
    int32 score = 0;

    uint64 friends,enemies;
    if (wtm) {
        friends = p->white_pawns;
        enemies = p->black_pawns;
    } else {
        friends = p->black_pawns;
        enemies = p->white_pawns;
    }

    uint64 file_mask = bb_files[get_file(sq)] ^ bb_squares[sq];
    if (!(file_mask & friends)) {
        if (file_mask & enemies) {
            score += rook_half_open_file;
        } else {
            score += rook_open_file;
        }
    }

    return score;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movl %edx, %eax
movl %edx, %ecx
xorb $0x1, %cl
movzbl %cl, %ecx
movq 0x158(%rdi,%rax,8), %r14
movq 0x158(%rdi,%rcx,8), %r15
movl %esi, %edi
callq 0xbfd8
movl %eax, %eax
leaq 0xf8549(%rip), %rcx     # 0xfd430
movl %ebx, %edx
leaq 0xf85c0(%rip), %rsi     # 0xfd4b0
movq (%rsi,%rdx,8), %rdx
xorq (%rcx,%rax,8), %rdx
testq %r14, %rdx
pushq $0x19
popq %rax
pushq $0xf
popq %rcx
cmovel %eax, %ecx
xorl %eax, %eax
testq %r15, %rdx
cmovel %ecx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_rooks(position*)
int32 eval_rooks(position *p) {
    int32 score = 0;

    uint64 pmap = p->white_rooks;
    while (pmap) {
        square_t sq = (square_t)get_msb(pmap);
        score += eval_rook(p,sq,true);
        pmap ^= bb_squares[sq];
    }

    pmap = p->black_rooks;
    while (pmap) {
        square_t sq = (square_t)get_lsb(pmap);
        score -= eval_rook(p,sq,false);
        pmap ^= bb_squares[sq];
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x188(%rdi), %r14
xorl %ebp, %ebp
pushq $0x1
popq %r15
leaq 0xf857c(%rip), %r13     # 0xfd4b0
testq %r14, %r14
je 0x4f5d
movq %r14, %rdi
callq 0x3a44
movl %eax, %r12d
movq %rbx, %rdi
movl %eax, %esi
movl %r15d, %edx
callq 0x4f9d
addl %eax, %ebp
movl %r12d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x4f34
movq 0x190(%rbx), %r14
testq %r14, %r14
je 0x4f8c
movq %r14, %rdi
callq 0x397d
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x4f9d
subl %eax, %ebp
movl %r15d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x4f64
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_rook(position*, square_t, bool)
int32 eval_rook(position *p,square_t sq,bool wtm) {
    int32 score = wtm ? rook_pst[sq] : rook_pst[fliprank[sq]];
    score += eval_major_on_7th(p,sq,wtm);
    score += eval_rook_open_file(p,sq,wtm);
    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %r12d
testl %edx, %edx
jne 0x4fbf
leaq 0x228f5(%rip), %rax     # 0x278b0
movslq (%rax,%r12,4), %r12
leaq 0x22cea(%rip), %r13     # 0x27cb0
movzbl %dl, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x4cf4
movl %eax, %r15d
addl (%r13,%r12,4), %r15d
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x4eb6
addl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_queens(position*)
int32 eval_queens(position *p) {
    int32 score = 0;

    uint64 pmap = p->white_queens;
    while (pmap) {
        square_t sq = (square_t)get_msb(pmap);
        score += eval_queen(p,sq,true);
        pmap ^= bb_squares[sq];
    }

    pmap = p->black_queens;
    while (pmap) {
        square_t sq = (square_t)get_lsb(pmap);
        score -= eval_queen(p,sq,false);
        pmap ^= bb_squares[sq];
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x198(%rdi), %r14
xorl %ebp, %ebp
pushq $0x1
popq %r15
leaq 0xf8493(%rip), %r13     # 0xfd4b0
testq %r14, %r14
je 0x5046
movq %r14, %rdi
callq 0x3a44
movl %eax, %r12d
movq %rbx, %rdi
movl %eax, %esi
movl %r15d, %edx
callq 0x5086
addl %eax, %ebp
movl %r12d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x501d
movq 0x1a0(%rbx), %r14
testq %r14, %r14
je 0x5075
movq %r14, %rdi
callq 0x397d
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x5086
subl %eax, %ebp
movl %r15d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x504d
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_kings(position*, int32_pair)
int32 eval_kings(position *p,int32_pair npmat) {
    int32 score = 0;

    const int endgame_threshold = knight_val*2 + rook_val;

    // if black has a lot of material then eval white in the middle game
    if (npmat.val2 >= endgame_threshold) {
        score += king_pst[p->white_king];
        score += eval_scale(eval_king_safety(p,true),npmat.val2);
    } else {
        score += king_endgame_pst[p->white_king];
    }

    if (npmat.val1 >= endgame_threshold) {
        score -= king_pst[fliprank[p->black_king]];
        score -= eval_scale(eval_king_safety(p,false),npmat.val1);
    } else {
        score -= king_endgame_pst[fliprank[p->black_king]];
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %r13
shrq $0x20, %r13
movl 0x14c(%rdi), %r12d
leaq 0x229d4(%rip), %r15     # 0x27ab0
cmpl $0x44c, %r13d           # imm = 0x44C
jl 0x5104
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x5520
imull %r13d, %eax
movl $0xc44, %ecx            # imm = 0xC44
cltd
idivl %ecx
movl %eax, %ebp
addl (%r15,%r12,4), %ebp
jmp 0x510f
leaq 0x22ca5(%rip), %rax     # 0x27db0
movl (%rax,%r12,4), %ebp
movl 0x150(%r14), %eax
leaq 0x22793(%rip), %rcx     # 0x278b0
movslq (%rcx,%rax,4), %r12
cmpl $0x44c, %ebx            # imm = 0x44C
jl 0x5144
movq %r14, %rdi
xorl %esi, %esi
callq 0x5520
imull %ebx, %eax
movl $0xc44, %ecx            # imm = 0xC44
cltd
idivl %ecx
addl (%r15,%r12,4), %eax
jmp 0x514f
leaq 0x22c65(%rip), %rax     # 0x27db0
movl (%rax,%r12,4), %eax
subl %eax, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_pawns_no_hash(position*)
int32 eval_pawns_no_hash(position *p) {
    int32 score = 0;

    uint64 pmap = p->white_pawns;
    while (pmap) {
        square_t sq = (square_t)get_msb(pmap);
        score += eval_pawn(p,sq,true);
        pmap ^= bb_squares[sq];
    }

    pmap = p->black_pawns;
    while (pmap) {
        square_t sq = (square_t)get_lsb(pmap);
        score -= eval_pawn(p,sq,false);
        pmap ^= bb_squares[sq];
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x158(%rdi), %r14
xorl %ebp, %ebp
pushq $0x1
popq %r15
leaq 0xf831e(%rip), %r13     # 0xfd4b0
testq %r14, %r14
je 0x51bb
movq %r14, %rdi
callq 0x3a44
movl %eax, %r12d
movq %rbx, %rdi
movl %eax, %esi
movl %r15d, %edx
callq 0x5794
addl %eax, %ebp
movl %r12d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x5192
movq 0x160(%rbx), %r14
testq %r14, %r14
je 0x51ea
movq %r14, %rdi
callq 0x397d
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x5794
subl %eax, %ebp
movl %r15d, %eax
xorq (%r13,%rax,8), %r14
jmp 0x51c2
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_pawns(position*)
int32 eval_pawns(position *p) {

    int32 score;

    // try the pawn hash
    uint64 val = get_hash_entry(&phtbl,p->pawn_key);
    if (val != 0) {
        score = get_pawn_hash_entry_score(val);
        assert(score==eval_pawns_no_hash(p));
    } else {
        score = eval_pawns_no_hash(p);
        // store (always replace)
        store_hash_entry(&phtbl,p->pawn_key,build_pawn_hash_val(score));
    }

    return score;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x1c0(%rdi), %rsi
leaq 0xf5d10(%rip), %rdi     # 0xfaf20
callq 0x5e2e
testq %rax, %rax
je 0x524f
movq %rax, %rdi
callq 0x5d2e
movl %eax, %ebx
movq %r14, %rdi
callq 0x5170
cmpl %eax, %ebx
je 0x5279
leaq 0x22c89(%rip), %rdi     # 0x27ec0
leaq 0x22c9f(%rip), %rsi     # 0x27edd
leaq 0x22ca5(%rip), %rcx     # 0x27eea
movl $0xed, %edx
callq 0x20c0
movq %r14, %rdi
callq 0x5170
movl %eax, %ebx
movq 0x1c0(%r14), %r14
movl %eax, %edi
callq 0x5cc3
leaq 0xf5cb2(%rip), %rdi     # 0xfaf20
movq %r14, %rsi
movq %rax, %rdx
callq 0x5e8b
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_nonpawn_material(position*)
int32_pair eval_nonpawn_material(position *p) {
    int32_pair score;

    score.val1 = p->piece_counts[WHITE][ROOK] * rook_val
            + p->piece_counts[WHITE][KNIGHT] * knight_val
            + p->piece_counts[WHITE][BISHOP] * bishop_val
            + p->piece_counts[WHITE][QUEEN] * queen_val;

    score.val2 = p->piece_counts[BLACK][ROOK] * rook_val
            + p->piece_counts[BLACK][KNIGHT] * knight_val
            + p->piece_counts[BLACK][BISHOP] * bishop_val
            + p->piece_counts[BLACK][QUEEN] * queen_val;

    assert(score.val1==eval_nonpawn_material_slow(p).val1);
    assert(score.val2==eval_nonpawn_material_slow(p).val2);


    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movdqu 0x124(%rdi), %xmm0
movdqa 0x22ba1(%rip), %xmm1    # 0x27eb0
pshufd $0xf5, %xmm0, %xmm2     # xmm2 = xmm0[1,1,3,3]
pmuludq %xmm1, %xmm0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
pmuludq %xmm2, %xmm1
pshufd $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,3]
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddd %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
paddd %xmm1, %xmm0
movd %xmm0, %ebx
imull $0x1f4, 0x110(%rdi), %r15d # imm = 0x1F4
imull $0x12c, 0x108(%rdi), %ebp # imm = 0x12C
imull $0x140, 0x10c(%rdi), %r14d # imm = 0x140
imull $0x384, 0x114(%rdi), %r12d # imm = 0x384
callq 0x5283
cmpl %eax, %ebx
jne 0x539d
addl %r15d, %ebp
addl %r12d, %r14d
addl %ebp, %r14d
shrq $0x20, %rax
cmpl %eax, %r14d
jne 0x53bc
shlq $0x20, %r14
movl %ebx, %eax
orq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22b63(%rip), %rdi     # 0x27f07
leaq 0x22b32(%rip), %rsi     # 0x27edd
leaq 0x22b84(%rip), %rcx     # 0x27f36
movl $0x12a, %edx            # imm = 0x12A
callq 0x20c0
leaq 0x22ba0(%rip), %rdi     # 0x27f63
leaq 0x22b13(%rip), %rsi     # 0x27edd
leaq 0x22b65(%rip), %rcx     # 0x27f36
movl $0x12b, %edx            # imm = 0x12B
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_pawn_material_slow(position*)
int32_pair eval_pawn_material_slow(position *p) {
    int32_pair score;
    score.val1 = 0;
    score.val2 = 0;

    for (int sq=0;sq<64;sq++) {
        switch(p->piece[sq]) {
        case PAWN:
            score.val1 += pawn_val;
            break;
        case -PAWN:
            score.val2 += pawn_val;
            break;
        }
    }

    return score;
}

// Assembly:
xorl %edx, %edx
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x40, %rdx
je 0x5401
movl (%rdi,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x53f9
cmpl $0x1, %esi
jne 0x53fc
addl $0x64, %eax
jmp 0x53fc
addl $0x64, %ecx
incq %rdx
jmp 0x53e1
shlq $0x20, %rcx
movl %eax, %eax
orq %rcx, %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval_pawn_material(position*)
int32_pair eval_pawn_material(position *p) {
    int32_pair score;
    score.val1 = p->piece_counts[WHITE][PAWN] * pawn_val;
    score.val2 = p->piece_counts[BLACK][PAWN] * pawn_val;

    assert(score.val1==eval_pawn_material_slow(p).val1);
    assert(score.val2==eval_pawn_material_slow(p).val2);

    return score;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
imull $0x64, 0x120(%rdi), %ebp
imull $0x64, 0x104(%rdi), %ebx
callq 0x53db
cmpl %eax, %ebp
jne 0x543d
shrq $0x20, %rax
cmpl %eax, %ebx
jne 0x545c
shlq $0x20, %rbx
movl %ebp, %eax
orq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x22b4e(%rip), %rdi     # 0x27f92
leaq 0x22a92(%rip), %rsi     # 0x27edd
leaq 0x22b6c(%rip), %rcx     # 0x27fbe
movl $0x149, %edx            # imm = 0x149
callq 0x20c0
leaq 0x22b85(%rip), %rdi     # 0x27fe8
leaq 0x22a73(%rip), %rsi     # 0x27edd
leaq 0x22b4d(%rip), %rcx     # 0x27fbe
movl $0x14a, %edx            # imm = 0x14A
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/eval.cpp
// Function: eval(position*, bool)
int32 eval(position *p,bool mat_only) {
    int32 score = 0;

    int32_pair npmat = eval_nonpawn_material(p);
    score += npmat.val1 - npmat.val2;

    int32_pair pmat = eval_pawn_material(p);
    score += pmat.val1 - pmat.val2;

    if (!mat_only) {
        score += eval_pawns(p);
        score += eval_knights(p);
        score += eval_bishops(p);
        score += eval_rooks(p);
        score += eval_queens(p);
        score += eval_kings(p,npmat);
    }

    return p->player==WHITE ? score : -score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
callq 0x52f7
movq %rax, %r14
shrq $0x20, %rax
movl %r14d, %r12d
subl %eax, %r12d
movq %rbx, %rdi
callq 0x540b
movq %rax, %r15
shrq $0x20, %rax
subl %eax, %r15d
addl %r12d, %r15d
testl %ebp, %ebp
jne 0x5507
movq %rbx, %rdi
callq 0x51fb
movl %eax, %ebp
movq %rbx, %rdi
callq 0x4d60
movl %eax, %r12d
addl %ebp, %r12d
movq %rbx, %rdi
callq 0x4e25
movl %eax, %ebp
addl %r12d, %ebp
movq %rbx, %rdi
callq 0x4f12
movl %eax, %r12d
addl %ebp, %r12d
addl %r15d, %r12d
movq %rbx, %rdi
callq 0x4ffb
movl %eax, %ebp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x50b6
movl %eax, %r15d
addl %ebp, %r15d
addl %r12d, %r15d
movl %r15d, %eax
negl %eax
cmpl $0x1, 0x138(%rbx)
cmovel %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/evalp.cpp
// Function: eval_pawn(position*, square_t, bool)
int32 eval_pawn(position *p,square_t sq,bool wtm) {
    int32 score = wtm ? pawn_pst[sq] : pawn_pst[fliprank[sq]];

    if (is_passed(p,sq,wtm)) {
        score += passed_pawn;
    }
    if (is_doubled(p,sq,wtm)) {
        score += doubled_pawn;
    }
    if (is_isolated(p,sq,wtm)) {
        score += isolated_pawn;
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %eax
testl %edx, %edx
jne 0x57b2
leaq 0x22872(%rip), %rcx     # 0x28020
movslq (%rcx,%rax,4), %rax
leaq 0x22967(%rip), %rcx     # 0x28120
movl (%rcx,%rax,4), %r15d
movzbl %dl, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x580e
leal 0x14(%r15), %r12d
testb %al, %al
cmovel %r15d, %r12d
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x5866
leal -0xa(%r12), %r15d
testb %al, %al
cmovel %r12d, %r15d
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x58e2
leal -0x14(%r15), %ecx
testb %al, %al
cmovel %r15d, %ecx
movl %ecx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/evalp.cpp
// Function: is_doubled(position*, square_t, bool)
bool is_doubled(position *pos,square_t pawn_sq,bool wtm) {
    assert( (wtm && pos->piece[pawn_sq]==PAWN) || (!wtm && pos->piece[pawn_sq]==-PAWN));

    uint64 file_mask = bb_files[get_file(pawn_sq)] ^ bb_squares[pawn_sq];

    if (wtm){
        if (file_mask & pos->white_pawns) return true;
    } else {
        if (file_mask & pos->black_pawns) return true;
    }

    return false;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rdi, %rbx
movl %esi, %r14d
movl (%rdi,%r14,4), %eax
testl %edx, %edx
je 0x589c
cmpl $0x1, %eax
je 0x58a1
leaq 0x2299a(%rip), %rdi     # 0x28220
leaq 0x229de(%rip), %rsi     # 0x2826b
leaq 0x229e5(%rip), %rcx     # 0x28279
pushq $0x22
popq %rdx
callq 0x20c0
cmpl $-0x1, %eax
jne 0x587f
movl %esi, %edi
callq 0xbfd8
movl %eax, %eax
leaq 0xf7b7f(%rip), %rdx     # 0xfd430
leaq 0xf7bf8(%rip), %rcx     # 0xfd4b0
movq (%rcx,%r14,8), %rcx
xorq (%rdx,%rax,8), %rcx
movb $0x1, %al
testb %bpl, %bpl
je 0x58d2
testq %rcx, 0x158(%rbx)
jne 0x58dd
jmp 0x58db
testq %rcx, 0x160(%rbx)
jne 0x58dd
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq