// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/socket.c
// Function: lso_doflush
static lso_error_t lso_doflush(struct luasocket *S, int mode) {
	size_t amount = 0, n;
	struct iovec iov;
	int error;

	if (mode & LSO_LINEBUF) {
		if (S->obuf.eol > 0) {
			amount = S->obuf.eol;
		} else if (fifo_rlen(&S->obuf.fifo) >= S->obuf.maxline) {
			amount = S->obuf.maxline;
		}
	} else if (mode & LSO_FULLBUF) {
		amount = fifo_rlen(&S->obuf.fifo);
		amount -= amount % S->obuf.bufsiz;
	} else if (mode & LSO_NOBUF) {
		amount = fifo_rlen(&S->obuf.fifo);
	}

	while (amount) {
		if (!fifo_slice(&S->obuf.fifo, &iov, 0, amount))
			break; /* should never happen */

		if (!(n = so_write(S->socket, iov.iov_base, iov.iov_len, &error)))
			goto error;

		fifo_discard(&S->obuf.fifo, n);
		amount -= n;
		S->obuf.eol -= MIN(S->obuf.eol, n);
	}

	return 0;
error:
	switch (error) {
	case EPIPE:
		S->obuf.eof = 1;

		break;
	} /* switch() */

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1bfa5
movq -0x10(%rbp), %rax
cmpq $0x0, 0x100(%rax)
jbe 0x1bf71
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x1bfa3
movq -0x10(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
callq 0x1c210
movq -0x10(%rbp), %rcx
cmpq 0xb0(%rcx), %rax
jb 0x1bfa1
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x1bfa3
jmp 0x1c00d
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1bfe6
movq -0x10(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
callq 0x1c210
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
xorl %edx, %edx
divq 0xb8(%rcx)
movq -0x20(%rbp), %rax
subq %rdx, %rax
movq %rax, -0x20(%rbp)
jmp 0x1c00b
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1c009
movq -0x10(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
callq 0x1c210
movq %rax, -0x20(%rbp)
jmp 0x1c00b
jmp 0x1c00d
jmp 0x1c00f
cmpq $0x0, -0x20(%rbp)
je 0x1c0dc
movq -0x10(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rcx
leaq -0x38(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1c230
cmpq $0x0, %rax
jne 0x1c045
jmp 0x1c0dc
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0xf430
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x1c06d
jmp 0x1c0e5
movq -0x10(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
movq -0x28(%rbp), %rsi
callq 0x1c340
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
cmpq -0x28(%rbp), %rax
jae 0x1c0b6
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x1c0be
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x100(%rax)
jmp 0x1c00f
movl $0x0, -0x4(%rbp)
jmp 0x1c100
movl -0x3c(%rbp), %eax
subl $0x20, %eax
jne 0x1c0fa
jmp 0x1c0ef
movq -0x10(%rbp), %rax
movb $0x1, 0xf8(%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)