// File: /workspace/github_c_makefile_star2_O0/uhlin[P]enhanced-duc/source/network-openssl.c
// Function: net_ssl_send
int
net_ssl_send(const char *fmt, ...)
{
	char		*buf = NULL;
	char		*bufptr = NULL;
	int		 buflen = 0;
	int		 n_sent = 0;
	size_t		 newSize = 0;
	static const char
			 message_terminate[] = "\r\n\r\n";
	va_list		 ap;

	log_assert_arg_nonnull("net_ssl_send", "fmt", fmt);

	va_start(ap, fmt);
	if (my_vasprintf(&buf, fmt, ap) < 0)
		fatal(errno, "%s: my_vasprintf", __func__);
	va_end(ap);

	newSize = strlen(buf) + nitems(message_terminate);
	buf = xrealloc(buf, newSize);

	if (strlcat(buf, message_terminate, newSize) >= newSize)
		fatal(EOVERFLOW, "%s: strlcat", __func__);
	if (strlen(buf) > INT_MAX) {
		free(buf);
		return -1;
	}

	bufptr = buf;
	buflen = (int) strlen(buf);

	while (buflen > 0) {
		if (ssl == NULL || g_socket == -1)
			break;

		ERR_clear_error();
		const int ret = SSL_write(ssl, bufptr, buflen);

		if (ret > 0) {
			if (BIO_flush(SSL_get_wbio(ssl)) != 1)
				log_debug("%s: error flushing write bio",
				    __func__);
			n_sent += ret;
			bufptr += ret;
			buflen -= ret;
		} else {
			switch (SSL_get_error(ssl, ret)) {
			case SSL_ERROR_NONE:
				fatal(0, "%s: 'SSL_ERROR_NONE' reached "
				    "unexpectedly", __func__);
				break;
			case SSL_ERROR_WANT_READ:
			case SSL_ERROR_WANT_WRITE:
				log_debug("%s: want read / want write", __func__);
				continue;
			}

			free(buf);
			return -1;
		}
	}

	free(buf);
	return (n_sent > 0 ? 0 : -1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
testb %al, %al
je 0x74e1
movaps %xmm0, -0xe0(%rbp)
movaps %xmm1, -0xd0(%rbp)
movaps %xmm2, -0xc0(%rbp)
movaps %xmm3, -0xb0(%rbp)
movaps %xmm4, -0xa0(%rbp)
movaps %xmm5, -0x90(%rbp)
movaps %xmm6, -0x80(%rbp)
movaps %xmm7, -0x70(%rbp)
movq %r9, -0xe8(%rbp)
movq %r8, -0xf0(%rbp)
movq %rcx, -0xf8(%rbp)
movq %rdx, -0x100(%rbp)
movq %rsi, -0x108(%rbp)
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x4ba9(%rip), %rdi      # 0xc0e2
leaq 0x4baf(%rip), %rsi      # 0xc0ef
callq 0x7780
leaq -0x50(%rbp), %rax
leaq -0x110(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x18(%rbp), %rdi
callq 0x7380
cmpl $0x0, %eax
jge 0x759b
callq 0x4050
movl (%rax), %edi
leaq 0x4b66(%rip), %rsi      # 0xc0f3
leaq 0x4b4e(%rip), %rdx      # 0xc0e2
movb $0x0, %al
callq 0x5fa0
leaq -0x50(%rbp), %rax
movq -0x18(%rbp), %rdi
callq 0x41b0
addq $0x5, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xa800
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x4eb4(%rip), %rsi      # 0xc484
callq 0x9e00
cmpq -0x30(%rbp), %rax
jb 0x75f5
movl $0x4b, %edi
leaq 0x4b1d(%rip), %rsi      # 0xc104
leaq 0x4af4(%rip), %rdx      # 0xc0e2
movb $0x0, %al
callq 0x5fa0
movq -0x18(%rbp), %rdi
callq 0x41b0
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jbe 0x761b
movq -0x18(%rbp), %rdi
callq 0x4510
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7767
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x41b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x774b
cmpq $0x0, 0x93af(%rip)      # 0x109f0
je 0x764f
leaq 0x8e5e(%rip), %rax      # 0x104a8
cmpl $-0x1, (%rax)
jne 0x7654
jmp 0x774b
callq 0x45c0
movq 0x9390(%rip), %rdi      # 0x109f0
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x47d0
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jle 0x76d6
movq 0x9374(%rip), %rdi      # 0x109f0
callq 0x4250
movq %rax, %rdi
movl $0xb, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x4100
cmpl $0x1, %eax
je 0x76af
leaq 0x4a6f(%rip), %rdi      # 0xc110
leaq 0x4a3a(%rip), %rsi      # 0xc0e2
movb $0x0, %al
callq 0x6170
movl -0x54(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x54(%rbp), %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x54(%rbp), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
jmp 0x7746
movq 0x9313(%rip), %rdi      # 0x109f0
movl -0x54(%rbp), %esi
callq 0x4040
movl %eax, %ecx
movl %ecx, -0x114(%rbp)
testl %eax, %eax
je 0x7703
jmp 0x76f3
movl -0x114(%rbp), %eax
addl $-0x2, %eax
subl $0x2, %eax
jb 0x771a
jmp 0x7734
xorl %edi, %edi
leaq 0x4a21(%rip), %rsi      # 0xc12d
leaq 0x49cf(%rip), %rdx      # 0xc0e2
movb $0x0, %al
callq 0x5fa0
leaq 0x4a36(%rip), %rdi      # 0xc157
leaq 0x49ba(%rip), %rsi      # 0xc0e2
movb $0x0, %al
callq 0x6170
jmp 0x762f
movq -0x18(%rbp), %rdi
callq 0x4510
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7767
jmp 0x762f
movq -0x18(%rbp), %rdi
callq 0x4510
movl -0x28(%rbp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)