LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: 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
movq %rsp, %rbp
subq $0x990, %rsp            # imm = 0x990
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x980(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %ecx
movl %ecx, %edx
callq 0xac70
movq %rax, -0x988(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0xd903
leaq -0x980(%rbp), %rdi
movq -0x988(%rbp), %rsi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x14d00
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0xd98d
leaq -0x980(%rbp), %rax
movq %rax, -0x990(%rbp)
movq -0x990(%rbp), %rax
cmpq -0x988(%rbp), %rax
jae 0xd985
movq -0x990(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xd930
jmp 0xd971
movq -0x10(%rbp), %rdi
movq -0x990(%rbp), %rax
movq (%rax), %rsi
leaq 0xc636b(%rip), %rdx     # 0xd3cb0
callq 0x3620
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
subl $0x1, %esi
callq 0xd8a0
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xc6344(%rip), %rsi     # 0xd3cb0
callq 0x39a0
movq -0x990(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x990(%rbp)
jmp 0xd911
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x990, %rsp            # imm = 0x990
popq %rbp
retq
nopw (%rax,%rax)
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
leaq 0xc612e(%rip), %rdi     # 0xd3ae0
callq 0x64e0
movq $0x0, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x4(%rbp), %eax
jg 0xda1b
movl -0x14(%rbp), %esi
leaq 0x295cc(%rip), %rdi     # 0x36fa4
movb $0x0, %al
callq 0x8c60
movl -0x14(%rbp), %esi
leaq 0xc60f7(%rip), %rdi     # 0xd3ae0
callq 0xd8a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0x29693(%rip), %rdi     # 0x37090
movb $0x0, %al
callq 0x8c60
movq -0x20(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xd9c6
movq -0x10(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0xff, %esi
callq 0x22d0
cmpq $0x0, %rax
je 0xda7b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2050
cmpq $0x0, %rax
je 0xda79
movb $0x1, -0x19(%rbp)
jmp 0xda7b
jmp 0xda48
movb -0x19(%rbp), %al
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xf3e0
movq -0x8(%rbp), %rdi
callq 0x64e0
callq 0x14080
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xd8a0
movq %rax, -0x30(%rbp)
callq 0x14080
subl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq 0x2918d(%rip), %rdi     # 0x37072
movb $0x0, %al
callq 0x8c60
imulq $0x3e8, -0x30(%rbp), %rax # imm = 0x3E8
movslq -0x34(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
leaq 0x29708(%rip), %rdi     # 0x3760f
movb $0x0, %al
callq 0x8c60
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0xdf22
movl $0x1, %edi
callq 0x21f0
movq -0x30(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: jswaff[P]prophet3/src/pos.cpp
// Function: remove_rook_castling_availability(position*, square_t)
void remove_rook_castling_availability(position *p,square_t sq) {
    if (sq==A1) {
        p->castling_rights &= CASTLE_NOT_WQ;
    } else if (sq==H1) {
        p->castling_rights &= CASTLE_NOT_WK;
    } else if (sq==A8) {
        p->castling_rights &= CASTLE_NOT_BQ;
    } else if (sq==H8) {
        p->castling_rights &= CASTLE_NOT_BK;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x38, -0xc(%rbp)
jne 0xf286
movq -0x8(%rbp), %rax
movl 0x140(%rax), %ecx
andl $0xd, %ecx
movl %ecx, 0x140(%rax)
jmp 0xf2db
cmpl $0x3f, -0xc(%rbp)
jne 0xf2a1
movq -0x8(%rbp), %rax
movl 0x140(%rax), %ecx
andl $0xe, %ecx
movl %ecx, 0x140(%rax)
jmp 0xf2d9
cmpl $0x0, -0xc(%rbp)
jne 0xf2bc
movq -0x8(%rbp), %rax
movl 0x140(%rax), %ecx
andl $0x7, %ecx
movl %ecx, 0x140(%rax)
jmp 0xf2d7
cmpl $0x7, -0xc(%rbp)
jne 0xf2d5
movq -0x8(%rbp), %rax
movl 0x140(%rax), %ecx
andl $0xb, %ecx
movl %ecx, 0x140(%rax)
jmp 0xf2d7
jmp 0xf2d9
jmp 0xf2db
popq %rbp
retq
nopl (%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xab20
testb $0x1, %al
jne 0xf2ff
jmp 0xf317
movq -0x10(%rbp), %rdi
callq 0xaaa0
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xf260
movq -0x10(%rbp), %rdi
callq 0xaa80
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x6, -0x1c(%rbp)
jne 0xf34b
movq -0x8(%rbp), %rax
movl 0x140(%rax), %ecx
andl $0xc, %ecx
movl %ecx, 0x140(%rax)
jmp 0xf382
cmpl $-0x6, -0x1c(%rbp)
jne 0xf366
movq -0x8(%rbp), %rax
movl 0x140(%rax), %ecx
andl $0x3, %ecx
movl %ecx, 0x140(%rax)
jmp 0xf380
cmpl $0x4, -0x1c(%rbp)
je 0xf372
cmpl $-0x4, -0x1c(%rbp)
jne 0xf37e
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0xf260
jmp 0xf380
jmp 0xf382
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xfa4b
jmp 0xfa6a
leaq 0x25af7(%rip), %rdi     # 0x35549
leaq 0x27c21(%rip), %rsi     # 0x3767a
movl $0x17d, %edx            # imm = 0x17D
leaq 0x28237(%rip), %rcx     # 0x37c9c
callq 0x20c0
xorl %eax, %eax
cmpl $0x0, -0xc(%rbp)
movb %al, -0x11(%rbp)
jl 0xfa7f
cmpl $0x3f, -0xc(%rbp)
setle %al
movb %al, -0x11(%rbp)
movb -0x11(%rbp), %al
testb $0x1, %al
jne 0xfa88
jmp 0xfa8a
jmp 0xfaa9
leaq 0x257b1(%rip), %rdi     # 0x35242
leaq 0x27be2(%rip), %rsi     # 0x3767a
movl $0x17e, %edx            # imm = 0x17E
leaq 0x281f8(%rip), %rcx     # 0x37c9c
callq 0x20c0
movb $0x1, %al
cmpl $0x1, -0x10(%rbp)
movb %al, -0x12(%rbp)
je 0xfabe
cmpl $0x0, -0x10(%rbp)
sete %al
movb %al, -0x12(%rbp)
movb -0x12(%rbp), %al
testb $0x1, %al
jne 0xfac7
jmp 0xfac9
jmp 0xfae8
leaq 0x25787(%rip), %rdi     # 0x35257
leaq 0x27ba3(%rip), %rsi     # 0x3767a
movl $0x17f, %edx            # imm = 0x17F
leaq 0x281b9(%rip), %rcx     # 0x37c9c
callq 0x20c0
cmpl $0x1, -0x10(%rbp)
jne 0xfb02
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movl (%rax,%rcx,4), %edi
callq 0x14dc0
movb %al, -0x13(%rbp)
jmp 0xfb14
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movl (%rax,%rcx,4), %edi
callq 0x14da0
movb %al, -0x13(%rbp)
movb -0x13(%rbp), %al
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nop
// File: jswaff[P]prophet3/src/pos.cpp
// Function: is_zugzwang(position*)
bool is_zugzwang(position *pos) {

    if (pos->piece_counts[WHITE][ROOK] + pos->piece_counts[WHITE][KNIGHT]
           + pos->piece_counts[WHITE][BISHOP] + pos->piece_counts[WHITE][QUEEN] == 0)
    {
        return true;
    }

    if (pos->piece_counts[BLACK][ROOK] + pos->piece_counts[BLACK][KNIGHT]
           + pos->piece_counts[BLACK][BISHOP] + pos->piece_counts[BLACK][QUEEN] == 0)
    {
        return true;
    }


    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x12c(%rax), %eax
movq -0x10(%rbp), %rcx
addl 0x124(%rcx), %eax
movq -0x10(%rbp), %rcx
addl 0x128(%rcx), %eax
movq -0x10(%rbp), %rcx
addl 0x130(%rcx), %eax
cmpl $0x0, %eax
jne 0x1002b
movb $0x1, -0x1(%rbp)
jmp 0x10062
movq -0x10(%rbp), %rax
movl 0x110(%rax), %eax
movq -0x10(%rbp), %rcx
addl 0x108(%rcx), %eax
movq -0x10(%rbp), %rcx
addl 0x10c(%rcx), %eax
movq -0x10(%rbp), %rcx
addl 0x114(%rcx), %eax
cmpl $0x0, %eax
jne 0x1005e
movb $0x1, -0x1(%rbp)
jmp 0x10062
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
popq %rbp
retq
nopl (%rax)
// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movb %cl, %al
movb %dl, %cl
movl 0x18(%rbp), %edx
movl 0x10(%rbp), %edx
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %cl
movb %cl, -0x19(%rbp)
andb $0x1, %al
movb %al, -0x1a(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
cmpl $0x3, 0x18(%rbp)
jge 0x101b0
cmpl $0xfe0b, -0x24(%rbp)    # imm = 0xFE0B
jge 0x101b0
cmpl $0xfe0b, 0x10(%rbp)     # imm = 0xFE0B
jge 0x101b0
cmpl $0xffff01f5, -0x24(%rbp) # imm = 0xFFFF01F5
jle 0x101b0
cmpl $0xffff01f5, 0x10(%rbp) # imm = 0xFFFF01F5
jle 0x101b0
cmpl $0x0, -0x20(%rbp)
jne 0x101b0
testb $0x1, -0x19(%rbp)
jne 0x101b0
testb $0x1, -0x1a(%rbp)
jne 0x101b0
movq -0x18(%rbp), %rdi
callq 0xab20
testb $0x1, %al
jne 0x101b0
movq -0x18(%rbp), %rdi
callq 0xaae0
cmpl $0x0, %eax
jne 0x101b0
movq -0x18(%rbp), %rdi
callq 0xaac0
cmpl $0x1, %eax
jne 0x10154
movq -0x18(%rbp), %rdi
callq 0xaaa0
movl %eax, %edi
callq 0x120d0
cmpl $0x6, %eax
je 0x101b0
movq -0x18(%rbp), %rdi
callq 0xaaa0
movl %eax, %edi
callq 0x120d0
cmpl $0x1, %eax
je 0x101b0
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x7630
movl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x28(%rbp)
cmpl $0x2, 0x18(%rbp)
jge 0x10184
movl -0x28(%rbp), %ecx
addl $0xc8, %ecx
movb $0x1, %al
cmpl -0x24(%rbp), %ecx
movb %al, -0x29(%rbp)
jle 0x101a6
xorl %eax, %eax
cmpl $0x3, 0x18(%rbp)
movb %al, -0x2a(%rbp)
jge 0x101a0
movl -0x28(%rbp), %eax
addl $0x1f4, %eax            # imm = 0x1F4
cmpl -0x24(%rbp), %eax
setle %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x101b4
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nop
// File: 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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
movb 0x10(%rbp), %al
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
leaq -0x10(%rbp), %rdi
callq 0xab90
cmpl $0x0, %eax
jne 0x102ac
jmp 0x102cb
leaq 0x27bcd(%rip), %rdi     # 0x37e80
leaq 0x27bdf(%rip), %rsi     # 0x37e99
movl $0x27, %edx
leaq 0x27be2(%rip), %rcx     # 0x37ea8
callq 0x20c0
leaq -0x18(%rbp), %rdi
callq 0xab90
cmpl $0x0, %eax
jne 0x102db
jmp 0x102fa
leaq 0x27c10(%rip), %rdi     # 0x37ef2
leaq 0x27bb0(%rip), %rsi     # 0x37e99
movl $0x28, %edx
leaq 0x27bb3(%rip), %rcx     # 0x37ea8
callq 0x20c0
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rdx
movq %rdx, 0x30(%rcx)
movq %rdx, 0x38(%rcx)
movq %rdx, 0x28(%rcx)
movq -0x10(%rbp), %rdx
movq %rdx, 0x8(%rcx)
movq -0x18(%rbp), %rdx
movq %rdx, 0x10(%rcx)
movq -0x20(%rbp), %rdx
movq %rdx, 0x18(%rcx)
movq -0x28(%rbp), %rdx
movq %rdx, 0x20(%rcx)
movl $0x0, (%rcx)
movb -0x29(%rbp), %dl
andb $0x1, %dl
movb %dl, 0x4(%rcx)
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x113fd
jmp 0x1141c
leaq 0x26b6a(%rip), %rdi     # 0x37f6e
leaq 0x26a8e(%rip), %rsi     # 0x37e99
movl $0x1a5, %edx            # imm = 0x1A5
leaq 0x26dc9(%rip), %rcx     # 0x381e0
callq 0x20c0
cmpq $0x0, -0x10(%rbp)
je 0x11425
jmp 0x11444
leaq 0x26b49(%rip), %rdi     # 0x37f75
leaq 0x26a66(%rip), %rsi     # 0x37e99
movl $0x1a6, %edx            # imm = 0x1A6
leaq 0x26da1(%rip), %rcx     # 0x381e0
callq 0x20c0
cmpq $0x0, -0x18(%rbp)
je 0x1144d
jmp 0x1146c
leaq 0x26dc2(%rip), %rdi     # 0x38216
leaq 0x26a3e(%rip), %rsi     # 0x37e99
movl $0x1a7, %edx            # imm = 0x1A7
leaq 0x26d79(%rip), %rcx     # 0x381e0
callq 0x20c0
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0xabe0
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x114c1
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rax
movslq (%rax), %rdx
shlq $0x3, %rdx
callq 0x20f0
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
jmp 0x114cb
movq -0x8(%rbp), %rax
movl $0x1, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x11974
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x138(%rax), %esi
callq 0xfc10
testb $0x1, %al
jne 0x1195a
jmp 0x1196b
movl $0xffff, %ecx           # imm = 0xFFFF
subl -0x14(%rbp), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x18(%rbp)
jmp 0x11972
movl $0x0, -0x18(%rbp)
jmp 0x11974
movl -0x18(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x40, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x11a27
movq -0x10(%rbp), %rdi
callq 0x4870
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl (%rax,%rcx,4), %edi
callq 0x68c0
movl %eax, -0x20(%rbp)
cmpl $0x40, -0x14(%rbp)
je 0x11a01
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x11a0d
movl -0x20(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
leaq 0xf3c57(%rip), %rax     # 0x105670
movq (%rax,%rcx,8), %rax
xorq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x119ce
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
// File: 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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
cmpl $0x8, -0x10(%rbp)
je 0x11a52
jmp 0x11a71
leaq 0x267d2(%rip), %rdi     # 0x3822b
leaq 0x267d8(%rip), %rsi     # 0x38238
movl $0x29, %edx
leaq 0x267d8(%rip), %rcx     # 0x38244
callq 0x20c0
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xf45f3(%rip), %rax     # 0x106070
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x10(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0x11aa7
cmpl $0x4, -0x10(%rbp)
je 0x11aa7
cmpl $0x2, -0x10(%rbp)
je 0x11aa7
cmpl $0x6, -0x10(%rbp)
jne 0x11af4
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x9170
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x188(%rcx), %rcx
movq -0x8(%rbp), %rdx
orq 0x198(%rdx), %rcx
movq -0x8(%rbp), %rdx
orq 0x190(%rdx), %rcx
movq -0x8(%rbp), %rdx
orq 0x1a0(%rdx), %rcx
andq %rcx, %rax
movq %rax, -0x30(%rbp)
jmp 0x11b3f
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x8fc0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x178(%rcx), %rcx
movq -0x8(%rbp), %rdx
orq 0x198(%rdx), %rcx
movq -0x8(%rbp), %rdx
orq 0x180(%rdx), %rcx
movq -0x8(%rbp), %rdx
orq 0x1a0(%rdx), %rcx
andq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x47b0
cmpl $0x1, %eax
ja 0x11b4f
jmp 0x11b6e
leaq 0x26737(%rip), %rdi     # 0x3828d
leaq 0x266db(%rip), %rsi     # 0x38238
movl $0x35, %edx
leaq 0x266db(%rip), %rcx     # 0x38244
callq 0x20c0
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
andq 0x1a8(%rcx), %rax
cmpq $0x0, %rax
je 0x11b93
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x11bb8
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
andq 0x1b0(%rcx), %rax
cmpq $0x0, %rax
je 0x11bb6
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x11bb8
addq $0x40, %rsp
popq %rbp
retq
nop
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaae0
movl %eax, -0x14(%rbp)
cmpl $0x5, -0x14(%rbp)
jne 0x11be7
movl $0x2715, -0x4(%rbp)     # imm = 0x2715
jmp 0x11c33
cmpl $0x4, -0x14(%rbp)
jne 0x11bf6
movl $0x2714, -0x4(%rbp)     # imm = 0x2714
jmp 0x11c33
cmpl $0x3, -0x14(%rbp)
jne 0x11c05
movl $0x2713, -0x4(%rbp)     # imm = 0x2713
jmp 0x11c33
cmpl $0x2, -0x14(%rbp)
jne 0x11c0d
jmp 0x11c2c
leaq 0x25052(%rip), %rdi     # 0x36c66
leaq 0x2661d(%rip), %rsi     # 0x38238
movl $0x42, %edx
leaq 0x2667f(%rip), %rcx     # 0x382a6
callq 0x20c0
movl $0x2712, -0x4(%rbp)     # imm = 0x2712
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaae0
cmpl $0x0, %eax
je 0x11f41
movq -0x10(%rbp), %rdi
callq 0x11bc0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0xab20
testb $0x1, %al
jne 0x11f50
jmp 0x11f63
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x11c40
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0x8(%rbp), %edi
callq 0x12070
movl %eax, -0x1c(%rbp)
movl -0xc(%rbp), %edi
callq 0x12070
movl %eax, %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %edi
callq 0x120d0
movl %eax, -0x18(%rbp)
movl -0xc(%rbp), %edi
callq 0x120d0
movl %eax, %ecx
movl -0x18(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x11fe1
cmpl $0x0, -0x14(%rbp)
jge 0x11fd0
movl $0x4, -0x4(%rbp)
jmp 0x1205e
cmpl $0x0, -0x14(%rbp)
jle 0x11fdf
movl $0x0, -0x4(%rbp)
jmp 0x1205e
jmp 0x12057
cmpl $0x0, -0x10(%rbp)
jge 0x1201e
cmpl $0x0, -0x14(%rbp)
jne 0x11ff6
movl $0x2, -0x4(%rbp)
jmp 0x1205e
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x12007
movl $0x3, -0x4(%rbp)
jmp 0x1205e
movl -0x14(%rbp), %eax
xorl %ecx, %ecx
subl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jne 0x1201c
movl $0x1, -0x4(%rbp)
jmp 0x1205e
jmp 0x12055
cmpl $0x0, -0x14(%rbp)
jne 0x1202d
movl $0x6, -0x4(%rbp)
jmp 0x1205e
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x1203e
movl $0x7, -0x4(%rbp)
jmp 0x1205e
movl -0x14(%rbp), %eax
xorl %ecx, %ecx
subl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jne 0x12053
movl $0x5, -0x4(%rbp)
jmp 0x1205e
jmp 0x12055
jmp 0x12057
movl $0x8, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x4(%rbp)
movb %al, -0xd(%rbp)
jl 0x12870
cmpl $0x3f, -0x4(%rbp)
setle %al
movb %al, -0xd(%rbp)
movb -0xd(%rbp), %al
testb $0x1, %al
jne 0x12879
jmp 0x1287b
jmp 0x1289a
leaq 0x25ce8(%rip), %rdi     # 0x3856a
leaq 0x25a97(%rip), %rsi     # 0x38320
movl $0x7b, %edx
leaq 0x25ce6(%rip), %rcx     # 0x3857b
callq 0x20c0
movl -0x4(%rbp), %edi
callq 0x120d0
movl %eax, -0x8(%rbp)
movl -0x4(%rbp), %edi
callq 0x12070
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0x14(%rbp)
movl -0xc(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl -0x14(%rbp), %edx
cmpl %eax, %edx
sete %al
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x257ee(%rip), %rsi     # 0x38705
callq 0x22c0
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x31(%rbp)
je 0x12f45
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x5, %rax
setle %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x12f4e
jmp 0x12fae
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x14400
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x12f7e
leaq 0x257c0(%rip), %rdi     # 0x3872d
movb $0x0, %al
callq 0x8f00
movl $0x1, %edi
callq 0x21f0
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x25765(%rip), %rsi     # 0x38705
callq 0x22c0
movq %rax, -0x28(%rbp)
jmp 0x12f20
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)
// File: 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 %rbp
movq %rsp, %rbp
leaq 0x8749cd(%rip), %rdi    # 0x887b38
leaq 0xc096e(%rip), %rsi     # 0xd3ae0
movl $0x1c8, %edx            # imm = 0x1C8
callq 0x20f0
leaq 0xc095d(%rip), %rax     # 0xd3ae0
movl 0x144(%rax), %eax
movl %eax, %edx
shlq $0x5, %rdx
leaq 0x87e7da(%rip), %rdi    # 0x891970
leaq 0xc0b13(%rip), %rsi     # 0xd3cb0
callq 0x20f0
xorl %edi, %edi
callq 0x130e0
xorl %edi, %edi
callq 0x130b0
leaq 0xf0599(%rip), %rdi     # 0x103750
xorl %eax, %eax
movl %eax, %ecx
leaq 0xe(%rip), %rdx         # 0x131d0
movq %rcx, %rsi
callq 0x2300
popq %rbp
retq
nopl (%rax)
// File: jswaff[P]prophet3/src/think.cpp
// Function: build_search_stats_dto()
search_stats build_search_stats_dto() {
    search_stats stats;
    stats.nodes=0;
    stats.qnodes=0;
    stats.fail_highs=0;
    stats.fail_lows=0;
    stats.hash_exact_scores=0;
    stats.first_line_searched.n=0;
    stats.prunes=0;
    stats.last_pv.n=0;
    for (int i=0;i<MAX_PLY;i++) {
        stats.last_pv.mv[i] = BADMOVE;
        stats.first_line_searched.mv[i] = BADMOVE;
    }

    return stats;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x18(%rbp)
movq %rdi, %rax
movq %rax, -0x10(%rbp)
movq $0x0, 0x18(%rdi)
movq $0x0, 0x20(%rdi)
movq $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
movl $0x0, 0x350(%rdi)
movq $0x0, 0x678(%rdi)
movl $0x0, 0x28(%rdi)
movl $0x0, -0x4(%rbp)
cmpl $0x64, -0x4(%rbp)
jge 0x13a9b
movq -0x18(%rbp), %rax
movslq -0x4(%rbp), %rcx
movq $0x0, 0x30(%rax,%rcx,8)
movslq -0x4(%rbp), %rcx
movq $0x0, 0x358(%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x13a69
movq -0x10(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: jswaff[P]prophet3/src/time.cpp
// Function: get_search_time(int, int)
int32 get_search_time(int32 remaining_time,int32 increment) {
    if (remaining_time < 0)
        remaining_time = 0;

    int32 search_time = (remaining_time / 25) + increment;

    // try to leave 1/10th of a second for overhead to avoid time losses in very fast games
    search_time -= 100;
    if (search_time < 0) {
        search_time = 0;
    }

    return search_time;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
cmpl $0x0, -0x4(%rbp)
jge 0x140f7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl $0x19, %ecx
cltd
idivl %ecx
addl -0x8(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
subl $0x64, %eax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0x1411e
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2080
cmpq $0x2, %rax
je 0x14177
movl $0x40, -0x4(%rbp)
jmp 0x14216
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jl 0x1419e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x68, %eax
jg 0x1419e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
subl $0x61, %eax
movl %eax, -0x14(%rbp)
jmp 0x141d0
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x41, %eax
jl 0x141c5
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x48, %eax
jg 0x141c5
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
subl $0x41, %eax
movl %eax, -0x14(%rbp)
jmp 0x141ce
movl $0x40, -0x4(%rbp)
jmp 0x14216
jmp 0x141d0
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jl 0x14207
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x38, %eax
jg 0x14207
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %ecx
subl $0x30, %ecx
movl $0x8, %eax
subl %ecx, %eax
shll $0x3, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x14210
movl $0x40, -0x4(%rbp)
jmp 0x14216
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x14289
jmp 0x142a8
leaq 0x24a14(%rip), %rdi     # 0x38ca4
leaq 0x24a12(%rip), %rsi     # 0x38ca9
movl $0x32, %edx
leaq 0x24a14(%rip), %rcx     # 0x38cb7
callq 0x20c0
cmpq $0x0, -0x10(%rbp)
je 0x142b1
jmp 0x142d0
leaq 0x24a25(%rip), %rdi     # 0x38cdd
leaq 0x249ea(%rip), %rsi     # 0x38ca9
movl $0x33, %edx
leaq 0x249ec(%rip), %rcx     # 0x38cb7
callq 0x20c0
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x14346
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
leaq -0x15(%rbp), %rsi
callq 0x14350
cmpl $0x0, -0x1c(%rbp)
jle 0x1432e
movq -0x10(%rbp), %rdi
callq 0x2080
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x20, (%rax,%rcx)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rdi
leaq -0x15(%rbp), %rsi
callq 0x22f0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x142de
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xaa80
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0xaaa0
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x14220
movl -0x18(%rbp), %edi
movq -0x10(%rbp), %rsi
addq $0x2, %rsi
callq 0x14220
movq -0x8(%rbp), %rdi
callq 0xaae0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x143f2
cmpl $0x5, -0x1c(%rbp)
jne 0x143b6
movq -0x10(%rbp), %rax
movb $0x71, 0x4(%rax)
jmp 0x143ea
cmpl $0x4, -0x1c(%rbp)
jne 0x143c6
movq -0x10(%rbp), %rax
movb $0x72, 0x4(%rax)
jmp 0x143e8
cmpl $0x3, -0x1c(%rbp)
jne 0x143d6
movq -0x10(%rbp), %rax
movb $0x62, 0x4(%rax)
jmp 0x143e6
cmpl $0x2, -0x1c(%rbp)
jne 0x143e4
movq -0x10(%rbp), %rax
movb $0x6e, 0x4(%rax)
jmp 0x143e6
jmp 0x143e8
jmp 0x143ea
movq -0x10(%rbp), %rax
movb $0x0, 0x5(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: 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
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x1e0(%rbp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
callq 0x20f0
movq -0x18(%rbp), %rax
movl 0x144(%rax), %eax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
addl %ecx, %eax
movq %rsp, %rcx
movq %rcx, -0x1e8(%rbp)
movq %rax, %rdx
shlq $0x5, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x200(%rbp)
movq %rcx, %rsp
movq %rax, -0x1f0(%rbp)
movl $0x0, -0x1f4(%rbp)
movl -0x1f4(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x14be8
movq -0x10(%rbp), %rax
movslq -0x1f4(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x14a90
testb $0x1, %al
jne 0x14bb1
leaq 0x2416a(%rip), %rdi     # 0x38cfb
movb $0x0, %al
callq 0x8c60
movq -0x18(%rbp), %rdi
callq 0x64e0
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1f8(%rbp)
jmp 0x14bf6
movq -0x200(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x1f4(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rsi
leaq -0x1e0(%rbp), %rdi
callq 0x3620
movl -0x1f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f4(%rbp)
jmp 0x14b5c
movb $0x1, -0x1(%rbp)
movl $0x1, -0x1f8(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, %rsp
movb -0x1(%rbp), %al
andb $0x1, %al
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: jswaff[P]prophet3/src/utils.cpp
// Function: is_in_move_list(unsigned long long, unsigned long long*, unsigned long long*)
bool is_in_move_list(move mv,move *start,move *end) {
    for (move *mp=start;mp<end;mp++) {
        if (clear_score(*mp) == clear_score(mv)) {
            return true;
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x14c71
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0xac50
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0xac50
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jne 0x14c61
movb $0x1, -0x1(%rbp)
jmp 0x14c75
jmp 0x14c63
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0x14c2c
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %cl
movb %cl, -0x11(%rbp)
andb $0x1, %al
movb %al, -0x12(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x14d97
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x14d87
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0xab20
testb $0x1, %al
jne 0x14d63
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0xaae0
cmpl $0x0, %eax
je 0x14d74
testb $0x1, -0x11(%rbp)
je 0x14d72
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x14d85
testb $0x1, -0x12(%rbp)
je 0x14d83
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x14d85
jmp 0x14d87
jmp 0x14d89
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
jmp 0x14d2e
movl -0x18(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
// File: 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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0xbecb1(%rip), %rdi     # 0xd3ae0
callq 0xfef0
testb $0x1, %al
jne 0x14e3a
jmp 0x14e43
movl $0x1, -0x4(%rbp)
jmp 0x14ebd
leaq 0xbec96(%rip), %rdi     # 0xd3ae0
callq 0xff70
testb $0x1, %al
jne 0x14e55
jmp 0x14e5e
movl $0x2, -0x4(%rbp)
jmp 0x14ebd
leaq 0xbec7b(%rip), %rdi     # 0xd3ae0
callq 0x6180
testb $0x1, %al
jne 0x14e70
jmp 0x14e79
movl $0x3, -0x4(%rbp)
jmp 0x14ebd
leaq 0xbec60(%rip), %rdi     # 0xd3ae0
leaq 0xbee29(%rip), %rsi     # 0xd3cb0
callq 0x62d0
testb $0x1, %al
jne 0x14e92
jmp 0x14e9b
movl $0x5, -0x4(%rbp)
jmp 0x14ebd
leaq 0xbec3e(%rip), %rdi     # 0xd3ae0
callq 0x6490
testb $0x1, %al
jne 0x14ead
jmp 0x14eb6
movl $0x4, -0x4(%rbp)
jmp 0x14ebd
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: jswaff[P]prophet3/src/utils.cpp
// Function: random32()
uint32 random32() {
    /*
      random numbers from Mathematica 2.0.
      SeedRandom = 1;
      Table[Random[Integer, {0, 2^32 - 1}]
     */
    static unsigned long x[55] = {
            1410651636UL, 3012776752UL, 3497475623UL, 2892145026UL, 1571949714UL,
            3253082284UL, 3489895018UL, 387949491UL, 2597396737UL, 1981903553UL,
            3160251843UL, 129444464UL, 1851443344UL, 4156445905UL, 224604922UL,
            1455067070UL, 3953493484UL, 1460937157UL, 2528362617UL, 317430674UL,
            3229354360UL, 117491133UL, 832845075UL, 1961600170UL, 1321557429UL,
            747750121UL, 545747446UL, 810476036UL, 503334515UL, 4088144633UL,
            2824216555UL, 3738252341UL, 3493754131UL, 3672533954UL, 29494241UL,
            1180928407UL, 4213624418UL, 33062851UL, 3221315737UL, 1145213552UL,
            2957984897UL, 4078668503UL, 2262661702UL, 65478801UL, 2527208841UL,
            1960622036UL, 315685891UL, 1196037864UL, 804614524UL, 1421733266UL,
            2017105031UL, 3882325900UL, 810735053UL, 384606609UL, 2393861397UL };

    static int init = 1;
    static unsigned long y[55];
    static int j, k;
    unsigned long ul;

    if (init) {
        int i;

        init = 0;
        for (i = 0; i < 55; i++) {
            y[i] = x[i];
        }
        j = 24 - 1;
        k = 55 - 1;
    }

    ul = (y[k] += y[j]);
    if (--j < 0) {
        j = 55 - 1;
    }
    if (--k < 0) {
        k = 55 - 1;
    }

    return((uint32)ul);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $0x0, 0x3844d(%rip)     # 0x4d368
je 0x14f71
movl $0x0, 0x38441(%rip)     # 0x4d368
movl $0x0, -0xc(%rbp)
cmpl $0x37, -0xc(%rbp)
jge 0x14f5d
movslq -0xc(%rbp), %rcx
leaq 0x38271(%rip), %rax     # 0x4d1b0
movq (%rax,%rcx,8), %rdx
movslq -0xc(%rbp), %rcx
leaq 0x8abe32(%rip), %rax    # 0x8c0d80
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x14f2e
movl $0x17, 0x8abfd1(%rip)   # 0x8c0f38
movl $0x36, 0x8abfcb(%rip)   # 0x8c0f3c
movslq 0x8abfc0(%rip), %rcx    # 0x8c0f38
leaq 0x8abe01(%rip), %rax    # 0x8c0d80
movq (%rax,%rcx,8), %rax
movslq 0x8abfb2(%rip), %rdx    # 0x8c0f3c
leaq 0x8abdef(%rip), %rcx    # 0x8c0d80
addq (%rcx,%rdx,8), %rax
leaq 0x8abde4(%rip), %rcx    # 0x8c0d80
movq %rax, (%rcx,%rdx,8)
movq %rax, -0x8(%rbp)
movl 0x8abf8e(%rip), %eax    # 0x8c0f38
addl $-0x1, %eax
movl %eax, 0x8abf85(%rip)    # 0x8c0f38
cmpl $0x0, %eax
jge 0x14fc2
movl $0x36, 0x8abf76(%rip)   # 0x8c0f38
movl 0x8abf74(%rip), %eax    # 0x8c0f3c
addl $-0x1, %eax
movl %eax, 0x8abf6b(%rip)    # 0x8c0f3c
cmpl $0x0, %eax
jge 0x14fe0
movl $0x36, 0x8abf5c(%rip)   # 0x8c0f3c
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x150e8
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x60(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x150d2
movq -0x38(%rbp), %rax
cmpq -0x58(%rbp), %rax
jne 0x150d2
movl -0x28(%rbp), %eax
cmpl -0x48(%rbp), %eax
jne 0x150d2
movl -0x2c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jne 0x150d2
movl -0x24(%rbp), %eax
cmpl -0x44(%rbp), %eax
jne 0x150d2
movl -0x30(%rbp), %eax
cmpl -0x50(%rbp), %eax
je 0x150d8
movb $0x0, -0x1(%rbp)
jmp 0x150ec
jmp 0x150da
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x15036
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)