// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../libcperciva/network/network_read.c
// Function: network_read
void *
network_read(int fd, uint8_t * buf, size_t buflen, size_t minread,
    int (* callback)(void *, ssize_t), void * cookie)
{
	struct network_read_cookie * C;

	/* Make sure buflen is non-zero. */
	assert(buflen != 0);

	/* Sanity-check: # bytes must fit into a ssize_t. */
	assert(buflen <= SSIZE_MAX);

	/* Bake a cookie. */
	if ((C = mpool_network_read_cookie_malloc()) == NULL)
		goto err0;
	C->callback = callback;
	C->cookie = cookie;
	C->fd = fd;
	C->buf = buf;
	C->buflen = buflen;
	C->minlen = minread;
	C->bufpos = 0;

	/* Register a callback for network readiness. */
	if (events_network_register(callback_buf, C, C->fd,
	    EVENTS_NETWORK_OP_READ))
		goto err1;

	/* Success! */
	return (C);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x60f2
js 0x6111
movq %r9, %r12
movq %r8, %r14
movq %rdx, %r15
movq %rsi, %r13
movl %edi, %ebp
incq 0x54fd(%rip)            # 0xb478
movq 0x54de(%rip), %rax      # 0xb460
testq %rax, %rax
je 0x5fa0
movq 0x54e2(%rip), %rsi      # 0xb470
leaq -0x1(%rax), %rdx
movq %rdx, 0x54c7(%rip)      # 0xb460
movq -0x8(%rsi,%rax,8), %rbx
jmp 0x5fdb
movq %rcx, (%rsp)
incq 0x54d5(%rip)            # 0xb480
cmpl $0x0, 0x54d6(%rip)      # 0xb488
jne 0x5fca
movq 0x54dd(%rip), %rdi      # 0xb498
callq 0x6bc0
movl $0x1, 0x54be(%rip)      # 0xb488
movl $0x38, %edi
callq 0x2220
movq %rax, %rbx
movq (%rsp), %rcx
testq %rbx, %rbx
je 0x60de
movq %r14, (%rbx)
movq %r12, 0x8(%rbx)
movl %ebp, 0x10(%rbx)
movq %r13, 0x18(%rbx)
movq %r15, 0x20(%rbx)
movq %rcx, 0x28(%rbx)
movq $0x0, 0x30(%rbx)
leaq 0x146(%rip), %rdi       # 0x614f
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x301c
testl %eax, %eax
je 0x60e0
movq 0x543c(%rip), %rax      # 0xb460
movq 0x543d(%rip), %r14      # 0xb468
cmpq %r14, %rax
jae 0x604b
movq 0x5439(%rip), %rcx      # 0xb470
leaq 0x1(%rax), %rdx
movq %rdx, 0x541e(%rip)      # 0xb460
movq %rbx, (%rcx,%rax,8)
jmp 0x60de
movq 0x5426(%rip), %rax      # 0xb478
shrq $0x8, %rax
cmpq %rax, 0x5423(%rip)      # 0xb480
jbe 0x60cc
testq %r14, %r14
je 0x6130
movq %r14, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x60cc
movq %rax, %r15
movq 0x53ed(%rip), %r12      # 0xb470
shlq $0x3, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x21e0
cmpq 0x53f4(%rip), %r12      # 0xb490
je 0x60a6
movq %r12, %rdi
callq 0x2040
movq %r15, 0x53c3(%rip)      # 0xb470
shlq 0x53b4(%rip)            # 0xb468
movq 0x53a5(%rip), %rax      # 0xb460
leaq 0x1(%rax), %rcx
movq %rcx, 0x539a(%rip)      # 0xb460
movq %rbx, (%r15,%rax,8)
jmp 0x60d4
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x539a(%rip)     # 0xb478
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1914(%rip), %rdi      # 0x7a0d
leaq 0x1919(%rip), %rsi      # 0x7a19
leaq 0x1938(%rip), %rcx      # 0x7a3f
movl $0x76, %edx
callq 0x2160
leaq 0x197c(%rip), %rdi      # 0x7a94
leaq 0x18fa(%rip), %rsi      # 0x7a19
leaq 0x1919(%rip), %rcx      # 0x7a3f
movl $0x79, %edx
callq 0x2160
leaq 0xf89(%rip), %rdi       # 0x70c0
leaq 0xf93(%rip), %rsi       # 0x70d1
leaq 0xfae(%rip), %rcx       # 0x70f3
movl $0x5a, %edx
callq 0x2160