LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/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 0xbdf0c(%rip), %rdx     # 0xc24b0
movq %rdi, %rsi
xorl %ecx, %ecx
movl (%rsi), %r8d
testl %r8d, %r8d
je 0x45d7
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 $0x4, %rsi
addq $0x8, %rax
cmpq $0x200, %rax            # imm = 0x200
jne 0x45a9
movd 0x140(%rdi), %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pand 0x24d94(%rip), %xmm0    # 0x29390
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 0xbfaba(%rip), %xmm1    # 0xc40d0
pandn 0xbfaa2(%rip), %xmm0    # 0xc40c0
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 0x464a
leaq 0xbfa9a(%rip), %rdx     # 0xc40e0
xorq (%rdx,%rcx,8), %rax
movl 0x138(%rdi), %ecx
leaq 0xbfa59(%rip), %rdx     # 0xc40b0
xorq (%rdx,%rcx,8), %rax
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x12e8, %rsp           # imm = 0x12E8
movq %rdi, %rsi
leaq 0x20(%rsp), %rdi
callq 0x47b6
testl %eax, %eax
jle 0x4765
movl %eax, 0xc(%rsp)
movl %eax, %r12d
movq %r12, %r13
shlq $0x4, %r13
leaq 0x18(%rsp), %rbx
leaq 0x24da9(%rip), %r15     # 0x29445
xorl %ebp, %ebp
xorl %r14d, %r14d
cmpl $0x0, 0x28(%rsp,%rbp)
jle 0x46cb
movq 0x20(%rsp,%rbp), %rdi
movq %rbx, %rsi
callq 0xe09f
movl 0x28(%rsp,%rbp), %edx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x65d9
addl 0x28(%rsp,%rbp), %r14d
addq $0x10, %rbp
cmpq %rbp, %r13
jne 0x46a1
leaq 0x24d85(%rip), %rdi     # 0x29460
xorl %ebx, %ebx
movl %r14d, %esi
xorl %eax, %eax
callq 0x65d9
testl %r14d, %r14d
je 0x47a1
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x2140
movl %eax, %edi
callq 0x2150
callq 0x2060
cvtsi2sd %eax, %xmm1
divsd 0x24c8f(%rip), %xmm1    # 0x293a0
cvtsi2sd %r14d, %xmm0
mulsd %xmm1, %xmm0
leaq 0x24d51(%rip), %rdi     # 0x29472
movsd %xmm0, 0x10(%rsp)
movb $0x1, %al
callq 0x65d9
cmpl $0x0, 0xc(%rsp)
jle 0x47a1
shlq $0x4, %r12
xorl %eax, %eax
xorl %ebp, %ebp
movsd 0x10(%rsp), %xmm1
movl 0x28(%rsp,%rax), %ecx
testl %ecx, %ecx
jle 0x475a
addl %ecx, %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
ucomisd %xmm1, %xmm0
jae 0x4779
addq $0x10, %rax
cmpq %rax, %r12
jne 0x4743
jmp 0x47a1
leaq 0x24cf4(%rip), %rdi     # 0x29460
xorl %ebx, %ebx
xorl %esi, %esi
xorl %eax, %eax
callq 0x65d9
jmp 0x47a1
movq 0x20(%rsp,%rax), %rbx
leaq 0x18(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe09f
leaq 0x24cf2(%rip), %rdi     # 0x29487
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x65d9
movq %rbx, %rax
addq $0x12e8, %rsp           # imm = 0x12E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0xc014b(%rip), %r13     # 0xc4918
cmpq $0x0, (%r13)
je 0x48b3
movq %rsi, %r12
movq %rdi, %r14
leaq 0x24ce9(%rip), %rdi     # 0x294ce
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x65d9
movq %r12, %rdi
callq 0x459b
leaq 0x24ce4(%rip), %rsi     # 0x294e1
leaq 0x20(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2040
movq $0x0, 0x8(%rsp)
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x78e0
cmpq %rax, %r15
jae 0x486b
xorl %ebx, %ebx
movq (%r15), %rcx
testq %rcx, %rcx
je 0x485a
movslq %ebx, %rbx
movq %rbx, %rdx
shlq $0x4, %rdx
movq %rcx, (%r14,%rdx)
movl $0x0, 0x8(%r14,%rdx)
incl %ebx
addq $0x8, %r15
cmpq %rax, %r15
jb 0x4839
cmpl $0x12c, %ebx            # imm = 0x12C
jge 0x48d6
leaq 0x10(%rsp), %rcx
movq %r14, (%rcx)
movl %ebx, 0x8(%rcx)
movq (%r13), %rdi
leaq 0x74(%rip), %rdx        # 0x48f5
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %r8
callq 0x2250
testl %eax, %eax
je 0x48c3
movq 0x8(%rsp), %rsi
leaq 0x24b4d(%rip), %rdi     # 0x293ed
xorl %eax, %eax
callq 0x2330
movq 0x8(%rsp), %rdi
callq 0x2200
jmp 0x48c3
leaq 0x24bf2(%rip), %rdi     # 0x294ac
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x65d9
movl %ebx, %eax
addq $0xa00, %rsp            # imm = 0xA00
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x24c52(%rip), %rdi     # 0x2952f
leaq 0x24c56(%rip), %rsi     # 0x2953a
leaq 0x24c5c(%rip), %rcx     # 0x29547
movl $0x104, %edx            # imm = 0x104
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/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
cmpl $0x0, 0x8(%rbx)
jle 0x496d
movl %eax, %r15d
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rbx), %rax
movq (%rax,%r12), %rdi
callq 0x7854
cmpl %ebp, %eax
jne 0x495d
movq (%rbx), %rax
movq (%rax,%r12), %rdi
callq 0x785b
cmpl %r14d, %eax
jne 0x495d
movq (%rbx), %rax
addl %r15d, 0x8(%rax,%r12)
incq %r13
movslq 0x8(%rbx), %rax
addq $0x10, %r12
cmpq %rax, %r13
jl 0x4934
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_O3/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 0x4a4e
movq %rdi, %rbx
xorl %r14d, %r14d
movl $0x88, %ecx
xorl %r15d, %r15d
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %ebp, %ebp
movl (%rbx,%r14,4), %eax
addl $0x5, %eax
cmpl $0xa, %eax
ja 0x4a1f
btl %eax, %ecx
jb 0x4a00
movl $0x104, %edx            # imm = 0x104
btl %eax, %edx
jae 0x4a15
movl %r14d, %edi
callq 0xcdf5
movzbl %al, %eax
movl %eax, %ecx
andl $0x1, %ecx
notb %al
movzbl %al, %eax
andl $0x1, %eax
addl %eax, %r13d
addl %ecx, %r12d
setg %al
testl %r13d, %r13d
setg %cl
testb %cl, %al
jne 0x4a38
testl %ebp, %ebp
movl $0x0, %ebp
movl $0x88, %ecx
jle 0x4a1f
jmp 0x4a38
testl %ebp, %ebp
jg 0x4a38
testl %r12d, %r12d
jg 0x4a38
movl $0x1, %ebp
testl %r13d, %r13d
jle 0x4a1f
jmp 0x4a38
movl $0x653, %edx            # imm = 0x653
btl %eax, %edx
jb 0x4a38
cmpq $0x3f, %r14
leaq 0x1(%r14), %rax
setae %r15b
movq %rax, %r14
cmpq $0x40, %rax
jne 0x49aa
andb $0x1, %r15b
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24b34(%rip), %rdi     # 0x29589
leaq 0x24b31(%rip), %rsi     # 0x2958d
leaq 0x24b37(%rip), %rcx     # 0x2959a
movl $0x18, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/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 0x4b0d
movq %rdi, %r14
movl 0x144(%rdi), %eax
cmpl $0x173c, %eax           # imm = 0x173C
jae 0x4b2c
cmpl %eax, 0x148(%r14)
ja 0x4b4b
movq %rsi, %rbx
movq 0x1b8(%r14), %r15
movq %r14, %rdi
callq 0x5ee8
cmpq %rax, %r15
jne 0x4b6a
testq %rbx, %rbx
je 0x4b89
movl 0x144(%r14), %ecx
movl %ecx, %esi
subl 0x148(%r14), %esi
xorl %eax, %eax
cmpl %ecx, %esi
jae 0x4b07
movq 0x1b8(%r14), %rdx
movl %esi, %esi
subq %rsi, %rcx
shlq $0x5, %rsi
addq %rbx, %rsi
addq $0x8, %rsi
xorl %edi, %edi
cmpq %rdx, (%rsi)
sete %dil
addl %edi, %eax
addq $0x20, %rsi
decq %rcx
jne 0x4aed
cmpl $0x2, %eax
setae %al
popq %rbx
popq %r14
popq %r15
retq
leaq 0x24a75(%rip), %rdi     # 0x29589
leaq 0x24a72(%rip), %rsi     # 0x2958d
leaq 0x24aa4(%rip), %rcx     # 0x295c6
movl $0x41, %edx
callq 0x20d0
leaq 0x24abb(%rip), %rdi     # 0x295ee
leaq 0x24a53(%rip), %rsi     # 0x2958d
leaq 0x24a85(%rip), %rcx     # 0x295c6
movl $0x42, %edx
callq 0x20d0
leaq 0x24add(%rip), %rdi     # 0x2962f
leaq 0x24a34(%rip), %rsi     # 0x2958d
leaq 0x24a66(%rip), %rcx     # 0x295c6
movl $0x43, %edx
callq 0x20d0
leaq 0x24b01(%rip), %rdi     # 0x29672
leaq 0x24a15(%rip), %rsi     # 0x2958d
leaq 0x24a47(%rip), %rcx     # 0x295c6
movl $0x44, %edx
callq 0x20d0
leaq 0x245a0(%rip), %rdi     # 0x29130
leaq 0x249f6(%rip), %rsi     # 0x2958d
leaq 0x24a28(%rip), %rcx     # 0x295c6
movl $0x45, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf55ec(%rip), %r12     # 0xfa4b0
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 0xca3e
cmpl $0x7, %eax
jne 0x4efe
movq %r14, %rdi
callq 0x2080
movw $0xa, (%rsp,%rax)
incq %r15
cmpq $0x40, %r15
jne 0x4ec4
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x2080
movw $0xa, (%rsp,%rax)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x64b9
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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, %r14d
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %edi
callq 0xca69
testl %r14d, %r14d
je 0x4fca
xorl %r14d, %r14d
cmpl $0x1, %eax
jne 0x5024
movl 0x150(%rbx), %edi
callq 0xca69
testl %eax, %eax
jne 0x5024
movl $0x198, %r15d           # imm = 0x198
movl $0x188, %r14d           # imm = 0x188
jmp 0x4fee
xorl %r14d, %r14d
cmpl $0x6, %eax
jne 0x5024
movl 0x14c(%rbx), %edi
callq 0xca69
cmpl $0x7, %eax
jne 0x5024
movl $0x1a0, %r15d           # imm = 0x1A0
movl $0x190, %r14d           # imm = 0x190
movl %ebp, %eax
shlq $0x6, %rax
leaq 0xf5eb5(%rip), %rcx     # 0xfaeb0
movq 0x10(%rcx,%rax), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6828
movq (%rbx,%r15), %rcx
orq (%rbx,%r14), %rcx
testq %rax, %rcx
movl $0x32, %eax
movl $0x82, %r14d
cmovel %eax, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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), %r15
xorl %r14d, %r14d
testq %r15, %r15
je 0x5090
leaq 0x2478a(%rip), %r12     # 0x297e0
leaq 0xf5453(%rip), %r13     # 0xfa4b0
movq %r15, %rdi
callq 0x3c31
movl %eax, %ebp
movl 0x150(%rbx), %esi
movl %eax, %edi
callq 0xcb96
addl (%r12,%rbp,4), %r14d
addl %eax, %eax
subl %eax, %r14d
movq (%r13,%rbp,8), %rax
movq %rax, %rcx
xorq %r15, %rcx
cmpq %r15, %rax
movq %rcx, %r15
jne 0x505d
movq 0x170(%rbx), %r15
testq %r15, %r15
je 0x50e8
leaq 0xf540d(%rip), %rbp     # 0xfa4b0
movq %r15, %rdi
callq 0x3b67
movl %eax, %r12d
leaq 0x2482b(%rip), %rcx     # 0x298e0
movslq (%rcx,%r12,4), %r13
movl 0x14c(%rbx), %esi
movl %eax, %edi
callq 0xcb96
leaq 0x24713(%rip), %rcx     # 0x297e0
subl (%rcx,%r13,4), %r14d
leal (%r14,%rax,2), %r14d
movq (%rbp,%r12,8), %rax
movq %rax, %rcx
xorq %r15, %rcx
cmpq %r15, %rax
movq %rcx, %r15
jne 0x50a3
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x5117
leaq 0x247d2(%rip), %rdx     # 0x298e0
movslq (%rdx,%rcx,4), %rcx
movl $0x14c, %esi            # imm = 0x14C
pushq %rbx
leaq 0x246c1(%rip), %rdx     # 0x297e0
movl (%rdx,%rcx,4), %ebx
movl (%rdi,%rsi), %esi
movl %eax, %edi
callq 0xcb96
addl %eax, %eax
subl %eax, %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/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
testq %r15, %r15
je 0x517d
leaq 0x24a8b(%rip), %r12     # 0x29be0
leaq 0xf5354(%rip), %r13     # 0xfa4b0
movq %r15, %rdi
callq 0x3c31
movl %eax, %eax
addl (%r12,%rax,4), %ebx
movq (%r13,%rax,8), %rax
movq %rax, %rcx
xorq %r15, %rcx
cmpq %r15, %rax
movq %rcx, %r15
jne 0x515c
movq 0x180(%r14), %r14
testq %r14, %r14
je 0x51c3
leaq 0x24750(%rip), %r15     # 0x298e0
leaq 0x24a49(%rip), %r12     # 0x29be0
leaq 0xf5312(%rip), %r13     # 0xfa4b0
movq %r14, %rdi
callq 0x3b67
movl %eax, %eax
movslq (%r15,%rax,4), %rcx
subl (%r12,%rcx,4), %ebx
movq (%r13,%rax,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x519e
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0xca3e
movl %eax, %eax
leaq 0xf5214(%rip), %rcx     # 0xfa430
movl %ebx, %edx
leaq 0xf528b(%rip), %rsi     # 0xfa4b0
movq (%rsi,%rdx,8), %rdx
xorq (%rcx,%rax,8), %rdx
testq %r14, %rdx
movl $0x19, %eax
movl $0xf, %ecx
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_O3/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 %r12
pushq %rbx
movq %rdi, %rbx
movq 0x188(%rdi), %r14
xorl %ebp, %ebp
testq %r14, %r14
je 0x529c
leaq 0xf5245(%rip), %r12     # 0xfa4b0
movq %r14, %rdi
callq 0x3c31
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x52e8
addl %eax, %ebp
movl %r15d, %eax
movq (%r12,%rax,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x526b
movq 0x190(%rbx), %r14
testq %r14, %r14
je 0x52dd
leaq 0xf5201(%rip), %r12     # 0xfa4b0
movq %r14, %rdi
callq 0x3b67
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x52e8
subl %eax, %ebp
movl %r15d, %eax
movq (%r12,%rax,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x52af
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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
movq %r12, %r13
testl %edx, %edx
jne 0x530d
leaq 0x245d7(%rip), %rax     # 0x298e0
movslq (%rax,%r12,4), %r13
movzbl %dl, %r15d
movq %r14, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0x4f8a
movl %eax, %ebp
leaq 0x249b9(%rip), %rax     # 0x29ce0
addl (%rax,%r13,4), %ebp
movl %r15d, %eax
xorb $0x1, %al
movzbl %al, %eax
movq 0x158(%r14,%r15,8), %r15
movq 0x158(%r14,%rax,8), %r14
movl %ebx, %edi
callq 0xca3e
movl %eax, %eax
leaq 0xf50dd(%rip), %rcx     # 0xfa430
leaq 0xf5156(%rip), %rdx     # 0xfa4b0
movq (%rdx,%r12,8), %rdx
xorq (%rcx,%rax,8), %rdx
testq %r15, %rdx
movl $0x19, %eax
movl $0xf, %ecx
cmovel %eax, %ecx
xorl %eax, %eax
testq %r14, %rdx
cmovel %ecx, %eax
addl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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
testq %r14, %r14
je 0x53e7
leaq 0x24632(%rip), %r15     # 0x299e0
leaq 0xf50fb(%rip), %r12     # 0xfa4b0
movq %r14, %rdi
callq 0x3c31
movl %eax, %r13d
movq %rbx, %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x4f8a
addl (%r15,%r13,4), %ebp
addl %eax, %ebp
movq (%r12,%r13,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x53b5
movq 0x1a0(%rbx), %r14
testq %r14, %r14
je 0x543c
leaq 0xf50b6(%rip), %r13     # 0xfa4b0
movq %r14, %rdi
callq 0x3b67
movl %eax, %r15d
leaq 0x244d4(%rip), %rcx     # 0x298e0
movslq (%rcx,%r15,4), %r12
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x4f8a
leaq 0x245bd(%rip), %rcx     # 0x299e0
addl (%rcx,%r12,4), %eax
subl %eax, %ebp
movq (%r13,%r15,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x53fa
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_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rbx
shrq $0x20, %rbx
movl 0x14c(%rdi), %r13d
leaq 0x2463f(%rip), %r12     # 0x29ae0
cmpl $0x44c, %ebx            # imm = 0x44C
jl 0x54d9
movq %r15, %rdi
movl $0x1, %esi
callq 0x599c
imull %ebx, %eax
movslq %eax, %rbx
imulq $-0x59078029, %rbx, %rax # imm = 0xA6F87FD7
shrq $0x20, %rax
addl %eax, %ebx
movl %ebx, %eax
shrl $0x1f, %eax
sarl $0xb, %ebx
addl %eax, %ebx
addl (%r12,%r13,4), %ebx
jmp 0x54e4
leaq 0x24900(%rip), %rax     # 0x29de0
movl (%rax,%r13,4), %ebx
movl 0x150(%r15), %eax
leaq 0x243ee(%rip), %rcx     # 0x298e0
movslq (%rcx,%rax,4), %r13
cmpl $0x44c, %r14d           # imm = 0x44C
jl 0x552c
movq %r15, %rdi
xorl %esi, %esi
callq 0x599c
imull %r14d, %eax
cltq
imulq $-0x59078029, %rax, %rcx # imm = 0xA6F87FD7
shrq $0x20, %rcx
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
sarl $0xb, %eax
addl %ecx, %eax
addl (%r12,%r13,4), %eax
jmp 0x5537
leaq 0x248ad(%rip), %rax     # 0x29de0
movl (%rax,%r13,4), %eax
subl %eax, %ebx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
movq %rdi, %rbx
movq 0x158(%rdi), %r14
xorl %ebp, %ebp
testq %r14, %r14
je 0x55b4
leaq 0xf4f2d(%rip), %r12     # 0xfa4b0
movq %r14, %rdi
callq 0x3c31
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x5c24
addl %eax, %ebp
movl %r15d, %eax
movq (%r12,%rax,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x5583
movq 0x160(%rbx), %r14
testq %r14, %r14
je 0x55f5
leaq 0xf4ee9(%rip), %r12     # 0xfa4b0
movq %r14, %rdi
callq 0x3b67
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x5c24
subl %eax, %ebp
movl %r15d, %eax
movq (%r12,%rax,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x55c7
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf290b(%rip), %rdi     # 0xf7f20
callq 0x6312
testq %rax, %rax
je 0x5654
movq %rax, %rdi
callq 0x6209
movl %eax, %ebx
movq %r14, %rdi
callq 0x5563
cmpl %eax, %ebx
je 0x567e
leaq 0x248d4(%rip), %rdi     # 0x29f10
leaq 0x248ea(%rip), %rsi     # 0x29f2d
leaq 0x248f0(%rip), %rcx     # 0x29f3a
movl $0xed, %edx
callq 0x20d0
movq %r14, %rdi
callq 0x5563
movl %eax, %ebx
movq 0x1c0(%r14), %r14
movl %eax, %edi
callq 0x619c
leaq 0xf28ad(%rip), %rdi     # 0xf7f20
movq %r14, %rsi
movq %rax, %rdx
callq 0x636f
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x247ca(%rip), %xmm1    # 0x29ee0
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
imull $0x1f4, 0x110(%rdi), %r15d # imm = 0x1F4
imull $0x12c, 0x108(%rdi), %ebp # imm = 0x12C
movd %xmm0, %ebx
movl 0x10c(%rdi), %r12d
imull $0x384, 0x114(%rdi), %r14d # imm = 0x384
callq 0x5688
cmpl %eax, %ebx
jne 0x57a5
addl %r15d, %ebp
leal (%r12,%r12,4), %ecx
shll $0x6, %ecx
addl %r14d, %ecx
addl %ebp, %ecx
shrq $0x20, %rax
cmpl %eax, %ecx
jne 0x57c4
shlq $0x20, %rcx
movl %ebx, %eax
orq %rcx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x247ab(%rip), %rdi     # 0x29f57
leaq 0x2477a(%rip), %rsi     # 0x29f2d
leaq 0x247cc(%rip), %rcx     # 0x29f86
movl $0x12a, %edx            # imm = 0x12A
callq 0x20d0
leaq 0x247e8(%rip), %rdi     # 0x29fb3
leaq 0x2475b(%rip), %rsi     # 0x29f2d
leaq 0x247ad(%rip), %rcx     # 0x29f86
movl $0x12b, %edx            # imm = 0x12B
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/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 %ecx, %ecx
xorl %eax, %eax
movl (%rdi,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x57fb
cmpl $0x1, %esi
jne 0x57fe
addl $0x64, %eax
jmp 0x57fe
addl $0x64, %ecx
incq %rdx
cmpq $0x40, %rdx
jne 0x57e9
shlq $0x20, %rcx
movl %eax, %eax
orq %rcx, %rax
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 %rax
movl 0x104(%rdi), %ecx
movl 0x120(%rdi), %edx
pxor %xmm1, %xmm1
xorl %eax, %eax
movdqa 0x246c4(%rip), %xmm2    # 0x29ef0
movdqa 0x246cc(%rip), %xmm0    # 0x29f00
movdqu (%rdi,%rax,4), %xmm3
pcmpeqd %xmm2, %xmm3
pand %xmm0, %xmm3
paddd %xmm3, %xmm1
addq $0x4, %rax
cmpq $0x40, %rax
jne 0x5834
pshufd $0xee, %xmm1, %xmm2     # xmm2 = xmm1[2,3,2,3]
paddd %xmm1, %xmm2
pshufd $0x55, %xmm2, %xmm1     # xmm1 = xmm2[1,1,1,1]
paddd %xmm2, %xmm1
movd %xmm1, %eax
imull $0x64, %edx, %edx
cmpl %eax, %edx
jne 0x58b9
imull $0x64, %ecx, %ecx
pxor %xmm1, %xmm1
xorl %edx, %edx
pcmpeqd %xmm2, %xmm2
movdqu (%rdi,%rdx,4), %xmm3
pcmpeqd %xmm2, %xmm3
pand %xmm0, %xmm3
paddd %xmm3, %xmm1
addq $0x4, %rdx
cmpq $0x40, %rdx
jne 0x5879
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
paddd %xmm1, %xmm0
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
paddd %xmm0, %xmm1
movd %xmm1, %edx
cmpl %edx, %ecx
jne 0x58d8
shlq $0x20, %rcx
movl %eax, %eax
orq %rcx, %rax
popq %rcx
retq
leaq 0x24722(%rip), %rdi     # 0x29fe2
leaq 0x24666(%rip), %rsi     # 0x29f2d
leaq 0x24740(%rip), %rcx     # 0x2a00e
movl $0x149, %edx            # imm = 0x149
callq 0x20d0
leaq 0x24759(%rip), %rdi     # 0x2a038
leaq 0x24647(%rip), %rsi     # 0x29f2d
leaq 0x24721(%rip), %rcx     # 0x2a00e
movl $0x14a, %edx            # imm = 0x14A
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/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 0x56fe
movq %rax, %r14
shrq $0x20, %rax
movl %r14d, %r12d
subl %eax, %r12d
movq %rbx, %rdi
callq 0x5811
movq %rax, %r15
shrq $0x20, %rax
subl %eax, %r15d
addl %r12d, %r15d
testl %ebp, %ebp
jne 0x5983
movq %rbx, %rdi
callq 0x5600
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5032
movl %eax, %r12d
addl %ebp, %r12d
movq %rbx, %rdi
callq 0x5134
movl %eax, %ebp
addl %r12d, %ebp
movq %rbx, %rdi
callq 0x524b
movl %eax, %r12d
addl %ebp, %r12d
addl %r15d, %r12d
movq %rbx, %rdi
callq 0x538b
movl %eax, %ebp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x547d
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_O3/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 0x5c42
leaq 0x24432(%rip), %rcx     # 0x2a070
movslq (%rcx,%rax,4), %rax
leaq 0x24527(%rip), %rcx     # 0x2a170
movl (%rcx,%rax,4), %r15d
movzbl %dl, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x5c9e
leal 0x14(%r15), %r12d
testb %al, %al
cmovel %r15d, %r12d
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x5cf8
leal -0xa(%r12), %r15d
testb %al, %al
cmovel %r12d, %r15d
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x5d76
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_O3/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 0x5d30
cmpl $0x1, %eax
je 0x5d35
leaq 0x24558(%rip), %rdi     # 0x2a270
leaq 0x2459c(%rip), %rsi     # 0x2a2bb
leaq 0x245a3(%rip), %rcx     # 0x2a2c9
movl $0x22, %edx
callq 0x20d0
cmpl $-0x1, %eax
jne 0x5d11
movl %esi, %edi
callq 0xca3e
movl %eax, %eax
leaq 0xf46eb(%rip), %rdx     # 0xfa430
leaq 0xf4764(%rip), %rcx     # 0xfa4b0
movq (%rcx,%r14,8), %rcx
xorq (%rdx,%rax,8), %rcx
movb $0x1, %al
testb %bpl, %bpl
je 0x5d66
testq %rcx, 0x158(%rbx)
jne 0x5d71
jmp 0x5d6f
testq %rcx, 0x160(%rbx)
jne 0x5d71
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/evalp.cpp
// Function: init_evalp_bitboards()
void init_evalp_bitboards() {

    // isolated pawn masks
    for (int i=0;i<64;i++) {
        bb_isolated[i] = 0;
        file_t f = get_file((square_t)i);

        if (f > FILE_A) {
            bb_isolated[i] |= bb_files[f-1];
        }
        if (f < FILE_H) {
            bb_isolated[i] |= bb_files[f+1];
        }
    }

    // passed pawn masks
    for (int i=0;i<64;i++) {
        file_t f = get_file((square_t)i);

        bb_passed[i][WHITE] = bb_rays[i][NORTH];
        bb_passed[i][BLACK] = bb_rays[i][SOUTH];

        if (f > FILE_A) {
            bb_passed[i][WHITE] |= bb_rays[i-1][NORTH];
            bb_passed[i][BLACK] |= bb_rays[i-1][SOUTH];
        }
        if (f < FILE_H) {
            bb_passed[i][WHITE] |= bb_rays[i+1][NORTH];
            bb_passed[i][BLACK] |= bb_rays[i+1][SOUTH];
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0xbe52e(%rip), %r14     # 0xc4300
xorl %ebx, %ebx
leaq 0xf4655(%rip), %r15     # 0xfa430
movq $0x0, (%r14)
movl %ebx, %edi
callq 0xca3e
movq (%r14), %rcx
testl %eax, %eax
jle 0x5dff
leal -0x1(%rax), %edx
orq (%r15,%rdx,8), %rcx
movq %rcx, (%r14)
cmpl $0x6, %eax
ja 0x5e09
cltq
orq 0x8(%r15,%rax,8), %rcx
movq %rcx, (%r14)
incq %rbx
addq $0x8, %r14
cmpq $0x40, %rbx
jne 0x5ddb
xorl %ebx, %ebx
leaq 0xf5091(%rip), %r14     # 0xfaeb0
leaq 0xbe6da(%rip), %r15     # 0xc4500
movl %ebx, %edi
callq 0xca3e
movq %rbx, %rdi
shlq $0x6, %rdi
movq (%r14,%rdi), %rsi
movq 0x20(%r14,%rdi), %rcx
movq %rbx, %rdx
shlq $0x4, %rdx
addq %r15, %rdx
testl %eax, %eax
jle 0x5e61
orq -0x40(%rdi,%r14), %rsi
movq %rsi, 0x8(%rdx)
orq -0x20(%rdi,%r14), %rcx
movq %rcx, (%rdx)
cmpl $0x7, %eax
jae 0x5e7d
incq %rbx
movq %rbx, %rax
shlq $0x6, %rax
orq (%r14,%rax), %rsi
movq %rsi, 0x8(%rdx)
orq 0x20(%r14,%rax), %rcx
movq %rcx, (%rdx)
jmp 0x5e80
incq %rbx
cmpq $0x40, %rbx
jne 0x5e26
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/extend.cpp
// Function: extend(position*, unsigned long long, bool)
int32 extend(position *pos,move last_move,bool incheck) {

    assert(incheck==in_check(pos,pos->player));

    if (incheck) return 1;
    if (get_promopiece(last_move)) return 1;

    // pawn to 7th
    /*square_t to_sq = get_to_sq(last_move);
    if (pos->player==WHITE) { // black was on move
        if (pos->piece[to_sq]==-PAWN && get_rank(to_sq)==RANK_2) {
            return 1;
        }
    } else {
        if (pos->piece[to_sq]==PAWN && get_rank(to_sq)==RANK_7) {
            return 1;
        }
    }*/

    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movl 0x138(%rdi), %esi
callq 0xaf41
cmpb %bpl, %al
jne 0x5ec6
movl $0x1, %eax
testb %bpl, %bpl
jne 0x5ebf
movq %rbx, %rdi
callq 0x786f
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x24492(%rip), %rdi     # 0x2a35f
leaq 0x244ae(%rip), %rsi     # 0x2a382
leaq 0x244b6(%rip), %rcx     # 0x2a391
movl $0x10, %edx
callq 0x20d0
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/hash.cpp
// Function: build_hash_key(position*)
uint64 build_hash_key(position *pos) {
    uint64 hkey = 0;

    // fold in pieces
    for (int i=0;i<64;i++) {
        int piece = pos->piece[i];
        if (piece > NO_PIECE) {
            hkey ^= zkeys.pieces[piece][WHITE][i];
        } else if (piece < NO_PIECE) {
            hkey ^= zkeys.pieces[-piece][BLACK][i];
        }
    }

    // fold in player to move
    hkey ^= zkeys.ptm[pos->player];

    // castling rights
    assert(pos->castling_rights >= 0 && pos->castling_rights < 16);
    hkey ^= zkeys.casting_rights[pos->castling_rights];

    // ep square (including NO_SQUARE)
    assert(pos->ep_sq >= 0 && pos->ep_sq < 65);
    hkey ^= zkeys.ep[pos->ep_sq];

    return hkey;
}

// Assembly:
pushq %rax
leaq 0xf26a8(%rip), %rax     # 0xf8598
xorl %edx, %edx
movq %rax, %rsi
xorl %ecx, %ecx
movslq (%rdi,%rdx,4), %r8
testq %r8, %r8
jle 0x5f17
shlq $0xa, %r8
addq %rax, %r8
leaq (%r8,%rdx,8), %r8
addq $0x200, %r8             # imm = 0x200
xorq (%r8), %rcx
jmp 0x5f1c
testl %r8d, %r8d
js 0x5f2b
incq %rdx
addq $0x8, %rsi
cmpq $0x40, %rdx
jne 0x5ef7
jmp 0x5f37
negl %r8d
shlq $0xa, %r8
addq %rsi, %r8
jmp 0x5f12
movl 0x140(%rdi), %edx
cmpq $0x10, %rdx
jae 0x5f79
movl 0x13c(%rdi), %esi
cmpq $0x41, %rsi
jae 0x5f98
movl 0x138(%rdi), %eax
leaq 0xf263c(%rip), %rdi     # 0xf8598
movq 0x1c00(%rdi,%rax,8), %rax
xorq 0x1c10(%rdi,%rdx,8), %rax
xorq 0x1c90(%rdi,%rsi,8), %rax
xorq %rcx, %rax
popq %rcx
retq
leaq 0x24436(%rip), %rdi     # 0x2a3b6
leaq 0x24466(%rip), %rsi     # 0x2a3ed
leaq 0x2446c(%rip), %rcx     # 0x2a3fa
movl $0x1e, %edx
callq 0x20d0
leaq 0x2447d(%rip), %rdi     # 0x2a41c
leaq 0x24447(%rip), %rsi     # 0x2a3ed
leaq 0x2444d(%rip), %rcx     # 0x2a3fa
movl $0x22, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/hash.cpp
// Function: build_pawn_key(position*)
uint64 build_pawn_key(position *pos) {
    uint64 pkey = 0;

    uint64 pmap = pos->white_pawns;
    while (pmap) {
        square_t sq = (square_t)get_msb(pmap);
        pkey ^= zkeys.pieces[PAWN][WHITE][sq];
        pmap ^= bb_squares[sq];
    }

    pmap = pos->black_pawns;
    while (pmap) {
        square_t sq = (square_t)get_lsb(pmap);
        pkey ^= zkeys.pieces[PAWN][BLACK][sq];
        pmap ^= bb_squares[sq];
    }

    return pkey;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movq 0x158(%rdi), %r15
xorl %ebx, %ebx
testq %r15, %r15
je 0x6004
leaq 0xf25c0(%rip), %r12     # 0xf8598
leaq 0xf44d1(%rip), %r13     # 0xfa4b0
movq %r15, %rdi
callq 0x3c31
movl %eax, %eax
xorq 0x600(%r12,%rax,8), %rbx
movq (%r13,%rax,8), %rax
movq %rax, %rcx
xorq %r15, %rcx
cmpq %r15, %rax
movq %rcx, %r15
jne 0x5fdf
movq 0x160(%r14), %r14
testq %r14, %r14
je 0x6042
leaq 0xf2581(%rip), %r15     # 0xf8598
leaq 0xf4492(%rip), %r12     # 0xfa4b0
movq %r14, %rdi
callq 0x3b67
movl %eax, %eax
xorq 0x400(%r15,%rax,8), %rbx
movq (%r12,%rax,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0x601e
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/hash.cpp
// Function: build_hash_val(hash_entry_t, int, int, unsigned long long)
uint64 build_hash_val(hash_entry_t entry_type,int32 depth,int32 score,move mv) {
    assert(entry_type >= LOWER_BOUND && entry_type <= EXACT_SCORE);
    assert(depth >= 0);
    assert(depth <= 0xFFFF);
    assert(abs(score) <= CHECKMATE);
    assert(abs(score) <= 0xFFFF);
    set_move_score(&mv,0);

    // convert mate scores
    if (score > CHECKMATE-500) {
        if (entry_type==UPPER_BOUND) {
            // failing low on mate.  don't allow a cutoff, just store any associated move
            entry_type = MOVE_ONLY;
        } else {
            // convert to fail high
            entry_type = LOWER_BOUND;
            score = CHECKMATE-500;
        }
    } else if (score < -(CHECKMATE-500)) {
        if (entry_type==LOWER_BOUND) {
            // failing high on -mate.
            entry_type = MOVE_ONLY;
        } else {
            // convert to fail low
            entry_type = UPPER_BOUND;
            score = -(CHECKMATE-500);
        }
    }

    uint64 val = entry_type;
    val |= ((uint64)depth) << 2;
    if (score >= 0) {
        val |= ((uint64)score) << 18;
    } else {
        val |= ((uint64)-score) << 18;
        val |= ((uint64)1) << 34;
    }
    val |= ((uint64)mv) << 35;

    return val;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %r15d
movq %rcx, 0x8(%rsp)
leal -0x1(%r15), %eax
cmpl $0x3, %eax
jae 0x6120
movl %esi, %r14d
testl %esi, %esi
js 0x613f
cmpl $0x10000, %r14d         # imm = 0x10000
jae 0x615e
movl %edx, %ebx
movl %edx, %eax
negl %eax
cmovsl %edx, %eax
cmpl $0x10000, %eax          # imm = 0x10000
jae 0x617d
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x78bc
cmpl $0xfe0c, %ebx           # imm = 0xFE0C
jl 0x60c4
xorl %eax, %eax
cmpl $0x2, %r15d
setne %al
movl $0xfe0b, %ecx           # imm = 0xFE0B
cmovnel %ecx, %ebx
leal (%rax,%r14,4), %eax
jmp 0x60f1
cmpl $0xffff01f4, %ebx       # imm = 0xFFFF01F4
jg 0x60e9
xorl %eax, %eax
cmpl $0x1, %r15d
movl $0xffff01f5, %ecx       # imm = 0xFFFF01F5
cmovel %ebx, %ecx
setne %al
shll $0x2, %r14d
leal (%r14,%rax,2), %eax
movl %ecx, %ebx
jmp 0x60fc
leal (%r15,%r14,4), %eax
testl %ebx, %ebx
js 0x60fc
movl %ebx, %ebx
shlq $0x12, %rbx
orq %rax, %rbx
jmp 0x610a
negl %ebx
shlq $0x12, %rbx
orq %rax, %rbx
btsq $0x22, %rbx
movq 0x8(%rsp), %rax
shlq $0x23, %rax
orq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x24318(%rip), %rdi     # 0x2a43f
leaq 0x242bf(%rip), %rsi     # 0x2a3ed
leaq 0x24341(%rip), %rcx     # 0x2a476
movl $0x3d, %edx
callq 0x20d0
leaq 0x24368(%rip), %rdi     # 0x2a4ae
leaq 0x242a0(%rip), %rsi     # 0x2a3ed
leaq 0x24322(%rip), %rcx     # 0x2a476
movl $0x3e, %edx
callq 0x20d0
leaq 0x24354(%rip), %rdi     # 0x2a4b9
leaq 0x24281(%rip), %rsi     # 0x2a3ed
leaq 0x24303(%rip), %rcx     # 0x2a476
movl $0x3f, %edx
callq 0x20d0
leaq 0x24345(%rip), %rdi     # 0x2a4c9
leaq 0x24262(%rip), %rsi     # 0x2a3ed
leaq 0x242e4(%rip), %rcx     # 0x2a476
movl $0x40, %edx
callq 0x20d0