LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/movegen.cpp
// Function: gen_queen_moves(unsigned long long*, position*, square_t, bool, bool)
move* gen_queen_moves(move* m,position* p,square_t from,bool caps,bool noncaps) {
    assert(m);
    assert(p);
    assert(from >= A8 && from <= H1);

    uint64 queen_moves = get_queen_moves(p,from,get_target_squares(p,caps,noncaps));

    while (queen_moves) {
        square_t sq = (square_t)get_msb(queen_moves);
        m = add_move(m,p,QUEEN,from,sq);
        queen_moves ^= bb_squares[sq];
    }

    return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x89fd
movq %rsi, %r14
testq %rsi, %rsi
je 0x8a1c
movl %edx, %ebx
cmpl $0x40, %edx
jae 0x8a3b
movq %rdi, %r15
testb %cl, %cl
je 0x8980
xorl %eax, %eax
cmpl $0x1, 0x138(%r14)
sete %al
movq 0x1a8(%r14,%rax,8), %rdx
jmp 0x8982
xorl %edx, %edx
testb %r8b, %r8b
je 0x899b
movq 0x1b0(%r14), %rax
orq 0x1a8(%r14), %rax
notq %rax
orq %rax, %rdx
movq %r14, %rdi
movl %ebx, %esi
callq 0x67f6
testq %rax, %rax
je 0x89eb
movq %rax, %r12
leaq 0xf1afc(%rip), %r13     # 0xfa4b0
movq %r12, %rdi
callq 0x3c31
movl %eax, %ebp
movq %r15, %rdi
movq %r14, %rsi
movl $0x5, %edx
movl %ebx, %ecx
movl %eax, %r8d
callq 0x83d9
movq %rax, %r15
movl %ebp, %eax
movq (%r13,%rax,8), %rax
movq %rax, %rcx
xorq %r12, %rcx
cmpq %r12, %rax
movq %rcx, %r12
jne 0x89b4
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24a27(%rip), %rdi     # 0x2d42b
leaq 0x220ad(%rip), %rsi     # 0x2aab8
leaq 0x221fe(%rip), %rcx     # 0x2ac10
movl $0xcd, %edx
callq 0x20d0
leaq 0x2c8d9(%rip), %rdi     # 0x352fc
leaq 0x2208e(%rip), %rsi     # 0x2aab8
leaq 0x221df(%rip), %rcx     # 0x2ac10
movl $0xce, %edx
callq 0x20d0
leaq 0x21c35(%rip), %rdi     # 0x2a677
leaq 0x2206f(%rip), %rsi     # 0x2aab8
leaq 0x221c0(%rip), %rcx     # 0x2ac10
movl $0xcf, %edx
callq 0x20d0
nop
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/mvvlva.cpp
// Function: mvvlva_capture(position*, unsigned long long)
int32 mvvlva_capture(position *pos,move mv) {
    piece_t captured;
    if (is_epcapture(mv)) {
        captured = PAWN;
    } else {
        captured = (piece_t)pos->piece[get_to_sq(mv)];
    }
    assert(captured != NO_PIECE);
    int32 captured_val = captured < NO_PIECE ? -captured : captured;

    piece_t mover = (piece_t)pos->piece[get_from_sq(mv)];
    assert(mover != NO_PIECE);
    int32 mover_val = mover < NO_PIECE ? -mover : mover;

    return 1000 + (captured_val * 10) - mover_val;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x788d
movl $0x1, %ebp
testb %al, %al
jne 0x8abc
movq %r14, %rdi
callq 0x785b
movl %eax, %eax
movl (%rbx,%rax,4), %ebp
testl %ebp, %ebp
je 0x8b0a
movq %r14, %rdi
callq 0x7854
movl %eax, %eax
movl (%rbx,%rax,4), %eax
testl %eax, %eax
je 0x8aeb
movl %ebp, %ecx
negl %ecx
cmovsl %ebp, %ecx
movl %eax, %edx
negl %edx
leal (%rcx,%rcx,4), %ecx
cmovnsl %eax, %edx
leal (%rdx,%rcx,2), %eax
addl $0x3e8, %eax            # imm = 0x3E8
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x22220(%rip), %rdi     # 0x2ad12
leaq 0x221ca(%rip), %rsi     # 0x2acc3
leaq 0x221eb(%rip), %rcx     # 0x2aceb
movl $0x1e, %edx
callq 0x20d0
leaq 0x2055e(%rip), %rdi     # 0x2906f
leaq 0x221ab(%rip), %rsi     # 0x2acc3
leaq 0x221cc(%rip), %rcx     # 0x2aceb
movl $0x1a, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/mvvlva.cpp
// Function: mvvlva(position*, unsigned long long)
int32 mvvlva(position *pos,move mv) {
    int32 score = 0;

    if (get_promopiece(mv)!=NO_PIECE) {
        score = mvvlva_promo(mv);
    }
    if (is_capture(mv)) {
        score += mvvlva_capture(pos,mv);
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x786f
testl %eax, %eax
je 0x8b4b
movq %rbx, %rdi
callq 0x8a5c
movl %eax, %ebp
jmp 0x8b4d
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x7883
testb %al, %al
je 0x8b66
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8a90
addl %eax, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/next.cpp
// Function: test_good_move(unsigned long long, position*)
bool test_good_move(move mv,position *pos) {
    move moves[MAX_MOVES_PER_PLY];
    move *endp = gen_moves(moves,pos,true,true);

    bool valid =  is_in_move_list(mv,moves,endp);
    if (!valid) {
        char mv_text[10];
        move_to_str(mv,mv_text);
        print("good_move says move %s is good.\n",mv_text);
        draw_board(pos);
    }

    return valid;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x978, %rsp            # imm = 0x978
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7970
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xe682
movl %eax, %ebp
testb %al, %al
jne 0x953b
leaq 0x6(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0xe09f
leaq 0x21abd(%rip), %rdi     # 0x2afe6
movq %r15, %rsi
xorl %eax, %eax
callq 0x64b9
movq %rbx, %rdi
callq 0x4bd8
movl %ebp, %eax
addq $0x978, %rsp            # imm = 0x978
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/next.cpp
// Function: best_at_top(unsigned long long*, unsigned long long*)
bool best_at_top(move *startp,move *endp) {

    move *bestp = 0;
    int32 bestscore = 0;

    for (move *mp=startp;mp<endp;mp++) {
        if (*mp != 0) {
            int32 score = get_move_score(mp);
            if (bestp==0 || score > bestscore) {
                bestp = mp;
                bestscore = score;
            }
        }
    }

    if (bestp) {
        move tmpmv = *startp;
        *startp = *bestp;
        *bestp = tmpmv;
        return true;
    }

    return false;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
xorl %r14d, %r14d
cmpq %rsi, %rdi
jae 0x95ba
movq %rsi, %r15
movq %rdi, %rbx
xorl %r13d, %r13d
movq %rdi, %r12
cmpq $0x0, (%r12)
je 0x9596
movq %r12, %rdi
callq 0x78a1
testq %r13, %r13
sete %cl
cmpl %r14d, %eax
setg %dl
orb %cl, %dl
movq %r12, %rcx
jne 0x9590
movl %r14d, %eax
movq %r13, %rcx
movl %eax, %r14d
movq %rcx, %r13
addq $0x8, %r12
cmpq %r15, %r12
jb 0x9568
testq %r13, %r13
je 0x95b7
movq (%rbx), %rax
movq (%r13), %rcx
movq %rcx, (%rbx)
movq %rax, (%r13)
movb $0x1, %r14b
jmp 0x95ba
xorl %r14d, %r14d
movl %r14d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/next.cpp
// Function: place_move_on_top(unsigned long long*, unsigned long long*, unsigned long long)
bool place_move_on_top(move *start,move *end,move top_move) {
    assert(start);
    assert(end);

    if (top_move==BADMOVE) return false;

    assert(clear_score(top_move)==top_move);

    bool found_move=false;
    for (move *mp=start;mp<end;mp++) {
        if (*mp == top_move) {
            move tmp_move = *start;
            *start = top_move;
            *mp = tmp_move;
            found_move=true;
            break;
        }
    }
    return found_move;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x961c
movq %rsi, %r15
testq %rsi, %rsi
je 0x963b
movq %rdx, %rbx
testq %rdx, %rdx
je 0x9607
movq %rdi, %r14
movq %rbx, %rdi
callq 0x78dd
cmpq %rbx, %rax
jne 0x965a
cmpq %r15, %r14
jae 0x9607
movq %r14, %rax
cmpq %rbx, (%rax)
je 0x960f
addq $0x8, %rax
cmpq %r15, %rax
jb 0x95f9
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq (%r14), %rcx
movq %rbx, (%r14)
movq %rcx, (%rax)
movb $0x1, %al
jmp 0x9609
leaq 0x2196c(%rip), %rdi     # 0x2af8f
leaq 0x21729(%rip), %rsi     # 0x2ad53
leaq 0x21964(%rip), %rcx     # 0x2af95
movl $0xa0, %edx
callq 0x20d0
leaq 0x21980(%rip), %rdi     # 0x2afc2
leaq 0x2170a(%rip), %rsi     # 0x2ad53
leaq 0x21945(%rip), %rcx     # 0x2af95
movl $0xa1, %edx
callq 0x20d0
leaq 0x21965(%rip), %rdi     # 0x2afc6
leaq 0x216eb(%rip), %rsi     # 0x2ad53
leaq 0x21926(%rip), %rcx     # 0x2af95
movl $0xa5, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/next.cpp
// Function: good_pawn_move(position*, unsigned long long)
bool good_pawn_move(position *p,move m) {

    square_t from_sq = get_from_sq(m);
    square_t to_sq = get_to_sq(m);
    piece_t captured_piece = get_captured_piece(m);

    if (captured_piece==NO_PIECE) {
        if (p->piece[to_sq] != NO_PIECE) return false;
        if (p->player==WHITE) {
            square_t nsq = north(from_sq);
            square_t nnsq = north(nsq);
            if (to_sq==nsq || (to_sq==nnsq && p->piece[nsq]==NO_PIECE)) return true;
        } else {
            square_t ssq = south(from_sq);
            square_t sssq = south(ssq);
            if (to_sq==ssq || (to_sq==sssq && p->piece[ssq]==NO_PIECE)) return true;
        }
    } else {
        if (!(bb_pawn_attacks[from_sq][p->player] & bb_squares[to_sq])) return false;
        if (p->player==WHITE) {
            if (is_epcapture(m)) {
                if (to_sq==p->ep_sq && p->piece[south(to_sq)]==-PAWN) return true;
            } else {
                if (p->piece[to_sq]==-captured_piece) return true;
            }
        } else {
            if (is_epcapture(m)) {
                if (to_sq==p->ep_sq && p->piece[north(to_sq)]==PAWN) return true;
            } else {
                if (p->piece[to_sq]==captured_piece) return true;
            }
        }
    }

    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x7854
movl %eax, %r12d
movq %r15, %rdi
callq 0x785b
movl %eax, %ebp
movq %r15, %rdi
callq 0x7879
testl %eax, %eax
je 0x9704
movl %eax, %r14d
movl %r12d, %eax
movl 0x138(%rbx), %r13d
shlq $0x4, %rax
addq 0x38925(%rip), %rax     # 0x41fe8
movl %ebp, %r12d
leaq 0xf0de3(%rip), %rcx     # 0xfa4b0
movq (%rcx,%r12,8), %rcx
testq %rcx, (%rax,%r13,8)
je 0x970c
movq %r15, %rdi
callq 0x788d
cmpl $0x1, %r13d
jne 0x971d
testb %al, %al
je 0x9759
cmpl 0x13c(%rbx), %ebp
jne 0x970c
movl %ebp, %edi
callq 0xcc3e
movl %eax, %eax
cmpl $-0x1, (%rbx,%rax,4)
jne 0x970c
movb $0x1, %al
jmp 0x970e
movl %ebp, %eax
cmpl $0x0, (%rbx,%rax,4)
je 0x973c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %al, %al
je 0x9763
cmpl 0x13c(%rbx), %ebp
jne 0x970c
movl %ebp, %edi
callq 0xcc05
movl %eax, %ecx
movb $0x1, %al
cmpl $0x1, (%rbx,%rcx,4)
jne 0x970c
jmp 0x970e
cmpl $0x1, 0x138(%rbx)
jne 0x976d
movl %r12d, %edi
callq 0xcc05
movl %eax, %r14d
movl %eax, %edi
callq 0xcc05
jmp 0x977f
movb $0x1, %al
addl (%rbx,%r12,4), %r14d
jne 0x970c
jmp 0x970e
movb $0x1, %al
cmpl %r14d, (%rbx,%r12,4)
jne 0x970c
jmp 0x970e
movl %r12d, %edi
callq 0xcc3e
movl %eax, %r14d
movl %eax, %edi
callq 0xcc3e
movl %eax, %ecx
movb $0x1, %al
cmpl %r14d, %ebp
je 0x970e
cmpl %ecx, %ebp
jne 0x970c
movl %r14d, %ecx
cmpl $0x0, (%rbx,%rcx,4)
jne 0x970c
jmp 0x970e
nop
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/perft.cpp
// Function: perft(position*, int)
uint64 perft(position *pos,int32 depth) {
    uint64 nodes=0;
    move moves[MAX_MOVES_PER_PLY];

    move *endp = gen_legal_moves(moves,pos,true,true);

    if (depth == 1) {
        return num_moves(moves,endp,true,true);
    }

    for (move* mp=moves;mp<endp;mp++) {
        if (*mp==0) continue; // move purged as illegal
        apply_move(pos,*mp,gundos);
        nodes += perft(pos,depth-1);
        undo_last_move(pos,gundos);
    }

    return nodes;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x968, %rsp            # imm = 0x968
movl %esi, %ebx
movq %rdi, %r14
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x78e0
movq %rax, %r12
cmpl $0x1, %ebx
jne 0x97f0
movq %rsp, %rdi
movq %r12, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0xe70f
movl %eax, %r13d
jmp 0x983a
cmpq %r12, %r15
jae 0x9837
decl %ebx
xorl %r13d, %r13d
leaq 0xbf2ef(%rip), %rbp     # 0xc8af0
movq (%r15), %rsi
testq %rsi, %rsi
je 0x982c
movq %r14, %rdi
movq %rbp, %rdx
callq 0x30e1
movq %r14, %rdi
movl %ebx, %esi
callq 0x97a0
addq %rax, %r13
movq %r14, %rdi
movq %rbp, %rsi
callq 0x334b
addq $0x8, %r15
cmpq %r12, %r15
jb 0x9801
jmp 0x983a
xorl %r13d, %r13d
movq %r13, %rax
addq $0x968, %rsp            # imm = 0x968
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/perft.cpp
// Function: perft_iterate(int)
uint64 perft_iterate(int32 max_depth) {
    draw_board(&gpos);
    uint64 total_nodes=0;
    for (int d=1;d<=max_depth;d++) {
        print("perft %d: ",d);
        uint64 nodes=perft(&gpos,d);
        print("%llu\n",nodes);
        total_nodes += nodes;
    }

    return total_nodes;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0xbf0bd(%rip), %rdi     # 0xc8920
callq 0x4bd8
testl %ebx, %ebx
jle 0x98c9
negl %ebx
movl $0x1, %r13d
leaq 0xbf0a5(%rip), %r12     # 0xc8920
leaq 0x21871(%rip), %rbp     # 0x2b0f3
xorl %r14d, %r14d
leaq 0x2177b(%rip), %rdi     # 0x2b007
movl %r13d, %esi
xorl %eax, %eax
callq 0x64b9
movq %r12, %rdi
movl %r13d, %esi
callq 0x97a0
movq %rax, %r15
movq %rbp, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x64b9
addq %r15, %r14
leal (%rbx,%r13), %eax
incl %eax
movl %r13d, %ecx
incl %ecx
movl %ecx, %r13d
cmpl $0x1, %eax
jne 0x9885
jmp 0x98cc
xorl %r14d, %r14d
movq %r14, %rax
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/perft.cpp
// Function: get_line(char*, char const*, _IO_FILE*)
bool get_line(char* buffer,const char* line,FILE* file) {
    bool found=false;

    while (fgets(buffer,255,file) != NULL) {
        if (strstr(buffer,line)) {
            found=true;
            break;
        }
    }

    return found;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %r15, %rdi
movl $0xff, %esi
movq %rbx, %rdx
callq 0x22d0
movq %rax, %r12
testq %rax, %rax
je 0x9917
movq %r15, %rdi
movq %r14, %rsi
callq 0x2050
testq %rax, %rax
je 0x98ef
testq %r12, %r12
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/perft.cpp
// Function: test_case(position*, char const*, int, unsigned long long)
uint64 test_case(position *pos,const char *fen,int depth,uint64 expected) {
    set_pos(pos,fen);
    draw_board(pos);
    int32 start_time = milli_timer();
    uint64 actual = perft(pos,depth);
    int32 elapsed = milli_timer() - start_time + 1; // div by 0
    print("\nexpected (%d): %llu, actual: %llu\n",depth,expected,actual);
    print("nps: %lu\n\n",actual*1000/elapsed);
    if (actual != expected) {
        exit(1);
    }
    return actual;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %rbx
movl %edx, %ebp
movq %rdi, %r14
callq 0xaa82
movq %r14, %rdi
callq 0x4bd8
callq 0xdf08
movl %eax, %r15d
movq %r14, %rdi
movl %ebp, %esi
callq 0x97a0
movq %rax, %r14
callq 0xdf08
movl %eax, %r12d
subl %r15d, %r12d
incl %r12d
leaq 0x21422(%rip), %rdi     # 0x2b0d5
movl %ebp, %esi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x64b9
imulq $0x3e8, %r14, %rax      # imm = 0x3E8
movslq %r12d, %rcx
xorl %edx, %edx
divq %rcx
leaq 0x2199a(%rip), %rdi     # 0x2b672
movq %rax, %rsi
xorl %eax, %eax
callq 0x64b9
cmpq %rbx, %r14
jne 0x9cf3
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x21f0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/pos.cpp
// Function: remove_castling_availability(position*, unsigned long long)
void remove_castling_availability(position *p,move mv) {
    // if capturing a rook remove its castling availability
    if (is_capture(mv)) {
        square_t to_sq = get_to_sq(mv);
        remove_rook_castling_availability(p,to_sq);
    }

    // if a rook or king is moving, remove their castling availability.
    square_t from_sq = get_from_sq(mv);
    int32 piece = p->piece[from_sq];
    if (piece==KING) {
        p->castling_rights &= CASTLE_BLACK;
    } else if (piece==-KING) {
        p->castling_rights &= CASTLE_WHITE;
    } else if (piece==ROOK || piece==-ROOK) {
        remove_rook_castling_availability(p,from_sq);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x7883
testb %al, %al
je 0xa9dc
movq %r14, %rdi
callq 0x785b
cmpl $0x37, %eax
jg 0xa9b9
testl %eax, %eax
je 0xa9ca
cmpl $0x7, %eax
jne 0xa9dc
movl $0xb, %eax
jmp 0xa9d6
cmpl $0x38, %eax
je 0xa9d1
cmpl $0x3f, %eax
jne 0xa9dc
movl $0xe, %eax
jmp 0xa9d6
movl $0x7, %eax
jmp 0xa9d6
movl $0xd, %eax
andl %eax, 0x140(%rbx)
movq %r14, %rdi
callq 0x7854
movl %eax, %ecx
movl (%rbx,%rcx,4), %ecx
addl $0x6, %ecx
rorl %ecx
cmpl $0x6, %ecx
ja 0xaa49
leaq 0x20d16(%rip), %rdx     # 0x2b710
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x37, %eax
jg 0xaa26
testl %eax, %eax
je 0xaa37
cmpl $0x7, %eax
jne 0xaa49
movl $0xb, %eax
jmp 0xaa43
movl $0x3, %eax
jmp 0xaa43
movl $0xc, %eax
jmp 0xaa43
cmpl $0x38, %eax
je 0xaa3e
cmpl $0x3f, %eax
jne 0xaa49
movl $0xe, %eax
jmp 0xaa43
movl $0x7, %eax
jmp 0xaa43
movl $0xd, %eax
andl %eax, 0x140(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/pos.cpp
// Function: is_enemy_occupied(position*, square_t, color_t)
bool is_enemy_occupied(position *pos,square_t sq,color_t player) {
    assert(pos);
    assert(sq >= A8 && sq <= H1);
    assert(player==WHITE || player==BLACK);

    return player==WHITE ? is_black_piece(pos->piece[sq]) : is_white_piece(pos->piece[sq]);
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0xae61
cmpl $0x40, %esi
jae 0xae80
cmpl $0x2, %edx
jae 0xae9f
movl %esi, %eax
movl (%rdi,%rax,4), %edi
cmpl $0x1, %edx
jne 0xae5b
popq %rax
jmp 0xe76f
popq %rax
jmp 0xe769
leaq 0x1e721(%rip), %rdi     # 0x29589
leaq 0x20a22(%rip), %rsi     # 0x2b891
leaq 0x20ff6(%rip), %rcx     # 0x2be6c
movl $0x17d, %edx            # imm = 0x17D
callq 0x20d0
leaq 0x1e387(%rip), %rdi     # 0x2920e
leaq 0x20a03(%rip), %rsi     # 0x2b891
leaq 0x20fd7(%rip), %rcx     # 0x2be6c
movl $0x17e, %edx            # imm = 0x17E
callq 0x20d0
leaq 0x1e37d(%rip), %rdi     # 0x29223
leaq 0x209e4(%rip), %rsi     # 0x2b891
leaq 0x20fb8(%rip), %rcx     # 0x2be6c
movl $0x17f, %edx            # imm = 0x17F
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/pos.cpp
// Function: flip_board(position*)
void flip_board(position *pos) {

    // flip pieces around
    int32 orig_sq[64];
    for (int sq=0;sq<64;sq++) {
        orig_sq[sq] = pos->piece[sq];
        if (pos->piece[sq] != NO_PIECE) {
            remove_piece(pos,(square_t)sq);
        }
    }

    for (int sq=0;sq<64;sq++) {
        if (orig_sq[sq] != NO_PIECE) {
            add_piece(pos,-orig_sq[sq],(square_t)fliprank[sq]);
        }
    }

    square_t orig_white_king_sq = pos->white_king;
    pos->white_king = (square_t)fliprank[pos->black_king];
    pos->black_king = (square_t)fliprank[orig_white_king_sq];

    // swap players
    pos->player = opposite_player(pos->player);

    // flip ep square
    if (pos->ep_sq != NO_SQUARE) {
        pos->ep_sq = (square_t)fliprank[pos->ep_sq];
    }

    // castling rights
    int32 orig_castling_rights = pos->castling_rights;
    pos->castling_rights = 0;
    if (orig_castling_rights & CASTLE_WK) {
        pos->castling_rights |= CASTLE_BK;
    }
    if (orig_castling_rights & CASTLE_WQ) {
        pos->castling_rights |= CASTLE_BQ;
    }
    if (orig_castling_rights & CASTLE_BK) {
        pos->castling_rights |= CASTLE_WK;
    }
    if (orig_castling_rights & CASTLE_BQ) {
        pos->castling_rights |= CASTLE_WQ;
    }

    pos->hash_key = build_hash_key(pos);
    pos->pawn_key = build_pawn_key(pos);
    assert(test_pos_consistency(pos));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rbx
xorl %r14d, %r14d
movl (%rbx,%r14,4), %eax
movl %eax, (%rsp,%r14,4)
testl %eax, %eax
je 0xaf98
movq %rbx, %rdi
movl %r14d, %esi
callq 0xa78d
incq %r14
cmpq $0x40, %r14
jne 0xaf81
xorl %r15d, %r15d
leaq 0x207c5(%rip), %r14     # 0x2b770
movl (%rsp,%r15), %esi
testl %esi, %esi
je 0xafc1
negl %esi
movl (%r15,%r14), %edx
movq %rbx, %rdi
callq 0xa5f8
addq $0x4, %r15
cmpq $0x100, %r15            # imm = 0x100
jne 0xafab
movl 0x138(%rbx), %edi
movl 0x14c(%rbx), %eax
movl 0x150(%rbx), %ecx
movl (%r14,%rcx,4), %ecx
movl %ecx, 0x14c(%rbx)
movl (%r14,%rax,4), %eax
movl %eax, 0x150(%rbx)
callq 0xdf74
movl %eax, 0x138(%rbx)
movl 0x13c(%rbx), %eax
cmpq $0x40, %rax
je 0xb015
movl (%r14,%rax,4), %eax
movl %eax, 0x13c(%rbx)
movl 0x140(%rbx), %eax
movl %eax, %ecx
andl $0x3, %ecx
shrl $0x2, %eax
movl %eax, %edx
andl $0x1, %edx
leal (%rdx,%rcx,4), %ecx
andl $0x2, %eax
orl %ecx, %eax
movl %eax, 0x140(%rbx)
movq %rbx, %rdi
callq 0x5ee8
movq %rax, 0x1b8(%rbx)
movq %rbx, %rdi
callq 0x5fb7
movq %rax, 0x1c0(%rbx)
movq %rbx, %rdi
callq 0x231d4
testb %al, %al
je 0xb06d
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
leaq 0x20e67(%rip), %rdi     # 0x2bedb
leaq 0x20816(%rip), %rsi     # 0x2b891
leaq 0x20e73(%rip), %rcx     # 0x2bef5
movl $0x1c4, %edx            # imm = 0x1C4
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/prune.cpp
// Function: prune(position*, unsigned long long, bool, bool, int, int, int, int)
bool prune(position *pos,move last_move,bool incheck,bool gives_check,
        int32 extensions,int32 alpha,int32 beta,int32 depth) {

    if (depth < 3
        && alpha < (CHECKMATE-500) && beta < (CHECKMATE-500)
        && alpha > (-CHECKMATE+500) && beta > (-CHECKMATE+500)
        && extensions==0 && !incheck && !gives_check
        && !is_capture(last_move) && get_promopiece(last_move)==NO_PIECE
        && !(get_piece(last_move)==PAWN && (get_rank(get_to_sq(last_move))==RANK_2 || get_rank(get_to_sq(last_move))==RANK_7))) {

        int32 evalMat = -eval(pos,true);

        return (depth < 2 && (evalMat + pawn_val*2 <= alpha))   // futility pruning
            || (depth < 3 && (evalMat + pawn_val*5 <= alpha)) ;  // extended futility pruning
    }

    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r9d, %ebx
movq %rsi, %r15
movq %rdi, %r14
movl 0x38(%rsp), %ebp
movl 0x30(%rsp), %eax
cmpl $0x3, %ebp
setge %sil
movl $0xfe0b, %edi           # imm = 0xFE0B
cmpl %edi, %r9d
setge %r9b
orb %sil, %r9b
cmpl %edi, %eax
setge %sil
movl $0xffff01f6, %edi       # imm = 0xFFFF01F6
cmpl %edi, %ebx
setl %r10b
orb %sil, %r10b
orb %r9b, %r10b
cmpl %edi, %eax
setl %al
testl %r8d, %r8d
setne %sil
orb %al, %sil
orb %dl, %sil
orb %r10b, %sil
orb %cl, %sil
testb $0x1, %sil
jne 0xb22b
movq %r15, %rdi
callq 0x7883
testb %al, %al
jne 0xb22b
movq %r15, %rdi
callq 0x786f
testl %eax, %eax
je 0xb238
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x7865
cmpl $0x1, %eax
jne 0xb26d
movq %r15, %rdi
callq 0x785b
movl %eax, %edi
callq 0xca69
cmpl $0x6, %eax
je 0xb22b
movq %r15, %rdi
callq 0x785b
movl %eax, %edi
callq 0xca69
cmpl $0x1, %eax
je 0xb22b
movq %r14, %rdi
movl $0x1, %esi
callq 0x58f7
movl %eax, %ecx
cmpl $0x2, %ebp
setl %dl
movl $0xc8, %eax
subl %ecx, %eax
cmpl %ebx, %eax
setle %sil
movb $0x1, %al
testb %sil, %dl
jne 0xb22d
movl $0x1f4, %eax            # imm = 0x1F4
subl %ecx, %eax
cmpl %ebx, %eax
setle %al
jmp 0xb22d
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/search.cpp
// Function: build_move_order_dto(unsigned long long*, unsigned long long, unsigned long long, unsigned long long, unsigned long long, bool)
move_order_dto build_move_order_dto(move *startp,move pvmv,move hashmv,
        move killer1,move killer2,bool caps_only) {
    assert(get_move_score(&pvmv)==0);
    assert(get_move_score(&hashmv)==0);

    move_order_dto dto;
    dto.startp = dto.currentp = dto.endp = startp;
    dto.pv_move = pvmv;
    dto.hash_move = hashmv;
    dto.killer1 = killer1;
    dto.killer2 = killer2;
    dto.next_stage = PVMOVE;
    dto.caps_only = caps_only;
    return dto;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %r15
movq %rsi, %r12
movq %rdi, %r14
leaq 0x10(%rsp), %rdi
movq %rdx, (%rdi)
movq %rcx, 0x8(%rsp)
callq 0x78a1
testl %eax, %eax
jne 0xb356
leaq 0x8(%rsp), %rdi
callq 0x78a1
testl %eax, %eax
jne 0xb375
movb 0x40(%rsp), %al
movq %r12, 0x30(%r14)
movq %r12, 0x38(%r14)
movq %r12, 0x28(%r14)
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%r14)
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%r14)
movq %r15, 0x18(%r14)
movq %rbx, 0x20(%r14)
movl $0x0, (%r14)
movb %al, 0x4(%r14)
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x20bf0(%rip), %rdi     # 0x2bf4d
leaq 0x20c02(%rip), %rsi     # 0x2bf66
leaq 0x20c0a(%rip), %rcx     # 0x2bf75
movl $0x27, %edx
callq 0x20d0
leaq 0x20c43(%rip), %rdi     # 0x2bfbf
leaq 0x20be3(%rip), %rsi     # 0x2bf66
leaq 0x20beb(%rip), %rcx     # 0x2bf75
movl $0x28, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/search.cpp
// Function: update_parent_pv(move_line*, move_line*, unsigned long long)
void update_parent_pv(move_line *parent_pv,move_line* pv,move best_move) {
    assert(parent_pv);
    assert(pv);
    assert(best_move != BADMOVE);

    set_move_score(&best_move,0);

    parent_pv->mv[0] = best_move;
    if (pv->n > 0) {
        memcpy(parent_pv->mv+1,pv->mv,pv->n * sizeof(move));
        parent_pv->n = pv->n + 1;
    } else {
        parent_pv->n = 1;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, 0x8(%rsp)
testq %rdi, %rdi
je 0xc15b
movq %rsi, %r14
testq %rsi, %rsi
je 0xc17a
testq %rdx, %rdx
je 0xc199
movq %rdi, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x78bc
movq (%r15), %rax
movq %rax, 0x8(%rbx)
movslq (%r14), %rdx
testq %rdx, %rdx
jle 0xc14a
leaq 0x10(%rbx), %rdi
leaq 0x8(%r14), %rsi
shlq $0x3, %rdx
callq 0x2100
movl (%r14), %eax
incl %eax
jmp 0xc14f
movl $0x1, %eax
movl %eax, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1fed9(%rip), %rdi     # 0x2c03b
leaq 0x1fdfd(%rip), %rsi     # 0x2bf66
leaq 0x2013d(%rip), %rcx     # 0x2c2ad
movl $0x1a5, %edx            # imm = 0x1A5
callq 0x20d0
leaq 0x1fec1(%rip), %rdi     # 0x2c042
leaq 0x1fdde(%rip), %rsi     # 0x2bf66
leaq 0x2011e(%rip), %rcx     # 0x2c2ad
movl $0x1a6, %edx            # imm = 0x1A6
callq 0x20d0
leaq 0x20143(%rip), %rdi     # 0x2c2e3
leaq 0x1fdbf(%rip), %rsi     # 0x2bf66
leaq 0x200ff(%rip), %rcx     # 0x2c2ad
movl $0x1a7, %edx            # imm = 0x1A7
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/search.cpp
// Function: adjust_final_score_for_mates(position*, int, unsigned int, int)
int32 adjust_final_score_for_mates(position *pos,int32 score,uint32 moves_searched,int32 ply) {
    int32 adj_score = score;

    if (moves_searched==0) {
        if (in_check(pos,pos->player)) {
            adj_score = -(CHECKMATE-ply);
        } else {
            adj_score = DRAWSCORE;
        }
    }

    return adj_score;
}

// Assembly:
movl %esi, %eax
testl %edx, %edx
je 0xc5b3
retq
pushq %rbx
movl %ecx, %ebx
movl 0x138(%rdi), %esi
callq 0xaf41
movl %eax, %ecx
addl $0xffff0001, %ebx       # imm = 0xFFFF0001
xorl %eax, %eax
testb %cl, %cl
cmovnel %ebx, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/see.cpp
// Function: find_least_valuable(position*, unsigned long long)
square_t find_least_valuable(position *pos,uint64 attackers) {
    square_t lv_sq = NO_SQUARE;
    int32 lv_score = 0;

    while (attackers) {
        square_t sq = (square_t)get_lsb(attackers);

        int32 my_val = piece_val(pos->piece[sq]);
        if (lv_sq==NO_SQUARE || my_val < lv_score) {
            lv_score = my_val;
            lv_sq = sq;
        }

        attackers ^= bb_squares[sq];
    }

    return lv_sq;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0xc642
movq %rsi, %r14
movq %rdi, %rbx
xorl %r12d, %r12d
movl $0x40, %ebp
movq %r14, %rdi
callq 0x3b67
movl %eax, %r15d
movl %eax, %r13d
movl (%rbx,%r13,4), %edi
callq 0x4f30
cmpl $0x40, %ebp
sete %cl
cmpl %r12d, %eax
setl %dl
orb %cl, %dl
cmovnel %eax, %r12d
cmovnel %r15d, %ebp
leaq 0xede82(%rip), %rax     # 0xfa4b0
movq (%rax,%r13,8), %rax
movq %rax, %rcx
xorq %r14, %rcx
cmpq %r14, %rax
movq %rcx, %r14
jne 0xc5fa
jmp 0xc647
movl $0x40, %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_O3/jswaff[P]prophet3/src/see.cpp
// Function: add_xray_attackers(position*, square_t, dir_t, unsigned long long*, unsigned long long*)
void add_xray_attackers(position *pos,square_t from_sq,dir_t dir,
        uint64 *white_attackers,uint64 *black_attackers) {

    assert(dir != NODIR);

    uint64 targets = bb_rays[from_sq][dir];
    uint64 xrays;
    if (dir==NORTH || dir==SOUTH || dir==EAST || dir==WEST) {
        uint64 rook_moves = get_rook_moves(pos,from_sq,targets);
        xrays = rook_moves & (pos->white_rooks | pos->white_queens | pos->black_rooks | pos->black_queens);
    } else {
        uint64 bishop_moves = get_bishop_moves(pos,from_sq,targets);
        xrays = bishop_moves & (pos->white_bishops | pos->white_queens | pos->black_bishops | pos->black_queens);
    }

    assert(get_num_bits(xrays) <= 1);
    if (xrays & pos->white_pieces) {
        *white_attackers |= xrays;
    } else if (xrays & pos->black_pieces) {
        *black_attackers |= xrays;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x8, %edx
je 0xc70a
movq %r8, %r14
movq %rcx, %rbx
movq %rdi, %r15
movl %esi, %eax
movl %edx, %ecx
shlq $0x6, %rax
addq 0x35927(%rip), %rax     # 0x41fa8
movq (%rax,%rcx,8), %rax
cmpl $0x6, %edx
ja 0xc6f3
movl $0x55, %ecx
btl %edx, %ecx
jae 0xc6f3
movq %r15, %rdi
movq %rax, %rdx
callq 0x6828
movl $0x190, %ecx            # imm = 0x190
movl $0x188, %edx            # imm = 0x188
movq 0x198(%r15), %r12
orq (%r15,%rdx), %r12
orq (%r15,%rcx), %r12
orq 0x1a0(%r15), %r12
andq %rax, %r12
movq %r12, %rdi
callq 0x3b14
cmpl $0x2, %eax
jae 0xc729
testq %r12, 0x1a8(%r15)
jne 0xc6e4
movq %r14, %rbx
testq %r12, 0x1b0(%r15)
je 0xc6e7
orq %r12, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %r15, %rdi
movq %rax, %rdx
callq 0x6708
movl $0x180, %ecx            # imm = 0x180
movl $0x178, %edx            # imm = 0x178
jmp 0xc6a9
leaq 0x1fbe7(%rip), %rdi     # 0x2c2f8
leaq 0x1fbed(%rip), %rsi     # 0x2c305
leaq 0x1fbf2(%rip), %rcx     # 0x2c311
movl $0x29, %edx
callq 0x20d0
leaq 0x1fc2a(%rip), %rdi     # 0x2c35a
leaq 0x1fbce(%rip), %rsi     # 0x2c305
leaq 0x1fbd3(%rip), %rcx     # 0x2c311
movl $0x35, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/see.cpp
// Function: score_promotion(unsigned long long)
int32 score_promotion(move mv) {
    piece_t promo = get_promopiece(mv);
    if (promo==QUEEN) return 10005;
    if (promo==ROOK) return 10004;
    if (promo==BISHOP) return 10003;
    assert(promo==KNIGHT);
    return 10002;
}

// Assembly:
pushq %rax
callq 0x786f
leal -0x2(%rax), %ecx
cmpl $0x4, %ecx
jae 0xc75d
orl $0x2710, %eax           # imm = 0x2710
popq %rcx
retq
leaq 0x1e551(%rip), %rdi     # 0x2acb5
leaq 0x1fb9a(%rip), %rsi     # 0x2c305
leaq 0x1fc01(%rip), %rcx     # 0x2c373
movl $0x42, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/see.cpp
// Function: see(position*, unsigned long long)
int32 see(position *pos,move mv) {
    int32 score = 0;

    if (get_promopiece(mv) != NO_PIECE) {
        score = score_promotion(mv);
    }
    if (is_capture(mv)) {
        score += score_capture(pos,mv);
    }

    return score;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x786f
testl %eax, %eax
je 0xc988
movq %rbx, %rdi
callq 0xc748
movl %eax, %ebp
jmp 0xc98a
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x7883
testb %al, %al
je 0xc9a3
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc77c
addl %eax, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/square.cpp
// Function: get_dir_slow(square_t, square_t)
dir_t get_dir_slow(square_t from,square_t to) {
    int32 f_diff = get_file(from) - get_file(to);
    int32 r_diff = get_rank(from) - get_rank(to);

    if (f_diff == 0) {
        // same file
        if (r_diff < 0) return SOUTH;
        if (r_diff > 0) return NORTH;
    } else if (f_diff < 0) {
        // from is west of to
        if (r_diff == 0) return EAST;
        if (r_diff == f_diff) return SOUTHEAST;
        if (r_diff == -f_diff) return NORTHEAST;
    } else { // f_diff > 0
        // from is east of to
        if (r_diff == 0) return WEST;
        if (r_diff == f_diff) return NORTHWEST;
        if (r_diff == -f_diff) return SOUTHWEST;
    }

    return NODIR;
}

// Assembly:
pushq %rax
cmpl $0x40, %edi
jae 0xca1f
cmpl $0x40, %esi
jae 0xca1f
movl %edi, %ecx
andl $0x7, %ecx
movl %esi, %eax
andl $0x7, %eax
shrl $0x3, %edi
shrl $0x3, %esi
movl %edi, %edx
subl %esi, %edx
subl %eax, %ecx
jne 0xc9db
testl %edx, %edx
js 0xc9f6
xorl %eax, %eax
cmpl %esi, %edi
je 0xca18
jmp 0xca1d
js 0xc9fd
movl $0x6, %eax
cmpl %esi, %edi
je 0xca1d
movl $0x7, %eax
cmpl %ecx, %edx
je 0xca1d
movl $0x5, %eax
jmp 0xca14
movl $0x4, %eax
jmp 0xca1d
movl $0x2, %eax
cmpl %esi, %edi
je 0xca1d
movl $0x3, %eax
cmpl %ecx, %edx
je 0xca1d
movl $0x1, %eax
addl %ecx, %edx
je 0xca1d
movl $0x8, %eax
popq %rcx
retq
leaq 0x1c7e8(%rip), %rdi     # 0x2920e
leaq 0x1f9c0(%rip), %rsi     # 0x2c3ed
leaq 0x1f9e2(%rip), %rcx     # 0x2c416
movl $0x2e, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/square.cpp
// Function: is_light_sq(square_t)
bool is_light_sq(square_t sq) {
    assert(sq>=A8 && sq<=H1);
    rank_t r = get_rank(sq);
    file_t f = get_file(sq);
    return (r%2) == (f%2);
}

// Assembly:
cmpl $0x40, %edi
jae 0xce07
movl %edi, %eax
shrl $0x3, %eax
xorl %edi, %eax
testb $0x1, %al
sete %al
retq
pushq %rax
leaq 0x1f828(%rip), %rdi     # 0x2c637
leaq 0x1f5d7(%rip), %rsi     # 0x2c3ed
leaq 0x1f82b(%rip), %rcx     # 0x2c648
movl $0x7b, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/suites.cpp
// Function: get_ts_moves(position*, char*, unsigned long long*)
int get_ts_moves(position *pos,char *buf,move *m) {
    move *m_init = m;
    char *p = strtok(buf," ");

    while (p != NULL && (m-m_init) <= 5) {
        move mv = str_to_move(p,pos);
        if (mv==BADMOVE) {
            error("couldn't parse move.");
            exit(1);
        }
        *m = mv;
        m++;
        p = strtok(NULL," ");
    }

    return m-m_init;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %rax
movq %rdi, %r14
leaq 0x1f56d(%rip), %rsi     # 0x2c7d2
movq %rax, %rdi
callq 0x22c0
testq %rax, %rax
je 0xd2b7
movl $0x8, %r13d
xorl %r15d, %r15d
leaq 0x1f550(%rip), %r12     # 0x2c7d2
movq %rax, %rdi
movq %r14, %rsi
callq 0xe13f
testq %rax, %rax
je 0xd2c7
movq %rax, (%rbx,%r15,8)
xorl %edi, %edi
movq %r12, %rsi
callq 0x22c0
incq %r15
testq %rax, %rax
je 0xd2ba
leaq 0x8(%r13), %rcx
cmpq $0x30, %r13
movq %rcx, %r13
jl 0xd282
jmp 0xd2ba
xorl %r15d, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x1f52c(%rip), %rdi     # 0x2c7fa
xorl %eax, %eax
callq 0x2330
movl $0x1, %edi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/think.cpp
// Function: think()
void think() {

    // make a copy of the current position.  note that just because we are
    // operating off a copy of the global position, the global position
    // itself should remain unchanged until our search is complete.
    memcpy(&search_pos,&gpos,sizeof(position));

    // initialize the search's undo stack to what's already been played for draw detection
    memcpy(search_undos,gundos,gpos.move_counter * sizeof(undo));

    set_ponder_mode(false);
    set_abort_iterator(false);

    pthread_create(&think_thread,NULL,think_helper,NULL);
}

// Assembly:
pushq %rbx
leaq 0x86f5fe(%rip), %rdi    # 0x87c978
leaq 0xbb59f(%rip), %rbx     # 0xc8920
movl $0x1c8, %edx            # imm = 0x1C8
movq %rbx, %rsi
callq 0x2100
movl 0x144(%rbx), %edx
shlq $0x5, %rdx
leaq 0x879411(%rip), %rdi    # 0x8867b0
leaq 0xbb74a(%rip), %rsi     # 0xc8af0
callq 0x2100
xorl %ebx, %ebx
movb %bl, 0x86f5b2(%rip)     # 0x87c965
xorl %edi, %edi
callq 0xb2ab
movb %bl, 0x86f5b0(%rip)     # 0x87c970
xorl %edi, %edi
callq 0xb2ba
leaq 0xeb1c2(%rip), %rdi     # 0xf8590
leaq 0xa(%rip), %rdx         # 0xd3df
xorl %esi, %esi
xorl %ecx, %ecx
popq %rbx
jmp 0x2300
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/utils.cpp
// Function: str_to_sq(char const*)
square_t str_to_sq(const char *str_sq) {
    if (strlen(str_sq) != 2) {
        return NO_SQUARE;
    }
    int32 sq;

    // the first character should be a-h or A-H
    if (str_sq[0] >= 'a' && str_sq[0] <= 'h') {
        sq = str_sq[0] - 'a';
    } else if (str_sq[0] >= 'A' && str_sq[0] <= 'H') {
        sq = str_sq[0] - 'A';
    } else {
        return NO_SQUARE;
    }

    // the second character should be a digit 1-8
    if (str_sq[1] >= '1' && str_sq[1] <= '8') {
        sq += 8*(8-(str_sq[1]-'0'));
    } else {
        return NO_SQUARE;
    }

    return (square_t)sq;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x2080
movq %rax, %rcx
movl $0x40, %eax
cmpq $0x2, %rcx
jne 0xdfc3
movb (%rbx), %dl
leal -0x61(%rdx), %ecx
cmpb $0x8, %cl
jb 0xdfa8
addb $-0x41, %dl
movl %edx, %ecx
cmpb $0x7, %dl
ja 0xdfc3
movzbl 0x1(%rbx), %edx
leal -0x31(%rdx), %esi
cmpb $0x7, %sil
ja 0xdfc3
shll $0x3, %edx
andl $0x78, %edx
movzbl %cl, %eax
orl $0x40, %eax
subl %edx, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/utils.cpp
// Function: line_to_str(move_line*, char*)
void line_to_str(move_line *line,char *line_buffer) {
    assert(line);
    assert(line_buffer);
    line_buffer[0]='\0';
    char move_buffer[5];
    for (int i=0;i<line->n;i++) {
        move_to_str(line->mv[i],move_buffer);
        if (i>0) {
            int len=strlen(line_buffer);
            line_buffer[len] = ' ';
            line_buffer[len+1] = '\0';
        }
        strcat(line_buffer,move_buffer);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xe061
movq %rsi, %rbx
testq %rsi, %rsi
je 0xe080
movq %rdi, %r14
movb $0x0, (%rbx)
cmpl $0x0, (%rdi)
jle 0xe055
xorl %r12d, %r12d
leaq 0x3(%rsp), %r15
movq 0x8(%r14,%r12,8), %rdi
movq %r15, %rsi
callq 0xe09f
testq %r12, %r12
je 0xe03f
movq %rbx, %rdi
callq 0x2080
cltq
movb $0x20, (%rbx,%rax)
incl %eax
cltq
movb $0x0, (%rbx,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22f0
incq %r12
movslq (%r14), %rax
cmpq %rax, %r12
jl 0xe017
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1ee30(%rip), %rdi     # 0x2ce98
leaq 0x1ee2e(%rip), %rsi     # 0x2ce9d
leaq 0x1ee35(%rip), %rcx     # 0x2ceab
movl $0x32, %edx
callq 0x20d0
leaq 0x1ee4a(%rip), %rdi     # 0x2ced1
leaq 0x1ee0f(%rip), %rsi     # 0x2ce9d
leaq 0x1ee16(%rip), %rcx     # 0x2ceab
movl $0x33, %edx
callq 0x20d0
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/utils.cpp
// Function: move_to_str(unsigned long long, char*)
void move_to_str(move mv,char *buffer) {
    square_t from_sq = get_from_sq(mv);
    square_t to_sq = get_to_sq(mv);
    sq_to_str(from_sq,buffer);
    sq_to_str(to_sq,buffer+2);
    piece_t promo = get_promopiece(mv);
    if (promo != NO_PIECE) {
        if (promo==QUEEN) { buffer[4]='q'; }
        else if (promo==ROOK) { buffer[4]='r'; }
        else if (promo==BISHOP) { buffer[4]='b'; }
        else if (promo==KNIGHT) { buffer[4]='n'; }
        buffer[5]='\0';
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x7854
movl %eax, %r15d
movq %r14, %rdi
callq 0x785b
movl %eax, %ebp
movl %r15d, %edi
callq 0xca3e
addb $0x61, %al
movb %al, (%rbx)
movl %r15d, %edi
callq 0xca69
movb $0x38, %r15b
movb $0x38, %cl
subb %al, %cl
movb %cl, 0x1(%rbx)
xorl %r12d, %r12d
movb %r12b, 0x2(%rbx)
movl %ebp, %edi
callq 0xca3e
addb $0x61, %al
movb %al, 0x2(%rbx)
movl %ebp, %edi
callq 0xca69
subb %al, %r15b
movb %r15b, 0x3(%rbx)
movb %r12b, 0x4(%rbx)
movq %r14, %rdi
callq 0x786f
cmpl $0x5, %eax
ja 0xe132
movl %eax, %eax
leaq 0x1eb88(%rip), %rcx     # 0x2cca0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x6e, %al
jmp 0xe12f
movb $0x62, %al
jmp 0xe12f
movb $0x72, %al
jmp 0xe12f
movb $0x71, %al
movb %al, 0x4(%rbx)
movb $0x0, 0x5(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/utils.cpp
// Function: is_line_valid(move_line*, position*)
bool is_line_valid(move_line *line,position *pos) {

    // copy the position
    position my_pos;
    memcpy(&my_pos,pos,sizeof(position));

    undo undos[pos->move_counter + line->n];

    for (int i=0;i<line->n;i++) {
        if (!is_legal_move(line->mv[i],&my_pos)) {
            print("invalid line!\n");
            draw_board(pos);
            return false;
        }
        apply_move(&my_pos,line->mv[i],undos);
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb38, %rsp            # imm = 0xB38
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x200(%rbp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
callq 0x2100
movq %rsp, %rcx
movl (%r14), %eax
addl 0x144(%rbx), %eax
shlq $0x5, %rax
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
movb $0x1, %r15b
cmpl $0x0, (%r14)
jle 0xe66d
movq %rcx, -0x30(%rbp)
movq %rbx, -0x38(%rbp)
xorl %r13d, %r13d
movq 0x8(%r14,%r13,8), %rbx
leaq -0xb60(%rbp), %r15
movq %r15, %rdi
leaq -0x200(%rbp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x78e0
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xe682
testb %al, %al
je 0xe64f
movq 0x8(%r14,%r13,8), %rsi
leaq -0x200(%rbp), %rdi
movq %r12, %rdx
callq 0x30e1
incq %r13
movslq (%r14), %rax
cmpq %rax, %r13
jl 0xe5f0
movq -0x30(%rbp), %rcx
movb $0x1, %r15b
jmp 0xe66d
leaq 0x1e899(%rip), %rdi     # 0x2ceef
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x64b9
movq -0x38(%rbp), %rdi
callq 0x4bd8
movq -0x30(%rbp), %rcx
movq %rcx, %rsp
movl %r15d, %eax
leaq -0x28(%rbp), %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/utils.cpp
// Function: num_moves(unsigned long long*, unsigned long long*, bool, bool)
uint32 num_moves(move *startp,move *endp,bool caps,bool noncaps) {
    uint32 n=0;
    for (move* mp=startp;mp<endp;mp++) {
        if (*mp != 0) {
            if (is_capture(*mp) || get_promopiece(*mp)) {
                if (caps) n++;
            } else {
                if (noncaps) n++;
            }
        }
    }
    return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %ebp, %ebp
cmpq %rsi, %rdi
jae 0xe75e
movq %rsi, %rbx
movq %rdi, %r14
movzbl %cl, %r15d
movzbl %dl, %r12d
xorl %ebp, %ebp
movq (%r14), %rdi
testq %rdi, %rdi
je 0xe74e
callq 0x7883
testb %al, %al
jne 0xe74b
movq (%r14), %rdi
callq 0x786f
testl %eax, %eax
je 0xe759
addl %r12d, %ebp
addq $0x8, %r14
cmpq %rbx, %r14
jb 0xe72e
jmp 0xe75e
addl %r15d, %ebp
jmp 0xe74e
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/utils.cpp
// Function: get_game_status()
game_status get_game_status() {
    if (is_checkmate(&gpos)) return CHECKMATED;
    if (is_stalemate(&gpos)) return STALEMATED;
    if (is_lack_of_mating_material(&gpos)) return DRAW_MATERIAL;
    if (is_draw_by_rep(&gpos,gundos)) return DRAW_REP;
    if (is_draw_by_50(&gpos)) return DRAW_BY_50;

    return INPROGRESS;
}

// Assembly:
pushq %rax
leaq 0xba197(%rip), %rdi     # 0xc8920
callq 0xb08c
movl %eax, %ecx
movl $0x1, %eax
testb %cl, %cl
jne 0xe7f7
leaq 0xba180(%rip), %rdi     # 0xc8920
callq 0xb102
movl %eax, %ecx
movl $0x2, %eax
testb %cl, %cl
jne 0xe7f7
leaq 0xba169(%rip), %rdi     # 0xc8920
callq 0x4980
movl %eax, %ecx
movl $0x3, %eax
testb %cl, %cl
jne 0xe7f7
leaq 0xba152(%rip), %rdi     # 0xc8920
leaq 0xba31b(%rip), %rsi     # 0xc8af0
callq 0x4a6d
movl %eax, %ecx
movl $0x5, %eax
testb %cl, %cl
jne 0xe7f7
leaq 0xba134(%rip), %rdi     # 0xc8920
callq 0x4ba8
movzbl %al, %eax
shll $0x2, %eax
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/utils.cpp
// Function: undo_stacks_equal(undo*, undo*, int)
bool undo_stacks_equal(undo* stack1, undo* stack2,int32 num_elements) {

    for (int32 i=0;i<num_elements;i++) {
        undo e1 = *(stack1 + i);
        undo e2 = *(stack2 + i);

        if (e1.mv != e2.mv || e1.hash_key != e2.hash_key
                || e1.fifty_counter != e2.fifty_counter
                || e1.ep_sq != e2.ep_sq
                || e1.castling_rights != e2.castling_rights
                || e1.captured != e2.captured)
        {
            return false;
        }
    }

    return true;
}

// Assembly:
testl %edx, %edx
jle 0xe939
movq (%rdi), %rax
cmpq (%rsi), %rax
jne 0xe93d
movl %edx, %ecx
movl $0x8, %r8d
movl $0x1, %edx
xorl %eax, %eax
movq (%rdi,%r8), %r9
cmpq (%rsi,%r8), %r9
jne 0xe93f
movdqu 0x8(%rsi,%r8), %xmm0
movdqu 0x8(%rdi,%r8), %xmm1
pcmpeqd %xmm0, %xmm1
movmskps %xmm1, %r9d
cmpb $0xf, %r9b
jne 0xe93f
cmpq %rcx, %rdx
setae %al
je 0xe93f
movq 0x18(%rdi,%r8), %r9
leaq 0x20(%r8), %r10
incq %rdx
cmpq 0x18(%rsi,%r8), %r9
movq %r10, %r8
je 0xe8f3
jmp 0xe93f
movb $0x1, %al
jmp 0xe93f
xorl %eax, %eax
andb $0x1, %al
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_bk()
void handle_bk() {
    if (book_db==0) {
        print("\tbook not enabled\n");
    } else {
        move_freq_pair mfp[300];
        int32 num_book_moves = get_book_moves(mfp,&gpos);

        if (num_book_moves > 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);
                    print("\t%s, freq: %d\n",move_buffer,mfp[i].freq);
                }
            }
        } else {
            print("\tno book moves found\n");
        }
    }
    print("\n"); // blank line required by protocol
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x12d8, %rsp           # imm = 0x12D8
leaq 0xb5fbf(%rip), %rax     # 0xc4918
cmpq $0x0, (%rax)
je 0xe9bc
leaq 0xb9fba(%rip), %rsi     # 0xc8920
leaq 0x10(%rsp), %rdi
callq 0x47b6
testl %eax, %eax
jle 0xe9c5
movl %eax, %r15d
shlq $0x4, %r15
leaq 0x8(%rsp), %rbx
leaq 0x1e5ac(%rip), %r14     # 0x2cf33
xorl %r12d, %r12d
cmpl $0x0, 0x18(%rsp,%r12)
jle 0xe9b1
movq 0x10(%rsp,%r12), %rdi
movq %rbx, %rsi
callq 0xe09f
movl 0x18(%rsp,%r12), %edx
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x64b9
addq $0x10, %r12
cmpq %r12, %r15
jne 0xe98a
jmp 0xe9d3
leaq 0x1e55d(%rip), %rdi     # 0x2cf20
jmp 0xe9cc
leaq 0x1e576(%rip), %rdi     # 0x2cf42
xorl %eax, %eax
callq 0x64b9
leaq 0x1bf06(%rip), %rdi     # 0x2a8e0
xorl %eax, %eax
callq 0x64b9
addq $0x12d8, %rsp           # imm = 0x12D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq