LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/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:
movl %edi, %eax
xorl %ecx, %ecx
testl %edi, %edi
cmovlel %ecx, %eax
pushq $0x19
popq %rcx
xorl %edx, %edx
divl %ecx
addl %esi, %eax
cmpl $0x65, %eax
pushq $0x64
popq %rcx
cmovll %ecx, %eax
addl $-0x64, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x40
popq %rax
cmpq $0x2, %rcx
jne 0xd525
movb (%rbx), %dl
leal -0x61(%rdx), %ecx
cmpb $0x8, %cl
jb 0xd50a
addb $-0x41, %dl
movl %edx, %ecx
cmpb $0x7, %dl
ja 0xd525
movzbl 0x1(%rbx), %edx
leal -0x31(%rdx), %esi
cmpb $0x7, %sil
ja 0xd525
shll $0x3, %edx
andl $0x78, %edx
movzbl %cl, %eax
orl $0x40, %eax
subl %edx, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 0xd5c0
movq %rsi, %rbx
testq %rsi, %rsi
je 0xd5d9
movq %rdi, %r14
movb $0x0, (%rbx)
xorl %r12d, %r12d
leaq 0x3(%rsp), %r15
movslq (%r14), %rax
cmpq %rax, %r12
jge 0xd5b4
movq 0x8(%r14,%r12,8), %rdi
movq %r15, %rsi
callq 0xd5f6
testq %r12, %r12
je 0xd5a4
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
jmp 0xd574
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1d881(%rip), %rdi     # 0x2ae48
leaq 0x1d87f(%rip), %rsi     # 0x2ae4d
leaq 0x1d886(%rip), %rcx     # 0x2ae5b
pushq $0x32
jmp 0xd5f0
leaq 0x1d8a1(%rip), %rdi     # 0x2ae81
leaq 0x1d866(%rip), %rsi     # 0x2ae4d
leaq 0x1d86d(%rip), %rcx     # 0x2ae5b
pushq $0x33
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x736b
movl %eax, %ebp
movq %r14, %rdi
callq 0x7372
movl %eax, %r15d
movl %ebp, %edi
movq %rbx, %rsi
callq 0xd527
leaq 0x2(%rbx), %rsi
movl %r15d, %edi
callq 0xd527
movq %r14, %rdi
callq 0x7386
cmpl $0x5, %eax
ja 0xd65b
movl %eax, %eax
leaq 0x1d60f(%rip), %rcx     # 0x2ac50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x6e, %al
jmp 0xd658
movb $0x62, %al
jmp 0xd658
movb $0x72, %al
jmp 0xd658
movb $0x71, %al
movb %al, 0x4(%rbx)
movb $0x0, 0x5(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x200(%rbp), %r15
movl $0x1c8, %edx            # imm = 0x1C8
movq %r15, %rdi
callq 0x20f0
movq %rsp, -0x38(%rbp)
movl (%r14), %eax
movq %rbx, -0x30(%rbp)
addl 0x144(%rbx), %eax
shlq $0x5, %rax
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
xorl %r13d, %r13d
movslq (%r14), %rbx
cmpq %rbx, %r13
jge 0xdab2
movq 0x8(%r14,%r13,8), %rdi
movq %r15, %rsi
callq 0xd9e8
testb %al, %al
je 0xda9b
movq 0x8(%r14,%r13,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x2fa5
incq %r13
jmp 0xda6d
leaq 0x1d3fd(%rip), %rdi     # 0x2ae9f
xorl %eax, %eax
callq 0x5fdd
movq -0x30(%rbp), %rdi
callq 0x4938
cmpq %rbx, %r13
setge %al
movq -0x38(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movq %rsi, %r12
cmpq %rbx, %rsi
jae 0xdaff
movq (%r12), %rdi
callq 0x73f4
movq %rax, %r15
movq %r14, %rdi
callq 0x73f4
leaq 0x8(%r12), %rsi
cmpq %rax, %r15
jne 0xdad9
cmpq %rbx, %r12
setb %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
movl %ecx, %ebx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
xorl %r15d, %r15d
cmpq %r14, %r12
jae 0xdb94
movq (%r12), %rdi
testq %rdi, %rdi
je 0xdb89
callq 0x739a
testb %al, %al
jne 0xdb86
movq (%r12), %rdi
callq 0x7386
testl %eax, %eax
je 0xdb8f
addl %ebp, %r15d
addq $0x8, %r12
jmp 0xdb62
addl %ebx, %r15d
jmp 0xdb89
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 0xbdd60(%rip), %rdi     # 0xcb920
callq 0xa76e
testb %al, %al
je 0xdbcd
pushq $0x1
jmp 0xdc0e
leaq 0xbdd4c(%rip), %rdi     # 0xcb920
callq 0xa7bd
testb %al, %al
je 0xdbe1
pushq $0x2
jmp 0xdc0e
leaq 0xbdd38(%rip), %rdi     # 0xcb920
callq 0x4710
testb %al, %al
je 0xdbf5
pushq $0x3
jmp 0xdc0e
leaq 0xbdd24(%rip), %rdi     # 0xcb920
leaq 0xbdeed(%rip), %rsi     # 0xcbaf0
callq 0x47e8
testb %al, %al
je 0xdc11
pushq $0x5
popq %rax
popq %rcx
retq
leaq 0xbdd08(%rip), %rdi     # 0xcb920
callq 0x490a
movzbl %al, %eax
shll $0x2, %eax
jmp 0xdc0f
// File: /workspace/github_cpp_makefile_star2_O2/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:
xorl %r9d, %r9d
testl %edx, %edx
movl $0x0, %eax
cmovgl %edx, %eax
pushq $0x10
popq %r8
movq %r9, %rcx
cmpq %r9, %rax
je 0xdd3f
movq -0x10(%rdi,%r8), %r9
cmpq -0x10(%rsi,%r8), %r9
jne 0xdd3f
movq -0x8(%rdi,%r8), %r9
cmpq -0x8(%rsi,%r8), %r9
jne 0xdd3f
leaq 0x1(%rcx), %r9
movdqu (%rsi,%r8), %xmm0
movdqu (%rdi,%r8), %xmm1
addq $0x20, %r8
pcmpeqd %xmm0, %xmm1
movmskps %xmm1, %r10d
cmpb $0xf, %r10b
je 0xdcfd
movslq %edx, %rax
cmpq %rax, %rcx
setge %al
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/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 0xb9bb7(%rip), %rax     # 0xc7918
cmpq $0x0, (%rax)
je 0xddc4
leaq 0xbdbb2(%rip), %rsi     # 0xcb920
leaq 0x10(%rsp), %rdi
callq 0x455e
testl %eax, %eax
jle 0xddcd
movl %eax, %r15d
shlq $0x4, %r15
leaq 0x8(%rsp), %rbx
leaq 0x1d154(%rip), %r14     # 0x2aee3
xorl %r12d, %r12d
cmpq %r12, %r15
je 0xdddb
cmpl $0x0, 0x18(%rsp,%r12)
jle 0xddbe
movq 0x10(%rsp,%r12), %rdi
movq %rbx, %rsi
callq 0xd5f6
movl 0x18(%rsp,%r12), %edx
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x5fdd
addq $0x10, %r12
jmp 0xdd92
leaq 0x1d105(%rip), %rdi     # 0x2aed0
jmp 0xddd4
leaq 0x1d11e(%rip), %rdi     # 0x2aef2
xorl %eax, %eax
callq 0x5fdd
leaq 0x1aaae(%rip), %rdi     # 0x28890
xorl %eax, %eax
callq 0x5fdd
addq $0x12d8, %rsp           # imm = 0x12D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: print_thinking_output(move_line*, int, int, int, unsigned long long)
void print_thinking_output(move_line* line,int32 depth,int32 score,int32 start_time,uint64 nodes) {
    assert(line);
    assert(line->n > 0);

    char buffer[1024];
    line_to_str(line,buffer);
    int32 time_centis = (milli_timer() - start_time) / 10;
    print("%2d %5d %5d %7llu %s\n",depth,score,time_centis,nodes,buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
testq %rdi, %rdi
je 0xdeb6
cmpl $0x0, (%rdi)
jle 0xdecf
movq %r8, %rbx
movl %ecx, %r15d
movl %edx, %ebp
movl %esi, %r14d
movq %rsp, %r12
movq %r12, %rsi
callq 0xd551
callq 0xd470
subl %r15d, %eax
pushq $0xa
popq %rcx
cltd
idivl %ecx
leaq 0x1d0e0(%rip), %rdi     # 0x2af72
movl %r14d, %esi
movl %ebp, %edx
movl %eax, %ecx
movq %rbx, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x5fdd
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cf8b(%rip), %rdi     # 0x2ae48
leaq 0x1d04e(%rip), %rsi     # 0x2af12
leaq 0x1d056(%rip), %rcx     # 0x2af21
pushq $0x42
jmp 0xdee6
leaq 0x1d090(%rip), %rdi     # 0x2af66
leaq 0x1d035(%rip), %rsi     # 0x2af12
leaq 0x1d03d(%rip), %rcx     # 0x2af21
pushq $0x43
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: think_and_make_move()
void think_and_make_move() {
    // check if game is over before we even get started.
    game_status gs = get_game_status();
    if (gs != INPROGRESS) {
        print_result(gs);
        return;
    }

    think();
}

// Assembly:
pushq %rax
callq 0xdbb8
testl %eax, %eax
je 0xdf61
movl %eax, %edi
popq %rax
jmp 0xdeec
popq %rax
jmp 0xc96e
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_level()
void handle_level() {
    char mps[10],base[10];
    if (scanf("%s",mps)==EOF) return;
    if (scanf("%s",base)==EOF) return;
    float f_inc = 0.0;
    if (scanf("%f",&f_inc)==EOF) return;
    int32 my_increment = (int32)(f_inc * 1000); // convert to ms
    printd("# increment: %d\n",my_increment);
    set_increment(my_increment);
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
leaq 0x1c6ef(%rip), %rdi     # 0x2a684
leaq 0x16(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe002
leaq 0x1c6d7(%rip), %rdi     # 0x2a684
leaq 0xc(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe002
leaq 0x8(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x1d089(%rip), %rdi     # 0x2b056
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe002
movss 0x8(%rsp), %xmm0
mulss 0x1cee5(%rip), %xmm0    # 0x2aecc
cvttss2si %xmm0, %ebx
leaq 0x1d067(%rip), %rdi     # 0x2b059
movl %ebx, %esi
xorl %eax, %eax
callq 0x60fd
movl %ebx, %edi
callq 0xc8e3
addq $0x20, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_memory()
void handle_memory() {
    int32 mem_in_mb;
    if (scanf("%d",&mem_in_mb)==EOF) return;

    printd("# received memory command, N=%d\n",mem_in_mb);
    if (mem_in_mb != last_mem_in_mb) {
        free(htbl.tblptr);
        free(phtbl.tblptr);

        uint32 total_hash_size = mem_in_mb * 1024 * 1024; // convert to bytes

        init_hash_table(&htbl,total_hash_size / 2);
        init_hash_table(&phtbl,total_hash_size / 2);

        last_mem_in_mb = mem_in_mb;
    } else {
        printd("# memory usage hasn't changed, skipping free/malloc\n");
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0x1d053(%rip), %rdi     # 0x2b06a
leaq 0xc(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe09f
movl 0xc(%rsp), %esi
leaq 0x1d03a(%rip), %rdi     # 0x2b06d
xorl %eax, %eax
callq 0x60fd
movl 0xc(%rsp), %eax
cmpl 0x8aad50(%rip), %eax    # 0x8b8d94
jne 0xe056
leaq 0x1d041(%rip), %rdi     # 0x2b08e
xorl %eax, %eax
callq 0x60fd
jmp 0xe09f
leaq 0xece93(%rip), %rbx     # 0xfaef0
movq (%rbx), %rdi
callq 0x21e0
leaq 0xeceb4(%rip), %r14     # 0xfaf20
movq (%r14), %rdi
callq 0x21e0
movl 0xc(%rsp), %ebp
shll $0x13, %ebp
andl $0x7ff80000, %ebp       # imm = 0x7FF80000
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5d49
movq %r14, %rdi
movl %ebp, %esi
callq 0x5d49
movl 0xc(%rsp), %eax
movl %eax, 0x8aacf5(%rip)    # 0x8b8d94
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_new()
void handle_new() {
    stop_search_thread();
    force_mode = false;
    reset_pos(&gpos);
    set_max_depth(0);
}

// Assembly:
pushq %rax
callq 0xde33
movb $0x0, 0x370e9(%rip)     # 0x451b0
leaq 0xbd852(%rip), %rdi     # 0xcb920
callq 0xa187
xorl %edi, %edi
popq %rax
jmp 0xc8ea
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_perft()
void handle_perft() {
    draw_board(&gpos);
    int max_depth;
    if (scanf("%d",&max_depth) != EOF) {
        int32 start = milli_timer();
        uint64 nodes=perft_iterate(max_depth);
        int32 end = milli_timer();
        if (end==start) end = start+1;
        print("\n# nodes: %lu\n",nodes);
        print("# elapsed time: %d ms\n",end-start);
        print("# rate: %.2f n/s\n\n",nodes*1000.0/(end-start));
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0xbd818(%rip), %rdi     # 0xcb920
callq 0x4938
leaq 0x1cf56(%rip), %rdi     # 0x2b06a
leaq 0xc(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe1af
callq 0xd470
movl %eax, %r14d
movl 0xc(%rsp), %edi
callq 0x90c7
movq %rax, %r15
callq 0xd470
leal 0x1(%r14), %ebx
cmpl %r14d, %eax
cmovnel %eax, %ebx
leaq 0x1cf70(%rip), %rdi     # 0x2b0c3
movq %r15, %rsi
xorl %eax, %eax
callq 0x5fdd
subl %r14d, %ebx
leaq 0x1cf6b(%rip), %rdi     # 0x2b0d2
movl %ebx, %esi
xorl %eax, %eax
callq 0x5fdd
movq %r15, %xmm1
punpckldq 0x1c643(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c64b(%rip), %xmm1    # 0x2a7d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x1c64f(%rip), %xmm0    # 0x2a7e8
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm0
leaq 0x1cf41(%rip), %rdi     # 0x2b0e9
movb $0x1, %al
callq 0x5fdd
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_ping()
void handle_ping() {
    if (!is_pondering()) {
        stop_search_thread();
    }
    int n;
    if (scanf("%d",&n) != EOF) {
        print("pong %d\n",n);
    }
}

// Assembly:
pushq %rax
callq 0xc908
testb %al, %al
jne 0xe1f2
callq 0xde33
leaq 0x1ce71(%rip), %rdi     # 0x2b06a
leaq 0x4(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe21c
movl 0x4(%rsp), %esi
leaq 0x1cee7(%rip), %rdi     # 0x2b0fc
xorl %eax, %eax
callq 0x5fdd
popq %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_probe_book()
void handle_probe_book() {
    move mv = probe_book(&gpos);
    if (mv==0) {
        print("no move found.\n");
    } else {
        print_move(mv);
    }
}

// Assembly:
pushq %rax
leaq 0xbd6f2(%rip), %rdi     # 0xcb920
callq 0x4439
testq %rax, %rax
je 0xe241
movq %rax, %rdi
popq %rax
jmp 0xdc25
leaq 0x1cebd(%rip), %rdi     # 0x2b105
xorl %eax, %eax
popq %rcx
jmp 0x5fdd
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_protover()
void handle_protover() {
    int version;
    if (scanf("%d",&version) != EOF) {
        if (version < 2) {
            error("protover >= 2 expected.\n");
            exit(0);
        }

        print("feature analyze=0 black=0 colors=0 cores=0 ping=1 draw=0 debug=1 edit=0 ics=1\n");
        print("feature level=0 name=1 nps=0 memory=1 playother=1 pause=0 resume=0 reuse=1 san=0\n");
        print("feature setboard=1 sigint=0 sigterm=0 smp=0 st=0 time=1 usermove=1\n");
        print("feature white=0 variants=\"normal\"\n");
        print("feature done=1\n"); // must be last
    }
}

// Assembly:
pushq %rax
leaq 0x1ce12(%rip), %rdi     # 0x2b06a
leaq 0x4(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe2b6
cmpl $0x1, 0x4(%rsp)
jle 0xe2b8
leaq 0x1ceb7(%rip), %rdi     # 0x2b12e
xorl %eax, %eax
callq 0x5fdd
leaq 0x1cef8(%rip), %rdi     # 0x2b17d
xorl %eax, %eax
callq 0x5fdd
leaq 0x1cf3c(%rip), %rdi     # 0x2b1cf
xorl %eax, %eax
callq 0x5fdd
leaq 0x1cf72(%rip), %rdi     # 0x2b213
xorl %eax, %eax
callq 0x5fdd
leaq 0x1cf87(%rip), %rdi     # 0x2b236
xorl %eax, %eax
callq 0x5fdd
popq %rax
retq
leaq 0x1ce56(%rip), %rdi     # 0x2b115
xorl %eax, %eax
callq 0x622a
xorl %edi, %edi
callq 0x21f0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_quit()
void handle_quit() {
    stop_search_thread();
    if (book_db != 0) {
        sqlite3_close(book_db);
    }
    free(htbl.tblptr);
    free(phtbl.tblptr);

    print("bye...\n");
    exit(0);
}

// Assembly:
pushq %rax
callq 0xde33
leaq 0xb963e(%rip), %rax     # 0xc7918
movq (%rax), %rdi
testq %rdi, %rdi
je 0xe2e7
callq 0x20a0
leaq 0xecc02(%rip), %rax     # 0xfaef0
movq (%rax), %rdi
callq 0x21e0
leaq 0xecc23(%rip), %rax     # 0xfaf20
movq (%rax), %rdi
callq 0x21e0
leaq 0x1cf3a(%rip), %rdi     # 0x2b246
xorl %eax, %eax
callq 0x5fdd
xorl %edi, %edi
callq 0x21f0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_result()
void handle_result() {
    stop_search_thread();
    char result[10],text[100],comment[100];
    if (scanf("%s",result)==EOF) return;
    comment[0]='\0';
    do {
        if (scanf("%s",text)==EOF) return; // the reason the game is over {bla bla}
        if (strlen(comment)>0) strcat(comment," ");
        strcat(comment,text);
    } while (!strchr(text,'}') && strlen(comment) < 50);
    print("# RESULT: %s\n",result);
    print("# COMMENT: %s\n",comment);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xe8, %rsp
callq 0xde33
leaq 0x1c2f1(%rip), %rdi     # 0x2a684
leaq 0x6(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe438
leaq 0x10(%rsp), %rbx
movb $0x0, (%rbx)
leaq 0x1c2cd(%rip), %r14     # 0x2a684
leaq 0x80(%rsp), %r15
pushq $0x7d
popq %rbp
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe438
cmpb $0x0, 0x10(%rsp)
je 0xe3ea
movq %rbx, %rdi
callq 0x2080
movw $0x20, 0x10(%rsp,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22f0
movq %r15, %rdi
movl %ebp, %esi
callq 0x2070
testq %rax, %rax
jne 0xe412
movq %rbx, %rdi
callq 0x2080
cmpq $0x32, %rax
jb 0xe3c2
leaq 0x1ce35(%rip), %rdi     # 0x2b24e
leaq 0x6(%rsp), %rsi
xorl %eax, %eax
callq 0x5fdd
leaq 0x1ce30(%rip), %rdi     # 0x2b25c
leaq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x5fdd
addq $0xe8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_sd()
void handle_sd() {
    int32 my_max_depth;
    if (scanf("%d",&my_max_depth)==EOF) return;
    printd("# MAX DEPTH: %d\n",my_max_depth);
    set_max_depth(my_max_depth);
}

// Assembly:
pushq %rax
leaq 0x1cc1c(%rip), %rdi     # 0x2b06a
leaq 0x4(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe47a
movl 0x4(%rsp), %esi
leaq 0x1ce01(%rip), %rdi     # 0x2b26b
xorl %eax, %eax
callq 0x60fd
movl 0x4(%rsp), %edi
callq 0xc8ea
popq %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_setboard()
void handle_setboard() {
    char fen[255];
    if (!fgets(fen, 255, stdin)) {
        return;
    }
    printd("# SETBOARD FEN: %s\n",fen);
    if (!set_pos(&gpos,fen)) {
        print("tellusererror illegal position\n");
    }
    draw_board(&gpos);
}

// Assembly:
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq 0x36b35(%rip), %rax     # 0x44fc0
movq (%rax), %rdx
movq %rsp, %rdi
movl $0xff, %esi
callq 0x22d0
testq %rax, %rax
je 0xe4e1
leaq 0x1cdd5(%rip), %rdi     # 0x2b27c
movq %rsp, %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x60fd
leaq 0xbd465(%rip), %rdi     # 0xcb920
movq %rbx, %rsi
callq 0xa1b8
testb %al, %al
jne 0xe4d5
leaq 0x1cdc2(%rip), %rdi     # 0x2b290
xorl %eax, %eax
callq 0x5fdd
leaq 0xbd444(%rip), %rdi     # 0xcb920
callq 0x4938
addq $0x100, %rsp            # imm = 0x100
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: handle_time()
void handle_time() {
    int32 my_time_remaining;
    if (scanf("%d",&my_time_remaining)==EOF) return;
    my_time_remaining *= 10; // centiseconds to milliseconds
    printd("# TIME REMAINING: %d\n",my_time_remaining);
    set_time_remaining(my_time_remaining);
}

// Assembly:
pushq %rax
leaq 0x1cb78(%rip), %rdi     # 0x2b06a
leaq 0x4(%rsp), %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0xe523
imull $0xa, 0x4(%rsp), %esi
movl %esi, 0x4(%rsp)
leaq 0x1cd9d(%rip), %rdi     # 0x2b2b0
xorl %eax, %eax
callq 0x60fd
movl 0x4(%rsp), %edi
callq 0xc8dc
popq %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/xboard.cpp
// Function: parse_command(char const*)
void parse_command(const char *cmd) {

    last_input_time = milli_timer();
    printd("# RECEIVED: %s\n",cmd);

    int len=sizeof(function_table)/sizeof(function_table_entry);

    for (int i=0;i<len;i++) {
        function_table_entry fte = function_table[i];
        if (strcmp(cmd,fte.name)==0) {
            fte.func();
            return;
        }
    }

    print("Error (unknown command): %s\n",cmd);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0xd470
movl %eax, 0x8aa6d9(%rip)    # 0x8b8d90
leaq 0x1cdb8(%rip), %rdi     # 0x2b476
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x60fd
leaq 0x36aee(%rip), %r15     # 0x451c0
leaq 0x10(%r14), %rcx
cmpq $0x2d0, %rcx            # imm = 0x2D0
je 0xe701
movq (%r14,%r15), %rsi
movq %rbx, %rdi
movq %rcx, %r14
callq 0x2260
testl %eax, %eax
jne 0xe6d2
movq %r14, %rcx
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
jmpq *-0x8(%rcx,%rax)
leaq 0x1cd7e(%rip), %rdi     # 0x2b486
movq %rbx, %rsi
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x5fdd
nop
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/apply__test.cpp
// Function: test_undo_double_pawn_push()
void test_undo_double_pawn_push() {
    position pos;
    reset_pos(&pos);

    position save_pos;
    memcpy(&save_pos,&pos,sizeof(position));

    move mv = to_move(PAWN,E2,E4);
    apply_move(&pos,mv,gundos);

    undo_last_move(&pos,gundos);
    assert(equal_pos(&pos,&save_pos,true));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
callq 0xa187
leaq 0x8(%rsp), %r14
movl $0x1c8, %edx            # imm = 0x1C8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20f0
pushq $0x1
popq %rbp
pushq $0x34
popq %rsi
pushq $0x24
popq %rdx
movl %ebp, %edi
callq 0x7284
leaq 0xbcbec(%rip), %r15     # 0xcbaf0
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31f8
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x98c8
testb %al, %al
je 0xef3c
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c985(%rip), %rdi     # 0x2b8c8
leaq 0x1c595(%rip), %rsi     # 0x2b4df
leaq 0x1c996(%rip), %rcx     # 0x2b8e7
movl $0x85, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/apply__test.cpp
// Function: test_undo_capturing_promotion()
void test_undo_capturing_promotion() {
    position pos;
    set_pos(&pos,"r7/1PK5/8/8/k7/8/8/8 w - -");

    position save_pos;
    memcpy(&save_pos,&pos,sizeof(position));

    move mv = to_capture(PAWN,B7,A8,ROOK);
    set_promopiece(&mv,QUEEN);
    apply_move(&pos,mv,gundos);

    undo_last_move(&pos,gundos);
    assert(equal_pos(&pos,&save_pos,true));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
leaq 0x1c99a(%rip), %rsi     # 0x2b909
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
leaq 0x8(%rsp), %r14
movl $0x1c8, %edx            # imm = 0x1C8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20f0
pushq $0x1
popq %rbp
pushq $0x9
popq %rsi
pushq $0x4
popq %rcx
movl %ebp, %edi
xorl %edx, %edx
callq 0x72a3
movq %rsp, %r15
movq %rax, (%r15)
pushq $0x5
popq %rsi
movq %r15, %rdi
callq 0x733b
movq (%r15), %rsi
leaq 0xbcb2f(%rip), %r15     # 0xcbaf0
movq %rbx, %rdi
movq %r15, %rdx
callq 0x2fa5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31f8
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x98c8
testb %al, %al
je 0xeff6
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c8cb(%rip), %rdi     # 0x2b8c8
leaq 0x1c4db(%rip), %rsi     # 0x2b4df
leaq 0x1c919(%rip), %rcx     # 0x2b924
movl $0x94, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/apply__test.cpp
// Function: test_undo_epcapture()
void test_undo_epcapture() {
    position pos;
    set_pos(&pos,"k7/8/8/8/pP6/8/K7/8 b - b3");

    position save_pos;
    memcpy(&save_pos,&pos,sizeof(position));

    move mv = to_capture(PAWN,A4,B3,PAWN);
    set_epcapture(&mv);
    apply_move(&pos,mv,gundos);

    undo_last_move(&pos,gundos);
    assert(equal_pos(&pos,&save_pos,true));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
leaq 0x1c920(%rip), %rsi     # 0x2b949
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
leaq 0x8(%rsp), %r14
movl $0x1c8, %edx            # imm = 0x1C8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20f0
pushq $0x20
popq %rsi
pushq $0x29
popq %rdx
pushq $0x1
popq %rbp
movl %ebp, %edi
movl %ebp, %ecx
callq 0x72a3
movq %rsp, %r15
movq %rax, (%r15)
movq %r15, %rdi
callq 0x7352
movq (%r15), %rsi
leaq 0xbca78(%rip), %r15     # 0xcbaf0
movq %rbx, %rdi
movq %r15, %rdx
callq 0x2fa5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31f8
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x98c8
testb %al, %al
je 0xf0ad
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c814(%rip), %rdi     # 0x2b8c8
leaq 0x1c424(%rip), %rsi     # 0x2b4df
leaq 0x1c8a2(%rip), %rcx     # 0x2b964
movl $0xa3, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/apply__test.cpp
// Function: test_undo_castle()
void test_undo_castle() {
    position pos;
    set_pos(&pos,"k7/8/8/8/8/8/8/4K2R w K -");

    position save_pos;
    memcpy(&save_pos,&pos,sizeof(position));

    move mv = to_move(KING,E1,G1);
    set_castle(&mv);
    apply_move(&pos,mv,gundos);

    undo_last_move(&pos,gundos);
    assert(equal_pos(&pos,&save_pos,true));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x3a0, %rsp            # imm = 0x3A0
leaq 0x1c8a0(%rip), %rsi     # 0x2b97f
leaq 0x1d8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
leaq 0x10(%rsp), %r14
movl $0x1c8, %edx            # imm = 0x1C8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20f0
pushq $0x6
popq %rdi
pushq $0x3c
popq %rsi
pushq $0x3e
popq %rdx
callq 0x7284
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
movq %r15, %rdi
callq 0x7366
movq (%r15), %rsi
leaq 0xbc9c4(%rip), %r15     # 0xcbaf0
movq %rbx, %rdi
movq %r15, %rdx
callq 0x2fa5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31f8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xf161
addq $0x3a0, %rsp            # imm = 0x3A0
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1c760(%rip), %rdi     # 0x2b8c8
leaq 0x1c370(%rip), %rsi     # 0x2b4df
leaq 0x1c823(%rip), %rcx     # 0x2b999
movl $0xb2, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/apply__test.cpp
// Function: test_apply()
void test_apply() {
    test_apply_move();
    test_undo_double_pawn_push();
    test_undo_capturing_promotion();
    test_undo_epcapture();
    test_undo_castle();
}

// Assembly:
pushq %rax
callq 0xe718
callq 0xeebb
callq 0xef5b
callq 0xf015
popq %rax
jmp 0xf0cc
nop
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_attacked_by_knight()
void test_attacked_by_knight() {
    position pos;
    set_pos(&pos,"3k4/8/8/3n4/3N4/8/8/3K4 w - - 0 1");

    uint64 white_map=0,black_map=0;
    for (int32 sq=A8;sq<=H1;sq++) {
        if (attacked_by_knight(&pos,(square_t)sq,WHITE)) {
            white_map |= bb_squares[sq];
        }

        if (attacked_by_knight(&pos,(square_t)sq,BLACK)) {
            black_map |= bb_squares[sq];
        }
    }

    assert(white_map==(bb_squares[C6] | bb_squares[E6] | bb_squares[F5]
                     | bb_squares[F3] | bb_squares[E2] | bb_squares[C2]
                     | bb_squares[B3] | bb_squares[B5]));


    assert(black_map==(bb_squares[C7] | bb_squares[E7] | bb_squares[F6]
                     | bb_squares[F4] | bb_squares[E3] | bb_squares[C3]
                     | bb_squares[B4] | bb_squares[B6]));


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
leaq 0x1c7fd(%rip), %rsi     # 0x2b9b1
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xa1b8
xorl %r14d, %r14d
pushq $0x1
popq %rbp
leaq 0xee2e4(%rip), %r15     # 0xfd4b0
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq $0x40, %r14
je 0xf207
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x3550
testb %al, %al
je 0xf1ed
orq (%r15,%r14,8), %r13
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x3550
testb %al, %al
je 0xf202
orq (%r15,%r14,8), %r12
incq %r14
jmp 0xf1d2
movq 0xa0(%r15), %rax
orq 0x90(%r15), %rax
orq 0xe8(%r15), %rax
orq 0x168(%r15), %rax
orq 0x1a0(%r15), %rax
orq 0x190(%r15), %rax
orq 0x148(%r15), %rax
orq 0xc8(%r15), %rax
cmpq %rax, %r13
jne 0xf28d
movq 0x60(%r15), %rax
orq 0x50(%r15), %rax
orq 0xa8(%r15), %rax
orq 0x128(%r15), %rax
orq 0x160(%r15), %rax
orq 0x150(%r15), %rax
orq 0x108(%r15), %rax
orq 0x88(%r15), %rax
cmpq %rax, %r12
jne 0xf2a6
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c73f(%rip), %rdi     # 0x2b9d3
leaq 0x1c7cb(%rip), %rsi     # 0x2ba66
leaq 0x1c7da(%rip), %rcx     # 0x2ba7c
pushq $0x1d
jmp 0xf2bd
leaq 0x1c7ee(%rip), %rdi     # 0x2ba9b
leaq 0x1c7b2(%rip), %rsi     # 0x2ba66
leaq 0x1c7c1(%rip), %rcx     # 0x2ba7c
pushq $0x22
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_attacked_by_king()
void test_attacked_by_king() {
    position pos;
    set_pos(&pos,"3k4/8/8/3n4/3K4/8/8/8 w - - 0 1");

    uint64 white_map=0,black_map=0;
    for (int32 sq=A8;sq<=H1;sq++) {
        if (attacked_by_king(&pos,(square_t)sq,WHITE)) {
            white_map |= bb_squares[sq];
        }

        if (attacked_by_king(&pos,(square_t)sq,BLACK)) {
            black_map |= bb_squares[sq];
        }
    }
    assert(white_map==(bb_squares[C5] | bb_squares[D5] | bb_squares[E5]
                     | bb_squares[C4] | bb_squares[E4] | bb_squares[C3]
                     | bb_squares[D3] | bb_squares[E3]));


    assert(black_map==(bb_squares[C8] | bb_squares[E8] | bb_squares[C7]
                     | bb_squares[D7] | bb_squares[E7]));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
leaq 0x1c853(%rip), %rsi     # 0x2bb2e
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xa1b8
xorl %r14d, %r14d
pushq $0x1
popq %rbp
leaq 0xee1bd(%rip), %r15     # 0xfd4b0
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq $0x40, %r14
je 0xf32e
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x35d1
testb %al, %al
je 0xf314
orq (%r15,%r14,8), %r13
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x35d1
testb %al, %al
je 0xf329
orq (%r15,%r14,8), %r12
incq %r14
jmp 0xf2f9
movq 0xd8(%r15), %rax
orq 0xd0(%r15), %rax
orq 0xe0(%r15), %rax
orq 0x110(%r15), %rax
orq 0x120(%r15), %rax
orq 0x150(%r15), %rax
orq 0x158(%r15), %rax
orq 0x160(%r15), %rax
cmpq %rax, %r13
jne 0xf396
movq 0x20(%r15), %rax
orq 0x10(%r15), %rax
orq 0x50(%r15), %rax
orq 0x58(%r15), %rax
orq 0x60(%r15), %rax
cmpq %rax, %r12
jne 0xf3af
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c7b1(%rip), %rdi     # 0x2bb4e
leaq 0x1c6c2(%rip), %rsi     # 0x2ba66
leaq 0x1c836(%rip), %rcx     # 0x2bbe1
pushq $0x37
jmp 0xf3c6
leaq 0x1c848(%rip), %rdi     # 0x2bbfe
leaq 0x1c6a9(%rip), %rsi     # 0x2ba66
leaq 0x1c81d(%rip), %rcx     # 0x2bbe1
pushq $0x3b
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_attacked_by_pawn()
void test_attacked_by_pawn() {
    position pos;
    set_pos(&pos,"3k4/8/8/3p4/3P3P/8/8/3K4 w - - 0 1");

    for (int32 sq=A8;sq<=H1;sq++) {
        assert(attacked_by_pawn(&pos,(square_t)sq,WHITE)==
                (sq==C5 || sq==E5 || sq==G5));

        assert(attacked_by_pawn(&pos,(square_t)sq,BLACK)==
                (sq==C4 || sq==E4));
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0x1c880(%rip), %rsi     # 0x2bc5e
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
xorl %r14d, %r14d
pushq $0x1
popq %rbp
cmpl $0x40, %r14d
je 0xf45e
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x36b6
movl %ebp, %ecx
cmpl $0x1a, %r14d
je 0xf41d
movl %ebp, %ecx
cmpl $0x1c, %r14d
je 0xf41d
xorl %ecx, %ecx
cmpl $0x1e, %r14d
sete %cl
movzbl %al, %eax
cmpl %eax, %ecx
jne 0xf46a
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x36b6
leal -0x22(%r14), %ecx
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
setne %cl
incl %r14d
cmpb %al, %cl
jne 0xf3f1
leaq 0x1c89b(%rip), %rdi     # 0x2bce7
leaq 0x1c613(%rip), %rsi     # 0x2ba66
leaq 0x1c870(%rip), %rcx     # 0x2bcca
pushq $0x47
jmp 0xf481
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1c810(%rip), %rdi     # 0x2bc81
leaq 0x1c5ee(%rip), %rsi     # 0x2ba66
leaq 0x1c84b(%rip), %rcx     # 0x2bcca
pushq $0x44
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_attacked_by_rook()
void test_attacked_by_rook() {
    position pos;
    set_pos(&pos,"8/1r3k2/8/3p4/3P3P/8/1P6/3K4 b - - 0 1");

    uint64 white_map=0,black_map=0;
    for (int32 sq=A8;sq<=H1;sq++) {
        if (attacked_by_rook(&pos,(square_t)sq,WHITE)) {
            white_map |= bb_squares[sq];
        }

        if (attacked_by_rook(&pos,(square_t)sq,BLACK)) {
            black_map |= bb_squares[sq];
        }
    }

    assert(white_map==0);
    assert(black_map==(bb_squares[B8] | bb_squares[A7] | bb_squares[C7]
            | bb_squares[D7] | bb_squares[E7] | bb_squares[F7]
            | bb_squares[B6] | bb_squares[B5] | bb_squares[B4]
            | bb_squares[B3] | bb_squares[B2]));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
leaq 0x1c887(%rip), %rsi     # 0x2bd26
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xa1b8
xorl %r14d, %r14d
pushq $0x1
popq %rbp
leaq 0xedff9(%rip), %r12     # 0xfd4b0
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq $0x40, %r14
je 0xf4f2
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x365c
testb %al, %al
je 0xf4d8
orq (%r12,%r14,8), %r13
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x365c
testb %al, %al
je 0xf4ed
orq (%r12,%r14,8), %r15
incq %r14
jmp 0xf4bd
testq %r13, %r13
jne 0xf565
movq 0x8(%r12), %rax
movdqa 0x50(%r12), %xmm0
movq 0xc8(%r12), %rcx
por 0x60(%r12), %xmm0
movq 0x148(%r12), %rdx
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
por %xmm0, %xmm1
movq %xmm1, %rsi
orq 0x40(%r12), %rsi
orq 0x88(%r12), %rax
orq 0x108(%r12), %rcx
orq 0x188(%r12), %rdx
orq %rcx, %rdx
orq %rax, %rdx
orq %rsi, %rdx
cmpq %rdx, %r15
jne 0xf57e
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c7e1(%rip), %rdi     # 0x2bd4d
leaq 0x1c4f3(%rip), %rsi     # 0x2ba66
leaq 0x1c7e0(%rip), %rcx     # 0x2bd5a
pushq $0x5a
jmp 0xf595
leaq 0x1c7f2(%rip), %rdi     # 0x2bd77
leaq 0x1c4da(%rip), %rsi     # 0x2ba66
leaq 0x1c7c7(%rip), %rcx     # 0x2bd5a
pushq $0x5e
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_attacked_by_bishop()
void test_attacked_by_bishop() {
    position pos;
    set_pos(&pos,"8/1r3k2/8/3bB3/8/8/8/3K4 b - - 0 1");

    uint64 white_map=0,black_map=0;
    for (int32 sq=A8;sq<=H1;sq++) {
        if (attacked_by_bishop(&pos,(square_t)sq,WHITE)) {
            white_map |= bb_squares[sq];
        }

        if (attacked_by_bishop(&pos,(square_t)sq,BLACK)) {
            black_map |= bb_squares[sq];
        }
    }

    assert(white_map==(bb_squares[D6] | bb_squares[C7] | bb_squares[B8]
            | bb_squares[F6] | bb_squares[G7] | bb_squares[H8]
            | bb_squares[D4] | bb_squares[C3] | bb_squares[B2] | bb_squares[A1]
            | bb_squares[F4] | bb_squares[G3] | bb_squares[H2]));

    assert(black_map==(bb_squares[C6] | bb_squares[B7]
            | bb_squares[E6] | bb_squares[F7]
            | bb_squares[C4] | bb_squares[B3] | bb_squares[A2]
            | bb_squares[E4] | bb_squares[F3] | bb_squares[G2] | bb_squares[H1]));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
leaq 0x1c88a(%rip), %rsi     # 0x2be3d
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xa1b8
xorl %r14d, %r14d
pushq $0x1
popq %rbp
leaq 0xedee5(%rip), %r15     # 0xfd4b0
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq $0x40, %r14
je 0xf606
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x367a
testb %al, %al
je 0xf5ec
orq (%r15,%r14,8), %r13
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x367a
testb %al, %al
je 0xf601
orq (%r15,%r14,8), %r12
incq %r14
jmp 0xf5d1
movq 0x50(%r15), %rax
orq 0x98(%r15), %rax
orq 0x8(%r15), %rax
orq 0xa8(%r15), %rax
orq 0x70(%r15), %rax
orq 0x38(%r15), %rax
orq 0x118(%r15), %rax
orq 0x150(%r15), %rax
orq 0x188(%r15), %rax
orq 0x1c0(%r15), %rax
orq 0x128(%r15), %rax
orq 0x170(%r15), %rax
orq 0x1b8(%r15), %rax
cmpq %rax, %r13
jne 0xf6b8
movq 0x48(%r15), %rax
orq 0x90(%r15), %rax
orq 0xa0(%r15), %rax
orq 0x68(%r15), %rax
orq 0x110(%r15), %rax
orq 0x148(%r15), %rax
orq 0x180(%r15), %rax
orq 0x120(%r15), %rax
orq 0x168(%r15), %rax
orq 0x1b0(%r15), %rax
orq 0x1f8(%r15), %rax
cmpq %rax, %r12
jne 0xf6d1
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c7a1(%rip), %rdi     # 0x2be60
leaq 0x1c3a0(%rip), %rsi     # 0x2ba66
leaq 0x1c87b(%rip), %rcx     # 0x2bf48
pushq $0x73
jmp 0xf6e8
leaq 0x1c88f(%rip), %rdi     # 0x2bf67
leaq 0x1c387(%rip), %rsi     # 0x2ba66
leaq 0x1c862(%rip), %rcx     # 0x2bf48
pushq $0x78
popq %rdx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_get_attackers()
void test_get_attackers() {
    position pos;
    set_pos(&pos,"1k1r3q/1ppn3p/p4b2/4p3/8/P2N2P1/1PP1R1BP/2K1Q3 w - -");

    uint64 attackers = get_attackers(&pos,E5,WHITE);

    assert(attackers & bb_squares[D3]);
    assert(attackers & bb_squares[E2]);
    assert(get_num_bits(attackers)==2);
}

// Assembly:
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0x1ca95(%rip), %rsi     # 0x2c393
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x37fc
leaq 0xedb90(%rip), %rcx     # 0xfd4b0
testq %rax, 0x158(%rcx)
je 0xf948
testq %rax, 0x1a0(%rcx)
je 0xf967
movq %rax, %rdi
callq 0x3928
cmpl $0x2, %eax
jne 0xf986
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
retq
leaq 0x1ca79(%rip), %rdi     # 0x2c3c8
leaq 0x1c110(%rip), %rsi     # 0x2ba66
leaq 0x1ca86(%rip), %rcx     # 0x2c3e3
movl $0xa1, %edx
callq 0x20c0
leaq 0x1ca8f(%rip), %rdi     # 0x2c3fd
leaq 0x1c0f1(%rip), %rsi     # 0x2ba66
leaq 0x1ca67(%rip), %rcx     # 0x2c3e3
movl $0xa2, %edx
callq 0x20c0
leaq 0x1ca8b(%rip), %rdi     # 0x2c418
leaq 0x1c0d2(%rip), %rsi     # 0x2ba66
leaq 0x1ca48(%rip), %rcx     # 0x2c3e3
movl $0xa3, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_get_attackers2()
void test_get_attackers2() {
    position pos;
    set_pos(&pos,"1k1r3q/1ppn3p/p4b2/4p3/8/P2N2P1/1PP1R1BP/2K1Q3 w - -");

    uint64 attackers = get_attackers(&pos,E5,BLACK);

    assert(attackers & bb_squares[D7]);
    assert(attackers & bb_squares[F6]);
    assert(get_num_bits(attackers)==2);
}

// Assembly:
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0x1c9df(%rip), %rsi     # 0x2c393
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
pushq $0x1c
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x37fc
leaq 0xedadb(%rip), %rcx     # 0xfd4b0
testq %rax, 0x58(%rcx)
je 0xf9fa
testq %rax, 0xa8(%rcx)
je 0xfa19
movq %rax, %rdi
callq 0x3928
cmpl $0x2, %eax
jne 0xfa38
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
retq
leaq 0x1ca32(%rip), %rdi     # 0x2c433
leaq 0x1c05e(%rip), %rsi     # 0x2ba66
leaq 0x1ca3f(%rip), %rcx     # 0x2c44e
movl $0xac, %edx
callq 0x20c0
leaq 0x1ca49(%rip), %rdi     # 0x2c469
leaq 0x1c03f(%rip), %rsi     # 0x2ba66
leaq 0x1ca20(%rip), %rcx     # 0x2c44e
movl $0xad, %edx
callq 0x20c0
leaq 0x1c9d9(%rip), %rdi     # 0x2c418
leaq 0x1c020(%rip), %rsi     # 0x2ba66
leaq 0x1ca01(%rip), %rcx     # 0x2c44e
movl $0xae, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_get_attackers3()
void test_get_attackers3() {
    position pos;
    set_pos(&pos,"8/p1k5/1p6/8/3b4/1Q6/8/7K w - -");

    uint64 attackers = get_attackers(&pos,B6,WHITE);

    assert(attackers & bb_squares[B3]);
    assert(get_num_bits(attackers)==1);
}

// Assembly:
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0x1ca1e(%rip), %rsi     # 0x2c484
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
pushq $0x11
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x37fc
leaq 0xeda28(%rip), %rcx     # 0xfd4b0
testq %rax, 0x148(%rcx)
je 0xfaa7
movq %rax, %rdi
callq 0x3928
cmpl $0x1, %eax
jne 0xfac6
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
retq
leaq 0x1c9f6(%rip), %rdi     # 0x2c4a4
leaq 0x1bfb1(%rip), %rsi     # 0x2ba66
leaq 0x1ca03(%rip), %rcx     # 0x2c4bf
movl $0xb7, %edx
callq 0x20c0
leaq 0x1ca0d(%rip), %rdi     # 0x2c4da
leaq 0x1bf92(%rip), %rsi     # 0x2ba66
leaq 0x1c9e4(%rip), %rcx     # 0x2c4bf
movl $0xb8, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_get_attackers4()
void test_get_attackers4() {
    position pos;
    set_pos(&pos,"8/p1k5/1p6/8/3b4/1Q6/8/7K w - -");

    uint64 attackers = get_attackers(&pos,B6,BLACK);

    assert(attackers & bb_squares[C7]);
    assert(attackers & bb_squares[A7]);
    assert(attackers & bb_squares[D4]);
    assert(get_num_bits(attackers)==3);
}

// Assembly:
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0x1c990(%rip), %rsi     # 0x2c484
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
pushq $0x11
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x37fc
leaq 0xed99b(%rip), %rcx     # 0xfd4b0
testq %rax, 0x50(%rcx)
je 0xfb40
testq %rax, 0x40(%rcx)
je 0xfb5f
testq %rax, 0x118(%rcx)
je 0xfb7e
movq %rax, %rdi
callq 0x3928
cmpl $0x3, %eax
jne 0xfb9d
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
retq
leaq 0x1c9ae(%rip), %rdi     # 0x2c4f5
leaq 0x1bf18(%rip), %rsi     # 0x2ba66
leaq 0x1c9bb(%rip), %rcx     # 0x2c510
movl $0xc1, %edx
callq 0x20c0
leaq 0x1c9c5(%rip), %rdi     # 0x2c52b
leaq 0x1bef9(%rip), %rsi     # 0x2ba66
leaq 0x1c99c(%rip), %rcx     # 0x2c510
movl $0xc2, %edx
callq 0x20c0
leaq 0x1c9c1(%rip), %rdi     # 0x2c546
leaq 0x1beda(%rip), %rsi     # 0x2ba66
leaq 0x1c97d(%rip), %rcx     # 0x2c510
movl $0xc3, %edx
callq 0x20c0
leaq 0x1c9bd(%rip), %rdi     # 0x2c561
leaq 0x1bebb(%rip), %rsi     # 0x2ba66
leaq 0x1c95e(%rip), %rcx     # 0x2c510
movl $0xc4, %edx
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/attack__test.cpp
// Function: test_attack()
void test_attack() {
    test_attacked_by_knight();
    test_attacked_by_king();
    test_attacked_by_pawn();
    test_attacked_by_rook();
    test_attacked_by_bishop();
    test_attacked_by_queen();
    test_get_attackers();
    test_get_attackers2();
    test_get_attackers3();
    test_get_attackers4();
}

// Assembly:
pushq %rax
callq 0xf19c
callq 0xf2c3
callq 0xf3cc
callq 0xf487
callq 0xf59b
callq 0xf6ee
callq 0xf8ef
callq 0xf9a5
callq 0xfa57
popq %rax
jmp 0xfae5