// File: /workspace/github_c_makefile_star2_O3/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 0x1670e
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 0x167d7
leaq 0x30(%r14), %r15
movl $0x0, 0x80(%r14)
addl %ebx, 0x3c(%r14)
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0x16772
leaq 0xd5e4(%rip), %rsi      # 0x23d34
leaq 0xddcd(%rip), %rdx      # 0x24524
leaq 0xddd5(%rip), %r8       # 0x24533
movl $0x8, %edi
movl $0x58d, %ecx            # imm = 0x58D
movl %ebx, %r9d
xorl %eax, %eax
callq 0x1771e
movq %r15, %rdi
callq 0x1cecd
testl %eax, %eax
je 0x166fd
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x166fd
movq 0x128(%r14), %rax
testq %rax, %rax
leaq 0xd656(%rip), %r9       # 0x23dfe
cmovneq %rax, %r9
leaq 0xd581(%rip), %rsi      # 0x23d34
leaq 0xdd6a(%rip), %rdx      # 0x24524
leaq 0xdd81(%rip), %r8       # 0x24542
movl $0x3, %edi
movl $0x590, %ecx            # imm = 0x590
xorl %eax, %eax
callq 0x1771e
jmp 0x166fd
movq 0x78(%r14), %rdi
movl %ebx, %esi
callq 0x3030
cmpl $0x3, %eax
je 0x167fb
movl %eax, %ebp
cmpl $0x2, %eax
jne 0x1680d
movl $0x2, 0x80(%r14)
jmp 0x16806
movl $0x3, 0x80(%r14)
xorl %ebx, %ebx
jmp 0x166fd
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x2, 0x84(%r14)
je 0x166fd
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x1687c
movl %ebp, %edi
callq 0x17106
movq %rax, %r10
movq 0x128(%r14), %rax
testq %rax, %rax
leaq 0xd5b7(%rip), %r11      # 0x23dfe
cmovneq %rax, %r11
leaq 0xd4e2(%rip), %rsi      # 0x23d34
leaq 0xdccb(%rip), %rdx      # 0x24524
leaq 0xce0e(%rip), %r8       # 0x2366e
movl $0x3, %edi
movl $0x57e, %ecx            # imm = 0x57E
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1771e
addq $0x10, %rsp
cmpl $0x5, %ebp
jne 0x166fd
callq 0x34a0
movq %rax, %rbp
testl %ebp, %ebp
je 0x166fd
leaq 0xd498(%rip), %r15      # 0x23d34
leaq 0xdc81(%rip), %r12      # 0x24524
leaq 0xcdc4(%rip), %r13      # 0x2366e
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x168fd
movslq %ebp, %rdi
xorl %esi, %esi
callq 0x3120
movq %rax, %r10
movq 0x128(%r14), %r11
testq %r11, %r11
leaq 0xd52a(%rip), %rax      # 0x23dfe
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 0x1771e
addq $0x10, %rsp
callq 0x34a0
movq %rax, %rbp
testl %ebp, %ebp
jne 0x168aa
jmp 0x166fd