// File: /workspace/github_c_makefile_star2_O1/uhlin[P]enhanced-duc/source/network-openssl.c
// Function: net_ssl_recv
int
net_ssl_recv(char *recvbuf, size_t recvbuf_size)
{
	log_assert_arg_nonnull("net_ssl_recv", "recvbuf", recvbuf);

	if (ssl == NULL || g_socket == -1)
		return -1;
	else if (!SSL_pending(ssl)) {
		const int	 maxfdp1 = g_socket + 1;
		fd_set		 readset;
		struct timeval	 tv;

		tv.tv_sec	= 10;
		tv.tv_usec	= 333;

		FD_ZERO(&readset);
		FD_SET(g_socket, &readset);

		errno = 0;

		if (select(maxfdp1, &readset, NULL, NULL, &tv) == -1) {
			log_warn(errno, "%s: select", __func__);
			return -1;
		} else if (!FD_ISSET(g_socket, &readset)) {
			log_warn(0, "%s: no data to receive  --  timed out!",
			    __func__);
			return -1;
		}
	}

	int bytes_received = 0;
	ERR_clear_error();

	if ((bytes_received = SSL_read(ssl, recvbuf, recvbuf_size)) > 0) {
		if (BIO_flush(SSL_get_rbio(ssl)) != 1)
			log_debug("%s: error flushing read bio", __func__);
		return 0;
	}

	switch (SSL_get_error(ssl, bytes_received)) {
	case SSL_ERROR_NONE:
		return 0;
	case SSL_ERROR_WANT_READ:
	case SSL_ERROR_WANT_WRITE:
		log_warn(0, "%s: want read / want write", __func__);
		return 0;
	}

	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
testq %rdi, %rdi
je 0x6a02
movq %rdi, %r14
movq 0x7fa0(%rip), %rdi      # 0xe7e0
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x69ed
leaq 0x7bfa(%rip), %rbp      # 0xe450
cmpl $-0x1, (%rbp)
je 0x69ed
movq %rsi, %rbx
callq 0x4810
testl %eax, %eax
je 0x68d0
callq 0x45f0
movq 0x7f68(%rip), %rdi      # 0xe7e0
movq %r14, %rsi
movl %ebx, %edx
callq 0x4070
movq 0x7f57(%rip), %rdi      # 0xe7e0
testl %eax, %eax
jle 0x6998
callq 0x4600
xorl %r15d, %r15d
movq %rax, %rdi
movl $0xb, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4110
cmpl $0x1, %eax
je 0x69ed
leaq 0x377f(%rip), %rdi      # 0xa039
leaq 0x3731(%rip), %rsi      # 0x9ff2
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x57b1
jmp 0x69ed
movl (%rbp), %ecx
movq %rsp, %rax
movq $0xa, (%rax)
movq $0x14d, 0x8(%rax)       # imm = 0x14D
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r12
movaps %xmm0, (%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x40(%r12)
movaps %xmm0, 0x50(%r12)
movaps %xmm0, 0x60(%r12)
movaps %xmm0, 0x70(%r12)
leal 0x1(%rcx), %r15d
leal 0x3f(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movl %eax, %edx
andl $-0x40, %edx
subl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
sarl $0x6, %eax
cltq
orq %rdx, 0x10(%rsp,%rax,8)
callq 0x4050
movq %rax, %r13
movl $0x0, (%rax)
movl %r15d, %edi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rsp, %r8
callq 0x43d0
cmpl $-0x1, %eax
je 0x69ce
movl (%rbp), %eax
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
movq 0x10(%rsp,%rcx,8), %rcx
btq %rax, %rcx
jb 0x686c
leaq 0x3685(%rip), %rsi      # 0xa012
leaq 0x365e(%rip), %rdx      # 0x9ff2
xorl %edi, %edi
jmp 0x69e0
movl %eax, %esi
callq 0x4040
movl %eax, %r15d
leal -0x2(%r15), %eax
cmpl $0x2, %eax
jae 0x69c7
leaq 0x3625(%rip), %rsi      # 0x9fd7
leaq 0x3639(%rip), %rdx      # 0x9ff2
xorl %r15d, %r15d
xorl %edi, %edi
xorl %eax, %eax
callq 0x591f
jmp 0x69ed
testl %r15d, %r15d
jne 0x69e7
jmp 0x69ed
movl (%r13), %edi
leaq 0x362e(%rip), %rsi      # 0xa007
leaq 0x3612(%rip), %rdx      # 0x9ff2
xorl %eax, %eax
callq 0x591f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x37d2(%rip), %rsi      # 0xa1db
leaq 0x35e2(%rip), %rdx      # 0x9ff2
leaq 0x35e8(%rip), %rcx      # 0x9fff
movl $0x16, %edi
xorl %eax, %eax
callq 0x563c