LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: allocateNewDirent
struct ext2_dir_entry_2 *allocateNewDirent(struct ext2_inode *parent_inode, int size) {
    struct ext2_dir_entry_2 *new_dir_entry = NULL;
    // search in all used direct block
    for(int i = 0; i<12;i++) {
        if (parent_inode->i_block[i] != 0) {
            new_dir_entry = allocateDirentHelper(parent_inode->i_block[i], size);
            if (new_dir_entry!=NULL)
                return new_dir_entry;
        }
    }

    // if we cannot find a space, try to allocate a new block
    int newBlockNum = 0;
    for(int i = 0; i<12;i++) {
        if (parent_inode->i_block[i] != 0) continue;
        newBlockNum = allocateNewBlock();
        parent_inode->i_block[i] = newBlockNum;

        // increse parentdir size
        parent_inode->i_blocks+=(EXT2_BLOCK_SIZE+511)/512;
        parent_inode->i_size+=EXT2_BLOCK_SIZE;

        // insert dummy head
        new_dir_entry = (struct ext2_dir_entry_2 *)getBlock(newBlockNum);
        new_dir_entry->file_type = EXT2_FT_UNKNOWN;
        new_dir_entry->inode = 0;
        new_dir_entry->name_len = 0;
        new_dir_entry->rec_len = ((sizeof(struct ext2_dir_entry_2)+3)/4)*4;

        // return new setted dir_entry
        new_dir_entry = (void *)new_dir_entry + new_dir_entry->rec_len;
        new_dir_entry->rec_len=EXT2_BLOCK_SIZE-((sizeof(struct ext2_dir_entry_2)+3)/4)*4;
        return new_dir_entry;
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x34a3(%rip), %r14      # 0x50b0
movq (%r14), %rcx
xorl %eax, %eax
xorl %edx, %edx
movq %rax, %rdi
movslq 0x28(%rbx,%rax,4), %rax
testq %rax, %rax
je 0x1c5a
shlq $0xa, %rax
addq %rcx, %rax
xorl %r8d, %r8d
movzbl 0x6(%rax), %r9d
addl $0xc, %r9d
andl $-0x4, %r9d
movzwl 0x4(%rax), %r11d
movl %r11d, %r10d
subl %r9d, %r10d
cmpl %esi, %r10d
jge 0x1c73
addl %r11d, %r8d
movl %r11d, %r9d
addq %r9, %rax
cmpl $0x400, %r8d            # imm = 0x400
jb 0x1c2b
leaq 0x1(%rdi), %rax
cmpq $0xb, %rdi
setae %dl
cmpq $0xc, %rax
jne 0x1c14
cmpq $0xb, %rdi
jae 0x1c83
jmp 0x1cd9
movw %r9w, 0x4(%rax)
movw %r10w, 0x4(%rax,%r9)
testb $0x1, %dl
je 0x1c9b
xorl %eax, %eax
xorl %r15d, %r15d
cmpl $0x0, 0x28(%rbx,%r15,4)
je 0x1ca0
incq %r15
cmpq $0xc, %r15
jne 0x1c88
jmp 0x1cd9
addq %r9, %rax
jmp 0x1cd9
callq 0x1a6c
movl %eax, 0x28(%rbx,%r15,4)
addl $0x2, 0x1c(%rbx)
addl $0x400, 0x4(%rbx)       # imm = 0x400
movq (%r14), %rcx
cltq
shlq $0xa, %rax
movabsq $0x800000000, %rdx      # imm = 0x800000000
addq %rcx, %rax
addq $0x8, %rax
movq %rdx, -0x8(%rax)
movw $0x3f8, 0x4(%rax)       # imm = 0x3F8
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: allocateDirentHelper
struct ext2_dir_entry_2 *allocateDirentHelper(int blockNum, int size) {
    /*
    * Helper function for initDirent
    */
    struct ext2_dir_entry_2 *dir_entry, *new_dir_entry;
    int total_rec_len, actural_len, residue_len;

    dir_entry = (struct ext2_dir_entry_2 *)getBlock(blockNum);
    total_rec_len = 0;
    while (total_rec_len < EXT2_BLOCK_SIZE) {
        // calculate residue
        actural_len = calculateActuralSize(dir_entry);
        residue_len = dir_entry->rec_len - actural_len;
        if (residue_len >= size) {
            new_dir_entry = (void *)dir_entry+actural_len;
            dir_entry->rec_len=actural_len;
            new_dir_entry->rec_len=residue_len;
            return new_dir_entry;
        }
        total_rec_len = total_rec_len + dir_entry->rec_len;
        dir_entry = (void *) dir_entry + dir_entry->rec_len;
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x33c1(%rip), %rax      # 0x50b0
shll $0xa, %edi
movslq %edi, %rcx
addq (%rax), %rcx
xorl %eax, %eax
xorl %edx, %edx
movzbl 0x6(%rcx), %edi
addl $0xc, %edi
andl $-0x4, %edi
movzwl 0x4(%rcx), %r9d
movl %r9d, %r8d
subl %edi, %r8d
cmpl %esi, %r8d
jge 0x1d29
addl %r9d, %edx
movl %r9d, %edi
addq %rdi, %rcx
cmpl $0x400, %edx            # imm = 0x400
jb 0x1cfc
jmp 0x1d37
leaq (%rcx,%rdi), %rax
movw %di, 0x4(%rcx)
movw %r8w, 0x4(%rcx,%rdi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: getInodeFromPath
int getInodeFromPath(char *path) {
    /*
    * return: inodeNum of the path, 0 if path is not found or invalid
    */
    struct ext2_inode *inodeTable = getInodeTable();
    int inode_num = EXT2_ROOT_INO;
    struct ext2_inode *cur_inode = &inodeTable[inode_num-1];
    char *next_file;
    int endWithDir = path[strlen(path)-1] == '/'; // is path endwith '/' ?

    if (path[0] != '/') {
        // invalid path: absolute path startwith 
        return 0;
    }

    // travel through path
    next_file = strtok(path, "/");
    while(next_file != NULL) {
        // cannot have a non-directory type file in the middle of path
        if (!(cur_inode->i_mode & EXT2_S_IFDIR)) {
            // Invalid path; non-dir type file inside path
            return 0;
        }

        // get next inode from current directory
        inode_num = searchFileInDir(cur_inode, next_file);
        // update inode to next file with next_file
        if (inode_num != 0) {
            cur_inode = &inodeTable[inode_num-1];
        } else {
            // invalid path: file name not found
            return 0;
        }

        next_file = strtok(NULL, "/");
    }

    if (!(cur_inode->i_mode & EXT2_S_IFDIR) && endWithDir) {
        // invalid path: path endwith '/' but have a non-dir type file at the end
        return 0;
    }
    return inode_num;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
callq 0x1060
xorl %r14d, %r14d
cmpb $0x2f, (%r15)
jne 0x1e87
movb -0x1(%r15,%rax), %r13b
leaq 0x32bc(%rip), %rax      # 0x50b0
movq (%rax), %r14
movl 0x808(%r14), %r12d
shll $0xa, %r12d
leaq (%r14,%r12), %rbx
addq $0x80, %rbx
leaq 0x136c(%rip), %rsi      # 0x3180
movq %r15, %rdi
callq 0x1100
testq %rax, %rax
je 0x1e6e
movb %r13b, -0x29(%rbp)
leaq (%r14,%r12), %r13
addq $-0x80, %r13
leaq 0x134c(%rip), %r12      # 0x3180
xorl %r14d, %r14d
testb $0x40, 0x1(%rbx)
je 0x1e87
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1ae6
testl %eax, %eax
je 0x1e87
movl %eax, %r15d
movslq %eax, %rbx
shlq $0x7, %rbx
addq %r13, %rbx
xorl %edi, %edi
movq %r12, %rsi
callq 0x1100
testq %rax, %rax
jne 0x1e37
movb -0x29(%rbp), %r13b
jmp 0x1e74
movl $0x2, %r15d
xorb $0x2f, %r13b
movb 0x1(%rbx), %al
andb $0x40, %al
xorl %r14d, %r14d
orb %r13b, %al
cmovnel %r15d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: getFileNameFromPath
void getFileNameFromPath(char *fileName, char *path) {
    /*
    * return the last section of path into fileName
    */
    char *curr = strtok(path, "/");
    while (curr != NULL) {
        strcpy(fileName, curr);
        curr = strtok(NULL, "/");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x12d3(%rip), %rsi      # 0x3180
movq %rax, %rdi
callq 0x1100
testq %rax, %rax
je 0x1edb
leaq 0x12bf(%rip), %r14      # 0x3180
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1040
xorl %edi, %edi
movq %r14, %rsi
callq 0x1100
testq %rax, %rax
jne 0x1ec1
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: getParentDirPath
void getParentDirPath(char *path) {
    /*
    * modify input path
    */
    assert (strcmp(path, "/")!=0);

    int len = strlen(path);
    if (path[len-1]=='/')
        path[len-1] = '\0';
    char *target = strrchr(path, '/');
    *(target+1) = '\0';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x2f, (%rdi)
jne 0x1ef4
cmpb $0x0, 0x1(%rbx)
je 0x1f22
movq %rbx, %rdi
callq 0x1060
decl %eax
cltq
cmpb $0x2f, (%rbx,%rax)
jne 0x1f0a
movb $0x0, (%rbx,%rax)
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x1090
movb $0x0, 0x1(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x1259(%rip), %rdi      # 0x3182
leaq 0x1267(%rip), %rsi      # 0x3197
leaq 0x126c(%rip), %rcx      # 0x31a3
movl $0x153, %edx            # imm = 0x153
callq 0x10a0
// File: /workspace/github_c_makefile_star2_O3/opencoff[P]crypto-rand/cryptorand.c
// Function: crypto_rand_init
int
crypto_rand_init(crypto_rand_state *st, int algo, crypto_rand_entropy_t entropy)
{
    if (!entropy) return -EINVAL;


    memset(st, 0, sizeof *st);
    st->entropy = entropy;

    switch (algo) {
        case CRYPTO_RAND_AES:
            _aes_setup(st);
            __aes_init(st);
            break;

        case CRYPTO_RAND_CHACHA20:
            _chacha_setup(st);
            __chacha_init(st);
            break;

        default:
            return -EINVAL;
    }

    // When we startup, st->buf is zero so, we're encrypting a
    // zero-buf with a random key & IV.
    _rs_rekey(st, 0, 0);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl $0xffffffea, %ebp       # imm = 0xFFFFFFEA
testq %rdx, %rdx
je 0x152c
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
movl $0x530, %edx            # imm = 0x530
xorl %esi, %esi
callq 0x1060
movq %r14, 0x510(%rbx)
cmpl $0x2, %r15d
je 0x14a3
cmpl $0x1, %r15d
jne 0x152c
leaq 0x273(%rip), %rax       # 0x16ca
movq %rax, 0x518(%rbx)
leaq 0x279(%rip), %rax       # 0x16de
movq %rax, 0x520(%rbx)
leaq 0x29d(%rip), %rax       # 0x1710
movq %rax, 0x528(%rbx)
movq %rsp, %rdi
movl $0x30, %esi
callq *%r14
testl %eax, %eax
jne 0x1539
leaq 0x20(%rsp), %rdx
leaq 0x410(%rbx), %rdi
movq %rsp, %rsi
callq 0x1eb2
jmp 0x1518
leaq 0x2e0(%rip), %rax       # 0x178a
movq %rax, 0x518(%rbx)
leaq 0x854(%rip), %rax       # 0x1d0c
movq %rax, 0x520(%rbx)
leaq 0x897(%rip), %rax       # 0x1d5d
movq %rax, 0x528(%rbx)
movq %rsp, %rdi
movl $0x28, %esi
callq *%r14
testl %eax, %eax
jne 0x1558
movaps (%rsp), %xmm0
movups %xmm0, 0x420(%rbx)
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x430(%rbx)
movaps 0x1b56(%rip), %xmm0     # 0x3050
movups %xmm0, 0x410(%rbx)
movq $0x0, 0x440(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x448(%rbx)
movq %rbx, %rdi
callq *0x518(%rbx)
movq %rbx, %rdi
callq *0x520(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ac4(%rip), %rdi      # 0x3004
leaq 0x1b19(%rip), %rsi      # 0x3060
leaq 0x1b43(%rip), %rcx      # 0x3091
movl $0x78, %edx
callq 0x1050
leaq 0x1aa5(%rip), %rdi      # 0x3004
leaq 0x1afa(%rip), %rsi      # 0x3060
leaq 0x1b72(%rip), %rcx      # 0x30df
movl $0x3e, %edx
callq 0x1050
// File: /workspace/github_c_makefile_star2_O3/opencoff[P]crypto-rand/cryptorand.c
// Function: crypto_rand_buf
void
crypto_rand_buf(crypto_rand_state* st, void *buf, size_t n)
{
    uint8_t *end = st->buf + sizeof st->buf;

    _rs_stir_if_needed(st, n);
    while (n > 0) {
        size_t avail = end - st->ptr;
        if (avail > 0) {
            size_t m = minimum(n, avail);

            memcpy(buf, st->ptr, m);

            buf     += m;
            n       -= m;
            st->ptr += m;
        } else 
            _rs_rekey(st, NULL, 0);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x400(%rdi), %r13
movq 0x408(%rdi), %rax
cmpq %rdx, %rax
ja 0x15c1
movq %r15, %rdi
callq *0x528(%r15)
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x1060
movq %r13, 0x400(%r15)
movl $0x20000, %eax          # imm = 0x20000
subq %rbx, %rax
movq %rax, 0x408(%r15)
testq %rbx, %rbx
je 0x1610
movq (%r13), %rsi
movq %r13, %r12
subq %rsi, %r12
je 0x15fa
cmpq %r12, %rbx
cmovbq %rbx, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0x1090
addq %r12, %r14
subq %r12, %rbx
addq %r12, (%r13)
jmp 0x15cb
movq %r15, %rdi
callq *0x518(%r15)
movq %r15, %rdi
callq *0x520(%r15)
jmp 0x15cb
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/opencoff[P]crypto-rand/cryptorand.c
// Function: crypto_rand_uniform32_bounded
uint32_t
crypto_rand_uniform32_bounded(crypto_rand_state *st, uint32_t upper_bound)
{
    uint32_t r, min;

    if (upper_bound < 2)
        return 0;

    /* 2**32 % x == (2**32 - x) % x */
    min = -upper_bound % upper_bound;

    /*
     * This could theoretically loop forever but each retry has
     * p > 0.5 (worst case, usually far better) of selecting a
     * number inside the range we need, so it should rarely need
     * to re-roll.
     */
    for (;;) {
        r = crypto_rand_uniform32(st);
        if (r >= min)
            break;
    }

    return r % upper_bound;
}

// Assembly:
xorl %eax, %eax
cmpl $0x2, %esi
jb 0x166c
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %eax
negl %eax
xorl %edx, %edx
divl %esi
movl %edx, %ebp
leaq 0x4(%rsp), %r15
movl $0x0, 0x4(%rsp)
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x1577
movl 0x4(%rsp), %eax
cmpl %ebp, %eax
jb 0x163c
xorl %edx, %edx
divl %ebx
movl %edx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/opencoff[P]crypto-rand/cryptorand.c
// Function: crypto_rand_uniform64_bounded
uint64_t
crypto_rand_uniform64_bounded(crypto_rand_state *st, uint64_t upper_bound)
{
    uint64_t r, min;

    if (upper_bound < 2)
        return 0;

    /* 2**64 % x == (2**64 - x) % x */
    min = -upper_bound % upper_bound;

    /*
     * This could theoretically loop forever but each retry has
     * p > 0.5 (worst case, usually far better) of selecting a
     * number inside the range we need, so it should rarely need
     * to re-roll.
     */
    for (;;) {
        r = crypto_rand_uniform64(st);
        if (r >= min)
            break;
    }

    return r % upper_bound;
}

// Assembly:
cmpq $0x2, %rsi
jae 0x1676
xorl %eax, %eax
retq
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rax
negq %rax
xorl %edx, %edx
divq %rsi
movq %rdx, %r15
movq %rsp, %r12
movq $0x0, (%rsp)
movl $0x8, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x1577
movq (%rsp), %rax
cmpq %r15, %rax
jb 0x1695
xorl %edx, %edx
divq %rbx
movq %rdx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/opencoff[P]crypto-rand/./cipher.h
// Function: _aes_rekey
static void
__aes_rekey(crypto_rand_state *st)
{
    uint8_t rnd[AESRAND_KEYSZ + AESRAND_IVSZ];

    int r = (*st->entropy)(rnd, sizeof rnd);
    assert(r == 0);

    _rs_rekey(st, rnd, sizeof(rnd));
}

// Assembly:
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movq %rsp, %rdi
movl $0x30, %esi
callq *0x510(%rbx)
testl %eax, %eax
jne 0x176b
movq %rbx, %rdi
callq *0x518(%rbx)
xorl %eax, %eax
movups (%rbx,%rax), %xmm0
xorps (%rsp,%rax), %xmm0
movups %xmm0, (%rbx,%rax)
addq $0x10, %rax
cmpq $0x30, %rax
jne 0x1735
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq %rbx, %rdi
callq *0x520(%rbx)
addq $0x30, %rsp
popq %rbx
retq
leaq 0x1892(%rip), %rdi      # 0x3004
leaq 0x18e7(%rip), %rsi      # 0x3060
leaq 0x18eb(%rip), %rcx      # 0x306b
movl $0x5b, %edx
callq 0x1050
// File: /workspace/github_c_makefile_star2_O3/opencoff[P]crypto-rand/./cipher.h
// Function: _chacha_rekey
static void
__chacha_rekey(crypto_rand_state *st)
{
    uint8_t rnd[ARC4R_KEYSZ + ARC4R_IVSZ];

    int r = (*st->entropy)(rnd, sizeof rnd);
    assert(r == 0);

    _rs_rekey(st, rnd, sizeof(rnd));
}

// Assembly:
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movq %rsp, %rdi
movl $0x28, %esi
callq *0x510(%rbx)
testl %eax, %eax
jne 0x1db5
movq %rbx, %rdi
callq *0x518(%rbx)
xorl %eax, %eax
movb (%rsp,%rax), %cl
xorb %cl, (%rbx,%rax)
incq %rax
cmpq $0x28, %rax
jne 0x1d82
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq $0x0, 0x20(%rsp)
movq %rbx, %rdi
callq *0x520(%rbx)
addq $0x30, %rsp
popq %rbx
retq
leaq 0x1248(%rip), %rdi      # 0x3004
leaq 0x129d(%rip), %rsi      # 0x3060
leaq 0x12ec(%rip), %rcx      # 0x30b6
movl $0x22, %edx
callq 0x1050
// File: /workspace/github_c_makefile_star2_O3/opencoff[P]crypto-rand/posix_entropy.c
// Function: getentropy
int
getentropy(void* buf, size_t n)
{
    static int fd = -1;
    uint8_t* b    = (uint8_t*)buf;

    if (fd < 0)
        fd = randopen("/dev/urandom");

    while (n > 0)
    {
        ssize_t m = (read)(fd, b, n);

        if (m < 0) {
            if (errno == EINTR) continue;
            error(1, errno, "Fatal read error while reading rand dev");
        }
        b += m;
        n -= m;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x0, 0x2d23(%rip)      # 0x50a0
jns 0x23bc
leaq 0xef7(%rip), %rdi       # 0x327d
xorl %esi, %esi
xorl %eax, %eax
callq 0x10c0
movl %eax, %ebp
testl %eax, %eax
jns 0x23b6
callq 0x1040
movl (%rax), %esi
leaq 0xf0f(%rip), %rdx       # 0x32b2
leaq 0xed3(%rip), %rcx       # 0x327d
movl $0x1, %edi
xorl %eax, %eax
callq 0x1130
movl %ebp, 0x2ce4(%rip)      # 0x50a0
testq %rbx, %rbx
je 0x2407
leaq 0xec2(%rip), %r15       # 0x328a
movl 0x2cd2(%rip), %edi      # 0x50a0
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1070
movq %rax, %r12
testq %rax, %rax
jns 0x23fc
callq 0x1040
movl (%rax), %esi
cmpl $0x4, %esi
je 0x2402
movl $0x1, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1130
addq %r12, %r14
subq %r12, %rbx
testq %rbx, %rbx
jne 0x23c8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/clunk.c
// Function: computermove
struct move computermove(struct thudboard * board)
{
    struct move move;

    puts("Thinking...");
    fflush(stdout);
    // move = iterdeepen(board, SEARCHSECS);
    move = montecarlo(board, SEARCHSECS);
    showmove(& move);

    return move;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x3d5f(%rip), %rdi      # 0x508c
callq 0x1040
movq 0x6cbf(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
callq 0x11e0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x3c, %edx
callq 0x3d68
movq %r14, %rdi
callq 0x3a1e
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: setup
void setup(struct thudboard * board)
{
    erase(board);

    board->isdwarfturn = true;
    board->captless = 0;

    for (int y=0; y < SIZE; ++y)
    {
        for (int x=0; x < SIZE; ++x)
        {
            switch (toupper(stdlayout[y][x]))
            {
            case 'D':
                placedwarf(board, (struct coord) {x,y});
                break;
            case 'T':
                placetroll(board, (struct coord) {x,y});
                break;
            case '#':
                set(board->blocks, (struct coord) {x,y});
                break;
            case '.':
                break;
            default:
                fprintf(stderr, "unknown board character\n");
                exit(1);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movups %xmm0, 0x70(%rdi)
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movb $0x1, (%rdi)
xorl %r12d, %r12d
callq 0x10c0
movq %rax, %r14
leaq 0x69b7(%rip), %r13      # 0x8170
xorl %ebp, %ebp
xorl %r15d, %r15d
movq (%r14), %rax
movq (%r13,%rbp,8), %rcx
movsbq (%rcx,%r15), %rcx
movl (%rax,%rcx,4), %eax
cmpl $0x43, %eax
jg 0x17df
cmpl $0x23, %eax
je 0x17f7
cmpl $0x2e, %eax
je 0x1826
jmp 0x1858
cmpl $0x54, %eax
je 0x1808
cmpl $0x44, %eax
jne 0x1858
leaq (%r12,%r15), %rsi
movq %rbx, %rdi
callq 0x32e3
jmp 0x1826
movl $0x4000, %eax           # imm = 0x4000
movl %r15d, %ecx
shrl %cl, %eax
orw %ax, 0x3e(%rbx,%rbp,2)
jmp 0x1826
leaq (%r12,%r15), %rsi
movq %rbx, %rdi
callq 0x43c0
movl $0x4000, %eax           # imm = 0x4000
movl %r15d, %ecx
shrl %cl, %eax
orw %ax, 0x20(%rbx,%rbp,2)
incl 0x60(%rbx)
incq %r15
cmpq $0xf, %r15
jne 0x17be
incq %rbp
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r12
cmpq $0xf, %rbp
jne 0x17bb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1200
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: zerowindow
struct move zerowindow(struct thudboard * board, int depth,
                       time_t stoptime, jmp_buf stopsearch)
{
    struct movelist list = allmoves(board);
    struct moveheap queue = heapof(board, & list);

    //??? should make sure move exists
    struct scoredmove best = popscored(& queue);

    domove(board, best.move);
    best.score = mtdf(board, depth, best.score, stoptime, stopsearch);
    undomove(board, best.move);

    while (queue.used > 0)
    {
        struct scoredmove temp = popscored(& queue);

        domove(board, temp.move);

        int result = absearch(board, depth, FULL_WIDTH,
                              best.score-1, best.score, NULL,
                              stoptime, stopsearch);

        if (result > best.score)
        {
            best = temp;
            best.score = _mtdf(board, depth,
                               result, result, INT_MAX,
                               stoptime, stopsearch);
        }

        undomove(board, temp.move);
    }

    return * best.move;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r14
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r12
cmpb $0x1, (%rsi)
movq %rdi, 0x20(%rsp)
movq %rsi, %rdi
jne 0x1906
callq 0x21cf
jmp 0x190b
callq 0x24b2
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %r12, %rdi
callq 0x2055
leaq 0x28(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x3cb1
movl %eax, %ebx
movq %rdx, %r13
movq %r12, %rdi
movq %rdx, %rsi
callq 0x20ec
movq %r14, (%rsp)
movq %r12, %rdi
movl %ebp, %esi
movl %ebx, %edx
movl $0x80000000, %ecx       # imm = 0x80000000
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %r15, %r9
callq 0x2132
movl %eax, %ebx
movq %r12, %rdi
movq %r13, 0x18(%rsp)
movq %r13, %rsi
callq 0x2124
leaq 0x28(%rsp), %rax
cmpl $0x0, (%rax)
jle 0x19eb
leaq 0x28(%rsp), %rdi
callq 0x3cb1
movq %rdx, %r13
movq %r12, %rdi
movq %rdx, %rsi
callq 0x20ec
leal -0x1(%rbx), %ecx
movq %r14, 0x8(%rsp)
movq %r15, (%rsp)
movq %r12, %rdi
movl %ebp, %esi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %ebx, %r8d
xorl %r9d, %r9d
callq 0x1ae9
cmpl %ebx, %eax
jle 0x19d9
movq %r14, (%rsp)
movq %r12, %rdi
movl %ebp, %esi
movl %eax, %edx
movl %eax, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %r15, %r9
callq 0x2132
movl %eax, %ebx
movq %r13, 0x18(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2124
cmpl $0x0, 0x28(%rsp)
jg 0x197a
movl $0x16, %ecx
movq 0x20(%rsp), %rax
movq %rax, %rdi
movq 0x18(%rsp), %rsi
rep  movsl (%rsi), %es:(%rdi)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: iterdeepen
struct move iterdeepen(struct thudboard * board, int searchtime)
{
    struct move bestmove;

    struct thudboard tempboard = * board;
    time_t stoptime = time(NULL) + searchtime;

    jmp_buf stopsearch;
    if (setjmp(stopsearch) == 0) for (int depth=1; true; depth += 1)
    {
        struct move move;
        absearch(& tempboard, depth, FULL_WIDTH,
                 INT_MIN, INT_MAX, & move,
                 stoptime, stopsearch);
        bestmove = move;

        // log to stderr
        fprintf(stderr, "best move at depth %d: ", depth);
        fshowmove(stderr, & bestmove);
    }

    return bestmove;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
movl $0x10, %ecx
rep  movsq (%rsi), %es:(%rdi)
xorl %eax, %eax
movl %eax, %edi
callq 0x11d0
movq %rax, %r14
leaq 0xe0(%rsp), %rdi
callq 0x1050
testl %eax, %eax
je 0x1a63
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %ebp, %rax
addq %rax, %r14
movq %r14, (%rsp)
movl $0x1, %r14d
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leaq 0x88(%rsp), %r13
movq 0x6560(%rip), %r15      # 0x7fe8
xorl %eax, %eax
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
movl %r14d, %esi
movl %r12d, %edx
movl $0x80000000, %ecx       # imm = 0x80000000
movl %r12d, %r8d
movq %r13, %r9
leaq 0xe0(%rsp), %rax
pushq %rax
pushq 0x8(%rsp)
callq 0x1ae9
addq $0x10, %rsp
movl $0x16, %ecx
movq %rbx, %rdi
movq %r13, %rsi
rep  movsl (%rsi), %es:(%rdi)
movq (%r15), %rdi
leaq 0x36a1(%rip), %rsi      # 0x5170
movl %r14d, %edx
movl %ebp, %eax
callq 0x1190
movq (%r15), %rdi
movq %rbx, %rsi
callq 0x1e50
incl %r14d
jmp 0x1a8c
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: fshowmove
void fshowmove(FILE * stream, struct move * move)
{
    putc(move->isdwarfmove ? 'd' : 'T', stream);
    putc(' ', stream);
    fshowpos(stream, move->from);
    fputs("-", stream);
    fshowpos(stream, move->to);
    for (int i=0; i < move->numcapts; ++i)
    {
        fputs("x", stream);
        fshowpos(stream, move->capts[i]);
    }
    putc('\n', stream);
    fflush(stream);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movzbl (%rsi), %edi
shll $0x4, %edi
addl $0x54, %edi
movq %rbx, %rsi
callq 0x1110
movl $0x20, %edi
movq %rbx, %rsi
callq 0x1110
movq 0x4(%r14), %rcx
movslq %ecx, %rax
shrq $0x20, %rcx
movq 0x6359(%rip), %rdx      # 0x81e8
movsbl (%rdx,%rax), %edx
incl %ecx
leaq 0x3399(%rip), %r15      # 0x5235
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1190
leaq 0x322d(%rip), %rdi      # 0x50dd
movq %rbx, %rsi
callq 0x10f0
movq 0xc(%r14), %rcx
movslq %ecx, %rax
shrq $0x20, %rcx
movq 0x631e(%rip), %rdx      # 0x81e8
movsbl (%rdx,%rax), %edx
incl %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1190
cmpl $0x0, 0x14(%r14)
jle 0x1f32
leaq 0x31e8(%rip), %r15      # 0x50d3
leaq 0x3343(%rip), %r12      # 0x5235
xorl %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x10f0
movq 0x18(%r14,%r13,8), %rcx
movslq %ecx, %rax
shrq $0x20, %rcx
movq 0x62d5(%rip), %rdx      # 0x81e8
movsbl (%rdx,%rax), %edx
incl %ecx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1190
incq %r13
movslq 0x14(%r14), %rax
cmpq %rax, %r13
jl 0x1ef5
movl $0xa, %edi
movq %rbx, %rsi
callq 0x1110
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x11e0
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: heapof
struct moveheap heapof(struct thudboard * board, struct movelist * list)
{
    bool isdwarfturn = board->isdwarfturn;

    struct moveheap heap;
    initheap(& heap);

    for (int i=0; i < list->used; ++i)
    {
        struct move * move = & (list->moves[i]);

        domove(board, move);
        int score = evaluate(board);
        if (isdwarfturn) score *= -1;
        undomove(board, move);

        insert(& heap, score, move);
    }

    return heap;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movb (%rdi), %al
movb %al, 0x7(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x3ad4
cmpl $0x0, (%rbx)
jle 0x20d3
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x8(%rbx), %r12
addq %r15, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x20ec
movq %r14, %rdi
callq 0x219d
movl %eax, %ebp
negl %ebp
cmpb $0x0, 0x7(%rsp)
cmovel %eax, %ebp
movq %r14, %rdi
movq %r12, %rsi
callq 0x2124
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x3b05
incq %r13
movslq (%rbx), %rax
addq $0x58, %r15
cmpq %rax, %r13
jl 0x2084
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: evaluate
int evaluate(struct thudboard * board)
{
    eval_count += 1;
    struct tableentry * entry = ttget(board->hash);
    if (entry) return entry->scoreguess;
    else return heuristic(board);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
incl 0x60d1(%rip)            # 0x8278
movq 0x68(%rdi), %rdi
callq 0x4500
testq %rax, %rax
je 0x21ba
movl 0x10(%rax), %eax
jmp 0x21cd
imull $0xfa0, 0x60(%rbx), %ecx # imm = 0xFA0
imull $0xfffffc18, 0x5c(%rbx), %eax # imm = 0xFFFFFC18
addl %ecx, %eax
subl 0x64(%rbx), %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: addmoves
void addmoves(int num, struct thudboard * board, struct genstate * ctx,
              struct movelist * list, struct moveheap * queue)
{
    bool isdwarfturn = board->isdwarfturn;

    struct move * move;

    for (int i=0; i < num; ++i)
    {
        move = next(list);
        * move = board->isdwarfturn ? nextdwarfplay(board, ctx)
                                    : nexttrollplay(board, ctx);
        if (! ctx->resume)
        {
            list->used -= 1;
            break;
        }

        domove(board, move);
        int score = evaluate(board);
        if (isdwarfturn) score *= -1;
        undomove(board, move);

        insert(queue, score, move);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
testl %edi, %edi
jle 0x28ab
movq %rdx, %r15
movq %rsi, %r12
movl %edi, %ebp
movb (%rsi), %al
movb %al, 0xf(%rsp)
leaq 0x20(%rsp), %r13
movq 0x10(%rsp), %rdi
callq 0x3d09
movq %rax, %r14
cmpb $0x1, (%r12)
jne 0x2840
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x28ba
jmp 0x284e
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2b3b
movl $0x16, %ecx
movq %r14, %rdi
movq %r13, %rsi
rep  movsl (%rsi), %es:(%rdi)
cmpq $0x0, (%r15)
je 0x28a4
movq %r12, %rdi
movq %r14, %rsi
callq 0x20ec
movq %r12, %rdi
callq 0x219d
movl %eax, %ebx
negl %ebx
cmpb $0x0, 0xf(%rsp)
cmovel %eax, %ebx
movq %r12, %rdi
movq %r14, %rsi
callq 0x2124
movq 0x18(%rsp), %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x3b05
decl %ebp
jne 0x281c
jmp 0x28ab
movq 0x10(%rsp), %rax
decl (%rax)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: nextpos
struct coord nextpos(bitboard bits, struct coord cur)
{
    cur.x += 1;

    for (int i=cur.y*SIZE+cur.x; i < SIZE*SIZE; ++i)
    {
        struct coord pos = (struct coord) {i % SIZE, i / SIZE};
        if (get(bits, pos)) return pos;
    }

    return initpos;
}

// Assembly:
movq %rsi, %rax
shrq $0x20, %rax
leal (%rax,%rax,4), %eax
leal (%rax,%rax,2), %eax
addl %esi, %eax
incl %eax
cmpl $0xe0, %eax
jg 0x2ec0
movslq %eax, %rcx
imulq $-0x77777777, %rcx, %rdx # imm = 0x88888889
shrq $0x20, %rdx
addl %eax, %edx
movl %edx, %ecx
shrl $0x1f, %ecx
sarl $0x3, %edx
addl %ecx, %edx
leal (%rdx,%rdx,4), %ecx
leal (%rcx,%rcx,2), %esi
movl %eax, %ecx
subl %esi, %ecx
movl $0x4000, %esi           # imm = 0x4000
shrl %cl, %esi
movslq %edx, %r8
testw %si, (%rdi,%r8,2)
je 0x2ea0
xorl %eax, %eax
jmp 0x2ebc
leal 0x1(%rsi), %eax
movslq %eax, %rcx
imulq $-0x77777777, %rcx, %rdx # imm = 0x88888889
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %r8d
shrl $0x1f, %r8d
sarl $0x3, %edx
addl %r8d, %edx
leal (%rdx,%rdx,4), %r8d
leal (%r8,%r8,2), %r8d
subl %r8d, %ecx
movl $0x4000, %r8d           # imm = 0x4000
shrl %cl, %r8d
movslq %edx, %r9
testw %r8w, (%rdi,%r9,2)
jne 0x2eb3
movl %eax, %esi
cmpl $0xe0, %eax
jne 0x2e62
movl $0xe, %ecx
movl $0xe, %edx
cmpl $0xe0, %esi
setge %al
testb %al, %al
je 0x2ecc
movl 0x525a(%rip), %ecx      # 0x8120
movl 0x5258(%rip), %edx      # 0x8124
shlq $0x20, %rdx
movl %ecx, %eax
orq %rdx, %rax
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: dodwarf
void dodwarf(struct thudboard * board, struct move * move)
{
    if (move->numcapts > 0) capttroll(board, move->capts[0]);
    movedwarf(board, move->from, move->to);
    board->isdwarfturn = false;
    hashturn(board);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x0, 0x14(%rsi)
jle 0x2f6e
movq 0x18(%r14), %rcx
movl $0x4000, %eax           # imm = 0x4000
shrl %cl, %eax
notl %eax
movq %rcx, %rdx
sarq $0x20, %rdx
andw %ax, 0x20(%rbx,%rdx,2)
movq %rbx, %rdi
movq %rcx, %rsi
callq 0x43c0
decl 0x60(%rbx)
movq 0x4(%r14), %rsi
movq 0xc(%r14), %rdx
movq %rbx, %rdi
callq 0x2fb5
movb $0x0, (%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4392
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: movedwarf
void movedwarf(struct thudboard * board, struct coord from, struct coord to)
{
    unset(board->dwarfs, from);
    hashdwarf(board, from);
    board->dwarfclump -= countneighbors(board->dwarfs, from);
    board->dwarfclump += countneighbors(board->dwarfs, to);
    hashdwarf(board, to);
    set(board->dwarfs, to);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movl $0x4000, %eax           # imm = 0x4000
movl %r15d, %ecx
shrl %cl, %eax
leaq 0x2(%rdi), %r12
movl $0x4000, %ebp           # imm = 0x4000
notl %eax
movq %rsi, %rcx
sarq $0x20, %rcx
andw %ax, 0x2(%rdi,%rcx,2)
callq 0x439e
movq %r12, %rdi
movq %r15, %rsi
callq 0x3a30
movl 0x64(%r14), %r15d
subl %eax, %r15d
movl %r15d, 0x64(%r14)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3a30
addl %r15d, %eax
movl %eax, 0x64(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x439e
movl %ebx, %ecx
shrl %cl, %ebp
sarq $0x20, %rbx
orw %bp, 0x2(%r14,%rbx,2)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: undodwarf
void undodwarf(struct thudboard * board, struct move * move)
{
    movedwarf(board, move->to, move->from);
    if (move->numcapts > 0) placetroll(board, move->capts[0]);
    board->isdwarfturn = true;
    hashturn(board);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x4(%rsi), %rdx
movq 0xc(%rsi), %rsi
callq 0x2fb5
cmpl $0x0, 0x14(%r14)
jle 0x307a
movq 0x18(%r14), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x43c0
movl $0x4000, %eax           # imm = 0x4000
movl %r14d, %ecx
shrl %cl, %eax
sarq $0x20, %r14
orw %ax, 0x20(%rbx,%r14,2)
incl 0x60(%rbx)
movb $0x1, (%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4392
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: hasneighbor
bool hasneighbor(bitboard bits, struct coord pos)
{
    for (int i=0; i < NUMDIRS; ++i)
    {
        struct coord neighbor = {pos.x + DX[i], pos.y + DY[i]};
        if (inbounds(neighbor) && get(bits, neighbor)) return true;
    }
    return false;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rdx
shrq $0x20, %rdx
movb $0x1, %al
xorl %r8d, %r8d
leaq 0x505f(%rip), %r9       # 0x8130
leaq 0x5078(%rip), %r10      # 0x8150
xorl %r11d, %r11d
movl (%r8,%r9), %ecx
addl %esi, %ecx
movl (%r8,%r10), %ebx
addl %edx, %ebx
cmpl $0xf, %ecx
setae %bpl
cmpl $0xf, %ebx
setae %r14b
orb %bpl, %r14b
jne 0x3109
movl $0x4000, %ebp           # imm = 0x4000
shrl %cl, %ebp
movl %ebx, %ecx
testw %bp, (%rdi,%rcx,2)
jne 0x3121
cmpq $0x7, %r11
leaq 0x1(%r11), %rcx
setb %al
addq $0x4, %r8
movq %rcx, %r11
cmpq $0x8, %rcx
jne 0x30db
andb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: dotroll
void dotroll(struct thudboard * board, struct move * move)
{
    captdwarfs(board, move->numcapts, move->capts);
    movetroll(board, move->from, move->to);
    board->isdwarfturn = true;
    hashturn(board);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x14(%rsi), %esi
leaq 0x18(%rbx), %rdx
callq 0x3161
movq 0x4(%rbx), %rsi
movq 0xc(%rbx), %rdx
movq %r14, %rdi
callq 0x31cf
movb $0x1, (%r14)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4392
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: captdwarfs
void captdwarfs(struct thudboard * board, int num, struct coord * froms)
{
    for (int i=0; i < num; ++i)
    {
        unset(board->dwarfs, froms[i]);
        hashdwarf(board, froms[i]);
        board->dwarfclump -= countneighbors(board->dwarfs, froms[i]);
    }
    board->numdwarfs -= num;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r15
testl %esi, %esi
jle 0x31bc
movq %rdx, %r14
leaq 0x2(%r15), %r12
movl %ebx, %r13d
xorl %ebp, %ebp
movq (%r14,%rbp,8), %rcx
movl $0x4000, %eax           # imm = 0x4000
shrl %cl, %eax
notl %eax
sarq $0x20, %rcx
andw %ax, 0x2(%r15,%rcx,2)
movq (%r14,%rbp,8), %rsi
movq %r15, %rdi
callq 0x439e
movq (%r14,%rbp,8), %rsi
movq %r12, %rdi
callq 0x3a30
subl %eax, 0x64(%r15)
incq %rbp
cmpq %rbp, %r13
jne 0x3181
subl %ebx, 0x5c(%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: movetroll
void movetroll(struct thudboard * board, struct coord from, struct coord to)
{
    unset(board->trolls, from);
    hashtroll(board, from);
    hashtroll(board, to);
    set(board->trolls, to);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movl $0x4000, %eax           # imm = 0x4000
movl %esi, %ecx
shrl %cl, %eax
movq %rdi, %r14
movl $0x4000, %ebp           # imm = 0x4000
notl %eax
movq %rsi, %rcx
sarq $0x20, %rcx
andw %ax, 0x20(%rdi,%rcx,2)
callq 0x43c0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x43c0
movl %ebx, %ecx
shrl %cl, %ebp
sarq $0x20, %rbx
orw %bp, 0x20(%r14,%rbx,2)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: undotroll
void undotroll(struct thudboard * board, struct move * move)
{
    movetroll(board, move->to, move->from);
    placedwarfs(board, move->numcapts, move->capts);
    board->isdwarfturn = false;
    hashturn(board);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x4(%rsi), %rdx
movq 0xc(%rsi), %rsi
callq 0x31cf
movl 0x14(%rbx), %esi
addq $0x18, %rbx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3254
movb $0x0, (%r14)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4392
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: placedwarfs
void placedwarfs(struct thudboard * board, int num, struct coord * tos)
{
    for (int i=0; i < num; ++i)
    {
        board->dwarfclump += countneighbors(board->dwarfs, tos[i]);
        hashdwarf(board, tos[i]);
        set(board->dwarfs, tos[i]);
    }
    board->numdwarfs += num;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r15
testl %esi, %esi
jle 0x32ad
movq %rdx, %r14
leaq 0x2(%r15), %r12
movl %ebx, %r13d
xorl %ebp, %ebp
movq (%r14,%rbp,8), %rsi
movq %r12, %rdi
callq 0x3a30
addl %eax, 0x64(%r15)
movq (%r14,%rbp,8), %rsi
movq %r15, %rdi
callq 0x439e
movq (%r14,%rbp,8), %rcx
movl $0x4000, %eax           # imm = 0x4000
shrl %cl, %eax
sarq $0x20, %rcx
orw %ax, 0x2(%r15,%rcx,2)
incq %rbp
cmpq %rbp, %r13
jne 0x3274
addl %ebx, 0x5c(%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: placedwarf
void placedwarf(struct thudboard * board, struct coord to)
{
    board->dwarfclump += countneighbors(board->dwarfs, to);
    hashdwarf(board, to);
    set(board->dwarfs, to);
    board->numdwarfs += 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
addq $0x2, %rdi
callq 0x3a30
addl %eax, 0x64(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x439e
movl $0x4000, %eax           # imm = 0x4000
movl %ebx, %ecx
shrl %cl, %eax
sarq $0x20, %rbx
orw %ax, 0x2(%r14,%rbx,2)
incl 0x5c(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: show
void show(struct thudboard * board)
{
    puts("   A B C D E F G H J K L M N O P");
    for (int y=0; y < SIZE; ++y)
    {
        printf("%2d", y+1);
        for (int x=0; x < SIZE; ++x)
        {
            putchar(' ');

            if (dwarfat(board, (struct coord) {x,y})) putchar('d');
            else if (trollat(board, (struct coord) {x,y})) putchar('T');
            else if (blockat(board, (struct coord) {x,y})) putchar('#');
            else putchar('.');
        }
        putchar('\n');
    }

    putchar('\n');
    printf("%d Dwarf%s and %d Troll%s have been captured.\n",
           board->dwarfscaptured, pl(board->dwarfscaptured),
           board->trollscaptured, pl(board->trollscaptured));
    printf("It is the %s player's turn\n",
           board->isdwarfturn ? "Dwarf" : "Troll");

    fflush(stdout);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x1e44(%rip), %rdi      # 0x51a3
callq 0x1040
leaq 0x1e59(%rip), %r14      # 0x51c4
xorl %r12d, %r12d
leaq 0x1(%r12), %r15
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1030
xorl %ebp, %ebp
movl $0x20, %edi
callq 0x1080
movl $0x4000, %eax           # imm = 0x4000
movl %ebp, %ecx
shrl %cl, %eax
movl $0x64, %edi
testw %ax, 0x2(%rbx,%r12,2)
jne 0x33c1
movl $0x54, %edi
testw %ax, 0x20(%rbx,%r12,2)
jne 0x33c1
movl $0x2e, %edi
testw %ax, 0x3e(%rbx,%r12,2)
je 0x33c1
movl $0x23, %edi
callq 0x1080
incl %ebp
cmpl $0xf, %ebp
jne 0x3382
movl $0xa, %edi
callq 0x1080
movq %r15, %r12
cmpq $0xf, %r15
jne 0x336e
movl $0xa, %edi
callq 0x1080
movl 0x70(%rbx), %esi
cmpl $0x1, %esi
leaq 0x1dff(%rip), %rax      # 0x51f6
leaq 0x1da3(%rip), %r8       # 0x51a1
movq %r8, %rdx
cmoveq %rax, %rdx
movl 0x74(%rbx), %ecx
cmpl $0x1, %ecx
cmoveq %rax, %r8
leaq 0x1db2(%rip), %rdi      # 0x51c8
xorl %eax, %eax
callq 0x1030
leaq 0x1def(%rip), %rax      # 0x5213
leaq 0x1dee(%rip), %rsi      # 0x5219
cmpb $0x0, (%rbx)
cmovneq %rax, %rsi
leaq 0x1dbe(%rip), %rdi      # 0x51f7
xorl %eax, %eax
callq 0x1030
movq 0x4bb1(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x11e0
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: legalmove
bool legalmove(struct thudboard * board, struct move * move)
{
    // board and move must agree on whose turn it is
    if (board->isdwarfturn != move->isdwarfmove) return false;
    // move source must be in bounds
    else if (! inbounds(move->from)) return false;
    // move target must be in bounds
    else if (! inbounds(move->to)) return false;
    // check move details
    else if (move->isdwarfmove) return legaldwarfmove(board, move);
    else return legaltrollmove(board, move);
}

// Assembly:
movb (%rdi), %al
cmpb (%rsi), %al
jne 0x34c7
movq 0x4(%rsi), %rcx
cmpl $0xf, %ecx
setae %dl
shrq $0x20, %rcx
cmpl $0xf, %ecx
setae %cl
orb %dl, %cl
jne 0x34c7
movabsq $0xf00000000, %rcx      # imm = 0xF00000000
movq 0xc(%rsi), %rdx
cmpl $0xf, %edx
setae %r8b
cmpq %rcx, %rdx
setae %cl
orb %r8b, %cl
jne 0x34c7
testb %al, %al
jne 0x34ca
jmp 0x3685
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: domoveupdatecapts
void domoveupdatecapts(struct thudboard * board, struct move * move)
{
    if (board->isdwarfturn)
    {
        dodwarf(board, move);
        board->trollscaptured += move->numcapts;
    }
    else
    {
        dotroll(board, move);
        board->dwarfscaptured += move->numcapts;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x1, (%rdi)
jne 0x38a4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2f37
movl 0x14(%r14), %eax
addl %eax, 0x74(%rbx)
jmp 0x38b6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3128
movl 0x14(%r14), %eax
addl %eax, 0x70(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: getpos
bool getpos(char ** input, struct coord * pos)
{
    pos->x = lettertocolumn(** input);
    if (pos->x == -1) return false;
    * input += 1;

    int numchars;
    int numconvs = sscanf(* input, "%2d%n", & pos->y, & numchars);
    if (numconvs < 1) return false;
    pos->y -= 1;
    if (pos->y < 0 || pos->y >= SIZE) return false;

    * input += numchars;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r15
movsbq (%r15), %r12
callq 0x10c0
movq (%rax), %rax
movl (%rax,%r12,4), %eax
movsbl %al, %ecx
shll $0x18, %eax
leal -0x52(%rcx), %edx
xorl %esi, %esi
cmpl $0x4a, %ecx
setge %sil
negl %esi
cmpl $-0x11, %edx
leal -0x41(%rcx,%rsi), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmovbl %edx, %ecx
cmpl $0x49000000, %eax       # imm = 0x49000000
cmovel %edx, %ecx
movl %ecx, (%r14)
cmpl $-0x1, %ecx
je 0x39a9
incq %r15
movq %r15, (%rbx)
addq $0x4, %r14
leaq 0x189f(%rip), %rsi      # 0x521f
xorl %ebp, %ebp
leaq 0xc(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1060
testl %eax, %eax
jle 0x39b8
movl (%r14), %eax
leal -0x1(%rax), %ecx
movl %ecx, (%r14)
addl $-0x10, %eax
cmpl $-0xf, %eax
jae 0x39ad
xorl %ebp, %ebp
jmp 0x39b8
movslq 0xc(%rsp), %rax
addq %rax, (%rbx)
movb $0x1, %bpl
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/thudlib.c
// Function: countneighbors
int countneighbors(bitboard bits, struct coord pos)
{
    int neighbors = 0;
    for (int i=0; i < NUMDIRS; ++i)
    {
        struct coord neighbor = {pos.x + DX[i], pos.y + DY[i]};
        if (inbounds(neighbor)) neighbors += get(bits, neighbor);
    }
    return neighbors;
}

// Assembly:
pushq %rbp
pushq %rbx
movq %rsi, %rdx
shrq $0x20, %rdx
xorl %r8d, %r8d
leaq 0x46ed(%rip), %r9       # 0x8130
leaq 0x4706(%rip), %r10      # 0x8150
xorl %eax, %eax
movl (%r8,%r9), %ecx
addl %esi, %ecx
movl (%r8,%r10), %r11d
addl %edx, %r11d
cmpl $0xf, %ecx
setae %bl
cmpl $0xf, %r11d
setae %bpl
orb %bl, %bpl
jne 0x3a81
movl $0x4000, %ebx           # imm = 0x4000
shrl %cl, %ebx
movl %r11d, %ecx
andw (%rdi,%rcx,2), %bx
cmpw $0x1, %bx
sbbl $-0x1, %eax
addq $0x4, %r8
cmpq $0x20, %r8
jne 0x3a4c
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/icarroll[P]clunk/heap.c
// Function: heapdown
static void heapdown(struct moveheap * heap, int i)
{
    int l = left(i);
    int r = right(i);

    if (r < heap->used)
    {
        int j = i;
        if (score(heap, l) > score(heap, i)) j = l;
        if (score(heap, r) > score(heap, j)) j = r;

        if (i != j)
        {
            swap(heap, i, j);
            heapdown(heap, j);
        }
    }
    else if (l < heap->used
             && score(heap, i) < score(heap, l))
    {
        swap(heap, i, l);
    }
}

// Assembly:
leal 0x1(,%rsi,2), %eax
leal 0x2(,%rsi,2), %ecx
movl (%rdi), %r8d
cmpl %r8d, %ecx
jge 0x3c6f
movq 0x8(%rdi), %r8
movslq %eax, %rdx
shlq $0x4, %rdx
movl (%r8,%rdx), %edx
movslq %esi, %r9
shlq $0x4, %r9
cmpl (%r8,%r9), %edx
jg 0x3c0b
movl %esi, %eax
movslq %ecx, %rdx
shlq $0x4, %rdx
movl (%r8,%rdx), %edx
movslq %eax, %r10
shlq $0x4, %r10
cmpl (%r8,%r10), %edx
jg 0x3c25
movl %eax, %ecx
cmpl %esi, %ecx
je 0x3cb0
movl %ecx, %edx
addq %r8, %r9
movups (%r9), %xmm0
movaps %xmm0, -0x18(%rsp)
movslq %ecx, %rax
shlq $0x4, %rax
movups (%r8,%rax), %xmm0
movups %xmm0, (%r9)
movq 0x8(%rdi), %rcx
movaps -0x18(%rsp), %xmm0
movups %xmm0, (%rcx,%rax)
leal 0x1(%rdx,%rdx), %eax
leal 0x2(,%rdx,2), %ecx
movl (%rdi), %r8d
movl %edx, %esi
cmpl %r8d, %ecx
jl 0x3bed
jmp 0x3c71
movl %esi, %edx
cmpl %r8d, %eax
jge 0x3cb0
movq 0x8(%rdi), %rsi
movslq %edx, %rcx
shlq $0x4, %rcx
movl (%rsi,%rcx), %edx
cltq
shlq $0x4, %rax
cmpl (%rsi,%rax), %edx
jge 0x3cb0
addq %rsi, %rcx
addq %rax, %rsi
movups (%rcx), %xmm0
movaps %xmm0, -0x18(%rsp)
movups (%rsi), %xmm0
movups %xmm0, (%rcx)
movq 0x8(%rdi), %rcx
movaps -0x18(%rsp), %xmm0
movups %xmm0, (%rcx,%rax)
retq