// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/liball/../libcperciva/network/network_write.c
// Function: network_write
void *
network_write(int fd, const uint8_t * buf, size_t buflen, size_t minwrite,
    int (* callback)(void *, ssize_t), void * cookie)
{
	struct network_write_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_write_cookie_malloc()) == NULL)
		goto err0;
	C->callback = callback;
	C->cookie = cookie;
	C->fd = fd;
	C->buf = buf;
	C->buflen = buflen;
	C->minlen = minwrite;
	C->bufpos = 0;

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

	/* Success! */
	return (C);

err1:
	mpool_network_write_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 0x8fc6
js 0x8fe5
movq %r9, %r12
movq %r8, %r14
movq %rdx, %r15
movq %rsi, %r13
movl %edi, %ebp
incq 0x8771(%rip)            # 0x115b0
movq 0x8752(%rip), %rax      # 0x11598
testq %rax, %rax
je 0x8e64
movq 0x8756(%rip), %rsi      # 0x115a8
leaq -0x1(%rax), %rdx
movq %rdx, 0x873b(%rip)      # 0x11598
movq -0x8(%rsi,%rax,8), %rbx
jmp 0x8e9f
movq %rcx, (%rsp)
incq 0x8749(%rip)            # 0x115b8
cmpl $0x0, 0x874a(%rip)      # 0x115c0
jne 0x8e8e
movq 0x8751(%rip), %rdi      # 0x115d0
callq 0xa0d0
movl $0x1, 0x8732(%rip)      # 0x115c0
movl $0x38, %edi
callq 0x2220
movq %rax, %rbx
movq (%rsp), %rcx
testq %rbx, %rbx
je 0x8fb2
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 0x156(%rip), %rdi       # 0x9023
movq %rbx, %rsi
movl %ebp, %edx
movl $0x1, %ecx
callq 0x3190
testl %eax, %eax
je 0x8fb4
movq 0x86ad(%rip), %r12      # 0x11598
movq 0x86ae(%rip), %r13      # 0x115a0
cmpq %r13, %r12
jae 0x8f13
movq 0x86aa(%rip), %rax      # 0x115a8
leaq 0x1(%r12), %rcx
movq %rcx, 0x868e(%rip)      # 0x11598
movq %rbx, (%rax,%r12,8)
jmp 0x8fb2
movq 0x8696(%rip), %rax      # 0x115b0
shrq $0x8, %rax
cmpq %rax, 0x8693(%rip)      # 0x115b8
jbe 0x8fa0
testq %r13, %r13
je 0x9004
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x8fa0
movq %rax, %r14
movq 0x865d(%rip), %r15      # 0x115a8
leaq (,%r13,8), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2200
cmpq 0x8663(%rip), %r15      # 0x115c8
je 0x8f7d
movq %r15, %rdi
callq 0x2040
movq 0x862a(%rip), %r13      # 0x115a0
movq 0x861b(%rip), %r12      # 0x11598
movq %r14, 0x8624(%rip)      # 0x115a8
addq %r13, %r13
movq %r13, 0x8612(%rip)      # 0x115a0
leaq 0x1(%r12), %rax
movq %rax, 0x85fe(%rip)      # 0x11598
movq %rbx, (%r14,%r12,8)
jmp 0x8fa8
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x85fe(%rip)     # 0x115b0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3523(%rip), %rdi      # 0xc4f0
leaq 0x35e7(%rip), %rsi      # 0xc5bb
leaq 0x3607(%rip), %rcx      # 0xc5e2
movl $0x9f, %edx
callq 0x2180
leaq 0x358b(%rip), %rdi      # 0xc577
leaq 0x35c8(%rip), %rsi      # 0xc5bb
leaq 0x35e8(%rip), %rcx      # 0xc5e2
movl $0xa2, %edx
callq 0x2180
leaq 0x20c5(%rip), %rdi      # 0xb0d0
leaq 0x20cf(%rip), %rsi      # 0xb0e1
leaq 0x20ea(%rip), %rcx      # 0xb103
movl $0x5a, %edx
callq 0x2180