// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/socket.c
// Function: lso_checktodo
static lso_error_t lso_checktodo(struct luasocket *S) {
	int todo, error;

	while ((todo = (S->todo & ~S->done))) {
		if (todo & LSO_DO_FLUSH) {
			so_clear(S->socket);

			if ((error = lso_doflush(S, LSO_NOBUF)))
				return error;

			S->done |= LSO_DO_FLUSH;
		} else if (todo & LSO_DO_STARTTLS) {
			so_clear(S->socket);

			if (!S->tls.once) {
				S->tls.once = 1;

				if (S->ibuf.mode & LSO_PUSHBACK)
					fifo_rvec(&S->ibuf.fifo, &S->tls.config.pushback, 1);

				error = so_starttls(S->socket, &S->tls.config);

				if (S->ibuf.mode & LSO_PUSHBACK) {
					fifo_purge(&S->ibuf.fifo);
					S->ibuf.eom = 0;
				}
			} else {
				error = so_starttls(S->socket, NULL);
			}

			if (S->tls.config.instance) {
				SSL_free(S->tls.config.instance);
				S->tls.config.instance = NULL;
			}

			if (S->tls.config.context) {
				SSL_CTX_free(S->tls.config.context);
				S->tls.config.context = NULL;
			}

			if (error)
				return error;

			S->done |= LSO_DO_STARTTLS;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
je 0x1bf1f
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1bde8
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rdi
callq 0xf8d0
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x1bf30
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
je 0x1bdd6
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1bf26
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x4(%rax)
jmp 0x1bf1a
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1bf18
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rdi
callq 0xf8d0
movq -0x10(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x1be9e
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x1be52
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
addq $0x8, %rsi
addq $0x18, %rsi
movl $0x1, %edx
callq 0x1c110
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
addq $0x8, %rsi
callq 0x10600
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x1be9c
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
callq 0x1c1c0
movq -0x10(%rbp), %rax
movb $0x0, 0x91(%rax)
jmp 0x1beb5
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10600
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1bed9
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0xf7f0
movq -0x10(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x1befd
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xf100
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
cmpl $0x0, -0x18(%rbp)
je 0x1bf0b
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1bf26
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x4(%rax)
jmp 0x1bf1a
jmp 0x1bd7c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop