LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: callback_readmetadata
static int
callback_readmetadata(void * cookie, int status,
    const uint8_t * buf, size_t len)
{
	struct metadata * M = cookie;
	uint8_t nbuf[104];

	/* Failures are bad. */
	if (status == 1)
		goto err0;

	/* Did the item exist? */
	if (status == 2) {
		warnp("metadata table is not initialized");
		goto err0;
	}

	/* We should have 104 bytes. */
	if (len != 104) {
		warn0("metadata has incorrect size: %zu", len);
		goto err0;
	}

	/* Parse it. */
	M->M_stored.nextblk = be64dec(&buf[0]);
	M->M_stored.deletedto = be64dec(&buf[8]);
	M->M_stored.generation = be64dec(&buf[16]);
	M->M_stored.lastblk = be64dec(&buf[24]);
	M->itemsz = be64dec(&buf[64]);
	memcpy(M->tableid, &buf[72], 32);

	/* Generate a random process ID. */
	if (entropy_read(M->process_id, 32)) {
		warn0("Failed to generate random process ID");
		goto err0;
	}

	/* Write new metadata back. */
	memcpy(nbuf, buf, 104);
	memcpy(&nbuf[32], M->process_id, 32);
	if (proto_dynamodb_kv_request_icas(M->Q, "metadata", buf, 104,
	    nbuf, 104, callback_claimmetadata, M))
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
cmpl $0x1, %esi
je 0x3f0a
cmpl $0x2, %esi
jne 0x3dfa
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3ea6
movq %rax, %rbx
leaq 0x8b5b(%rip), %rdi      # 0xc946
xorl %eax, %eax
callq 0x8759
andl $0x0, (%rbx)
jmp 0x3f0a
cmpq $0x68, %rcx
jne 0x3e8b
movq %rdx, %r14
movq %rdi, %rbx
movq %rdx, %rdi
callq 0x418f
movq %rax, 0x8(%rbx)
leaq 0x8(%r14), %rdi
callq 0x418f
movq %rax, 0x10(%rbx)
leaq 0x10(%r14), %rdi
callq 0x418f
movq %rax, 0x18(%rbx)
leaq 0x18(%r14), %rdi
callq 0x418f
movq %rax, 0x20(%rbx)
leaq 0x40(%r14), %rdi
callq 0x418f
movq %rax, 0xd8(%rbx)
movups 0x48(%r14), %xmm0
movups 0x58(%r14), %xmm1
movups %xmm0, 0xe0(%rbx)
movups %xmm1, 0xf0(%rbx)
leaq 0x98(%rbx), %r15
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x6904
testl %eax, %eax
je 0x3eb6
leaq 0x8b07(%rip), %rdi      # 0xc989
xorl %eax, %eax
callq 0x88e8
jmp 0x3e9c
leaq 0x8ad6(%rip), %rdi      # 0xc968
movq %rcx, %rsi
xorl %eax, %eax
callq 0x88e8
callq 0x20a0
andl $0x0, (%rax)
jmp 0x3f0a
leaq 0x8a99(%rip), %rdi      # 0xc946
xorl %eax, %eax
callq 0x88e8
jmp 0x3f0a
movq %rsp, %r12
pushq $0x68
popq %r13
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2250
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movaps %xmm0, 0x20(%r12)
movaps %xmm1, 0x30(%r12)
movq (%rbx), %rdi
leaq 0x2ac(%rip), %rax       # 0x4196
leaq 0x890b(%rip), %rsi      # 0xc7fc
movq %r14, %rdx
movq %r13, %rcx
movq %r12, %r8
movq %r13, %r9
pushq %rbx
pushq %rax
callq 0x8c5e
popq %rcx
popq %rdx
testl %eax, %eax
je 0x3f1b
pushq $-0x1
popq %rax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %eax, %eax
jmp 0x3f0d
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: writemetadata
static int
writemetadata(struct metadata * M)
{
	uint8_t obuf[104];
	uint8_t buf[104];

	/* Is a write already in progress? */
	if (M->write_inprogress == 1) {
		M->write_wanted = 1;
		return (0);
	}

	/* We're going to start a write now. */
	M->write_inprogress = 1;
	M->write_wanted = 0;

	/* We're going to store the latest metadata values. */
	M->M_storing = M->M_latest;

	/* The requested callback will be performed when the store completes. */
	M->M_latest.callback_state = NULL;

	/* Increment metadata generation for the next metadata stored. */
	M->M_latest.generation++;

	/* Encode metadata. */
	be64enc(&obuf[0], M->M_stored.nextblk);
	be64enc(&obuf[8], M->M_stored.deletedto);
	be64enc(&obuf[16], M->M_stored.generation);
	be64enc(&obuf[24], M->M_stored.lastblk);
	memcpy(&obuf[32], M->process_id, 32);
	be64enc(&obuf[64], M->itemsz);
	memcpy(&obuf[72], M->tableid, 32);
	be64enc(&buf[0], M->M_storing.nextblk);
	be64enc(&buf[8], M->M_storing.deletedto);
	be64enc(&buf[16], M->M_storing.generation);
	be64enc(&buf[24], M->M_storing.lastblk);
	memcpy(&buf[32], M->process_id, 32);
	be64enc(&buf[64], M->itemsz);
	memcpy(&buf[72], M->tableid, 32);

	/* Write metadata. */
	if (proto_dynamodb_kv_request_icas(M->Q, "metadata", obuf, 104,
	    buf, 104, callback_writemetadata, M))
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
movq %rdi, %rax
cmpl $0x1, 0xc8(%rdi)
jne 0x3f88
movl $0x1, 0xcc(%rax)
xorl %eax, %eax
retq
subq $0xd8, %rsp
movq $0x1, 0xc8(%rax)
movups 0x68(%rax), %xmm0
movups %xmm0, 0x38(%rax)
movups 0x78(%rax), %xmm0
movups %xmm0, 0x48(%rax)
movups 0x88(%rax), %xmm0
movups %xmm0, 0x58(%rax)
andq $0x0, 0x88(%rax)
incq 0x78(%rax)
movq 0x8(%rax), %rcx
bswapq %rcx
leaq 0x70(%rsp), %rdx
movq %rcx, (%rdx)
movq 0x10(%rax), %rcx
bswapq %rcx
movq %rcx, 0x8(%rdx)
movq 0x18(%rax), %rcx
bswapq %rcx
movq %rcx, 0x10(%rdx)
movq 0x20(%rax), %rcx
bswapq %rcx
movq %rcx, 0x18(%rdx)
movups 0x98(%rax), %xmm0
movups 0xa8(%rax), %xmm1
movaps %xmm0, 0x20(%rdx)
movaps %xmm1, 0x30(%rdx)
movq 0xd8(%rax), %rcx
bswapq %rcx
movq %rcx, 0x40(%rdx)
movups 0xe0(%rax), %xmm0
movups 0xf0(%rax), %xmm1
movups %xmm0, 0x48(%rdx)
movups %xmm1, 0x58(%rdx)
movq 0x38(%rax), %rsi
bswapq %rsi
movq %rsp, %r8
movq %rsi, (%r8)
movq 0x40(%rax), %rsi
bswapq %rsi
movq %rsi, 0x8(%r8)
movq 0x48(%rax), %rsi
bswapq %rsi
movq %rsi, 0x10(%r8)
movq 0x50(%rax), %rsi
bswapq %rsi
movq %rsi, 0x18(%r8)
movups 0x98(%rax), %xmm0
movups 0xa8(%rax), %xmm1
movaps %xmm0, 0x20(%r8)
movaps %xmm1, 0x30(%r8)
movq %rcx, 0x40(%r8)
movups 0xe0(%rax), %xmm0
movups 0xf0(%rax), %xmm1
movups %xmm0, 0x48(%r8)
movups %xmm1, 0x58(%r8)
movq (%rax), %rdi
leaq 0x142(%rip), %r10       # 0x41d9
leaq 0x875e(%rip), %rsi      # 0xc7fc
pushq $0x68
popq %rcx
movq %rcx, %r9
pushq %rax
pushq %r10
callq 0x8c5e
popq %rcx
popq %rdx
movl %eax, %ecx
xorl %eax, %eax
negl %ecx
sbbl %eax, %eax
addq $0xd8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: metadata_free
void
metadata_free(struct metadata * M)
{

	/* Behave consistently with free(NULL). */
	if (M == NULL)
		return;

	/* We shouldn't have any updates or callbacks in flight. */
	assert(M->M_latest.callback_state == NULL);
	assert(M->callback_deletedto == NULL);

	/* Free our structure. */
	free(M);
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x414f
cmpq $0x0, 0x88(%rdi)
jne 0x4151
cmpq $0x0, 0xb8(%rdi)
jne 0x4170
popq %rax
jmp 0x2040
popq %rax
retq
leaq 0x86da(%rip), %rdi      # 0xc832
leaq 0x86f6(%rip), %rsi      # 0xc855
leaq 0x879c(%rip), %rcx      # 0xc902
movl $0x1cd, %edx            # imm = 0x1CD
callq 0x21a0
leaq 0x87b1(%rip), %rdi      # 0xc928
leaq 0x86d7(%rip), %rsi      # 0xc855
leaq 0x877d(%rip), %rcx      # 0xc902
movl $0x1ce, %edx            # imm = 0x1CE
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: callback_writemetadata
static int
callback_writemetadata(void * _m, int status)
{
	struct metadata * M = _m;
	int (* callback)(void *);
	void * cookie;
	int rc = 0;
	int rc2;

	/* Sanity-check. */
	assert(M->write_inprogress);

	/* Did we succeed? */
	switch (status) {
	case 0:
		/* Request succeeded. */
		break;
	case 1:
		/* Request failed.  This is bad. */
		warn0("Failed to store metadata to DynamoDB!");
		goto err0;
	case 2:
		/* Another process stole the metadata from us. */
		warn0("Lost ownership of metadata in DynamoDB!");

		/*
		 * We could error out here, but it's safer to just abort;
		 * another process stealing our metadata tells us that we
		 * should not do anything else at all.
		 */
		_exit(0);
	}

	/* We're no longer storing metadata. */
	M->write_inprogress = 0;

	/* The values we were storing have now been stored. */
	M->M_stored = M->M_storing;

	/* Perform callbacks as appropriate. */
	if (M->M_stored.callback_state != NULL) {
		callback = M->M_stored.callback_state;
		cookie = M->M_stored.cookie_state;
		if ((rc2 = (callback)(cookie)) != 0)
			rc = rc2;
	}
	if (M->callback_deletedto != NULL) {
		callback = M->callback_deletedto;
		cookie = M->cookie_deletedto;
		if ((rc2 = (callback)(cookie)) != 0)
			rc = rc2;
	}

	/* Start another write if needed. */
	if (M->write_wanted) {
		if ((rc2 = writemetadata(M)) != 0)
			rc = rc2;
	}

	/* Return status from callbacks or writemetadata. */
	return (rc);

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

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
cmpl $0x0, 0xc8(%rdi)
je 0x4285
cmpl $0x1, %esi
je 0x422c
cmpl $0x2, %esi
je 0x42a4
movq %rdi, %rbx
andl $0x0, 0xc8(%rdi)
movups 0x38(%rdi), %xmm0
movups 0x48(%rdi), %xmm1
movups 0x58(%rdi), %xmm2
movups %xmm2, 0x28(%rdi)
movups %xmm0, 0x8(%rdi)
movups %xmm1, 0x18(%rdi)
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x4247
movq 0x30(%rbx), %rdi
callq *%rax
movl %eax, %ebp
jmp 0x4249
leaq 0x87de(%rip), %rdi      # 0xca11
xorl %eax, %eax
callq 0x88e8
callq 0x20a0
andl $0x0, (%rax)
pushq $-0x1
popq %rbp
jmp 0x427c
xorl %ebp, %ebp
movq 0xb8(%rbx), %rax
testq %rax, %rax
je 0x4263
movq 0xc0(%rbx), %rdi
callq *%rax
testl %eax, %eax
cmovnel %eax, %ebp
cmpl $0x0, 0xcc(%rbx)
je 0x427c
movq %rbx, %rdi
callq 0x3f6f
xorl %ecx, %ecx
negl %eax
sbbl %ecx, %ecx
orl %ecx, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x8749(%rip), %rdi      # 0xc9d5
leaq 0x85c2(%rip), %rsi      # 0xc855
leaq 0x874f(%rip), %rcx      # 0xc9e9
movl $0xc2, %edx
callq 0x21a0
leaq 0x878c(%rip), %rdi      # 0xca37
xorl %eax, %eax
callq 0x88e8
callq 0x20a0
andl $0x0, (%rax)
xorl %edi, %edi
callq 0x20c0
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/lbs-dynamodb/objmap.c
// Function: objmap
const char *
objmap(uint64_t N)
{
	uint8_t Nbuf[8];
	static char key[17]; /* 0123456789ABCDEF\0 */

	/* Serialize the value N. */
	be64enc(Nbuf, N);

	/* Hexify the 8-byte integer. */
	hexify(Nbuf, key, 8);

	/* Return the constructed string. */
	return (key);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
bswapq %rdi
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
leaq 0xf305(%rip), %rbx      # 0x135e0
pushq $0x8
popq %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7258
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../libcperciva/util/entropy.c
// Function: entropy_read_init
struct entropy_read_cookie *
entropy_read_init(void)
{
	struct entropy_read_cookie * er;

	/* Allocate cookie. */
	if ((er = malloc(sizeof(struct entropy_read_cookie))) == NULL) {
		warnp("malloc");
		goto err0;
	}

	/* Open /dev/urandom. */
	if ((er->fd = open("/dev/urandom", O_RDONLY)) == -1) {
		warnp("open(/dev/urandom)");
		goto err1;
	}

	/* Success! */
	return (er);

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

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
pushq $0x4
popq %rdi
callq 0x2270
testq %rax, %rax
je 0x6764
movq %rax, %rbx
leaq 0x6a76(%rip), %rdi      # 0xd1a9
xorl %esi, %esi
xorl %eax, %eax
callq 0x2300
movl %eax, (%rbx)
cmpl $-0x1, %eax
jne 0x67b1
callq 0x20a0
cmpl $0x0, (%rax)
je 0x6799
movq %rax, %r14
leaq 0x6a5f(%rip), %rdi      # 0xd1b6
xorl %eax, %eax
callq 0x8759
andl $0x0, (%r14)
jmp 0x67a7
callq 0x20a0
cmpl $0x0, (%rax)
je 0x6787
movq %rax, %r14
leaq 0x6a2a(%rip), %rdi      # 0xd1a2
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x8759
andl $0x0, (%r14)
jmp 0x67b1
leaq 0x6a14(%rip), %rdi      # 0xd1a2
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x88e8
jmp 0x67b1
leaq 0x6a16(%rip), %rdi      # 0xd1b6
xorl %eax, %eax
callq 0x88e8
movq %rbx, %rdi
callq 0x2040
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../libcperciva/util/entropy.c
// Function: entropy_read_fill
int
entropy_read_fill(struct entropy_read_cookie * er, uint8_t * buf,
    size_t buflen)
{
	ssize_t lenread;

	/* Sanity checks. */
	assert(er != NULL);
	assert(buflen <= SSIZE_MAX);

	/* Read bytes until we have filled the buffer. */
	while (buflen > 0) {
		if ((lenread = read(er->fd, buf, buflen)) == -1) {
			warnp("read(/dev/urandom)");
			goto err0;
		}

		/* The random device should never EOF. */
		if (lenread == 0) {
			warn0("EOF on /dev/urandom?");
			goto err0;
		}

		/* We've filled a portion of the buffer. */
		buf += (size_t)lenread;
		buflen -= (size_t)lenread;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x6855
movq %rdx, %rbx
testq %rdx, %rdx
js 0x686e
movq %rsi, %r14
movq %rdi, %r15
testq %rbx, %rbx
je 0x6802
movl (%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2210
testq %rax, %rax
je 0x6826
cmpq $-0x1, %rax
je 0x6806
addq %rax, %r14
subq %rax, %rbx
jmp 0x67dc
xorl %eax, %eax
jmp 0x684f
callq 0x20a0
cmpl $0x0, (%rax)
je 0x683e
movq %rax, %rbx
leaq 0x6a1f(%rip), %rdi      # 0xd239
xorl %eax, %eax
callq 0x8759
andl $0x0, (%rbx)
jmp 0x684c
leaq 0x6a1f(%rip), %rdi      # 0xd24c
xorl %eax, %eax
callq 0x88e8
callq 0x20a0
andl $0x0, (%rax)
jmp 0x684c
leaq 0x69f4(%rip), %rdi      # 0xd239
xorl %eax, %eax
callq 0x88e8
pushq $-0x1
popq %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x696d(%rip), %rdi      # 0xd1c9
leaq 0x6971(%rip), %rsi      # 0xd1d4
leaq 0x6988(%rip), %rcx      # 0xd1f2
pushq $0x4a
jmp 0x6885
leaq 0x683b(%rip), %rdi      # 0xd0b0
leaq 0x6958(%rip), %rsi      # 0xd1d4
leaq 0x696f(%rip), %rcx      # 0xd1f2
pushq $0x4b
popq %rdx
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../libcperciva/util/entropy.c
// Function: entropy_read_done
int
entropy_read_done(struct entropy_read_cookie * er)
{

	/* Sanity check. */
	assert(er != NULL);

	/* Close the device. */
	while (close(er->fd) == -1) {
		if (errno != EINTR) {
			warnp("close(/dev/urandom)");
			goto err1;
		}
	}

	/* Clean up. */
	free(er);

	/* Success! */
	return (0);

err1:
	free(er);

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

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x68e7
movq %rdi, %rbx
movl (%rbx), %edi
callq 0x21c0
cmpl $-0x1, %eax
jne 0x68c6
callq 0x20a0
movq %rax, %r14
movl (%rax), %eax
cmpl $0x4, %eax
je 0x6897
leaq 0x69dc(%rip), %rdi      # 0xd295
testl %eax, %eax
jne 0x68ca
xorl %eax, %eax
callq 0x88e8
jmp 0x68d5
xorl %ebp, %ebp
jmp 0x68d8
xorl %eax, %eax
callq 0x8759
andl $0x0, (%r14)
pushq $-0x1
popq %rbp
movq %rbx, %rdi
callq 0x2040
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x68db(%rip), %rdi      # 0xd1c9
leaq 0x68df(%rip), %rsi      # 0xd1d4
leaq 0x6965(%rip), %rcx      # 0xd261
pushq $0x70
popq %rdx
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../libcperciva/util/entropy.c
// Function: entropy_read
int
entropy_read(uint8_t * buf, size_t buflen)
{
	struct entropy_read_cookie * er;

	/* Sanity-check the buffer size. */
	assert(buflen <= SSIZE_MAX);

	/* Open /dev/urandom. */
	if ((er = entropy_read_init()) == NULL) {
		warn0("entropy_read_init");
		goto err0;
	}

	/* Read bytes until we have filled the buffer. */
	if (entropy_read_fill(er, buf, buflen)) {
		warn0("entropy_read_fill");
		goto err1;
	}

	/* Close the device. */
	if (entropy_read_done(er)) {
		warn0("entropy_read_done");
		goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rsi, %rsi
js 0x698b
movq %rsi, %r14
movq %rdi, %r15
callq 0x6718
testq %rax, %rax
je 0x6953
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x67bc
testl %eax, %eax
je 0x695c
leaq 0x69a5(%rip), %rdi      # 0xd2df
xorl %eax, %eax
callq 0x88e8
callq 0x20a0
andl $0x0, (%rax)
movq %rbx, %rdi
callq 0x688b
jmp 0x697e
leaq 0x6973(%rip), %rdi      # 0xd2cd
jmp 0x696f
movq %rbx, %rdi
callq 0x688b
testl %eax, %eax
je 0x6987
leaq 0x6982(%rip), %rdi      # 0xd2f1
xorl %eax, %eax
callq 0x88e8
callq 0x20a0
andl $0x0, (%rax)
pushq $-0x1
popq %rax
popq %rbx
popq %r14
popq %r15
retq
xorl %eax, %eax
jmp 0x6981
leaq 0x671e(%rip), %rdi      # 0xd0b0
leaq 0x683b(%rip), %rsi      # 0xd1d4
leaq 0x6909(%rip), %rcx      # 0xd2a9
movl $0x91, %edx
callq 0x21a0
nop
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../lib/proto_lbs/proto_lbs_server.c
// Function: proto_lbs_request_read
int
proto_lbs_request_read(struct netbuf_read * R, struct proto_lbs_request * req)
{
	struct wire_packet P;

	/* Try to grab a packet from the buffered reader. */
	if (wire_readpacket_peek(R, &P))
		goto err0;

	/* Do we have a packet? */
	if (P.buf == NULL)
		goto nopacket;

	/* Parse this packet. */
	if (proto_lbs_request_parse(&P, req))
		goto err0;

	/* Consume the packet. */
	wire_readpacket_consume(R, &P);

	/* Success! */
	return (0);

nopacket:
	/* Record that no request was available. */
	req->type = PROTO_LBS_NONE;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %rsi
callq 0x9798
pushq $-0x1
popq %rbp
testl %eax, %eax
jne 0x94d5
movq 0x10(%rsp), %r15
testq %r15, %r15
je 0x94bb
movq 0x8(%rsp), %r12
movq %r12, %rax
shrq $0x20, %rax
jne 0x9547
movq (%rsp), %rax
movq %rax, (%r14)
cmpq $0x4, %r12
jb 0x94d5
movq %r15, %rdi
callq 0x978b
movl %eax, 0x8(%r14)
cmpl $0x4, %eax
ja 0x94d5
movl %eax, %eax
leaq 0x48ce(%rip), %rcx      # 0xdd68
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0xc, %r12
jne 0x94d5
addq $0x4, %r15
movq %r15, %rdi
callq 0x9790
movq %rax, 0x10(%r14)
jmp 0x94c8
orl $-0x1, 0x8(%r14)
jmp 0x94d3
cmpq $0x4, %r12
jne 0x94d5
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x9b58
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x10, %r12
jb 0x94d5
leaq 0x4(%r15), %rdi
callq 0x978b
movl %eax, %r13d
movl %eax, 0x10(%r14)
leaq 0x8(%r15), %rdi
callq 0x9790
movq %rax, 0x18(%r14)
testl %r13d, %r13d
je 0x94d5
addq $-0x10, %r12
movl %r12d, %eax
xorl %edx, %edx
divl %r13d
testl %edx, %edx
jne 0x94d5
movl %eax, 0x14(%r14)
movq %r12, %rdi
callq 0x2270
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x94d5
addq $0x10, %r15
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2250
jmp 0x94c8
leaq 0x491b(%rip), %rdi      # 0xde69
leaq 0x4846(%rip), %rsi      # 0xdd9b
leaq 0x4922(%rip), %rcx      # 0xde7e
pushq $0x15
popq %rdx
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../lib/proto_lbs/proto_lbs_server.c
// Function: proto_lbs_response_params
int
proto_lbs_response_params(struct netbuf_write * Q, uint64_t ID,
    uint32_t blklen, uint64_t blkno)
{
	uint8_t * wbuf;

	/* Get a packet data buffer. */
	if ((wbuf = wire_writepacket_getbuf(Q, ID, 12)) == NULL)
		goto err0;

	/* Write the packet data. */
	be32enc(&wbuf[0], blklen);
	be64enc(&wbuf[4], blkno);

	/* Finish the packet. */
	if (wire_writepacket_done(Q, wbuf, 12))
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %r14
movl %edx, %ebp
movq %rdi, %rbx
pushq $0xc
popq %rdx
callq 0xa19c
testq %rax, %rax
je 0x95a8
movq %rax, %r15
bswapl %ebp
movl %ebp, (%rax)
movq %rax, %rdi
addq $0x4, %rdi
movq %r14, %rsi
callq 0x95ba
pushq $0xc
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa266
testl %eax, %eax
je 0x95ad
pushq $-0x1
popq %rax
jmp 0x95af
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../lib/proto_lbs/proto_lbs_server.c
// Function: proto_lbs_response_params2
int
proto_lbs_response_params2(struct netbuf_write * Q, uint64_t ID,
    uint32_t blklen, uint64_t blkno, uint64_t lastblk)
{
	uint8_t * wbuf;

	/* Get a packet data buffer. */
	if ((wbuf = wire_writepacket_getbuf(Q, ID, 20)) == NULL)
		goto err0;

	/* Write the packet data. */
	be32enc(&wbuf[0], blklen);
	be64enc(&wbuf[4], blkno);
	be64enc(&wbuf[12], lastblk);

	/* Finish the packet. */
	if (wire_writepacket_done(Q, wbuf, 20))
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %r14
movq %rcx, %r12
movl %edx, %ebp
movq %rdi, %rbx
pushq $0x14
popq %rdx
callq 0xa19c
testq %rax, %rax
je 0x9615
movq %rax, %r15
bswapl %ebp
movl %ebp, (%rax)
leaq 0x4(%rax), %rdi
movq %r12, %rsi
callq 0x95ba
movq %r15, %rdi
addq $0xc, %rdi
movq %r14, %rsi
callq 0x95ba
pushq $0x14
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa266
testl %eax, %eax
je 0x961a
pushq $-0x1
popq %rax
jmp 0x961c
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../lib/proto_lbs/proto_lbs_server.c
// Function: proto_lbs_response_get
int
proto_lbs_response_get(struct netbuf_write * Q, uint64_t ID,
    int status, uint32_t blklen, const uint8_t * buf)
{
	uint8_t * wbuf;
	size_t len;

	/* Sanity check. */
	assert((status == 0) || (status == 1));

	/* Compute the response length. */
	len = 4 + ((status == 0) ? blklen : 0);

	/* Get a packet data buffer. */
	if ((wbuf = wire_writepacket_getbuf(Q, ID, len)) == NULL)
		goto err0;

	/* Write the packet data. */
	be32enc(&wbuf[0], (uint32_t)status);
	if (status == 0)
		memcpy(&wbuf[4], buf, blklen);

	/* Finish the packet. */
	if (wire_writepacket_done(Q, wbuf, len))
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x2, %edx
jae 0x96a9
movq %r8, %r14
movl %ecx, %r12d
movl %edx, %ebp
movq %rdi, %rbx
leal 0x4(%r12), %eax
testl %edx, %edx
pushq $0x4
popq %r15
cmovel %eax, %r15d
movq %r15, %rdx
callq 0xa19c
testq %rax, %rax
je 0x9693
movq %rax, %r13
andw $0x0, (%rax)
movb %bpl, 0x3(%rax)
movb $0x0, 0x2(%rax)
testl %ebp, %ebp
jne 0x9681
movq %r13, %rdi
addq $0x4, %rdi
movl %r12d, %edx
movq %r14, %rsi
callq 0x2250
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xa266
testl %eax, %eax
je 0x9698
pushq $-0x1
popq %rax
jmp 0x969a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x46cc(%rip), %rdi      # 0xdd7c
leaq 0x46e4(%rip), %rsi      # 0xdd9b
leaq 0x4701(%rip), %rcx      # 0xddbf
movl $0xc5, %edx
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../lib/proto_lbs/proto_lbs_server.c
// Function: proto_lbs_response_append
int
proto_lbs_response_append(struct netbuf_write * Q, uint64_t ID,
    int status, uint64_t blkno)
{
	uint8_t * wbuf;
	size_t len;

	/* Sanity check. */
	assert((status == 0) || (status == 1));

	/* Compute the response length. */
	len = (status == 0) ? 12 : 4;

	/* Get a packet data buffer. */
	if ((wbuf = wire_writepacket_getbuf(Q, ID, len)) == NULL)
		goto err0;

	/* Write the packet data. */
	be32enc(&wbuf[0], (uint32_t)status);
	if (status == 0)
		be64enc(&wbuf[4], blkno);

	/* Finish the packet. */
	if (wire_writepacket_done(Q, wbuf, len))
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpl $0x2, %edx
jae 0x973d
movq %rcx, %r14
movl %edx, %ebp
movq %rdi, %rbx
xorl %eax, %eax
testl %edx, %edx
sete %al
leaq 0x4(,%rax,8), %r15
movq %r15, %rdx
callq 0xa19c
testq %rax, %rax
je 0x972d
movq %rax, %r12
andw $0x0, (%rax)
movb %bpl, 0x3(%rax)
movb $0x0, 0x2(%rax)
testl %ebp, %ebp
jne 0x971b
movq %r12, %rdi
addq $0x4, %rdi
movq %r14, %rsi
callq 0x95ba
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xa266
testl %eax, %eax
je 0x9732
pushq $-0x1
popq %rax
jmp 0x9734
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4638(%rip), %rdi      # 0xdd7c
leaq 0x4650(%rip), %rsi      # 0xdd9b
leaq 0x46c9(%rip), %rcx      # 0xde1b
movl $0xec, %edx
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: sink_open
int sink_open(struct sink *x, int search_path, char **argv)
{
	assert(x->sp->argv == NULL);
	memset(x, 0, sizeof(struct sink));
	x->sp->search_path = search_path;
	x->sp->argv = argv;
	assert(subprocess_fork(x->sp) == 0);
	x->fd = x->sp->child_fdin;
	DEBUG_INFO("sink_open(x,search_path=%i,argv=[argv[0]=[%s]]): done", search_path, argv[0]);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpq $0x0, 0x8(%rdi)
jne 0x2515
movq %rdi, %rbx
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
andq $0x0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movl %esi, 0x18(%rbx)
movq %rdx, 0x8(%rbx)
callq 0x6987
testl %eax, %eax
jne 0x252e
movl 0x30(%rbx), %eax
movl %eax, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x7b8c(%rip), %rdi      # 0xa0a8
leaq 0x7b99(%rip), %rsi      # 0xa0bc
leaq 0x7b9b(%rip), %rcx      # 0xa0c5
pushq $0x52
jmp 0x2545
leaq 0x7bbb(%rip), %rdi      # 0xa0f0
leaq 0x7b80(%rip), %rsi      # 0xa0bc
leaq 0x7b82(%rip), %rcx      # 0xa0c5
pushq $0x56
popq %rdx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: sink_close
void sink_close(struct sink *x)
{
	assert(x->sp->pid > 0);

	/* we are no more interested in tap output
	 */
	subprocess_close_child_fdin(x->sp);

	assert(subprocess_terminate(x->sp) == 0);

	x->fd = -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpl $0x0, 0x20(%rdi)
jle 0x257b
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
movq %r14, %rdi
callq 0x5d7d
movq %r14, %rdi
callq 0x6ae9
testl %eax, %eax
jne 0x2594
orl $-0x1, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x7b8a(%rip), %rdi      # 0xa10c
leaq 0x7b33(%rip), %rsi      # 0xa0bc
leaq 0x7b8b(%rip), %rcx      # 0xa11b
pushq $0x5e
jmp 0x25ab
leaq 0x7b9f(%rip), %rdi      # 0xa13a
leaq 0x7b1a(%rip), %rsi      # 0xa0bc
leaq 0x7b72(%rip), %rcx      # 0xa11b
pushq $0x64
popq %rdx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: fd_tap_open
int fd_tap_open(struct fd_tap *x, int fd)
{
	memset(x, 0, sizeof(struct fd_tap));
	x->fd = fd;
	assert(make_fd_non_blocking(x->fd) == 0);
	DEBUG_INFO("fd_tap_open(x,fd=%i): done", fd);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
andq $0x0, 0x4(%rdi)
movl %esi, (%rdi)
movl %esi, %edi
callq 0x4ee8
testl %eax, %eax
jne 0x25cb
xorl %eax, %eax
popq %rbp
retq
leaq 0x7b89(%rip), %rdi      # 0xa15b
leaq 0x7ae3(%rip), %rsi      # 0xa0bc
leaq 0x7b9c(%rip), %rcx      # 0xa17c
pushq $0x6d
popq %rdx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: file_tap_open
int file_tap_open(struct file_tap *x, const char *path)
{
	assert(x->path->s == NULL);
	memset(x, 0, sizeof(struct file_tap));
	str_copyz(x->path, path);
	x->fd = open(x->path->s, O_RDONLY);
	assert(x->fd > 0);
	assert(make_fd_non_blocking(x->fd) == 0);
	DEBUG_INFO("file_tap_open(x,path=[%s]): done", path);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpq $0x0, 0x8(%rdi)
jne 0x266d
movq %rdi, %rbx
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
callq 0x915f
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x22e0
movl %eax, (%rbx)
testl %eax, %eax
jle 0x268a
movl %eax, %edi
callq 0x4ee8
testl %eax, %eax
jne 0x26a9
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x7b5c(%rip), %rdi      # 0xa1d0
leaq 0x7a41(%rip), %rsi      # 0xa0bc
leaq 0x7b61(%rip), %rcx      # 0xa1e3
pushq $0x7c
popq %rdx
callq 0x21b0
leaq 0x7b85(%rip), %rdi      # 0xa216
leaq 0x7a24(%rip), %rsi      # 0xa0bc
leaq 0x7b44(%rip), %rcx      # 0xa1e3
movl $0x80, %edx
callq 0x21b0
leaq 0x7aab(%rip), %rdi      # 0xa15b
leaq 0x7a05(%rip), %rsi      # 0xa0bc
leaq 0x7b25(%rip), %rcx      # 0xa1e3
movl $0x81, %edx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: file_tap_close
void file_tap_close(struct file_tap *x)
{
	assert(x->path->len);
	assert(x->fd >= 0);
	close(x->fd);
	x->fd = -1;
	str_free(x->path);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpl $0x0, 0x10(%rdi)
je 0x26f6
movq %rdi, %rbx
movl (%rdi), %edi
testl %edi, %edi
js 0x2715
leaq 0x8(%rbx), %r14
callq 0x21e0
orl $-0x1, (%rbx)
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x90ee
leaq 0x7b23(%rip), %rdi      # 0xa220
leaq 0x79b8(%rip), %rsi      # 0xa0bc
leaq 0x7b22(%rip), %rcx      # 0xa22d
movl $0x88, %edx
callq 0x21b0
leaq 0x7a86(%rip), %rdi      # 0xa1a2
leaq 0x7999(%rip), %rsi      # 0xa0bc
leaq 0x7b03(%rip), %rcx      # 0xa22d
movl $0x89, %edx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: cat_tap_open
int cat_tap_open(struct cat_tap *x, const char *path, int seek_end)
{
	int pid;

	assert(x->path->s == NULL);
	assert(x->sp->argv == NULL); /* not used since we won't execve */
	memset(x, 0, sizeof(struct cat_tap));

	str_copyz(x->path, path);

	if ((pid = subprocess_fork0(x->sp)) == 0) {
		/* child
		 */
		int i;
		for (i = getdtablesize(); i >= 0; i--) {
			if (i <= STDERR_FILENO) continue;
			close(i);
		}
		if (seek_end) {
		  assert(tail_fn0(x->path->s) == 0);
		} else {
		  assert(tail_f(x->path->s) == 0);
		}
		exit(0);
	} else if (pid < 0) {
		return -1;
	}

	x->fd = x->sp->child_fdout;

	DEBUG_INFO("cat_tap_open(x, path=[%s]): done, pid=%i", path, x->sp->pid);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpq $0x0, 0x8(%rdi)
jne 0x27a7
movq %rdi, %r15
cmpq $0x0, 0x18(%rdi)
jne 0x27c6
movl %edx, %ebx
leaq 0x8(%r15), %r14
leaq 0x18(%r15), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movups %xmm0, (%r15)
andq $0x0, 0x50(%r15)
movq %r14, %rdi
callq 0x915f
movq %r12, %rdi
callq 0x62ad
testl %eax, %eax
je 0x27e5
js 0x279b
movl 0x44(%r15), %eax
movl %eax, (%r15)
xorl %eax, %eax
jmp 0x279e
pushq $-0x1
popq %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7a22(%rip), %rdi      # 0xa1d0
leaq 0x7907(%rip), %rsi      # 0xa0bc
leaq 0x7a98(%rip), %rcx      # 0xa254
movl $0x97, %edx
callq 0x21b0
leaq 0x78db(%rip), %rdi      # 0xa0a8
leaq 0x78e8(%rip), %rsi      # 0xa0bc
leaq 0x7a79(%rip), %rcx      # 0xa254
movl $0x98, %edx
callq 0x21b0
callq 0x2390
movl %eax, %r15d
testl %r15d, %r15d
js 0x2805
cmpl $0x3, %r15d
jb 0x2800
movl %r15d, %edi
callq 0x21e0
decl %r15d
jmp 0x27ed
movq (%r14), %rdi
testl %ebx, %ebx
jne 0x2836
xorl %esi, %esi
callq 0x4c48
testl %eax, %eax
je 0x2842
leaq 0x7a86(%rip), %rdi      # 0xa2a4
leaq 0x7897(%rip), %rsi      # 0xa0bc
leaq 0x7a28(%rip), %rcx      # 0xa254
movl $0xa8, %edx
callq 0x21b0
pushq $0x1
popq %rsi
callq 0x4c48
testl %eax, %eax
jne 0x2849
xorl %edi, %edi
callq 0x2340
leaq 0x7a3a(%rip), %rdi      # 0xa28a
leaq 0x7865(%rip), %rsi      # 0xa0bc
leaq 0x79f6(%rip), %rcx      # 0xa254
movl $0xa6, %edx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: cat_tap_close
void cat_tap_close(struct cat_tap *x)
{
	assert(x->sp->pid > 0);
	assert(x->sp->argv == NULL);

	/* we are no more interested in tap output
	 */
	subprocess_close_child_fdout(x->sp);
	subprocess_close_child_fderr(x->sp);

	DEBUG_INFO("sending SIGTERM to cat_tap pid %i", x->sp->pid);
	assert(kill(x->sp->pid, SIGTERM) == 0);

	assert(subprocess_terminate(x->sp) == 0);

	x->fd = -1;
	str_free(x->path);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpl $0x0, 0x30(%rdi)
jle 0x28c0
movq %rdi, %rbx
leaq 0x18(%rdi), %r14
cmpq $0x0, (%r14)
jne 0x28df
movq %r14, %rdi
callq 0x5de5
movq %r14, %rdi
callq 0x5e4d
movl 0x30(%rbx), %edi
pushq $0xf
popq %rsi
callq 0x2270
testl %eax, %eax
jne 0x28fe
movq %r14, %rdi
callq 0x6ae9
testl %eax, %eax
jne 0x291d
orl $-0x1, (%rbx)
addq $0x8, %rbx
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x90ee
leaq 0x7845(%rip), %rdi      # 0xa10c
leaq 0x77ee(%rip), %rsi      # 0xa0bc
leaq 0x79e7(%rip), %rcx      # 0xa2bc
movl $0xb8, %edx
callq 0x21b0
leaq 0x77c2(%rip), %rdi      # 0xa0a8
leaq 0x77cf(%rip), %rsi      # 0xa0bc
leaq 0x79c8(%rip), %rcx      # 0xa2bc
movl $0xb9, %edx
callq 0x21b0
leaq 0x79dc(%rip), %rdi      # 0xa2e1
leaq 0x77b0(%rip), %rsi      # 0xa0bc
leaq 0x79a9(%rip), %rcx      # 0xa2bc
movl $0xc1, %edx
callq 0x21b0
leaq 0x7816(%rip), %rdi      # 0xa13a
leaq 0x7791(%rip), %rsi      # 0xa0bc
leaq 0x798a(%rip), %rcx      # 0xa2bc
movl $0xc3, %edx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: fd_tap_read
int fd_tap_read(struct fd_tap *x, void *buf, int bufsz)
{
	int n = read(x->fd, buf, bufsz);
	if (n < 0) {
		int save_errno = errno;
		assert(n == -1);
		if (errno == EAGAIN) return -1;
		if (errno == EINTR) return -1;
		DEBUG("read(), errno=%i", save_errno);
		errno = save_errno;
		perror("read()");
		exit(1);
	}
	if (n) {
		x->bytes_read += n;
		//get_current_timeval(x->time_read);
	} else {
		assert(x->got_eof == 0);
		x->got_eof = 1;
	}
	return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl (%rdi), %edi
movslq %edx, %rdx
callq 0x2200
movq %rax, %rbx
testl %ebx, %ebx
js 0x2962
je 0x29b2
addl %ebx, 0x4(%r14)
jmp 0x29c1
callq 0x2080
cmpl $-0x1, %ebx
jne 0x29ce
movq %rax, %r14
movl (%rax), %r15d
cmpl $0x4, %r15d
je 0x29c1
cmpl $0xb, %r15d
je 0x29c1
leaq 0x7737(%rip), %rdi      # 0xa0bc
leaq 0x7fcc(%rip), %rdx      # 0xa958
movl $0xd1, %esi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x8e04
movl %r15d, (%r14)
leaq 0x7fcb(%rip), %rdi      # 0xa970
callq 0x2300
pushq $0x1
popq %rdi
callq 0x2340
cmpl $0x0, 0x8(%r14)
jne 0x29ed
movl $0x1, 0x8(%r14)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x792b(%rip), %rdi      # 0xa300
leaq 0x76e0(%rip), %rsi      # 0xa0bc
leaq 0x7925(%rip), %rcx      # 0xa308
movl $0xce, %edx
callq 0x21b0
leaq 0x7942(%rip), %rdi      # 0xa336
leaq 0x76c1(%rip), %rsi      # 0xa0bc
leaq 0x7906(%rip), %rcx      # 0xa308
movl $0xda, %edx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: buffer_new
struct buffer *buffer_new(struct buffer *tail, int id, void *buf, int bufsz)
{
	struct buffer *r = buffer_new0(tail);
	r->id = id;
#if 0
	DEBUG_INFO("%i -> %i", r->_position, tail ? tail->_position : -1);
	str_copyf(r->buf, "%s got %i bytes\n", id, bufsz);
#else
	str_copyn(r->buf, buf, bufsz);
#endif
	r->pos = 0;
	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebx
movq %rdx, %r14
movl %esi, %r15d
callq 0x2bc8
movq %rax, %r12
movl %r15d, 0x10(%rax)
leaq 0x18(%rax), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x910b
andl $0x0, 0x28(%r12)
movq %r12, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: buffer_free
void buffer_free(struct buffer *x)
{
	while (x) {
		struct buffer *t = x->tail;
		str_free(x->buf);
		free(x);
		x = t;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
testq %rbx, %rbx
je 0x2f27
movq 0x8(%rbx), %r14
leaq 0x18(%rbx), %rdi
callq 0x90ee
movq %rbx, %rdi
callq 0x2060
movq %r14, %rbx
jmp 0x2f08
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: buffer_queue_free
void buffer_queue_free(struct buffer_queue *x)
{
	if (x) {
		buffer_free(x->enqueue);
		buffer_free(x->dequeue);
		free(x);
	}
}

// Assembly:
testq %rdi, %rdi
je 0x2f59
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2efe
movq 0x8(%rbx), %rdi
callq 0x2efe
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x2060
retq
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: sink_write_from_queue
int sink_write_from_queue(struct sink *x, struct buffer_queue *q)
{
	struct buffer *b;
	int total = 0;
	while ((b = buffer_queue_dequeue(q))) {
		int n;
		n = sink_write(x, b);
		if (n < 0) {
			int save_errno = errno;
			assert(n == -1);
			if (errno == EAGAIN) {
				DEBUG_INFO("sink is busy. how many buffers remaining? %i", buffer_queue_len(q));
				break;
			}
			if (errno == EINTR) {
				DEBUG_INFO("sink got interrupted (EINTR). how many buffers remaining? %i", buffer_queue_len(q));
				break;
			}
			/* errors beyond recovery
			 */
			q->dequeue = buffer_tail0(b, q->dequeue); /* reschedule */
			if (errno == EPIPE) {
				DEBUG("sink got unrecoverable error (EPIPE - broken pipe)");
				errno = save_errno;
				return -1;
			}
			DEBUG("sink_write(), errno=%i", save_errno);
			errno = save_errno;
			perror("sink_write()");
			return -1;
		} else if (n) {
			total += n;
			if (b->pos < b->buf->len) {
				DEBUG_INFO("sink consumed (so far) %i bytes of %i, %i buffers enqueued",
				      b->pos, b->buf->len, buffer_queue_len(q));
				break;
			}
			DEBUG_INFO("sink consumed all %i bytes, %i buffers enqueued", b->pos, buffer_queue_len(q));
			/* discard consumed buffer
			 */
			buffer_free(b);
			b = NULL;
		} else {
			assert(x->got_eof);
			break;
		}
	}
	if (b) q->dequeue = buffer_tail0(b, q->dequeue); /* reschedule */
	return total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r12
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x2e84
testq %rax, %rax
je 0x31c9
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x2f5a
testl %eax, %eax
js 0x317b
je 0x31a1
addl %eax, %r14d
movl 0x28(%r15), %eax
cmpl 0x20(%r15), %eax
jl 0x31ad
movq %r15, %rdi
callq 0x2efe
jmp 0x3143
callq 0x2080
movl (%rax), %r13d
cmpl $0x4, %r13d
je 0x31ad
cmpl $0xb, %r13d
je 0x31ad
movq %rax, %r12
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x31db
movl (%rax), %ecx
incl %ecx
jmp 0x31dd
cmpl $0x0, 0x40(%r12)
je 0x3242
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x31bc
movl (%rax), %ecx
incl %ecx
jmp 0x31be
xorl %ecx, %ecx
movl %ecx, (%r15)
movq %rax, 0x8(%r15)
movq %r15, 0x8(%rbx)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ecx, %ecx
movl %ecx, (%r15)
movq %rax, 0x8(%r15)
movq %r15, 0x8(%rbx)
cmpl $0x20, (%r12)
jne 0x3213
leaq 0x6ec6(%rip), %rdi      # 0xa0bc
leaq 0x727a(%rip), %rdx      # 0xa477
movl $0x18c, %esi            # imm = 0x18C
xorl %eax, %eax
callq 0x8e04
movl %r13d, (%r12)
pushq $-0x1
popq %r14
jmp 0x31c9
leaq 0x6ea2(%rip), %rdi      # 0xa0bc
leaq 0x7289(%rip), %rdx      # 0xa4aa
movl $0x190, %esi            # imm = 0x190
movl %r13d, %ecx
xorl %eax, %eax
callq 0x8e04
movl %r13d, (%r12)
leaq 0x7286(%rip), %rdi      # 0xa4c1
callq 0x2300
jmp 0x320d
leaq 0x7285(%rip), %rdi      # 0xa4ce
leaq 0x6e6c(%rip), %rsi      # 0xa0bc
leaq 0x71e0(%rip), %rcx      # 0xa437
movl $0x1a1, %edx            # imm = 0x1A1
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/aimant.c
// Function: sink_flush_all_buffers
int sink_flush_all_buffers(struct sink *x, struct buffer_queue *q)
{
	int r;
	int total = 0;
	DEBUG_INFO("sink_flush_all_buffers(x=[pid=%i], q=[buffers=%i]) begin", x->sp->pid, buffer_queue_len(q));
	while (buffer_queue_len(q)) {
		int n;
		n = sink_write_from_queue(x, q);
		if (n < 0) {
			int save_errno = errno;
			assert(n == -1);
			DEBUG("sink_flush_all_buffers(x=[pid=%i]), errno=%i", x->sp->pid, save_errno);
			errno = save_errno;
			perror("sink_write_from_queue()");
			return -1;
		}
		total += n;
		if (x->got_eof) break;
		if ((r = wait_til_ready_for_write(x->fd, 5000 /* 5 secs */))) {
			int save_errno = errno;
			assert(r == -1);
			DEBUG("wait_til_ready_for_write(x->fd=%i), errno=%i", x->fd, save_errno);
			errno = save_errno;
			perror("wait_til_ready_for_write(x->fd)");
			return -1;
		}
	}
	DEBUG_INFO("sink_flush_all_buffers(x=[pid=%i,eof=%i], q=[buffers=%i]) done", x->sp->pid, x->got_eof, buffer_queue_len(q));
	return total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x2e54
testl %eax, %eax
je 0x3540
movq %rbx, %rdi
movq %r15, %rsi
callq 0x312c
testl %eax, %eax
js 0x34fd
addl %eax, %r14d
cmpl $0x0, 0x40(%rbx)
jne 0x3540
movl (%rbx), %edi
movl $0x1388, %esi           # imm = 0x1388
callq 0x3463
testl %eax, %eax
je 0x3482
cmpl $-0x1, %eax
jne 0x354e
callq 0x2080
movq %rax, %r14
movl (%rax), %r15d
movl (%rbx), %ecx
leaq 0x6be1(%rip), %rdi      # 0xa0bc
leaq 0x7143(%rip), %rdx      # 0xa625
movl $0x214, %esi            # imm = 0x214
movl %r15d, %r8d
xorl %eax, %eax
callq 0x8e04
movl %r15d, (%r14)
leaq 0x7157(%rip), %rdi      # 0xa652
jmp 0x3537
cmpl $-0x1, %eax
jne 0x356d
callq 0x2080
movq %rax, %r14
movl (%rax), %r15d
movl 0x20(%rbx), %ecx
leaq 0x6ba5(%rip), %rdi      # 0xa0bc
leaq 0x70c2(%rip), %rdx      # 0xa5e0
movl $0x20a, %esi            # imm = 0x20A
movl %r15d, %r8d
xorl %eax, %eax
callq 0x8e04
movl %r15d, (%r14)
leaq 0x70d6(%rip), %rdi      # 0xa60d
callq 0x2300
pushq $-0x1
popq %r14
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x856f(%rip), %rdi      # 0xbac4
leaq 0x6b60(%rip), %rsi      # 0xa0bc
leaq 0x703c(%rip), %rcx      # 0xa59f
movl $0x213, %edx            # imm = 0x213
callq 0x21b0
leaq 0x6d8c(%rip), %rdi      # 0xa300
leaq 0x6b41(%rip), %rsi      # 0xa0bc
leaq 0x701d(%rip), %rcx      # 0xa59f
movl $0x209, %edx            # imm = 0x209
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/subprocess.c
// Function: child_new
struct child *child_new(struct subprocess *sp)
{
	struct child *c = child_new0();
	assert(c);
	c->sp = sp;
	return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x5a78
testq %rax, %rax
je 0x5b3a
movq %rbx, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x6228(%rip), %rdi      # 0xbd69
leaq 0x53d1(%rip), %rsi      # 0xaf19
leaq 0x560c(%rip), %rcx      # 0xb15b
pushq $0x6f
popq %rdx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/subprocess.c
// Function: children_search_by_pid
struct child *children_search_by_pid(struct children * rbtree, int key)
{
	struct child *ret;
	int cmp;
	ret = rbtree->rbt_root;
	while (ret != &rbtree->rbt_nil && (cmp = child_cmp_by_pid(key, ret)) != 0) {
		if (cmp < 0) {
			ret = rbtn_left_get(struct child, _meta, ret);
		} else {
			ret = rbtn_right_get(struct child, _meta, ret);
		}
	}
	if (ret == &rbtree->rbt_nil) {
		ret = NULL;
	}
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
addq $0x8, %rdi
cmpq %rdi, %rax
je 0x5bac
movq 0x10(%rax), %rcx
cmpl %esi, 0x18(%rcx)
je 0x5bae
jle 0x5ba2
movq (%rax), %rax
jmp 0x5b8d
movq 0x8(%rax), %rax
andq $-0x2, %rax
jmp 0x5b8d
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/subprocess.c
// Function: children_free
void children_free(struct children * x)
{
    if (x) {
	struct child *c, *n;
	for (c = children_first(x); c; c = n) {
	    n = children_next(x, c);
	    children_remove(x, c);
	    child_free(c);
	}
	free(x);
    }
}

// Assembly:
testq %rdi, %rdi
je 0x5c07
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x4f5b
movq %rax, %r14
testq %r14, %r14
je 0x5bf5
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4fb6
movq %rax, %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5303
movq %r14, %rdi
callq 0x5b57
movq %r15, %r14
jmp 0x5bca
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2060
retq
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/subprocess.c
// Function: get_current_timeval
void get_current_timeval(struct timeval *tv)
{
#ifdef USE_CLOCK_GETTIME
	struct timespec ts[1];
	assert(clock_gettime(CLOCK_REALTIME, ts) == 0);
	tv->tv_sec = ts->tv_sec;
	tv->tv_usec = ts->tv_nsec / 1000;
#else
	assert(gettimeofday(tv, NULL) == 0);
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq -0x20(%rbp), %rsi
xorl %edi, %edi
callq 0x2110
testl %eax, %eax
jne 0x5c43
movq -0x20(%rbp), %rax
movq %rax, (%rbx)
movq -0x18(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0x553e(%rip), %rdi      # 0xb188
leaq 0x52c8(%rip), %rsi      # 0xaf19
leaq 0x5557(%rip), %rcx      # 0xb1af
movl $0xac, %edx
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/subprocess.c
// Function: interrupt_safe_sleep
void interrupt_safe_sleep(int msec)
{
	int r;
	struct timeval start;
	struct timeval current;
	struct timeval tv;
	long usec;
	long dmsec;

	get_current_timeval(&start);

	DEBUG_INFO("interrupt_safe_sleep(%u)", msec);

	tv.tv_sec = 0;
	tv.tv_usec = msec * 1000;
	r = select(0, NULL, NULL, NULL, &tv);
	while (r < 0) {
		assert(r == -1);
		assert(errno == EINTR);

		get_current_timeval(&current);
		if ((dmsec = DELTA_MSEC(&current, &start)) >= msec) {
			break;
		}

		DEBUG_INFO("resuming interrupt safe sleep, %li milliseconds to go, total %i", msec - dmsec, msec);
		tv.tv_sec = 0;
		tv.tv_usec = (msec - dmsec) * 1000;
		r = select(0, NULL, NULL, NULL, &tv);
	}

	get_current_timeval(&current);
	usec = DELTA_USEC(&current, &start);
	DEBUG_INFO("%li milliseconds elapsed (%lu usecs)", usec / 1000, usec);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edi, %r14d
leaq -0x58(%rbp), %r15
movq %r15, %rdi
callq 0x5c08
leaq -0x38(%rbp), %r8
andq $0x0, (%r8)
imull $0x3e8, %r14d, %eax     # imm = 0x3E8
cltq
movq %rax, 0x8(%r8)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2280
movq (%r15), %r12
movq 0x8(%r15), %r15
movslq %r14d, %r13
leaq -0x48(%rbp), %r14
movl $0x3e8, %ebx            # imm = 0x3E8
testl %eax, %eax
jns 0x5d27
cmpl $-0x1, %eax
jne 0x5d3f
callq 0x2080
cmpl $0x4, (%rax)
jne 0x5d5e
movq %r14, %rdi
callq 0x5c08
movq -0x48(%rbp), %rax
subq %r12, %rax
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
addq -0x40(%rbp), %rax
subq %r15, %rax
cqto
idivq %rbx
movq %r13, %rcx
subq %rax, %rcx
jle 0x5d27
andq $0x0, -0x38(%rbp)
imulq $0x3e8, %rcx, %rax      # imm = 0x3E8
movq %rax, -0x30(%rbp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
leaq -0x38(%rbp), %r8
callq 0x2280
jmp 0x5cc3
leaq -0x48(%rbp), %rdi
callq 0x5c08
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d7e(%rip), %rdi      # 0xbac4
leaq 0x51cc(%rip), %rsi      # 0xaf19
leaq 0x5486(%rip), %rcx      # 0xb1da
movl $0x17e, %edx            # imm = 0x17E
callq 0x21b0
leaq 0x5494(%rip), %rdi      # 0xb1f9
leaq 0x51ad(%rip), %rsi      # 0xaf19
leaq 0x5467(%rip), %rcx      # 0xb1da
movl $0x17f, %edx            # imm = 0x17F
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/subprocess.c
// Function: subprocess_close_child_fdin
void subprocess_close_child_fdin(struct subprocess *sp)
{
	assert(sp->pid > 0);
	if (sp->child_fdin >= 0) {
		assert(xclose(sp->child_fdin) == 0);
		sp->child_fdin = -1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl $0x0, 0x18(%rdi)
jle 0x5da7
movq %rdi, %rbx
movl 0x28(%rdi), %edi
testl %edi, %edi
js 0x5da0
callq 0x21e0
testl %eax, %eax
jne 0x5dc6
orl $-0x1, 0x28(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x4b19(%rip), %rdi      # 0xa8c7
leaq 0x5164(%rip), %rsi      # 0xaf19
leaq 0x544c(%rip), %rcx      # 0xb208
movl $0x193, %edx            # imm = 0x193
callq 0x21b0
leaq 0x5471(%rip), %rdi      # 0xb23e
leaq 0x5145(%rip), %rsi      # 0xaf19
leaq 0x542d(%rip), %rcx      # 0xb208
movl $0x195, %edx            # imm = 0x195
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/subprocess.c
// Function: subprocess_close_child_fdout
void subprocess_close_child_fdout(struct subprocess *sp)
{
	assert(sp->pid > 0);
	if (sp->child_fdout >= 0) {
		assert(xclose(sp->child_fdout) == 0);
		sp->child_fdout = -1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl $0x0, 0x18(%rdi)
jle 0x5e0f
movq %rdi, %rbx
movl 0x2c(%rdi), %edi
testl %edi, %edi
js 0x5e08
callq 0x21e0
testl %eax, %eax
jne 0x5e2e
orl $-0x1, 0x2c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x4ab1(%rip), %rdi      # 0xa8c7
leaq 0x50fc(%rip), %rsi      # 0xaf19
leaq 0x5436(%rip), %rcx      # 0xb25a
movl $0x19c, %edx            # imm = 0x19C
callq 0x21b0
leaq 0x545c(%rip), %rdi      # 0xb291
leaq 0x50dd(%rip), %rsi      # 0xaf19
leaq 0x5417(%rip), %rcx      # 0xb25a
movl $0x19e, %edx            # imm = 0x19E
callq 0x21b0