// File: /workspace/github_c_makefile_star2_O1/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 0x8f81
js 0x8fa0
movq %r9, %r12
movq %r8, %r14
movq %rdx, %r15
movq %rsi, %r13
movl %edi, %ebp
incq 0x87a9(%rip)            # 0x115b0
movq 0x878a(%rip), %rax      # 0x11598
testq %rax, %rax
je 0x8e2c
movq 0x878e(%rip), %rsi      # 0x115a8
leaq -0x1(%rax), %rdx
movq %rdx, 0x8773(%rip)      # 0x11598
movq -0x8(%rsi,%rax,8), %rbx
jmp 0x8e67
movq %rcx, (%rsp)
incq 0x8781(%rip)            # 0x115b8
cmpl $0x0, 0x8782(%rip)      # 0x115c0
jne 0x8e56
movq 0x8789(%rip), %rdi      # 0x115d0
callq 0xa050
movl $0x1, 0x876a(%rip)      # 0x115c0
movl $0x38, %edi
callq 0x2220
movq %rax, %rbx
movq (%rsp), %rcx
testq %rbx, %rbx
je 0x8f6d
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 0x149(%rip), %rdi       # 0x8fde
movq %rbx, %rsi
movl %ebp, %edx
movl $0x1, %ecx
callq 0x3158
testl %eax, %eax
je 0x8f6f
movq 0x86e5(%rip), %rax      # 0x11598
movq 0x86e6(%rip), %r14      # 0x115a0
cmpq %r14, %rax
jae 0x8eda
movq 0x86e2(%rip), %rcx      # 0x115a8
leaq 0x1(%rax), %rdx
movq %rdx, 0x86c7(%rip)      # 0x11598
movq %rbx, (%rcx,%rax,8)
jmp 0x8f6d
movq 0x86cf(%rip), %rax      # 0x115b0
shrq $0x8, %rax
cmpq %rax, 0x86cc(%rip)      # 0x115b8
jbe 0x8f5b
testq %r14, %r14
je 0x8fbf
movq %r14, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x8f5b
movq %rax, %r15
movq 0x8696(%rip), %r12      # 0x115a8
shlq $0x3, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2200
cmpq 0x869d(%rip), %r12      # 0x115c8
je 0x8f35
movq %r12, %rdi
callq 0x2040
movq %r15, 0x866c(%rip)      # 0x115a8
shlq 0x865d(%rip)            # 0x115a0
movq 0x864e(%rip), %rax      # 0x11598
leaq 0x1(%rax), %rcx
movq %rcx, 0x8643(%rip)      # 0x11598
movq %rbx, (%r15,%rax,8)
jmp 0x8f63
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x8643(%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 0x353a(%rip), %rdi      # 0xc4c2
leaq 0x35fe(%rip), %rsi      # 0xc58d
leaq 0x361e(%rip), %rcx      # 0xc5b4
movl $0x9f, %edx
callq 0x2180
leaq 0x35a2(%rip), %rdi      # 0xc549
leaq 0x35df(%rip), %rsi      # 0xc58d
leaq 0x35ff(%rip), %rcx      # 0xc5b4
movl $0xa2, %edx
callq 0x2180
leaq 0x210a(%rip), %rdi      # 0xb0d0
leaq 0x2114(%rip), %rsi      # 0xb0e1
leaq 0x212f(%rip), %rcx      # 0xb103
movl $0x5a, %edx
callq 0x2180