// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x38(%rdi), %edx
movslq 0x3c(%rdi), %rsi
xorl %ebx, %ebx
cmpl %esi, %edx
jne 0x16cc0
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r14
subl %esi, %edx
movq 0x78(%rdi), %rdi
addq 0x30(%r14), %rsi
callq 0x3650
movl %eax, %ebx
testl %eax, %eax
jle 0x16d89
leaq 0x30(%r14), %r15
movl $0x0, 0x80(%r14)
addl %ebx, 0x3c(%r14)
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x16d24
leaq 0xd026(%rip), %rsi      # 0x23d28
leaq 0xd80f(%rip), %rdx      # 0x24518
leaq 0xd817(%rip), %r8       # 0x24527
movl $0x8, %edi
movl $0x58d, %ecx            # imm = 0x58D
movl %ebx, %r9d
xorl %eax, %eax
callq 0x17d92
movq %r15, %rdi
callq 0x1d6fd
testl %eax, %eax
je 0x16caf
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x16caf
movq 0x128(%r14), %rax
testq %rax, %rax
leaq 0xd098(%rip), %r9       # 0x23df2
cmovneq %rax, %r9
leaq 0xcfc3(%rip), %rsi      # 0x23d28
leaq 0xd7ac(%rip), %rdx      # 0x24518
leaq 0xd7c3(%rip), %r8       # 0x24536
movl $0x3, %edi
movl $0x590, %ecx            # imm = 0x590
xorl %eax, %eax
callq 0x17d92
jmp 0x16caf
movq 0x78(%r14), %rdi
movl %ebx, %esi
callq 0x3030
cmpl $0x3, %eax
je 0x16dad
movl %eax, %ebp
cmpl $0x2, %eax
jne 0x16dbf
movl $0x2, 0x80(%r14)
jmp 0x16db8
movl $0x3, 0x80(%r14)
xorl %ebx, %ebx
jmp 0x16caf
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x2, 0x84(%r14)
je 0x16caf
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x16e2e
movl %ebp, %edi
callq 0x1776e
movq %rax, %r10
movq 0x128(%r14), %rax
testq %rax, %rax
leaq 0xcff9(%rip), %r11      # 0x23df2
cmovneq %rax, %r11
leaq 0xcf24(%rip), %rsi      # 0x23d28
leaq 0xd70d(%rip), %rdx      # 0x24518
leaq 0xc84c(%rip), %r8       # 0x2365e
movl $0x3, %edi
movl $0x57e, %ecx            # imm = 0x57E
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x17d92
addq $0x10, %rsp
cmpl $0x5, %ebp
jne 0x16caf
callq 0x34a0
movq %rax, %rbp
testl %ebp, %ebp
je 0x16caf
leaq 0xceda(%rip), %r15      # 0x23d28
leaq 0xd6c3(%rip), %r12      # 0x24518
leaq 0xc802(%rip), %r13      # 0x2365e
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x16eaf
movslq %ebp, %rdi
xorl %esi, %esi
callq 0x3120
movq %rax, %r10
movq 0x128(%r14), %r11
testq %r11, %r11
leaq 0xcf6c(%rip), %rax      # 0x23df2
cmoveq %rax, %r11
movl $0x3, %edi
movq %r15, %rsi
movq %r12, %rdx
movl $0x583, %ecx            # imm = 0x583
movq %r13, %r8
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x17d92
addq $0x10, %rsp
callq 0x34a0
movq %rax, %rbp
testl %ebp, %ebp
jne 0x16e5c
jmp 0x16caf