// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x4954(%rip), %rdi      # 0xc172
leaq 0x495a(%rip), %rsi      # 0xc17f
callq 0x7780
cmpq $0x0, 0x91be(%rip)      # 0x109f0
je 0x7840
leaq 0x8c6d(%rip), %rax      # 0x104a8
cmpl $-0x1, (%rax)
jne 0x784c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7ab6
movq 0x919d(%rip), %rdi      # 0x109f0
callq 0x47f0
cmpl $0x0, %eax
jne 0x79e1
leaq 0x8c40(%rip), %rax      # 0x104a8
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq $0xa, -0xb0(%rbp)
movq $0x14d, -0xa8(%rbp) # imm = 0x14D
leaq -0xa0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpq $0x10, %rax
jae 0x78d0
movq -0xc0(%rbp), %rax
movl -0xb4(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x789e
jmp 0x78d2
leaq 0x8bcf(%rip), %rax      # 0x104a8
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
leaq 0x8baf(%rip), %rax      # 0x104a8
movl (%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0xa0(%rbp,%rax,8), %rcx
movq %rcx, -0xa0(%rbp,%rax,8)
callq 0x4050
movl $0x0, (%rax)
movl -0x1c(%rbp), %edi
leaq -0xa0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0xb0(%rbp), %r8
movq %rcx, %rdx
callq 0x43c0
cmpl $-0x1, %eax
jne 0x796a
callq 0x4050
movl (%rax), %edi
leaq 0x4837(%rip), %rsi      # 0xc187
leaq 0x481b(%rip), %rdx      # 0xc172
movb $0x0, %al
callq 0x6300
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7ab6
leaq 0x8b37(%rip), %rax      # 0x104a8
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0xa0(%rbp,%rax,8), %rax
movq %rax, -0xd0(%rbp)
leaq 0x8b15(%rip), %rax      # 0x104a8
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xd0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x79dd
xorl %edi, %edi
leaq 0x47cf(%rip), %rsi      # 0xc192
leaq 0x47a8(%rip), %rdx      # 0xc172
movb $0x0, %al
callq 0x6300
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7ab6
jmp 0x79df
jmp 0x79e1
jmp 0x79e3
movl $0x0, -0xc4(%rbp)
callq 0x45c0
movq 0x8ff7(%rip), %rdi      # 0x109f0
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movl %eax, %edx
callq 0x4070
movl %eax, -0xc4(%rbp)
cmpl $0x0, %eax
jle 0x7a56
movq 0x8fd6(%rip), %rdi      # 0x109f0
callq 0x45d0
movq %rax, %rdi
movl $0xb, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x4100
cmpl $0x1, %eax
je 0x7a4d
leaq 0x477a(%rip), %rdi      # 0xc1b9
leaq 0x472c(%rip), %rsi      # 0xc172
movb $0x0, %al
callq 0x6170
movl $0x0, -0x4(%rbp)
jmp 0x7ab6
movq 0x8f93(%rip), %rdi      # 0x109f0
movl -0xc4(%rbp), %esi
callq 0x4040
movl %eax, %ecx
movl %ecx, -0xd4(%rbp)
testl %eax, %eax
je 0x7a86
jmp 0x7a76
movl -0xd4(%rbp), %eax
addl $-0x2, %eax
subl $0x2, %eax
jb 0x7a8f
jmp 0x7aaf
movl $0x0, -0x4(%rbp)
jmp 0x7ab6
xorl %edi, %edi
leaq 0x46bf(%rip), %rsi      # 0xc157
leaq 0x46d3(%rip), %rdx      # 0xc172
movb $0x0, %al
callq 0x6300
movl $0x0, -0x4(%rbp)
jmp 0x7ab6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)