// File: /workspace/github_c_makefile_star2_O2/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 0x157c6
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 0x3660
movl %eax, %ebx
testl %eax, %eax
jle 0x15882
andl $0x0, 0x80(%r14)
leaq 0x30(%r14), %r15
addl %ebx, 0x3c(%r14)
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0x15825
leaq 0xc52f(%rip), %rsi      # 0x21d34
leaq 0xcd18(%rip), %rdx      # 0x22524
leaq 0xcd20(%rip), %r8       # 0x22533
pushq $0x8
popq %rdi
movl $0x58d, %ecx            # imm = 0x58D
movl %ebx, %r9d
xorl %eax, %eax
callq 0x1662e
movq %r15, %rdi
callq 0x1b99d
testl %eax, %eax
je 0x157b5
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %rbx
cmpl $0x3, (%rax)
jl 0x157b5
movq 0x128(%r14), %rax
testq %rax, %rax
leaq 0xc5a9(%rip), %r9       # 0x21dfe
cmovneq %rax, %r9
leaq 0xc4d4(%rip), %rsi      # 0x21d34
leaq 0xccbd(%rip), %rdx      # 0x22524
leaq 0xccd4(%rip), %r8       # 0x22542
pushq $0x3
popq %rdi
movl $0x590, %ecx            # imm = 0x590
xorl %eax, %eax
callq 0x1662e
jmp 0x157b5
movq 0x78(%r14), %rdi
movl %ebx, %esi
callq 0x3030
cmpl $0x3, %eax
je 0x158a6
movl %eax, %ebp
cmpl $0x2, %eax
jne 0x158b8
movl $0x2, 0x80(%r14)
jmp 0x158b1
movl $0x3, 0x80(%r14)
xorl %ebx, %ebx
jmp 0x157b5
pushq $-0x1
popq %rbx
cmpl $0x2, 0x84(%r14)
je 0x157b5
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x15921
movl %ebp, %edi
callq 0x160f0
movq %rax, %r10
movq 0x128(%r14), %rax
testq %rax, %rax
leaq 0xc50e(%rip), %r11      # 0x21dfe
cmovneq %rax, %r11
leaq 0xc439(%rip), %rsi      # 0x21d34
leaq 0xcc22(%rip), %rdx      # 0x22524
leaq 0xbd65(%rip), %r8       # 0x2166e
pushq $0x3
popq %rdi
movl $0x57e, %ecx            # imm = 0x57E
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1662e
popq %rax
popq %rcx
cmpl $0x5, %ebp
jne 0x157b5
leaq 0xcbf3(%rip), %r12      # 0x22524
leaq 0xbd36(%rip), %r13      # 0x2166e
pushq $0x3
popq %rbp
callq 0x34b0
movq %rax, %r15
testl %r15d, %r15d
je 0x157b5
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x1593b
movslq %r15d, %rdi
xorl %esi, %esi
callq 0x3120
movq %rax, %r10
movq 0x128(%r14), %r11
testq %r11, %r11
leaq 0xc488(%rip), %rax      # 0x21dfe
cmoveq %rax, %r11
movl %ebp, %edi
leaq 0xc3b1(%rip), %rsi      # 0x21d34
movq %r12, %rdx
movl $0x583, %ecx            # imm = 0x583
movq %r13, %r8
movl %r15d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1662e
popq %rax
popq %rcx
jmp 0x1593b