// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/http.c
// Function: http_conn_send
static int http_conn_send(http_conn_t* conn)
{
	stream_t* s = &conn->conn.ws;
	int rsize = stream_rsize(s);
	int nsend;

	if (rsize == 0)
		return 0;

	nsend = SSL_write(conn->ssl, s->array + s->pos, rsize);
	if (nsend <= 0) {
		int err = SSL_get_error(conn->ssl, nsend);
		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;
		s->pos += nsend;
		logv("send %d bytes\n", nsend);
		if (stream_quake(s)) {
			loge("stream_quake() - %s\n",
				conn->tag ? conn->tag : "");
			return -1;
		}
		return nsend;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x2097f
movl $0x0, -0x4(%rbp)
jmp 0x20c31
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rax
addq %rax, %rsi
movl -0x1c(%rbp), %edx
callq 0x3660
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0x20b5b
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
movl -0x20(%rbp), %esi
callq 0x3030
movl %eax, -0x24(%rbp)
cmpl $0x2, -0x24(%rbp)
jne 0x209e1
movq -0x10(%rbp), %rax
movl $0x2, 0x80(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x20c31
cmpl $0x3, -0x24(%rbp)
jne 0x20a01
movq -0x10(%rbp), %rax
movl $0x3, 0x80(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x20c31
movq -0x10(%rbp), %rax
cmpl $0x2, 0x84(%rax)
je 0x20b4f
jmp 0x20a14
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x20a99
movl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x24(%rbp), %edi
callq 0x22270
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
je 0x20a51
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x20a5e
leaq 0x16a8e(%rip), %rax     # 0x374e6
movq %rax, -0x40(%rbp)
jmp 0x20a5e
movq -0x30(%rbp), %r10
movl -0x34(%rbp), %r9d
movq -0x40(%rbp), %rax
movl $0x3, %edi
leaq 0x169a6(%rip), %rsi     # 0x3741c
leaq 0x171ba(%rip), %rdx     # 0x37c37
movl $0x57e, %ecx            # imm = 0x57E
leaq 0x161c9(%rip), %r8      # 0x36c52
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x20a9b
cmpl $0x5, -0x24(%rbp)
jne 0x20b4d
jmp 0x20aa7
callq 0x34c0
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
je 0x20b4b
jmp 0x20aba
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x20b44
movl -0x24(%rbp), %eax
movl %eax, -0x4c(%rbp)
movslq -0x24(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3130
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
je 0x20afc
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x20b09
leaq 0x169e3(%rip), %rax     # 0x374e6
movq %rax, -0x58(%rbp)
jmp 0x20b09
movq -0x48(%rbp), %r10
movl -0x4c(%rbp), %r9d
movq -0x58(%rbp), %rax
movl $0x3, %edi
leaq 0x168fb(%rip), %rsi     # 0x3741c
leaq 0x1710f(%rip), %rdx     # 0x37c37
movl $0x583, %ecx            # imm = 0x583
leaq 0x1611e(%rip), %r8      # 0x36c52
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x20b46
jmp 0x20aa7
jmp 0x20b4d
jmp 0x20b4f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x20c31
movq -0x10(%rbp), %rax
movl $0x0, 0x80(%rax)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movb $0x0, %al
callq 0x242d0
cmpl $0x8, (%rax)
jl 0x20bac
movl -0x20(%rbp), %r9d
movl $0x8, %edi
leaq 0x1688a(%rip), %rsi     # 0x3741c
leaq 0x1709e(%rip), %rdx     # 0x37c37
movl $0x58d, %ecx            # imm = 0x58D
leaq 0x170a1(%rip), %r8      # 0x37c46
movb $0x0, %al
callq 0x243b0
jmp 0x20bae
movq -0x18(%rbp), %rdi
callq 0x2d870
cmpl $0x0, %eax
je 0x20c2b
jmp 0x20bbe
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x20c20
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
je 0x20be9
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x20bf6
leaq 0x168f6(%rip), %rax     # 0x374e6
movq %rax, -0x60(%rbp)
jmp 0x20bf6
movq -0x60(%rbp), %r9
movl $0x3, %edi
leaq 0x16816(%rip), %rsi     # 0x3741c
leaq 0x1702a(%rip), %rdx     # 0x37c37
movl $0x590, %ecx            # imm = 0x590
leaq 0x1703c(%rip), %r8      # 0x37c55
movb $0x0, %al
callq 0x243b0
jmp 0x20c22
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x20c31
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)