// File: /workspace/github_c_makefile_star2_O0/tomka[P]cliaspora/ssl.c
// Function: ssl_write
int
ssl_write(ssl_conn_t *cp, const void *buf, size_t size)
{
	int	       n, ec;
	fd_set	       wset;
	struct timeval tv;

	for (n = -1; n < 0;) {
		tv.tv_sec = 20; tv.tv_usec = 0;
		FD_ZERO(&wset); FD_SET(cp->sock, &wset);
		while (select(cp->sock + 1, NULL, &wset, NULL, &tv) == -1) {
			if (errno != EINTR) {
				warn("ssl_write(): select()");
				return (-1);
			}
		}
		if (!FD_ISSET(cp->sock, &wset)) {
			warnx("ssl_write(): Timeout");
			return (TIMEOUT);
		}
		if ((n = SSL_write(cp->handle, buf, size)) < 0) {
			switch ((ec = SSL_get_error(cp->handle, n))) {
			case SSL_ERROR_WANT_READ:
			case SSL_ERROR_WANT_WRITE:
				/* FALLTHROUGH */
				break;
			default:
				if (errno != 0) {
					warn("SSL_write() returned with %d," \
					     "SSL-error code %d", n, ec);
				} else {
					warnx("SSL_write() returned with %d," \
					      "SSL-error code %d", n, ec);
				}
				ERR_print_errors_fp(stderr);
				return (-1);
			}
		}
	}
	if (n == 0)
		cp->state = SSL_STATE_DISCONNECTED;
	return (n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
cmpl $0x0, -0x24(%rbp)
jge 0xa75f
movq $0x14, -0xb8(%rbp)
movq $0x0, -0xb0(%rbp)
leaq -0xa8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0x0, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpq $0x10, %rax
jae 0xa5d8
movq -0xc8(%rbp), %rax
movl -0xbc(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0xa5a6
jmp 0xa5da
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0xa8(%rbp,%rax,8), %rcx
movq %rcx, -0xa8(%rbp,%rax,8)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edi
addl $0x1, %edi
xorl %eax, %eax
movl %eax, %ecx
leaq -0xa8(%rbp), %rdx
leaq -0xb8(%rbp), %r8
movq %rcx, %rsi
callq 0x2290
cmpl $-0x1, %eax
jne 0xa668
callq 0x2060
cmpl $0x4, (%rax)
je 0xa666
leaq 0x50c2(%rip), %rdi      # 0xf715
movb $0x0, %al
callq 0x2120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa776
jmp 0xa619
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0xa8(%rbp,%rax,8), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xd0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0xa6ce
leaq 0x5070(%rip), %rdi      # 0xf72b
movb $0x0, %al
callq 0x22f0
movl $0x0, -0x4(%rbp)
jmp 0xa776
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
callq 0x25b0
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
jge 0xa75a
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movl -0x24(%rbp), %esi
callq 0x2040
movl %eax, -0x28(%rbp)
addl $-0x2, %eax
subl $0x1, %eax
ja 0xa70c
jmp 0xa70a
jmp 0xa758
callq 0x2060
cmpl $0x0, (%rax)
je 0xa72c
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
leaq 0x501d(%rip), %rdi      # 0xf740
movb $0x0, %al
callq 0x2120
jmp 0xa740
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
leaq 0x5007(%rip), %rdi      # 0xf740
movb $0x0, %al
callq 0x22f0
movq 0x7891(%rip), %rax      # 0x11fd8
movq (%rax), %rdi
callq 0x21c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa776
jmp 0xa75a
jmp 0xa56e
cmpl $0x0, -0x24(%rbp)
jne 0xa770
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)