// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/http.c
// Function: http_conn_recv
static int http_conn_recv(http_conn_t* conn)
{
	stream_t* s = &conn->conn.rs;
	char* buffer;
	int buflen, nread;
	size_t nparsed;

	if (s->cap < 8*1024) {
		if (stream_set_cap(s, 8 * 1024)) {
			return -1;
		}
	}

	buffer = s->array;
	buflen = s->cap;

	nread = SSL_read(conn->ssl, buffer, buflen);

	if (nread <= 0) {
		int err = SSL_get_error(conn->ssl, nread);
		if (err == SSL_ERROR_WANT_READ) {
			conn->ssl_status = SSL_ERROR_WANT_READ;
			return 0;
		}
		else if (err == SSL_ERROR_WANT_WRITE) {
			conn->ssl_status = SSL_ERROR_WANT_WRITE;
			return 0;
		}
		else {
			if (conn->status != HTTP_CONN_ST_IDLE) {
				loge("errno=%d, %s - %s\n",
					err, http_ssl_errstr(err),
					conn->tag ? conn->tag : "");
				if (err == SSL_ERROR_SYSCALL) {
					while ((err = ERR_get_error()) != 0) {
						loge("errno=%d, %s - %s\n",
							err, ERR_error_string(err, NULL),
							conn->tag ? conn->tag : "");
					}
				}
			}
			return -1;
		}
	}
	else {
		conn->ssl_status = 0;

		logv("recv %d bytes\n", nread);

		http_update_expire(conn);

		nparsed = http_parser_execute(&conn->parser, &parser_settings, s->array, nread);

		if (nparsed <= 0) {
			loge("%s - %s\n",
					http_errno_name(conn->parser.http_errno),
					conn->tag ? conn->tag : "");
			return -1;
		}

		return nread;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2000, 0x10(%rax)     # imm = 0x2000
jge 0x21dfd
movq -0x18(%rbp), %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x2d900
cmpl $0x0, %eax
je 0x21dfb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x220f6
jmp 0x21dfd
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x3060
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jg 0x21fe0
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
movl -0x28(%rbp), %esi
callq 0x3030
movl %eax, -0x34(%rbp)
cmpl $0x2, -0x34(%rbp)
jne 0x21e66
movq -0x10(%rbp), %rax
movl $0x2, 0x80(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x220f6
cmpl $0x3, -0x34(%rbp)
jne 0x21e86
movq -0x10(%rbp), %rax
movl $0x3, 0x80(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x220f6
movq -0x10(%rbp), %rax
cmpl $0x2, 0x84(%rax)
je 0x21fd4
jmp 0x21e99
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x21f1e
movl -0x34(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x34(%rbp), %edi
callq 0x22270
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
je 0x21ed6
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x21ee3
leaq 0x15609(%rip), %rax     # 0x374e6
movq %rax, -0x50(%rbp)
jmp 0x21ee3
movq -0x40(%rbp), %r10
movl -0x44(%rbp), %r9d
movq -0x50(%rbp), %rax
movl $0x3, %edi
leaq 0x15521(%rip), %rsi     # 0x3741c
leaq 0x1597b(%rip), %rdx     # 0x3787d
movl $0x5b7, %ecx            # imm = 0x5B7
leaq 0x14d44(%rip), %r8      # 0x36c52
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x21f20
cmpl $0x5, -0x34(%rbp)
jne 0x21fd2
jmp 0x21f2c
callq 0x34c0
movl %eax, -0x34(%rbp)
cmpl $0x0, %eax
je 0x21fd0
jmp 0x21f3f
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x21fc9
movl -0x34(%rbp), %eax
movl %eax, -0x5c(%rbp)
movslq -0x34(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3130
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
je 0x21f81
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x21f8e
leaq 0x1555e(%rip), %rax     # 0x374e6
movq %rax, -0x68(%rbp)
jmp 0x21f8e
movq -0x58(%rbp), %r10
movl -0x5c(%rbp), %r9d
movq -0x68(%rbp), %rax
movl $0x3, %edi
leaq 0x15476(%rip), %rsi     # 0x3741c
leaq 0x158d0(%rip), %rdx     # 0x3787d
movl $0x5bc, %ecx            # imm = 0x5BC
leaq 0x14c99(%rip), %r8      # 0x36c52
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x21fcb
jmp 0x21f2c
jmp 0x21fd2
jmp 0x21fd4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x220f6
movq -0x10(%rbp), %rax
movl $0x0, 0x80(%rax)
movb $0x0, %al
callq 0x242d0
cmpl $0x8, (%rax)
jl 0x22024
movl -0x28(%rbp), %r9d
movl $0x8, %edi
leaq 0x15412(%rip), %rsi     # 0x3741c
leaq 0x1586c(%rip), %rdx     # 0x3787d
movl $0x5c6, %ecx            # imm = 0x5C6
leaq 0x1586f(%rip), %r8      # 0x3788c
movb $0x0, %al
callq 0x243b0
jmp 0x22026
movq -0x10(%rbp), %rdi
callq 0x22360
movq -0x10(%rbp), %rdi
addq $0xb0, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movslq -0x28(%rbp), %rcx
leaq 0x1f9c4(%rip), %rsi     # 0x41a10
callq 0x4820
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
ja 0x220f0
jmp 0x22062
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x220e5
movq -0x10(%rbp), %rax
movl 0xc4(%rax), %edi
shrl $0x18, %edi
andl $0x7f, %edi
callq 0xadd0
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
je 0x220a6
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x220b3
leaq 0x15439(%rip), %rax     # 0x374e6
movq %rax, -0x78(%rbp)
jmp 0x220b3
movq -0x70(%rbp), %r9
movq -0x78(%rbp), %rax
movl $0x3, %edi
leaq 0x15355(%rip), %rsi     # 0x3741c
leaq 0x157af(%rip), %rdx     # 0x3787d
movl $0x5cf, %ecx            # imm = 0x5CF
leaq 0x14b82(%rip), %r8      # 0x36c5c
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x220e7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x220f6
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)