// File: /workspace/github_c_makefile_star2_O3/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 0x60fb
js 0x611a
movq %r9, %r12
movq %r8, %r14
movq %rdx, %r15
movq %rsi, %r13
movl %edi, %ebp
incq 0x5501(%rip)            # 0xb478
movq 0x54e2(%rip), %rax      # 0xb460
testq %rax, %rax
je 0x5f9c
movq 0x54e6(%rip), %rsi      # 0xb470
leaq -0x1(%rax), %rdx
movq %rdx, 0x54cb(%rip)      # 0xb460
movq -0x8(%rsi,%rax,8), %rbx
jmp 0x5fd7
movq %rcx, (%rsp)
incq 0x54d9(%rip)            # 0xb480
cmpl $0x0, 0x54da(%rip)      # 0xb488
jne 0x5fc6
movq 0x54e1(%rip), %rdi      # 0xb498
callq 0x6bf0
movl $0x1, 0x54c2(%rip)      # 0xb488
movl $0x38, %edi
callq 0x2220
movq %rax, %rbx
movq (%rsp), %rcx
testq %rbx, %rbx
je 0x60e7
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 0x153(%rip), %rdi       # 0x6158
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x3038
testl %eax, %eax
je 0x60e9
movq 0x5440(%rip), %r12      # 0xb460
movq 0x5441(%rip), %r13      # 0xb468
cmpq %r13, %r12
jae 0x6048
movq 0x543d(%rip), %rax      # 0xb470
leaq 0x1(%r12), %rcx
movq %rcx, 0x5421(%rip)      # 0xb460
movq %rbx, (%rax,%r12,8)
jmp 0x60e7
movq 0x5429(%rip), %rax      # 0xb478
shrq $0x8, %rax
cmpq %rax, 0x5426(%rip)      # 0xb480
jbe 0x60d5
testq %r13, %r13
je 0x6139
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x60d5
movq %rax, %r14
movq 0x53f0(%rip), %r15      # 0xb470
leaq (,%r13,8), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x21e0
cmpq 0x53f6(%rip), %r15      # 0xb490
je 0x60b2
movq %r15, %rdi
callq 0x2040
movq 0x53bd(%rip), %r13      # 0xb468
movq 0x53ae(%rip), %r12      # 0xb460
movq %r14, 0x53b7(%rip)      # 0xb470
addq %r13, %r13
movq %r13, 0x53a5(%rip)      # 0xb468
leaq 0x1(%r12), %rax
movq %rax, 0x5391(%rip)      # 0xb460
movq %rbx, (%r14,%r12,8)
jmp 0x60dd
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x5391(%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 0x1923(%rip), %rdi      # 0x7a25
leaq 0x1928(%rip), %rsi      # 0x7a31
leaq 0x1947(%rip), %rcx      # 0x7a57
movl $0x76, %edx
callq 0x2160
leaq 0x198b(%rip), %rdi      # 0x7aac
leaq 0x1909(%rip), %rsi      # 0x7a31
leaq 0x1928(%rip), %rcx      # 0x7a57
movl $0x79, %edx
callq 0x2160
leaq 0xf80(%rip), %rdi       # 0x70c0
leaq 0xf8a(%rip), %rsi       # 0x70d1
leaq 0xfa5(%rip), %rcx       # 0x70f3
movl $0x5a, %edx
callq 0x2160