LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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)
movq %rdx, %r15
movq %rsi, %r12
movb (%rsi), %al
movb %al, 0xf(%rsp)
xorl %ebx, %ebx
testl %edi, %edi
cmovgl %edi, %ebx
leaq 0x20(%rsp), %r13
subl $0x1, %ebx
jb 0x26ea
movq 0x10(%rsp), %rdi
callq 0x3a09
movq %rax, %rbp
cmpb $0x1, (%r12)
jne 0x2682
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x26f9
jmp 0x2690
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2980
pushq $0x16
popq %rcx
movq %rbp, %rdi
movq %r13, %rsi
rep  movsl (%rsi), %es:(%rdi)
cmpq $0x0, (%r15)
je 0x26e3
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1fa4
movq %r12, %rdi
callq 0x2053
movl %eax, %r14d
negl %r14d
cmpb $0x0, 0xf(%rsp)
cmovel %eax, %r14d
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1fdc
movq 0x18(%rsp), %rdi
movl %r14d, %esi
movq %rbp, %rdx
callq 0x3846
jmp 0x2655
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_O2/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
imull $0xf, %eax, %eax
leal (%rsi,%rax), %ecx
incl %ecx
pushq $0xf
popq %r8
movl %ecx, %esi
cmpl $0xe0, %ecx
jg 0x2c88
movl %esi, %eax
cltd
idivl %r8d
movl $0x4000, %r9d           # imm = 0x4000
movl %edx, %ecx
shrl %cl, %r9d
movslq %eax, %r10
leal 0x1(%rsi), %ecx
testw %r9w, (%rdi,%r10,2)
je 0x2c60
cmpl $0xe1, %esi
cmovgel 0x548b(%rip), %edx      # 0x8120
cmovgel 0x5488(%rip), %eax      # 0x8124
shlq $0x20, %rax
orq %rax, %rdx
movq %rdx, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2d4f
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x2d71
movq 0x4(%r14), %rsi
movq 0xc(%r14), %rdx
movq %rbx, %rdi
callq 0x2d96
movb $0x0, (%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3f43
// File: /workspace/github_c_makefile_star2_O2/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 0x3f4f
movq %r12, %rdi
movq %r15, %rsi
callq 0x3775
movl 0x64(%r14), %r15d
subl %eax, %r15d
movl %r15d, 0x64(%r14)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3775
addl %r15d, %eax
movl %eax, 0x64(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3f4f
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_O2/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 0x2d96
cmpl $0x0, 0x14(%r14)
jle 0x2e41
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x2e53
movb $0x1, (%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3f43
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
movq %rsi, %rax
shrq $0x20, %rax
xorl %edx, %edx
leaq 0x529d(%rip), %r8       # 0x8130
leaq 0x52b6(%rip), %r9       # 0x8150
xorl %r10d, %r10d
cmpq $0x8, %r10
je 0x2edc
movl (%rdx,%r8), %ecx
addl %esi, %ecx
movl (%rdx,%r9), %r11d
addl %eax, %r11d
cmpl $0xf, %ecx
setae %bl
cmpl $0xf, %r11d
setae %bpl
orb %bl, %bpl
jne 0x2ed3
movl $0x4000, %ebx           # imm = 0x4000
shrl %cl, %ebx
movl %r11d, %ecx
testw %bx, (%rdi,%rcx,2)
jne 0x2edc
incq %r10
addq $0x4, %rdx
jmp 0x2e9d
cmpq $0x8, %r10
setb %al
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2f1f
movq 0x4(%rbx), %rsi
movq 0xc(%rbx), %rdx
movq %r14, %rdi
callq 0x2f93
movb $0x1, (%r14)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3f43
// File: /workspace/github_c_makefile_star2_O2/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
movq %rdx, %r14
movl %esi, %ebx
movq %rdi, %r15
leaq 0x2(%rdi), %r12
xorl %r13d, %r13d
testl %esi, %esi
movl $0x0, %ebp
cmovgl %esi, %ebp
cmpq %r13, %rbp
je 0x2f80
movq (%r14,%r13,8), %rcx
movl $0x4000, %eax           # imm = 0x4000
shrl %cl, %eax
notl %eax
sarq $0x20, %rcx
andw %ax, 0x2(%r15,%rcx,2)
movq (%r14,%r13,8), %rsi
movq %r15, %rdi
callq 0x3f4f
movq (%r14,%r13,8), %rsi
movq %r12, %rdi
callq 0x3775
subl %eax, 0x64(%r15)
incq %r13
jmp 0x2f43
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_O2/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 0x3f6e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3f6e
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_O2/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 0x2f93
movl 0x14(%rbx), %esi
addq $0x18, %rbx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3018
movb $0x0, (%r14)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3f43
// File: /workspace/github_c_makefile_star2_O2/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
movq %rdx, %r14
movl %esi, %ebx
movq %rdi, %r15
leaq 0x2(%rdi), %r12
xorl %r13d, %r13d
testl %esi, %esi
movl $0x0, %ebp
cmovgl %esi, %ebp
cmpq %r13, %rbp
je 0x3077
movq (%r14,%r13,8), %rsi
movq %r12, %rdi
callq 0x3775
addl %eax, 0x64(%r15)
movq (%r14,%r13,8), %rsi
movq %r15, %rdi
callq 0x3f4f
movq (%r14,%r13,8), %rcx
movl $0x4000, %eax           # imm = 0x4000
shrl %cl, %eax
sarq $0x20, %rcx
orw %ax, 0x2(%r15,%rcx,2)
incq %r13
jmp 0x303c
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_O2/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 0x3775
addl %eax, 0x64(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3f4f
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_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x2077(%rip), %rdi      # 0x51a3
callq 0x1040
xorl %r12d, %r12d
pushq $0x20
popq %r15
pushq $0x64
popq %rbp
pushq $0x54
popq %r14
cmpq $0xf, %r12
je 0x31b2
leaq 0x1(%r12), %rsi
xorl %r13d, %r13d
leaq 0x2070(%rip), %rdi      # 0x51c4
movq %rsi, (%rsp)
xorl %eax, %eax
callq 0x1030
cmpl $0xf, %r13d
je 0x31a4
movl %r15d, %edi
callq 0x1080
movl $0x4000, %eax           # imm = 0x4000
movl %r13d, %ecx
shrl %cl, %eax
movl %ebp, %edi
testw %ax, 0x2(%rbx,%r12,2)
jne 0x319a
movl %r14d, %edi
testw %ax, 0x20(%rbx,%r12,2)
jne 0x319a
pushq $0x2e
popq %rdi
testw %ax, 0x3e(%rbx,%r12,2)
je 0x319a
pushq $0x23
popq %rdi
callq 0x1080
incl %r13d
jmp 0x315f
pushq $0xa
popq %rdi
callq 0x1080
movq (%rsp), %r12
jmp 0x313f
pushq $0xa
popq %rdi
callq 0x1080
movl 0x70(%rbx), %esi
cmpl $0x1, %esi
leaq 0x202f(%rip), %rax      # 0x51f6
leaq 0x1fd3(%rip), %r8       # 0x51a1
movq %r8, %rdx
cmoveq %rax, %rdx
movl 0x74(%rbx), %ecx
cmpl $0x1, %ecx
cmoveq %rax, %r8
leaq 0x1fe2(%rip), %rdi      # 0x51c8
xorl %eax, %eax
callq 0x1030
leaq 0x201f(%rip), %rax      # 0x5213
leaq 0x201e(%rip), %rsi      # 0x5219
cmpb $0x0, (%rbx)
cmovneq %rax, %rsi
leaq 0x1fee(%rip), %rdi      # 0x51f7
xorl %eax, %eax
callq 0x1030
movq 0x4de1(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11e0
// File: /workspace/github_c_makefile_star2_O2/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 0x329d
movq 0x4(%rsi), %rcx
cmpl $0xf, %ecx
setae %dl
shrq $0x20, %rcx
cmpl $0xf, %ecx
setae %cl
orb %dl, %cl
jne 0x329d
movabsq $0xf00000000, %rcx      # imm = 0xF00000000
movq 0xc(%rsi), %rdx
cmpl $0xf, %edx
setae %r8b
cmpq %rcx, %rdx
setae %cl
orb %r8b, %cl
jne 0x329d
testb %al, %al
jne 0x32a0
jmp 0x3467
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x364a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2d33
movl 0x14(%r14), %eax
addl %eax, 0x74(%rbx)
jmp 0x365c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2ee6
movl 0x14(%r14), %eax
addl %eax, 0x70(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r15
movsbl (%r15), %edi
callq 0x3676
movl %eax, (%r14)
cmpl $-0x1, %eax
je 0x3710
incq %r15
movq %r15, (%rbx)
addq $0x4, %r14
leaq 0x1b38(%rip), %rsi      # 0x521f
xorl %ebp, %ebp
leaq 0x4(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1060
testl %eax, %eax
jle 0x371f
movl (%r14), %eax
leal -0x1(%rax), %ecx
movl %ecx, (%r14)
addl $-0x10, %eax
cmpl $-0xf, %eax
jae 0x3714
xorl %ebp, %ebp
jmp 0x371f
movslq 0x4(%rsp), %rax
addq %rax, (%rbx)
movb $0x1, %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x49a8(%rip), %r9       # 0x8130
leaq 0x49c1(%rip), %r10      # 0x8150
xorl %eax, %eax
cmpq $0x20, %r8
je 0x37d2
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 0x37cc
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
jmp 0x3791
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/heap.c
// Function: pop
struct move * pop(struct moveheap * heap)
{
    struct move * move = heap->moves[0].move;

    heap->moves[0] = heap->moves[--heap->used];
    heapdown(heap, 0);

    return move;
}

// Assembly:
pushq %rbx
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rbx
movslq (%rdi), %rcx
decq %rcx
movl %ecx, (%rdi)
shlq $0x4, %rcx
movups (%rax,%rcx), %xmm0
movups %xmm0, (%rax)
xorl %esi, %esi
callq 0x38f6
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leal 0x1(,%rsi,2), %edx
leal 0x2(,%rsi,2), %ebp
movl (%rbx), %ecx
movslq %edx, %rax
movslq %esi, %rdi
cmpl %ecx, %ebp
jge 0x3956
movq 0x8(%rbx), %rcx
shlq $0x4, %rax
movl (%rcx,%rax), %eax
shlq $0x4, %rdi
cmpl (%rcx,%rdi), %eax
jg 0x392c
movl %esi, %edx
movslq %ebp, %rax
shlq $0x4, %rax
movl (%rcx,%rax), %eax
movslq %edx, %rdi
shlq $0x4, %rdi
cmpl (%rcx,%rdi), %eax
jg 0x3944
movl %edx, %ebp
cmpl %esi, %ebp
je 0x3979
movq %rbx, %rdi
movl %ebp, %edx
callq 0x39b5
movl %ebp, %esi
jmp 0x38fc
cmpl %ecx, %edx
jge 0x3979
movq 0x8(%rbx), %rcx
shlq $0x4, %rdi
movl (%rcx,%rdi), %edi
shlq $0x4, %rax
cmpl (%rcx,%rax), %edi
jge 0x3979
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x39b5
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/mcts.c
// Function: montecarlo
struct move montecarlo(struct thudboard * board, int searchtime) {
    time_t stoptime = time(NULL) + searchtime;

    if (! root) {
        root = malloc(sizeof(struct mctreenode));
        initmctree(root, board);
    }

    deepest = curdepth = 0;
    visited = 1;

    jmp_buf stopsearch;
    if (setjmp(stopsearch) == 0) while (time(NULL) < stoptime)
    {
        mcts_step(root);
    }

    printf("visited %d nodes with max depth %d\n", visited, deepest);

    // choose most visited child as move to make
    struct move bestmove = root->allmoves.moves[0];
    int bestvisited = root->children[0].visits;
    for (int ix=1 ; ix<root->allmoves.used ; ix+=1) {
        if (root->children[ix].visits > bestvisited) {
            bestmove = root->allmoves.moves[ix];
            bestvisited = root->children[ix].visits;
        }
    }
    printf("chose "); showmove(& bestmove);

    printf("freeing tree\n"); fflush(stdout);
    closemctree(root); //TODO reuse relevant subtree
    printf("freed tree\n"); fflush(stdout);

    return bestmove;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xc8, %rsp
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, %edi
callq 0x11d0
movq %rax, %r14
cmpq $0x0, 0x47f3(%rip)      # 0x8280
jne 0x3aab
movl $0xb0, %edi
callq 0x1090
movq %rax, 0x47e0(%rip)      # 0x8280
movq %rax, %rdi
movq %r15, %rsi
callq 0x3e34
andl $0x0, 0x47d6(%rip)      # 0x8288
andl $0x0, 0x47d3(%rip)      # 0x828c
movl $0x1, 0x47cd(%rip)      # 0x8290
movq %rsp, %rdi
callq 0x1050
testl %eax, %eax
je 0x3bca
movq %rbx, %r14
movl 0x47b4(%rip), %esi      # 0x8290
movl 0x47aa(%rip), %edx      # 0x828c
leaq 0x1777(%rip), %rdi      # 0x5260
xorl %ebp, %ebp
movl %ebp, %eax
callq 0x1030
movq 0x4787(%rip), %r9       # 0x8280
movq 0x88(%r9), %rdx
pushq $0x16
popq %rax
movq %rax, %rcx
movq %rbx, %rdi
movq %rdx, %rsi
rep  movsl (%rsi), %es:(%rdi)
movq 0x98(%r9), %r8
cvttsd2si 0xa8(%r8), %ecx
movslq 0x80(%r9), %r9
addq $0x58, %rdx
pushq $0x1
popq %r11
movl %ebp, %r10d
cmpq %r9, %r11
jge 0x3b68
cvtsi2sd %ecx, %xmm0
movsd 0x158(%r8,%r10,2), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x3b5f
leaq (%rdx,%r10), %rsi
movq %rax, %rcx
movq %rbx, %rdi
rep  movsl (%rsi), %es:(%rdi)
cvttsd2si 0x158(%r8,%r10,2), %ecx
incq %r11
addq $0x58, %r10
jmp 0x3b30
leaq 0x1715(%rip), %rdi      # 0x5284
xorl %eax, %eax
callq 0x1030
movq %rbx, %rdi
callq 0x3763
leaq 0x1706(%rip), %rdi      # 0x528b
callq 0x1040
movq 0x4467(%rip), %rbx      # 0x7ff8
movq (%rbx), %rdi
callq 0x11e0
movq 0x46e0(%rip), %rdi      # 0x8280
callq 0x3e85
leaq 0x16ec(%rip), %rdi      # 0x5298
callq 0x1040
movq (%rbx), %rdi
callq 0x11e0
movq %r14, %rax
addq $0xc8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movslq %ebp, %rax
movq %r14, %r15
addq %rax, %r15
xorl %eax, %eax
movl %eax, %r14d
movq %r14, %rdi
callq 0x11d0
cmpq %r15, %rax
jge 0x3ad3
movq 0x4690(%rip), %rdi      # 0x8280
callq 0x3bf7
jmp 0x3bd8
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/mctree.c
// Function: initmctree
void initmctree(struct mctreenode * node, struct thudboard * board) {
    node->boardstate = * board;
    node->allmoves = allmoves(board);
    int movecount = node->allmoves.used;
    node->unexplored_moves = movecount;
    node->children = malloc(movecount * sizeof(struct mctreenode));
    node->scoreguess = 0;
    node->visits = 1;
}

// Assembly:
pushq %rbx
movq %rsi, %rax
movq %rdi, %rbx
pushq $0x10
popq %rcx
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
callq 0x1f02
movq %rax, 0x80(%rbx)
movq %rdx, 0x88(%rbx)
movl %eax, 0x90(%rbx)
cltq
imulq $0xb0, %rax, %rdi
callq 0x1090
movq %rax, 0x98(%rbx)
xorps %xmm0, %xmm0
movhps 0x13c4(%rip), %xmm0     # xmm0 = xmm0[0,1],mem[0,1]
movups %xmm0, 0xa0(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/mctree.c
// Function: closemctree
void closemctree(struct mctreenode * node) {
    for (int ix=0 ; ix<node->allmoves.used ; ix+=1) {
        closemctree(& node->children[ix]);
    }
    free(node->children);

    closelist(& (node->allmoves));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x80(%rdi), %rbx
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x80(%r14), %rax
movq 0x98(%r14), %rdi
cmpq %rax, %r12
jge 0x3ec4
addq %r15, %rdi
callq 0x3e85
incq %r12
addq $0xb0, %r15
jmp 0x3e9d
callq 0x10e0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3a55
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/ttable.c
// Function: inithash
void inithash(void)
{
    // hashes should be "random" yet must be the same every run
    // otherwise the opening book file will be unusable
    srandom(1);

    turnhash = randomhash();

    for (int i=0; i < SIZE*SIZE; ++i)
    {
        dwarfhash[i] = randomhash();
        trollhash[i] = randomhash();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
pushq $0x1
popq %rdi
callq 0x10b0
callq 0x3edc
movq %rax, 0x4394(%rip)      # 0x82a0
xorl %ebx, %ebx
leaq 0x439b(%rip), %r14      # 0x82b0
leaq 0x4aa4(%rip), %r15      # 0x89c0
cmpq $0x708, %rbx            # imm = 0x708
je 0x3f3d
callq 0x3edc
movq %rax, (%rbx,%r14)
callq 0x3edc
movq %rax, (%rbx,%r15)
addq $0x8, %rbx
jmp 0x3f1c
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/ttable.c
// Function: initttable
void initttable(int memuse)
{
    TTABLESIZE = memuse / sizeof(struct tableentry);

    // allocate memory for table
    void * mem = mmap(NULL, memuse, PROT_READ | PROT_WRITE,
                      MAP_ANON | MAP_PRIVATE, -1, 0);
    ttable = (struct tableentry *) mem;

    // read in table data if present
    FILE * book = fopen(BOOKFILENAME, "r");
    if (book)
    {
        //printf("Reading opening book...");
        //fflush(stdout);
        struct tableentry temp;
        while (fread(& temp, sizeof(struct tableentry), 1, book))
        {
            int index = ttindex(temp.hash);
            ttable[index] = temp;
        }
        //printf(" done.\n");
        //fflush(stdout);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movslq %edi, %rsi
movl %esi, %eax
sarl $0x5, %eax
movl %eax, 0x510f(%rip)      # 0x90c8
pushq $0x3
popq %rdx
pushq $0x22
popq %rcx
pushq $-0x1
popq %r8
xorl %edi, %edi
xorl %r9d, %r9d
callq 0x11c0
movq %rax, 0x50fc(%rip)      # 0x90d0
leaq 0x12ca(%rip), %rdi      # 0x52a5
leaq 0x12c1(%rip), %rsi      # 0x52a3
callq 0x10a0
testq %rax, %rax
je 0x4046
movq %rax, %rbx
leaq 0x8(%rsp), %r14
pushq $0x20
popq %r15
pushq $0x1
popq %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x1120
testq %rax, %rax
je 0x4046
movq 0x8(%rsp), %rax
movslq 0x50aa(%rip), %rcx      # 0x90c8
xorl %edx, %edx
divq %rcx
movq 0x50a6(%rip), %rax      # 0x90d0
movslq %edx, %rcx
shlq $0x5, %rcx
movups 0x8(%rsp), %xmm0
movups 0x18(%rsp), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
jmp 0x3ffc
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/ttable.c
// Function: ttput
void ttput(struct tableentry newentry)
{
    int index = ttindex(newentry.hash);
    struct tableentry * entry = & ttable[index];

    if (newentry.worth >= entry->worth) * entry = newentry;
    else entry->worth -= newentry.worth;
}

// Assembly:
movq 0x8(%rsp), %rax
movslq 0x506a(%rip), %rcx      # 0x90c8
xorl %edx, %edx
divq %rcx
movq 0x5066(%rip), %rcx      # 0x90d0
movslq %edx, %rdx
shlq $0x5, %rdx
leaq (%rcx,%rdx), %rax
movl 0xc(%rcx,%rdx), %ecx
subl 0x14(%rsp), %ecx
jle 0x4083
movl %ecx, 0xc(%rax)
retq
leaq 0x8(%rsp), %rcx
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/icarroll[P]clunk/ttable.c
// Function: ttget
struct tableentry * ttget(hash_t hash)
{
    struct tableentry * entry = & ttable[ttindex(hash)];

    if (entry->hash == hash)
    {
      entry->worth = entry->depth;
      return entry;
    }
    else return NULL;
}

// Assembly:
movq 0x5032(%rip), %rsi      # 0x90d0
movslq 0x5023(%rip), %r8       # 0x90c8
xorl %ecx, %ecx
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movslq %edx, %rax
shlq $0x5, %rax
cmpq %rdi, (%rsi,%rax)
jne 0x40c8
addq %rax, %rsi
movl 0x8(%rsi), %eax
movl %eax, 0xc(%rsi)
movq %rsi, %rcx
movq %rcx, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/deoxyseq256128v13/ref/tweakableBC.c
// Function: multi
uint8_t multi (uint8_t x, uint8_t alpha) {
  if( 1 == alpha ) return x;
  if( 2 == alpha ) return mul2[x];
  if( 4 == alpha ) return mul2[mul2[x]];

  printf("Incorrect alpha (%d) passed to the function g in the tweakey schedule. Exiting...\n", alpha); exit(2);
}

// Assembly:
cmpl $0x1, %esi
je 0x1e49
cmpl $0x2, %esi
je 0x1e3a
cmpl $0x4, %esi
jne 0x1e4c
movzbl %dil, %eax
leaq 0x320a(%rip), %rcx      # 0x5040
movb (%rax,%rcx), %dil
movzbl %dil, %eax
leaq 0x31fb(%rip), %rcx      # 0x5040
movb (%rax,%rcx), %dil
movl %edi, %eax
retq
pushq %rax
movzbl %sil, %esi
leaq 0x5b08(%rip), %rdi      # 0x7960
xorl %eax, %eax
callq 0x1040
pushq $0x2
popq %rdi
callq 0x1070
// File: /workspace/github_c_makefile_star2_O2/eridanhq[P]miraclelib/setsamplerate.c
// Function: main
int main(int argc, char *argv[])
{
	int memfd;
	void *mapped_base;

	double rate; 

	rate = atof(argv[1]);

	memfd = open("/dev/mem", O_RDWR | O_SYNC);
	if (memfd == -1) {
		printf("Can't open /dev/mem.\n");
		exit(0);
	}

	// Map one page of memory into user space such that the device is in that page, but it may not
	// be at the start of the page

	mapped_base = mmap( (void *) MEM0_BASE_ADDRESS, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, memfd, FIFO_BASE_ADDRESS);
	if (mapped_base == (void *) -1) {
		printf("Can't map the memory to user space.\n");
		exit(0);
	}
	
	/* ----------- INSERT CODE BELOW THIS LINE ------------ */

	set_sample_rate_tx(rate,mapped_base);

	/* ----------- INSERT CODE ABOVE THIS LINE ------------ */

	if (munmap(mapped_base, MAP_SIZE) == -1) {
		printf("Can't unmap memory from user space.\n");
		exit(0);
	}
	close(memfd);
	
	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x8(%rsi), %rdi
callq 0x1070
movsd %xmm0, (%rsp)
leaq 0xd9f(%rip), %rdi       # 0x2004
movl $0x101002, %esi         # imm = 0x101002
xorl %eax, %eax
callq 0x1100
cmpl $-0x1, %eax
je 0x12cf
movl %eax, %ebx
pushq $0x3
popq %rdx
pushq $0x11
popq %rcx
movl $0x40000000, %edi       # imm = 0x40000000
movl $0x400000, %esi         # imm = 0x400000
movl $0x60000000, %r9d       # imm = 0x60000000
movl %eax, %r8d
callq 0x1090
cmpq $-0x1, %rax
je 0x12d8
movq %rax, %r14
movsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x1333
movl $0x400000, %esi         # imm = 0x400000
movq %r14, %rdi
callq 0x10f0
cmpl $-0x1, %eax
je 0x12e1
movl %ebx, %edi
callq 0x10d0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xd7f(%rip), %rdi       # 0x2055
jmp 0x12e8
leaq 0xd52(%rip), %rdi       # 0x2031
jmp 0x12e8
leaq 0xd25(%rip), %rdi       # 0x200d
callq 0x1060
xorl %edi, %edi
callq 0x1130
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/tests/nc-client/main.c
// Function: send_input
static int
send_input(void * cookie)
{
	struct senddata * send = (struct senddata *)cookie;
	size_t len = 0;

	/* Read data from stdin. */
	if ((send->nchars = getline(&send->buffer, &len, stdin)) != -1) {
		/* Send data to server. */
		if ((send->write_cookie = network_write(send->socket,
		    (uint8_t *)send->buffer, (size_t)send->nchars,
		    (size_t)send->nchars, callback_wrote, cookie)) == NULL) {
			warn0("network_write failure");
			goto err0;
		}
	} else {
		/* If we didn't get an EOF, then there was an error. */
		if (!feof(stdin)) {
			warn0("getline(..., ..., stdin)");
			goto err0;
		}

		/* We're not going to send anything else. */
		if (shutdown(send->socket, SHUT_WR)) {
			warnp("shutdown");
			goto err0;
		}

		/*
		 * The server should not send any data back, but attempting to
		 * read will detect when the other end of the socket is closed.
		 */
		if ((send->read_cookie = network_read(send->socket,
		    send->dummybuf, 1, 1, callback_stopping, cookie))
		    == NULL) {
			warn0("network_read initialize");
			goto err0;
		}

	}

	/* Success! */
	return (0);

err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsp, %rsi
andq $0x0, (%rsi)
movq %rdi, %rbx
movq 0x89f3(%rip), %r14      # 0xafd8
movq (%r14), %rdx
callq 0x22a0
movq %rax, 0x8(%rbx)
cmpq $-0x1, %rax
je 0x261f
movl 0x10(%rbx), %edi
movq (%rbx), %rsi
leaq 0xc2(%rip), %r8         # 0x26c6
movq %rax, %rdx
movq %rax, %rcx
movq %rbx, %r9
callq 0x4034
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x265a
xorl %eax, %eax
jmp 0x267c
movq (%r14), %rdi
callq 0x21d0
testl %eax, %eax
je 0x2663
movl 0x10(%rbx), %edi
pushq $0x1
popq %rsi
callq 0x20f0
testl %eax, %eax
je 0x2684
callq 0x2090
cmpl $0x0, (%rax)
je 0x26b6
movq %rax, %rbx
leaq 0x4a6a(%rip), %rdi      # 0x70b8
xorl %eax, %eax
callq 0x5499
andl $0x0, (%rbx)
jmp 0x2679
leaq 0x4a28(%rip), %rdi      # 0x7089
jmp 0x266a
leaq 0x4a35(%rip), %rdi      # 0x709f
xorl %eax, %eax
callq 0x5628
callq 0x2090
andl $0x0, (%rax)
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl 0x10(%rbx), %edi
leaq 0x30(%rbx), %rsi
leaq 0xae(%rip), %r8         # 0x2740
pushq $0x1
popq %rcx
movq %rcx, %rdx
movq %rbx, %r9
callq 0x3cdc
movq %rax, 0x28(%rbx)
testq %rax, %rax
jne 0x261b
leaq 0x4a0d(%rip), %rdi      # 0x70c1
jmp 0x266a
leaq 0x49fb(%rip), %rdi      # 0x70b8
xorl %eax, %eax
callq 0x5628
jmp 0x2679
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/tests/nc-client/main.c
// Function: callback_wrote
static int
callback_wrote(void * cookie, ssize_t lenwrit)
{
	struct senddata * send = (struct senddata *)cookie;

	/* We are no longer writing. */
	send->write_cookie = NULL;

	/* Check results. */
	if (lenwrit == -1) {
		warnp("network_write send");
		goto err0;
	} else {
		/* We should have sent everything. */
		assert(lenwrit == send->nchars);
	}

	/* Clear the buffer that was used. */
	free(send->buffer);
	send->buffer = NULL;

	return send_input(cookie);

err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbx
andq $0x0, 0x20(%rdi)
cmpq $-0x1, %rsi
je 0x26f0
movq %rdi, %rbx
cmpq %rsi, 0x8(%rdi)
jne 0x2723
movq (%rbx), %rdi
callq 0x2040
andq $0x0, (%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x25d0
callq 0x2090
cmpl $0x0, (%rax)
je 0x2710
movq %rax, %rbx
leaq 0x49d5(%rip), %rdi      # 0x70d9
xorl %eax, %eax
callq 0x5499
andl $0x0, (%rbx)
jmp 0x271e
leaq 0x49c2(%rip), %rdi      # 0x70d9
xorl %eax, %eax
callq 0x5628
pushq $-0x1
popq %rax
popq %rbx
retq
leaq 0x49c2(%rip), %rdi      # 0x70ec
leaq 0x49d3(%rip), %rsi      # 0x7104
leaq 0x49d3(%rip), %rcx      # 0x710b
pushq $0x7c
popq %rdx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/tests/nc-client/main.c
// Function: callback_stopping
static int
callback_stopping(void * cookie, ssize_t lenread)
{
	struct senddata * send = (struct senddata *)cookie;

	/* We are no longer reading. */
	send->read_cookie = NULL;

	/* Check results. */
	if (lenread == -1) {
		warnp("network_read received");
		goto err0;
	} else {
		/* We should have received nothing. */
		if (lenread != 0) {
			warn0("network_read received non-zero data");
			goto err0;
		}
	}

	/* Close connection. */
	send->conndone = 1;

	/* Success! */
	return (0);

err0:
	/* Failure! */
	return (-1);
}

// Assembly:
andq $0x0, 0x28(%rdi)
testq %rsi, %rsi
je 0x2771
pushq %rbx
cmpq $-0x1, %rsi
jne 0x277b
callq 0x2090
cmpl $0x0, (%rax)
je 0x2793
movq %rax, %rbx
leaq 0x49ca(%rip), %rdi      # 0x712f
xorl %eax, %eax
callq 0x5499
andl $0x0, (%rbx)
jmp 0x27a1
movl $0x1, 0x14(%rdi)
xorl %eax, %eax
retq
leaq 0x49c3(%rip), %rdi      # 0x7145
xorl %eax, %eax
callq 0x5628
callq 0x2090
andl $0x0, (%rax)
jmp 0x27a1
leaq 0x4995(%rip), %rdi      # 0x712f
xorl %eax, %eax
callq 0x5628
pushq $-0x1
popq %rax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/liball/../libcperciva/network/network_connect.c
// Function: network_connect_internal
static void *
network_connect_internal(struct sock_addr * const * sas,
    const struct sock_addr * sa_b, const struct timeval * timeo,
    int (* callback)(void *, int), void * cookie)
{
	struct connect_cookie * C;

	/* Bake a cookie. */
	if ((C = malloc(sizeof(struct connect_cookie))) == NULL)
		goto err0;
	C->callback = callback;
	C->cookie = cookie;
	C->sas = sas;
	C->sa_b = sa_b;
	C->cookie_immediate = NULL;
	C->cookie_timeo = NULL;
	C->s = -1;

	/* Do we have a timeout? */
	if (timeo != NULL) {
		memcpy(&C->timeo, timeo, sizeof(struct timeval));
		C->timeo_enabled = 1;
	} else {
		C->timeo_enabled = 0;
	}

	/* Try to connect to the first address. */
	if (tryconnect(C))
		goto err0;

	/* Success! */
	return (C);

err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r15
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbp
pushq $0x48
popq %rdi
callq 0x2200
testq %rax, %rax
je 0x399e
movq %rax, %rbx
movq %r13, (%rax)
movq %r15, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq %r12, 0x18(%rax)
andq $0x0, 0x30(%rax)
andq $0x0, 0x40(%rax)
orl $-0x1, 0x38(%rax)
testq %r14, %r14
je 0x398d
movups (%r14), %xmm0
movups %xmm0, 0x20(%rbx)
pushq $0x1
popq %rax
jmp 0x398f
xorl %eax, %eax
movl %eax, 0x3c(%rbx)
movq %rbx, %rdi
callq 0x3aa3
testl %eax, %eax
je 0x39a0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/liball/../libcperciva/network/network_connect.c
// Function: network_connect_cancel
void
network_connect_cancel(void * cookie)
{
	struct connect_cookie * C = cookie;

	/* We should have either an immediate callback or a socket. */
	assert((C->cookie_immediate != NULL) || (C->s != -1));
	assert((C->cookie_immediate == NULL) || (C->s == -1));

	/* Cancel any timer. */
	if (C->cookie_timeo != NULL)
		events_timer_cancel(C->cookie_timeo);

	/* Cancel any immediate callback. */
	if (C->cookie_immediate != NULL)
		events_immediate_cancel(C->cookie_immediate);

	/* Close any socket. */
	if (C->s != -1) {
		events_network_cancel(C->s, EVENTS_NETWORK_OP_WRITE);
		if (close(C->s))
			warnp("close");
	}

	/* Free the cookie. */
	free(C);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
movl 0x38(%rbx), %eax
testq %rdi, %rdi
je 0x3a06
cmpl $-0x1, %eax
je 0x3a0b
leaq 0x3a55(%rip), %rdi      # 0x7443
leaq 0x3a01(%rip), %rsi      # 0x73f6
leaq 0x3a23(%rip), %rcx      # 0x741f
movl $0x11f, %edx            # imm = 0x11F
callq 0x2150
cmpl $-0x1, %eax
je 0x3a84
movq 0x40(%rbx), %rax
testq %rax, %rax
je 0x3a20
movq %rax, %rdi
callq 0x37bb
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x3a2a
callq 0x2bdb
movl 0x38(%rbx), %edi
cmpl $-0x1, %edi
je 0x3a75
pushq $0x1
popq %rsi
callq 0x3144
movl 0x38(%rbx), %edi
callq 0x2170
testl %eax, %eax
je 0x3a75
callq 0x2090
cmpl $0x0, (%rax)
je 0x3a67
movq %rax, %r14
leaq 0x3a17(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5499
andl $0x0, (%r14)
jmp 0x3a75
leaq 0x3a03(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5628
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2040
leaq 0x393d(%rip), %rdi      # 0x73c8
leaq 0x3964(%rip), %rsi      # 0x73f6
leaq 0x3986(%rip), %rcx      # 0x741f
movl $0x11e, %edx            # imm = 0x11E
callq 0x2150
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/liball/../libcperciva/network/network_connect.c
// Function: tryconnect
static int
tryconnect(struct connect_cookie * C)
{

	/* Try addresses until we find one which doesn't fail immediately. */
	for (; C->sas[0] != NULL; C->sas++) {
		/* Can we try to connect to this address? */
		if ((C->s = sock_connect_bind_nb(C->sas[0], C->sa_b)) != -1)
			break;
	}

	/* Did we run out of addresses to try? */
	if (C->sas[0] == NULL)
		goto failed;

	/* If we've been asked to have a timeout, set one. */
	if (C->timeo_enabled) {
		if ((C->cookie_timeo = events_timer_register(callback_timeo,
		    C, &C->timeo)) == NULL)
			goto err1;
	} else {
		C->cookie_timeo = NULL;
	}

	/* Wait until this socket connects or fails to do so. */
	if (events_network_register(callback_connect, C, C->s,
	    EVENTS_NETWORK_OP_WRITE))
		goto err2;

	/* Success! */
	return (0);

failed:
	/* Schedule a callback. */
	if ((C->cookie_immediate =
	    events_immediate_register(docallback, C, 0)) == NULL)
		goto err1;

	/* Failure successfully handled. */
	return (0);

err2:
	if (C->cookie_timeo != NULL)
		events_timer_cancel(C->cookie_timeo);
err1:
	if ((C->s != -1) && close(C->s))
		warnp("close");
	free(C);

	/* Fatal error. */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rcx
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x3aff
movq 0x18(%rbx), %rsi
callq 0x4ea2
movl %eax, 0x38(%rbx)
movq 0x10(%rbx), %rcx
cmpl $-0x1, %eax
jne 0x3ad5
addq $0x8, %rcx
movq %rcx, 0x10(%rbx)
jmp 0x3aae
cmpq $0x0, (%rcx)
je 0x3aff
cmpl $0x0, 0x3c(%rbx)
je 0x3b1d
leaq 0x20(%rbx), %rdx
leaq 0xb3(%rip), %rdi        # 0x3b9f
movq %rbx, %rsi
callq 0x3648
movq %rax, 0x40(%rbx)
testq %rax, %rax
jne 0x3b22
jmp 0x3b49
leaq 0x15a(%rip), %rdi       # 0x3c60
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2af0
movq %rax, 0x30(%rbx)
testq %rax, %rax
jne 0x3b98
jmp 0x3b49
andq $0x0, 0x40(%rbx)
movl 0x38(%rbx), %edx
leaq 0x90(%rip), %rdi        # 0x3bbc
pushq $0x1
popq %rcx
movq %rbx, %rsi
callq 0x2de8
testl %eax, %eax
je 0x3b7b
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x3b49
callq 0x37bb
movl 0x38(%rbx), %edi
cmpl $-0x1, %edi
je 0x3b8d
callq 0x2170
testl %eax, %eax
je 0x3b8d
callq 0x2090
cmpl $0x0, (%rax)
je 0x3b7f
movq %rax, %r14
leaq 0x3903(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5499
andl $0x0, (%r14)
jmp 0x3b8d
xorl %ebp, %ebp
jmp 0x3b98
leaq 0x38eb(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5628
movq %rbx, %rdi
callq 0x2040
pushq $-0x1
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/liball/../libcperciva/network/network_connect.c
// Function: callback_connect
static int
callback_connect(void * cookie)
{
	struct connect_cookie * C = cookie;
	int sockerr;
	socklen_t sockerrlen = sizeof(int);

	/* Stop waiting for the timer callback. */
	if (C->cookie_timeo != NULL) {
		events_timer_cancel(C->cookie_timeo);
		C->cookie_timeo = NULL;
	}

	/* Did we succeed? */
	if (getsockopt(C->s, SOL_SOCKET, SO_ERROR, &sockerr, &sockerrlen))
		goto err1;
	if (sockerr != 0)
		return (dofailed(C));

	/*
	 * Perform the callback (this can be done here rather than being
	 * scheduled as an immediate callback, as we're already running from
	 * callback context).
	 */
	return (docallback(C));

err1:
	if (close(C->s))
		warnp("close");
	free(C);

	/* Fatal error! */
	return (-1);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x4, (%rsp)
movq 0x40(%rdi), %rdi
testq %rdi, %rdi
je 0x3bdd
callq 0x37bb
andq $0x0, 0x40(%rbx)
movl 0x38(%rbx), %edi
pushq $0x1
popq %rsi
pushq $0x4
popq %rdx
leaq 0x4(%rsp), %rcx
movq %rsp, %r8
callq 0x21a0
testl %eax, %eax
je 0x3c24
movl 0x38(%rbx), %edi
callq 0x2170
testl %eax, %eax
je 0x3c43
callq 0x2090
cmpl $0x0, (%rax)
je 0x3c35
movq %rax, %r14
leaq 0x385a(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5499
andl $0x0, (%r14)
jmp 0x3c43
cmpl $0x0, 0x4(%rsp)
je 0x3c56
movq %rbx, %rdi
callq 0x3c82
jmp 0x3c4e
leaq 0x3835(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5628
movq %rbx, %rdi
callq 0x2040
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
callq 0x3c60
jmp 0x3c4e
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]spiped/liball/../libcperciva/network/network_connect.c
// Function: dofailed
static int
dofailed(struct connect_cookie * C)
{

	/* Close the socket which failed to connect. */
	if (close(C->s))
		warnp("close");

	/* We don't have an open socket any more. */
	C->s = -1;

	/* This address didn't work. */
	C->sas++;

	/* Try other addresses until we run out of options. */
	return (tryconnect(C));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x38(%rdi), %edi
callq 0x2170
testl %eax, %eax
je 0x3cc4
callq 0x2090
cmpl $0x0, (%rax)
je 0x3cb6
movq %rax, %r14
leaq 0x37c8(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5499
andl $0x0, (%r14)
jmp 0x3cc4
leaq 0x37b4(%rip), %rdi      # 0x7471
xorl %eax, %eax
callq 0x5628
orl $-0x1, 0x38(%rbx)
addq $0x8, 0x10(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3aa3
// File: /workspace/github_c_makefile_star2_O2/keithnoguchi[P]pearls-in-action/0x8/scan.c
// Function: max_subtree_n
int max_subtree_n(const int a[], int n)
{
	int sofar;
	int curr;
	int i;

	/* assumes we have at least one positive entry */
	sofar = curr = 0;
	for (i = 0; i < n; i++) {
		curr = max(curr+a[i], 0);
		sofar = max(sofar, curr);
	}
	return sofar;
}

// Assembly:
xorl %ecx, %ecx
testl %esi, %esi
cmovlel %ecx, %esi
xorl %edx, %edx
xorl %eax, %eax
xorl %r8d, %r8d
cmpq %rdx, %rsi
je 0x1176
addl (%rdi,%rdx,4), %r8d
testl %r8d, %r8d
cmovlel %ecx, %r8d
cmpl %r8d, %eax
cmovlel %r8d, %eax
incq %rdx
jmp 0x115a
retq
nop
// File: /workspace/github_c_makefile_star2_O2/keithnoguchi[P]pearls-in-action/0x8/scan_test.c
// Function: test_max_subtree_n
int test_max_subtree_n(int *i)
{
	const struct test {
		const char	*name;
		const int	array[10];
		int		want;
	} tests[] = {
		{
			.name	= "31,-41,59,26,-53,58,97,-93,-23,84",
			.array	= {31, -41, 59, 26, -53, 58, 97, -93, -23, 84},
			.want	= 187,
		},
		{ /* sentry */ },
	};
	const struct test *t;
	int fail = 0;

	for (t = tests; t->name; t++) {
		int got;

		printf("%3d) %-25s: %-45s", ++(*i), "test_max_subtree_n", t->name);
		got = max_subtree_n(t->array, 10);
		if (got != t->want) {
			printf("FAIL, got(%d)!=want(%d)\n", got, t->want);
			fail++;
		} else
			puts("PASS");
	}
	return fail;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x2b80(%rip), %rsi      # 0x3d10
pushq $0xe
popq %rcx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xe64(%rip), %rcx       # 0x2004
leaq 0x38(%rsp), %r13
leaq 0xe7a(%rip), %r14       # 0x2026
leaq 0xe85(%rip), %r15       # 0x2038
pushq $0xa
popq %rbp
xorl %r12d, %r12d
testq %rcx, %rcx
je 0x120f
movl (%rbx), %esi
incl %esi
movl %esi, (%rbx)
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1040
leaq -0x30(%r13), %rdi
movl %ebp, %esi
callq 0x114c
movl -0x8(%r13), %edx
cmpl %edx, %eax
jne 0x11f2
leaq 0xe79(%rip), %rdi       # 0x2064
callq 0x1030
jmp 0x1205
leaq 0xe52(%rip), %rdi       # 0x204b
movl %eax, %esi
xorl %eax, %eax
callq 0x1040
incl %r12d
movq (%r13), %rcx
addq $0x38, %r13
jmp 0x11b9
movl %r12d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/keithnoguchi[P]pearls-in-action/0x8/bisect.c
// Function: _max_subtree_logn
static int __max_subtree_logn(const int a[], int l, int u)
{
	int left, right, sum;
	int m;
	int i;

	if (l > u)
		return -1;
	else if (l == u)
		return a[l];

	/* get the middle max */
	m = (l+u)/2;
	left = sum = 0;
	for (i = m; i >= l; i--) {
		sum += a[i];
		left = max(left, sum);
	}
	right = sum = 0;
	for (i = m+1; i <= u; i++) {
		sum += a[i];
		right = max(right, sum);
	}

	return max3(left+right, __max_subtree_logn(a, l, m), __max_subtree_logn(a, m+1, u));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r15d
movq %rdi, %r14
movl $0x80000000, %ebx       # imm = 0x80000000
pushq $-0x1
popq %rbp
cmpl %r15d, %esi
jg 0x12b1
je 0x12aa
leal (%rsi,%r15), %edx
shrl %edx
xorl %eax, %eax
xorl %ecx, %ecx
movl %edx, %edi
cmpl %esi, %edi
jl 0x126b
movl %edi, %r8d
addl (%r14,%r8,4), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
decl %edi
jmp 0x1257
leal 0x1(%rdx), %r12d
leal 0x1(%rdx), %ecx
xorl %r13d, %r13d
xorl %edi, %edi
cmpl %r15d, %ecx
jg 0x128c
addl (%r14,%rcx,4), %edi
cmpl %edi, %r13d
cmovlel %edi, %r13d
incq %rcx
jmp 0x1277
addl %eax, %r13d
movq %r14, %rdi
callq 0x122b
cmpl %eax, %r13d
cmovlel %eax, %r13d
cmpl %ebx, %r13d
cmovgl %r13d, %ebx
movl %r12d, %esi
jmp 0x1244
movl %r15d, %eax
movl (%r14,%rax,4), %ebp
cmpl %ebx, %ebp
cmovgl %ebp, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/keithnoguchi[P]pearls-in-action/0x8/bisect_test.c
// Function: test_max_subtree_logn
int test_max_subtree_logn(int *i)
{
	const struct test {
		const char	*name;
		const int	array[10];
		int		want;
	} tests[] = {
		{
			.name	= "31,-41,59,26,-53,58,97,-93,-23,84",
			.array	= {31, -41, 59, 26, -53, 58, 97, -93, -23, 84},
			.want	= 187,
		},
		{ /* sentry */ },
	};
	const struct test *t;
	int fail = 0;

	for (t = tests; t->name; t++) {
		int got;

		printf("%3d) %-25s: %-45s", ++(*i), "test_max_subtree_logn", t->name);
		got = max_subtree_logn(t->array, 10);
		if (got != t->want) {
			printf("FAIL, got(%d)!=want(%d)\n", got, t->want);
			fail++;
		} else
			puts("PASS");
	}
	return fail;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x2aa0(%rip), %rsi      # 0x3d80
pushq $0xe
popq %rcx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xd14(%rip), %rcx       # 0x2004
leaq 0x38(%rsp), %r13
leaq 0xd2a(%rip), %r14       # 0x2026
leaq 0xd66(%rip), %r15       # 0x2069
pushq $0xa
popq %rbp
xorl %r12d, %r12d
testq %rcx, %rcx
je 0x135f
movl (%rbx), %esi
incl %esi
movl %esi, (%rbx)
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1040
leaq -0x30(%r13), %rdi
movl %ebp, %esi
callq 0x1224
movl -0x8(%r13), %edx
cmpl %edx, %eax
jne 0x1342
leaq 0xd29(%rip), %rdi       # 0x2064
callq 0x1030
jmp 0x1355
leaq 0xd02(%rip), %rdi       # 0x204b
movl %eax, %esi
xorl %eax, %eax
callq 0x1040
incl %r12d
movq (%r13), %rcx
addq $0x38, %r13
jmp 0x1309
movl %r12d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)