LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_rstfl
int so_rstfl(int fd, int *oflags, int flags, int mask, int require) {
	const struct flops *f;
	int error;

	for (f = fltable; f < endof(fltable); f++) {
		if (!(f->flag & mask))
			continue;

		if ((error = f->set(fd, !!(f->flag & flags)))) {
			if ((f->flag & require) || error != EOPNOTSUPP)
				return error;

			*oflags &= ~f->flag;
		} else {
			*oflags &= ~f->flag;
			*oflags |= (f->flag & flags);
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0xc(%rsp)
movl %ecx, %ebp
movl %edx, 0x14(%rsp)
movq %rsi, %r15
movl %edi, 0x10(%rsp)
xorl %r13d, %r13d
leaq 0x23a0b(%rip), %rbx     # 0x44620
cmpq $0xef, %r13
ja 0x20c68
movl (%r13,%rbx), %r14d
testl %ebp, %r14d
je 0x20c62
xorl %esi, %esi
movl %r14d, %r12d
andl 0x14(%rsp), %r12d
setne %sil
movl 0x10(%rsp), %edi
callq *0x8(%r13,%rbx)
movl %r14d, %ecx
notl %ecx
testl %eax, %eax
je 0x20c59
testl %r14d, 0xc(%rsp)
jne 0x20c6a
cmpl $0x5f, %eax
jne 0x20c6a
andl (%r15), %ecx
jmp 0x20c5f
andl (%r15), %ecx
orl %r12d, %ecx
movl %ecx, (%r15)
addq $0x18, %r13
jmp 0x20c15
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_open
struct socket *(so_open)(const char *host, const char *port, int qtype, int domain, int type, const struct so_options *opts, int *error_) {
	_Bool isnumeric = sa_isnumeric(host);
	struct dns_resolver *res = NULL;
	struct addrinfo hints;
	struct socket *so;
	int error;

	if (!(so = so_make(opts, &error)))
		goto error;

	/*
	 * Copy host name as TLS server host name.
	 *
	 * NOTE: All the TLS RFCs (from RFC 3546 to RFC 6066)
	 * declare
	 *
	 *      Literal IPv4 and IPv6 addresses are not permitted in
	 *      "HostName".
	 *
	 * If the caller wants to send the IP address as the TLS
	 * server host name, they can set .tls_hostname explicitly.
	 */
	if (so->opts.tls_sendname == SO_OPTS_TLS_HOSTNAME && !isnumeric) {
		if (!(so->opts.tls_sendname = strdup(host)))
			goto syerr;
	}

	memset(&hints, 0, sizeof hints);

	hints.ai_flags    = AI_CANONNAME;
	hints.ai_family   = domain;
	hints.ai_socktype = type;

	if (isnumeric) {
		hints.ai_flags |= AI_NUMERICHOST;
	} else {
		struct dns_options *opts = dns_opts();

		opts->closefd.arg = so->opts.fd_close.arg;
		opts->closefd.cb = so->opts.fd_close.cb;

		if (!(res = dns_res_stub(opts, &error)))
			goto error;
	}

	if (!(so->res = dns_ai_open(host, port, qtype, &hints, res, &error)))
		goto error;

	so->todo = SO_S_GETADDR | SO_S_SOCKET | SO_S_BIND;

	dns_res_close(res);

	return so;
syerr:
	error = so_syerr();
error:
	dns_res_close(res);

	so_close(so);

	*error_ = error;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, %rbx
movl %r8d, %r13d
movl %ecx, %ebp
movl %edx, 0x4(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
xorl %r12d, %r12d
leaq 0x10(%rsp), %rdi
movl $0x80, %esi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x10310
movq %rax, %r14
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x20dfb
movq %rax, %rbx
testq %rax, %rax
je 0x20dc6
testq %r14, %r14
jne 0x20d26
cmpq $0x1, 0x40(%rbx)
jne 0x20d26
movq %r15, %rdi
callq 0x10970
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x20db9
andq $0x0, 0x38(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsp)
movups %xmm0, 0x28(%rsp)
movl $0x2, 0x10(%rsp)
movl %ebp, 0x14(%rsp)
movl %r13d, 0x18(%rsp)
testq %r14, %r14
je 0x20d5c
movl $0x6, 0x10(%rsp)
xorl %r12d, %r12d
jmp 0x20d80
leaq 0x90(%rsp), %rdi
andq $0x0, 0x10(%rdi)
movups 0x28(%rbx), %xmm0
movaps %xmm0, (%rdi)
movq %rsp, %rsi
callq 0xf880
movq %rax, %r12
testq %rax, %rax
je 0x20dc3
leaq 0x10(%rsp), %rcx
movq %rsp, %r9
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movl 0x4(%rsp), %edx
movq %r12, %r8
callq 0xfd90
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0x20dc6
movl $0xe, 0xb8(%rbx)
movq %r12, %rdi
callq 0xfe70
jmp 0x20de6
callq 0xf0a0
movl (%rax), %eax
movl %eax, (%rsp)
xorl %r12d, %r12d
movq 0xe0(%rsp), %r14
movq %r12, %rdi
callq 0xfe70
movq %rbx, %rdi
callq 0xf440
movl (%rsp), %eax
movl %eax, (%r14)
xorl %ebx, %ebx
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_make
static struct socket *so_make(const struct so_options *opts, int *error) {
	static const struct socket so_initializer = {
		.fd = -1,
		.domain = PF_UNSPEC,
		.cred = { (pid_t)-1, (uid_t)-1, (gid_t)-1, }
	};
	struct socket *so;
	size_t len;

	if (!(so = malloc(sizeof *so)))
		goto syerr;

	*so = so_initializer;
	so->opts = *opts;

	if (opts->sa_bind) {
		if (!(len = sa_len((void *)opts->sa_bind))) {
			*error = EAFNOSUPPORT;
			goto error;
		}

		if (!(so->opts.sa_bind = malloc(len)))
			goto syerr;

		memcpy((void *)so->opts.sa_bind, opts->sa_bind, len);
	}

	if (opts->tls_sendname && opts->tls_sendname != SO_OPTS_TLS_HOSTNAME) {
		if (!(so->opts.tls_sendname = strdup(opts->tls_sendname)))
			goto syerr;
	}

	return so;
syerr:
	*error = so_syerr();
error:
	if (so) {
		if (so->opts.tls_sendname != opts->tls_sendname)
			free((void *)so->opts.tls_sendname);

		if (so->opts.sa_bind != opts->sa_bind)
			free((void *)so->opts.sa_bind);

		free(so);
	}

	return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %r14
movl $0x220, %edi            # imm = 0x220
callq 0x101a0
testq %rax, %rax
je 0x20e92
movq %rax, %rbx
leaq 0x1079d(%rip), %rsi     # 0x315c0
movl $0x220, %edx            # imm = 0x220
movq %rax, %rdi
callq 0xfad0
pushq $0xa
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq (%r14), %r12
testq %r12, %r12
je 0x20e71
movq %r12, %rdi
callq 0x2048c
testl %eax, %eax
je 0x20e9e
movl %eax, %r13d
movq %r13, %rdi
callq 0x101a0
movq %rax, (%rbx)
testq %rax, %rax
je 0x20e89
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xfad0
movq 0x40(%r14), %rdi
cmpq $0x2, %rdi
jb 0x20ecd
callq 0x10970
movq %rax, 0x40(%rbx)
testq %rax, %rax
jne 0x20ecd
callq 0xf0a0
movl (%rax), %eax
jmp 0x20ea1
callq 0xf0a0
movl (%rax), %eax
movl %eax, (%r15)
jmp 0x20ecb
pushq $0x61
popq %rax
movl %eax, (%r15)
movq 0x40(%rbx), %rdi
cmpq 0x40(%r14), %rdi
je 0x20eb6
callq 0xffc0
movq (%r14), %r12
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x20ec3
callq 0xffc0
movq %rbx, %rdi
callq 0xffc0
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_close
int so_close(struct socket *so) {
	if (!so)
		return EINVAL;

	so_destroy(so);

	free(so);

	return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x20f46
pushq %rbx
movq %rdi, %rbx
callq 0x21e06
movq 0x50(%rbx), %rdi
callq 0xffe0
andq $0x0, 0x50(%rbx)
movq 0xa8(%rbx), %rdi
callq 0xffc0
andq $0x0, 0xa8(%rbx)
leaq 0x58(%rbx), %rdi
movq %rbx, %rsi
callq 0xf2c0
andw $0x0, 0xb0(%rbx)
movq 0x40(%rbx), %rdi
cmpq $0x2, %rdi
jb 0x20f32
callq 0xffc0
andq $0x0, 0x40(%rbx)
movq (%rbx), %rdi
callq 0xffc0
movq %rbx, %rdi
callq 0xffc0
xorl %eax, %eax
popq %rbx
retq
pushq $0x16
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_dial
struct socket *so_dial(const struct sockaddr *sa, int type, const struct so_options *opts, int *error_) {
	struct { struct addrinfo ai; struct sockaddr_storage ss; } *host;
	struct socket *so;
	int error;

	if (!(so = so_make(opts, &error)))
		goto error;

	if (!(host = malloc(sizeof *host)))
		goto syerr;

	memset(&host->ai, 0, sizeof host->ai);
	memcpy(&host->ss, sa, SO_MIN(af_len(sa->sa_family), sizeof host->ss));

	so->host = &host->ai;
	so->host->ai_family = sa->sa_family;
	so->host->ai_socktype = type;
	so->host->ai_protocol = 0;
	so->host->ai_addrlen = af_len(sa->sa_family);
	so->host->ai_addr = (struct sockaddr *)&host->ss;

	so->todo = SO_S_SOCKET | SO_S_BIND;

	return so;
syerr:
	error = so_syerr();
error:
	so_close(so);

	*error_ = error;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %r15
movl %esi, %ebp
movq %rdi, %r12
leaq 0xc(%rsp), %r14
movq %rdx, %rdi
movq %r14, %rsi
callq 0x20dfb
movq %rax, %rbx
testq %rax, %rax
je 0x20fd0
movl $0xb0, %edi
callq 0x101a0
testq %rax, %rax
je 0x20fc8
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rax, %r15
addq $0x30, %r15
movzwl (%r12), %eax
cmpl $0x1, %eax
je 0x21004
cmpl $0xa, %eax
je 0x20fe2
cmpl $0x2, %eax
jne 0x21021
movups (%r12), %xmm0
movups %xmm0, (%r15)
movq %r14, 0xa8(%rbx)
pushq $0x10
popq %rcx
pushq $0x2
jmp 0x2101e
callq 0xf0a0
movq %rax, %r14
movl (%r14), %ebp
movq %rbx, %rdi
callq 0xf440
movl %ebp, (%r15)
xorl %ebx, %ebx
jmp 0x21044
movups (%r12), %xmm0
movups 0xc(%r12), %xmm1
movups %xmm1, 0xc(%r15)
movups %xmm0, (%r15)
movq %r14, 0xa8(%rbx)
pushq $0x1c
popq %rcx
pushq $0xa
jmp 0x2101e
pushq $0x6e
popq %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0xfad0
movq %r14, 0xa8(%rbx)
pushq $0x6e
popq %rcx
pushq $0x1
popq %rax
jmp 0x2102a
movq %r14, 0xa8(%rbx)
xorl %ecx, %ecx
movl %eax, 0x4(%r14)
movl %ebp, 0x8(%r14)
movl %ecx, 0x10(%r14)
movq %r15, 0x18(%r14)
movl $0xc, 0xb8(%rbx)
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_fdopen
struct socket *so_fdopen(int fd, const struct so_options *opts, int *error_) {
	struct socket *so;
	int flags, mask, need, error;

	if (!(so = so_make(opts, &error)))
		goto error;

	if ((error = so_ftype(fd, &so->mode, &so->domain, &so->type, &so->protocol)))
		goto error;

	flags = so_opts2flags(opts, &mask);
	mask &= so_type2mask(so->mode, so->domain, so->type, so->protocol);
	need = ~(SO_F_NODELAY|SO_F_NOPUSH|SO_F_NOSIGPIPE|SO_F_OOBINLINE);

	if ((error = so_rstfl(fd, &so->flags, flags, mask, need)))
		goto error;

	so->fd = fd;

	return so;
error:
	so_close(so);

	*error_ = error;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %ebp
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x20dfb
movq %rax, %r14
testq %rax, %rax
je 0x210e6
leaq 0x5c(%r14), %rsi
leaq 0x60(%r14), %rdx
leaq 0x64(%r14), %rcx
leaq 0x68(%r14), %r8
movl %ebp, %edi
callq 0x2110f
testl %eax, %eax
jne 0x210e1
leaq 0xc(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2077a
movl %eax, %r15d
movl 0x5c(%r14), %edi
movl 0x60(%r14), %esi
movl 0x64(%r14), %edx
movl 0x68(%r14), %ecx
callq 0x207d9
andl (%r12), %eax
movq %r14, %rsi
addq $0x6c, %rsi
movl %ebp, %edi
movl %r15d, %edx
movl %eax, %ecx
movl $0xfffffd1f, %r8d       # imm = 0xFFFFFD1F
callq 0x10a50
testl %eax, %eax
je 0x21109
movl %eax, %r12d
jmp 0x210eb
movl 0x8(%rsp), %r12d
movq %r14, %rdi
callq 0xf440
movl %r12d, (%rbx)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, 0x58(%r14)
jmp 0x210f9
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_ftype
static so_error_t so_ftype(int fd, mode_t *mode, int *domain, int *type, int *protocol) {
	struct stat st;
	int error;

	if (0 != fstat(fd, &st))
		return errno;

	*mode = S_IFMT & st.st_mode;

	if (!S_ISSOCK(*mode))
		return 0;

#if defined SO_DOMAIN
	if (0 != getsockopt(fd, SOL_SOCKET, SO_DOMAIN, domain, &(socklen_t){ sizeof *domain })) {
		if (errno != ENOPROTOOPT)
			return errno;

		if ((error = so_ffamily(fd, domain)))
			return error;
	}
#else
	if ((error = so_ffamily(fd, domain)))
		return error;
#endif

	if (0 != getsockopt(fd, SOL_SOCKET, SO_TYPE, type, &(socklen_t){ sizeof *type }))
		return errno;

#if defined SO_PROTOCOL
	if (0 != getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, protocol, &(socklen_t){ sizeof *protocol })) {
		if (errno != ENOPROTOOPT)
			return errno;
	}
#else
	(void)protocol;
#endif

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movl %edi, %ebp
leaq 0x90(%rsp), %rsi
callq 0x10790
testl %eax, %eax
je 0x21149
callq 0xf0a0
movl (%rax), %eax
jmp 0x21213
movl $0xf000, %ecx           # imm = 0xF000
andl 0xa8(%rsp), %ecx
movl %ecx, (%r12)
xorl %eax, %eax
cmpl $0xc000, %ecx           # imm = 0xC000
jne 0x21213
leaq 0x8(%rsp), %r8
movl $0x4, (%r8)
pushq $0x1
popq %rsi
pushq $0x27
popq %rdx
movl %ebp, %edi
movq %r15, %rcx
callq 0xf9f0
testl %eax, %eax
je 0x211c3
callq 0xf0a0
movq %rax, %r12
movl (%rax), %eax
cmpl $0x5c, %eax
jne 0x21213
leaq 0xc(%rsp), %rdx
movl $0x80, (%rdx)
leaq 0x10(%rsp), %rsi
movl %ebp, %edi
callq 0xfcb0
testl %eax, %eax
je 0x211bb
movl (%r12), %eax
testl %eax, %eax
jne 0x21213
jmp 0x211c3
movzwl 0x10(%rsp), %eax
movl %eax, (%r15)
leaq 0x4(%rsp), %r8
movl $0x4, (%r8)
pushq $0x1
popq %rsi
pushq $0x3
popq %rdx
movl %ebp, %edi
movq %r14, %rcx
callq 0xf9f0
testl %eax, %eax
jne 0x2113d
movq %rsp, %r8
movl $0x4, (%r8)
pushq $0x1
popq %rsi
pushq $0x26
popq %rdx
movl %ebp, %edi
movq %rbx, %rcx
callq 0xf9f0
testl %eax, %eax
je 0x21211
callq 0xf0a0
movl (%rax), %eax
cmpl $0x5c, %eax
jne 0x21213
xorl %eax, %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_family
int so_family(struct socket *so, int *error_) {
	struct sockaddr_storage saddr;
	socklen_t slen = sizeof saddr;
	int error;

	if ((error = so_localaddr(so, (void *)&saddr, &slen)))
		{ *error_ = error; return AF_UNSPEC; }

	return *sa_family(&saddr);
}

// Assembly:
pushq %rbx
subq $0x90, %rsp
movq %rsi, %rbx
leaq 0xc(%rsp), %rdx
movl $0x80, (%rdx)
leaq 0x10(%rsp), %rsi
callq 0x10140
testl %eax, %eax
je 0x2124d
movl %eax, (%rbx)
xorl %eax, %eax
jmp 0x21252
movzwl 0x10(%rsp), %eax
addq $0x90, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_localaddr
int so_localaddr(struct socket *so, void *saddr, socklen_t *slen) {
	int error;

	if ((so_state(so) < SO_S_STARTTLS) && (error = so_exec(so)))
		return error;

	if (0 != getsockname(so->fd, saddr, slen))
		return errno;

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x212a3
cmpl $0x3f, %eax
jg 0x2127f
movq %r15, %rdi
callq 0x212cb
testl %eax, %eax
jne 0x2129d
movl 0x58(%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xfcb0
testl %eax, %eax
je 0x2129b
callq 0xf0a0
movl (%rax), %eax
jmp 0x2129d
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_state
static inline int so_state(const struct socket *so) {
	if (so->todo & ~so->done) {
		int i = 1;

		while (i < SO_S_END && !(i & (so->todo & ~so->done)))
			i <<= 1;

		return (i < SO_S_END)? i : 0;
	} else
		return 0;
}

// Assembly:
movl 0xb4(%rdi), %ecx
notl %ecx
xorl %eax, %eax
andl 0xb8(%rdi), %ecx
je 0x212ca
pushq $0x1
popq %rdx
cmpl $0x800, %edx            # imm = 0x800
jg 0x212ca
testl %ecx, %edx
jne 0x212c8
addl %edx, %edx
jmp 0x212b8
movl %edx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_remoteaddr
int so_remoteaddr(struct socket *so, void *saddr, socklen_t *slen) {
	int error;

	if ((so_state(so) < SO_S_STARTTLS) && (error = so_exec(so)))
		return error;

	if (0 != getpeername(so->fd, saddr, slen))
		return errno;

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x212a3
cmpl $0x3f, %eax
jg 0x21ad0
movq %r15, %rdi
callq 0x212cb
testl %eax, %eax
jne 0x21aee
movl 0x58(%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xf9c0
testl %eax, %eax
je 0x21aec
callq 0xf0a0
movl (%rax), %eax
jmp 0x21aee
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_resetssl
static void so_resetssl(struct socket *so) {
	ssl_discard(&so->ssl.ctx);
	so->ssl.state  = 0;
	so->ssl.error  = 0;
	so->ssl.accept = 0;
	so->ssl.vrfd   = 0;

	if (so->bio.ctx) {
		BIO_free(so->bio.ctx);
		so->bio.ctx = NULL;
	}

	free(so->bio.ahead.data);
	so->bio.ahead.data = NULL;
	so->bio.ahead.p = NULL;
	so->bio.ahead.pe = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xc8(%rdi), %r14
movq 0xc8(%rdi), %rdi
testq %rdi, %rdi
je 0x21e25
callq 0xf7b0
andw $0x0, 0x10(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq 0xe0(%rbx), %rdi
testq %rdi, %rdi
je 0x21e4b
callq 0xfe20
andq $0x0, 0xe0(%rbx)
movq 0xf0(%rbx), %rdi
callq 0xffc0
xorps %xmm0, %xmm0
movups %xmm0, 0xf0(%rbx)
andq $0x0, 0x100(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_read
size_t so_read(struct socket *so, void *dst, size_t lim, int *error_) {
	size_t len;
	int error;

	so_pipeign(so, 1);

	so->todo |= SO_S_SETREAD;

	if ((error = so_exec(so)))
		goto error;

	if (so->fd == -1) {
		error = ENOTCONN;
		goto error;
	}

	so->events &= ~POLLIN;
retry:
	if (so->ssl.ctx) {
		int n;

		ERR_clear_error();

		if ((n = SSL_read(so->ssl.ctx, dst, SO_MIN(lim, INT_MAX))) < 0) {
			if (SO_EINTR == (error = ssl_error(so->ssl.ctx, n, &so->events)))
				goto retry;
			goto error;
		} else if (n == 0) {
			error = EPIPE; /* FIXME: differentiate clean from unclean shutdown? */
			so->st.rcvd.eof = 1;
			goto error;
		}

		len = n;
	} else {
		if (!(len = so_sysread(so, dst, lim, &error)))
			goto error;
	}

	so_trace(SO_T_READ, so->fd, so->host, dst, (size_t)len, "rcvd %zu bytes", (size_t)len);
	st_update(&so->st.rcvd, len, &so->opts);

	so_pipeok(so, 1);

	return len;
error:
	*error_ = error;

	if (error != SO_EAGAIN)
		so_trace(SO_T_READ, so->fd, so->host, (void *)0, (size_t)0, "%s", so_strerror(error));

	so_pipeok(so, 1);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
pushq $0x1
popq %rsi
callq 0x22031
orb $-0x80, 0xb8(%rbx)
movq %rbx, %rdi
callq 0x212cb
testl %eax, %eax
je 0x21ee2
movl %eax, (%r14)
cmpl $0xb, %eax
jne 0x21f62
xorl %r12d, %r12d
jmp 0x21f95
cmpl $-0x1, 0x58(%rbx)
je 0x21f5c
movq %r14, 0x8(%rsp)
andb $-0x2, 0xb0(%rbx)
leaq 0xb0(%rbx), %r13
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpq %rbp, %r12
cmovbq %r12, %rbp
xorl %edx, %edx
pushq $0x4
popq %r14
cmpq $0x0, 0xc8(%rbx)
je 0x21fb2
callq 0x101c0
movq 0xc8(%rbx), %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0xf0d0
testl %eax, %eax
jns 0x21fdd
movq 0xc8(%rbx), %rdi
movl %eax, %esi
movq %r13, %rdx
callq 0x220bf
movl %r14d, %edx
cmpl $0x4, %eax
je 0x21f0d
movq 0x8(%rsp), %r14
jmp 0x21ece
pushq $0x6b
popq %rax
movl %eax, (%r14)
movl 0x58(%rbx), %ebp
movq 0xa8(%rbx), %r14
movl %eax, %edi
callq 0xfc60
movq %rax, (%rsp)
leaq 0xefcf(%rip), %r9       # 0x30f4d
xorl %r12d, %r12d
pushq $0x2
popq %rdi
movl %ebp, %esi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x221bb
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x22633
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14(%rsp), %rcx
movl %edx, (%rcx)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2213e
movq %rax, %r12
testq %rax, %rax
movq 0x8(%rsp), %r14
jne 0x21fe7
movl 0x14(%rsp), %eax
jmp 0x21ece
movq 0x8(%rsp), %r14
je 0x22023
movl %eax, %r12d
movl 0x58(%rbx), %esi
movq 0xa8(%rbx), %rdx
movq %r12, (%rsp)
leaq 0xf93a(%rip), %r9       # 0x31936
pushq $0x2
popq %rdi
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x221bb
leaq 0x88(%rbx), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x22616
jmp 0x21f95
movb $0x1, 0x90(%rbx)
pushq $0x20
jmp 0x21f5e
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_pipeign
static int so_pipeign(struct socket *so, _Bool rdonly) {
	if (!so_needign(so, rdonly))
		return 0;

#if _POSIX_REALTIME_SIGNALS > 0
	if (so->pipeign.ncalls++ > 0)
		return 0;

	sigemptyset(&so->pipeign.pending);
	sigpending(&so->pipeign.pending);

	if (sigismember(&so->pipeign.pending, SIGPIPE))
		return 0;

	sigset_t piped;
	sigemptyset(&piped);
	sigaddset(&piped, SIGPIPE);
	sigemptyset(&so->pipeign.blocked);

	return thr_sigmask(SIG_BLOCK, &piped, &so->pipeign.blocked);
#else
	return EOPNOTSUPP;
#endif
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
callq 0x23140
testb %al, %al
je 0x220b4
movl 0x108(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x108(%rbx)
testl %eax, %eax
jg 0x220b4
leaq 0x110(%rbx), %r14
movq %r14, %rdi
callq 0x100a0
movq %r14, %rdi
callq 0xf320
pushq $0xd
popq %rsi
movq %r14, %rdi
callq 0xf650
testl %eax, %eax
jne 0x220b4
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x100a0
pushq $0xd
popq %rsi
movq %r14, %rdi
callq 0x10570
addq $0x190, %rbx            # imm = 0x190
movq %rbx, %rdi
callq 0x100a0
xorl %edi, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xf360
addq $0x88, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: ssl_error
static int ssl_error(SSL *ctx, int rval, short *events) {
	unsigned long code;

	switch (SSL_get_error(ctx, rval)) {
	case SSL_ERROR_ZERO_RETURN:
		return SO_ECLOSURE;
	case SSL_ERROR_WANT_READ:
		*events |= POLLIN;

		return SO_EAGAIN;
	case SSL_ERROR_WANT_WRITE:
		*events |= POLLOUT;

		return SO_EAGAIN;
	case SSL_ERROR_WANT_CONNECT:
		*events |= POLLOUT;

		return SO_EAGAIN;
	case SSL_ERROR_WANT_ACCEPT:
		*events |= POLLIN;

		return SO_EAGAIN;
	case SSL_ERROR_WANT_X509_LOOKUP:
		return SO_EX509INT;
	case SSL_ERROR_SYSCALL:
		if ((code = ERR_peek_last_error()))
			return SO_EOPENSSL;
		else if (rval == 0)
			return ECONNRESET;
		else if (rval == -1 && so_soerr() && so_soerr() != SO_EAGAIN)
			return so_soerr();
		else
			return SO_EOPENSSL;
	case SSL_ERROR_SSL:
		/* FALL THROUGH */
	default:
		return SO_EOPENSSL;
	} /* switch(SSL_get_error()) */
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %ebx
callq 0xf070
addl $-0x2, %eax
cmpl $0x6, %eax
ja 0x2212d
leaq 0xf4a4(%rip), %rcx      # 0x31580
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
orb $0x1, (%r14)
jmp 0x220ef
orb $0x4, (%r14)
pushq $0xb
popq %rax
jmp 0x22132
movl $0x8c9c94ca, %eax       # imm = 0x8C9C94CA
jmp 0x22132
movl $0x8c9c94c8, %eax       # imm = 0x8C9C94C8
jmp 0x22132
callq 0xf090
movq %rax, %rcx
movl $0x8c9c94c7, %eax       # imm = 0x8C9C94C7
testq %rcx, %rcx
jne 0x22132
testl %ebx, %ebx
je 0x2213a
cmpl $-0x1, %ebx
jne 0x2212d
callq 0xf0a0
movl (%rax), %eax
cmpl $0xb, %eax
je 0x2212d
testl %eax, %eax
jne 0x22132
movl $0x8c9c94c7, %eax       # imm = 0x8C9C94C7
addq $0x8, %rsp
popq %rbx
popq %r14
retq
pushq $0x68
jmp 0x220f1
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_sysread
static size_t so_sysread(struct socket *so, void *dst, size_t lim, int *error) {
	long len;

retry:
#if _WIN32
	len = recv(so->fd, dst, SO_MIN(lim, LONG_MAX), 0);
#else
	len = read(so->fd, dst, SO_MIN(lim, LONG_MAX));
#endif

	if (len == -1)
		goto error;
	if (len == 0)
		goto epipe;

	return len;
epipe:
	*error = EPIPE;
	so->st.rcvd.eof = 1;

	return 0;
error:
	*error = so_soerr();

	switch (*error) {
	case SO_EINTR:
		goto retry;
#if SO_EWOULDBLOCK != SO_EAGAIN
	case SO_EWOULDBLOCK:
		*error = SO_EAGAIN;
		/* FALL THROUGH */
#endif
	case SO_EAGAIN:
		so->events |= POLLIN;
		break;
	} /* switch() */

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movabsq $0x7fffffffffffffff, %r13 # imm = 0x7FFFFFFFFFFFFFFF
cmpq %r13, %rdx
cmovbq %rdx, %r13
xorl %r14d, %r14d
movl 0x58(%rbx), %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x103b0
cmpq $-0x1, %rax
jne 0x22195
callq 0xf0a0
movl (%rax), %eax
movl %eax, (%r15)
cmpl $0x4, %eax
je 0x22164
cmpl $0xb, %eax
jne 0x221ae
orb $0x1, 0xb0(%rbx)
jmp 0x221ab
movq %rax, %r14
testq %rax, %rax
jne 0x221ae
movl $0x20, (%r15)
movb $0x1, 0x90(%rbx)
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: st_update
static int math_addull(unsigned long long *x, unsigned long long a, unsigned long long b) {
	if (~a < b) {
		*x = ~0ULL;

		return EOVERFLOW;
	} else {
		*x = a + b;

		return 0;
	}
}

// Assembly:
addq (%rdi), %rsi
pushq $-0x1
popq %rax
cmovaeq %rsi, %rax
movq %rax, (%rdi)
cmpb $0x1, 0x48(%rdx)
jne 0x22632
addq $0x10, %rdi
jmp 0xfca0
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_pipeok
static int so_pipeok(struct socket *so, _Bool rdonly) {
	if (!so_needign(so, rdonly))
		return 0;

#if _POSIX_REALTIME_SIGNALS > 0
	assert(so->pipeign.ncalls > 0);

	if (--so->pipeign.ncalls)
		return 0;

	if (sigismember(&so->pipeign.pending, SIGPIPE))
		return 0;

	sigset_t piped;
	sigemptyset(&piped);
	sigaddset(&piped, SIGPIPE);

	while (-1 == sigtimedwait(&piped, NULL, &(struct timespec){ 0, 0 }) && errno == EINTR)
		;;

	return thr_sigmask(SIG_SETMASK, &so->pipeign.blocked, NULL);
#else
	return EOPNOTSUPP;
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rdi, %rbx
callq 0x23140
testb %al, %al
je 0x226c4
movl 0x108(%rbx), %eax
testl %eax, %eax
jle 0x226d1
decl %eax
movl %eax, 0x108(%rbx)
jne 0x226c4
leaq 0x110(%rbx), %rdi
pushq $0xd
popq %rsi
callq 0xf650
testl %eax, %eax
jne 0x226c4
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x100a0
pushq $0xd
popq %rsi
movq %r14, %rdi
callq 0x10570
movq %rsp, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xf730
cmpl $-0x1, %eax
jne 0x226b0
callq 0xf0a0
cmpl $0x4, (%rax)
je 0x2268d
addq $0x190, %rbx            # imm = 0x190
pushq $0x2
popq %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xf360
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0xf33c(%rip), %rdi      # 0x31a14
leaq 0xf20f(%rip), %rsi      # 0x318ee
leaq 0xf345(%rip), %rcx      # 0x31a2b
movl $0x56e, %edx            # imm = 0x56E
callq 0xf8e0
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_write
size_t so_write(struct socket *so, const void *src, size_t len, int *error_) {
	size_t count;
	int error;

	so_pipeign(so, 0);

	so->todo |= SO_S_SETWRITE;

	if ((error = so_exec(so)))
		goto error;

	if (so->fd == -1) {
		error = ENOTCONN;
		goto error;
	}

	so->events &= ~POLLOUT;
retry:
	if (so->ssl.ctx) {
		if (len > 0) {
			int n;

			ERR_clear_error();

			if ((n = SSL_write(so->ssl.ctx, src, SO_MIN(len, INT_MAX))) < 0) {
				if (SO_EINTR == (error = ssl_error(so->ssl.ctx, n, &so->events)))
					goto retry;
				goto error;
			} else if (n == 0) {
				error = EPIPE; /* FIXME: differentiate clean from unclean shutdown? */
				so->st.sent.eof = 1;
				goto error;
			}

			count = n;
		} else {
			count = 0;
		}
	} else {
		if (!(count = so_syswrite(so, src, len, &error)))
			goto error;
	}

	so_trace(SO_T_WRITE, so->fd, so->host, src, (size_t)count, "sent %zu bytes", (size_t)count);
	st_update(&so->st.sent, count, &so->opts);

	so_pipeok(so, 0);

	return count;
error:
	*error_ = error;

	if (error != SO_EAGAIN)
		so_trace(SO_T_WRITE, so->fd, so->host, (void *)0, (size_t)0, "%s", so_strerror(error));

	so_pipeok(so, 0);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
xorl %esi, %esi
callq 0x22031
orb $0x1, 0xb9(%rbx)
movq %rbx, %rdi
callq 0x212cb
testl %eax, %eax
je 0x22738
movl %eax, (%r14)
cmpl $0xb, %eax
jne 0x227b4
xorl %r12d, %r12d
jmp 0x22852
cmpl $-0x1, 0x58(%rbx)
je 0x227ae
movq %r14, 0x8(%rsp)
andb $-0x5, 0xb0(%rbx)
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpq %rbp, %r13
cmovbq %r13, %rbp
leaq 0xb0(%rbx), %r14
xorl %r12d, %r12d
xorl %edx, %edx
cmpq $0x0, 0xc8(%rbx)
je 0x227e9
testq %r13, %r13
je 0x2281e
callq 0x101c0
movq 0xc8(%rbx), %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x10a60
testl %eax, %eax
jns 0x22814
movq 0xc8(%rbx), %rdi
movl %eax, %esi
movq %r14, %rdx
callq 0x220bf
pushq $0x4
popq %rdx
cmpl $0x4, %eax
je 0x22762
jmp 0x2280a
pushq $0x6b
popq %rax
movl %eax, (%r14)
movl 0x58(%rbx), %ebp
movq 0xa8(%rbx), %r14
movl %eax, %edi
callq 0xfc60
movq %rax, (%rsp)
leaq 0xe77d(%rip), %r9       # 0x30f4d
xorl %r12d, %r12d
pushq $0x3
popq %rdi
movl %ebp, %esi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x221bb
jmp 0x22852
leaq 0x14(%rsp), %rcx
movl %edx, (%rcx)
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x22879
movq %rax, %r12
testq %rax, %rax
jne 0x2281e
movl 0x14(%rsp), %eax
movq 0x8(%rsp), %r14
jmp 0x22724
movq 0x8(%rsp), %r14
je 0x2286e
movl %eax, %r12d
movl 0x58(%rbx), %esi
movq 0xa8(%rbx), %rdx
movq %r12, (%rsp)
leaq 0xf112(%rip), %r9       # 0x31945
pushq $0x3
popq %rdi
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x221bb
leaq 0x70(%rbx), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x22616
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22633
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x78(%rbx)
pushq $0x20
jmp 0x227b0
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_peek
size_t so_peek(struct socket *so, void *dst, size_t lim, int flags, int *_error) {
	int rstlowat = so->todo & SO_S_RSTLOWAT;
	long count;
	int lowat, error;

	so->todo &= ~SO_S_RSTLOWAT;

	error = so_exec(so);

	so->todo |= rstlowat;

	if (error)
		goto error;

	if (flags & SO_F_PEEKALL)
		so->events &= ~POLLIN;
retry:
	count = recv(so->fd, dst, lim, MSG_PEEK);

	if (count == -1)
		goto soerr;

	if ((size_t)count == lim || !(flags & SO_F_PEEKALL))
		return count;
pollin:
	if (!(so->todo & SO_S_RSTLOWAT)) {
		if (0 != getsockopt(so->fd, SOL_SOCKET, SO_RCVLOWAT, &so->olowat, &(socklen_t){ sizeof so->olowat }))
			goto soerr;

		if (lim > INT_MAX) {
			error = EOVERFLOW;

			goto error;
		}

		lowat = (int)lim;

		if (0 != setsockopt(so->fd, SOL_SOCKET, SO_RCVLOWAT, &lowat, sizeof lowat))
			goto soerr;

		so->todo |= SO_S_RSTLOWAT;
	}

	so->events |= POLLIN;

	*_error = SO_EAGAIN;

	return 0;
soerr:
	error = so_soerr();

	switch (error) {
	case SO_EINTR:
		goto retry;
#if SO_EWOULDBLOCK != SO_EAGAIN
	case SO_EWOULDBLOCK:
		/* FALL THROUGH */
#endif
	case SO_EAGAIN:
		if (flags & SO_F_PEEKALL)
			goto pollin;

		break;
	} /* switch() */
error:
	*_error = error;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x8(%rsp)
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
movl 0xb8(%rdi), %eax
movl %eax, %ebx
andl $0x200, %ebx            # imm = 0x200
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
movl %eax, 0xb8(%rdi)
callq 0x212cb
orl %ebx, 0xb8(%r14)
testl %eax, %eax
jne 0x22a54
testb $0x1, %bpl
je 0x2299c
andb $-0x2, 0xb0(%r14)
leaq 0xc0(%r14), %r13
pushq $0x1
popq %rbx
pushq $0x12
popq %r12
movl 0x58(%r14), %edi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
pushq $0x2
popq %rcx
callq 0xf460
cmpq $-0x1, %rax
je 0x229d8
testb $0x1, %bpl
je 0x22a5d
cmpq %r15, %rax
jne 0x229ef
jmp 0x22a5d
callq 0xf0a0
movl (%rax), %eax
cmpl $0x4, %eax
je 0x229aa
cmpl $0xb, %eax
jne 0x22a54
testb $0x1, %bpl
je 0x22a51
testb $0x2, 0xb9(%r14)
jne 0x22a49
movl 0x58(%r14), %edi
movl $0x4, (%rsp)
movl %ebx, %esi
movl %r12d, %edx
movq %r13, %rcx
movq %rsp, %r8
callq 0xf9f0
testl %eax, %eax
jne 0x229d8
cmpq $0x7fffffff, %r15       # imm = 0x7FFFFFFF
ja 0x22a6c
movl %r15d, 0x4(%rsp)
movl 0x58(%r14), %edi
movl %ebx, %esi
movl %r12d, %edx
leaq 0x4(%rsp), %rcx
pushq $0x4
popq %r8
callq 0x108f0
testl %eax, %eax
jne 0x229d8
orb $0x2, 0xb9(%r14)
orb $0x1, 0xb0(%r14)
pushq $0xb
popq %rax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4b
jmp 0x22a53
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_sendmsg
int so_sendmsg(struct socket *so, const struct msghdr *msg, int flags) {
	ssize_t count;
	int error;

	so_pipeign(so, 0);

	so->todo |= SO_S_SETWRITE;

	if ((error = so_exec(so)))
		goto error;

	so->events &= ~POLLOUT;

#if defined MSG_NOSIGNAL
	if (so->opts.fd_nosigpipe)
		flags |= MSG_NOSIGNAL;
#endif

retry:
	if (-1 == (count = sendmsg(so->fd, msg, flags)))
		goto syerr;

	st_update(&so->st.sent, count, &so->opts);

	so_pipeok(so, 0);

	return 0;
syerr:
	error = errno;
error:
	switch (error) {
	case SO_EINTR:
		goto retry;
#if SO_EWOULDBLOCK != SO_EAGAIN
	case SO_EWOULDBLOCK:
		/* FALL THROUGH */
#endif
	case SO_EAGAIN:
		so->events |= POLLOUT;

		break;
	} /* switch() */

	so_pipeok(so, 0);

	return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorl %esi, %esi
callq 0x22031
orb $0x1, 0xb9(%rbx)
movq %rbx, %rdi
callq 0x212cb
testl %eax, %eax
je 0x22a9e
movl %eax, %r15d
jmp 0x22ace
andb $-0x5, 0xb0(%rbx)
movl %ebp, %eax
orl $0x4000, %eax           # imm = 0x4000
cmpb $0x0, 0x1e(%rbx)
cmovnel %eax, %ebp
movl 0x58(%rbx), %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0xfab0
cmpq $-0x1, %rax
jne 0x22ae3
callq 0xf0a0
movl (%rax), %r15d
cmpl $0x4, %r15d
je 0x22ab3
cmpl $0xb, %r15d
jne 0x22af5
orb $0x4, 0xb0(%rbx)
jmp 0x22af5
leaq 0x70(%rbx), %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x22616
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22633
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_recvmsg
int so_recvmsg(struct socket *so, struct msghdr *msg, int flags) {
	ssize_t count;
	int error;

	so_pipeign(so, 1);

	so->todo |= SO_S_SETREAD;

	if ((error = so_exec(so)))
		goto error;

	so->events &= ~POLLIN;
retry:
	if (-1 == (count = recvmsg(so->fd, msg, flags))) {
		goto syerr;
	} else if (!count) {
		so->st.rcvd.eof = 1;
		error = EPIPE;
		goto error;
	}

	st_update(&so->st.rcvd, count, &so->opts);

	/* RE .msg_iovlen type
	 *
	 * 	- Linux    : size_t
	 * 	- OS X     : int
	 * 	- OpenBSD  : unsigned int
	 * 	- Solaris  : int
	 * 	- FreeBSD  : int
	 * 	- NetBSD   : int
	 * 	- RFC 2292 : size_t
	 */
	for (size_t i = 0; i < (size_t)msg->msg_iovlen; i++) {
		if ((size_t)count < msg->msg_iov[i].iov_len) {
			msg->msg_iov[i].iov_len = count;

			break;
		} else {
			count -= (ssize_t)msg->msg_iov[i].iov_len;
		}
	}

	so_pipeok(so, 1);

	return 0;
syerr:
	error = errno;
error:
	switch (error) {
	case SO_EINTR:
		goto retry;
#if SO_EWOULDBLOCK != SO_EAGAIN
	case SO_EWOULDBLOCK:
		/* FALL THROUGH */
#endif
	case SO_EAGAIN:
		so->events |= POLLIN;

		break;
	} /* switch() */

	so_pipeok(so, 1);

	return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x1
popq %rsi
callq 0x22031
orb $-0x80, 0xb8(%rbx)
movq %rbx, %rdi
callq 0x212cb
movl %eax, %ebp
testl %eax, %eax
jne 0x22b5d
andb $-0x2, 0xb0(%rbx)
movl 0x58(%rbx), %edi
movq %r14, %rsi
movl %r15d, %edx
callq 0xf390
cmpq $-0x1, %rax
jne 0x22b72
callq 0xf0a0
movl (%rax), %ebp
cmpl $0x4, %ebp
je 0x22b42
cmpl $0xb, %ebp
jne 0x22b84
orb $0x1, 0xb0(%rbx)
pushq $0xb
jmp 0x22b83
movq %rax, %r12
testq %rax, %rax
jne 0x22b9a
movb $0x1, 0x90(%rbx)
pushq $0x20
popq %rbp
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x22633
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x88(%rbx), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x22616
movq 0x18(%r14), %rcx
pushq $0x8
popq %rax
xorl %ebp, %ebp
subq $0x1, %rcx
jb 0x22b84
movq 0x10(%r14), %rsi
movq %r12, %rdx
subq (%rsi,%rax), %rdx
jb 0x22bd1
addq $0x10, %rax
movq %rdx, %r12
jmp 0x22bb5
movq %r12, (%rsi,%rax)
jmp 0x22b84
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_pollfd
int so_pollfd(struct socket *so) {
	switch (so_state(so)) {
	case SO_S_GETADDR:
		return dns_ai_pollfd(so->res);
	default:
		return so->fd;
	} /* switch() */
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x212a3
cmpl $0x2, %eax
jne 0x22c26
movq 0x50(%rbx), %rdi
popq %rbx
jmp 0xf140
movl 0x58(%rbx), %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_peereid
int so_peereid(struct socket *so, uid_t *uid, gid_t *gid) {
	int error;

	if ((error = so_loadcred(so)))
		return error;

	if (so->cred.uid == (uid_t)-1)
		return EOPNOTSUPP;

	if (uid)
		*uid = so->cred.uid;
	if (gid)
		*gid = so->cred.gid;

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
callq 0x22cdf
testl %eax, %eax
je 0x22cb4
popq %rbx
popq %r14
popq %r15
retq
movl 0x214(%r14), %eax
cmpl $-0x1, %eax
je 0x22cda
testq %r15, %r15
je 0x22cc8
movl %eax, (%r15)
xorl %eax, %eax
testq %rbx, %rbx
je 0x22cae
movl 0x218(%r14), %ecx
movl %ecx, (%rbx)
jmp 0x22cae
pushq $0x5f
popq %rax
jmp 0x22cae
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_peerpid
int so_peerpid(struct socket *so, pid_t *pid) {
	int error;

	if ((error = so_loadcred(so)))
		return error;

	if (so->cred.pid == (pid_t)-1)
		return EOPNOTSUPP;

	if (pid)
		*pid = so->cred.pid;

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x22cdf
testl %eax, %eax
je 0x22d55
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl 0x210(%r14), %ecx
cmpl $-0x1, %ecx
je 0x22d6c
xorl %eax, %eax
testq %rbx, %rbx
je 0x22d4d
movl %ecx, (%rbx)
jmp 0x22d4d
pushq $0x5f
popq %rax
jmp 0x22d4d
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: bio_methods_init
static void bio_methods_init(void) {
	int type = BIO_get_new_index();
	if (type == -1)
		return;

	bio_methods = BIO_meth_new(type|BIO_TYPE_SOURCE_SINK, "struct socket*");
	if (bio_methods == NULL)
		return;

	BIO_meth_set_write(bio_methods, bio_write);
	BIO_meth_set_read(bio_methods, bio_read);
	BIO_meth_set_puts(bio_methods, bio_puts);
	BIO_meth_set_ctrl(bio_methods, bio_ctrl);
	BIO_meth_set_create(bio_methods, bio_create);
	BIO_meth_set_destroy(bio_methods, bio_destroy);
}

// Assembly:
pushq %rax
callq 0x101d0
cmpl $-0x1, %eax
je 0x22e8d
orl $0x400, %eax            # imm = 0x400
leaq 0xeb4f(%rip), %rsi      # 0x3195a
movl %eax, %edi
callq 0xf920
movq %rax, 0x23897(%rip)     # 0x466b0
testq %rax, %rax
je 0x22e8d
leaq 0x6a(%rip), %rsi        # 0x22e8f
movq %rax, %rdi
callq 0x10890
movq 0x2387c(%rip), %rdi     # 0x466b0
leaq 0x119(%rip), %rsi       # 0x22f54
callq 0xfef0
movq 0x23869(%rip), %rdi     # 0x466b0
leaq 0x221(%rip), %rsi       # 0x2306f
callq 0x10040
movq 0x23856(%rip), %rdi     # 0x466b0
leaq 0x23e(%rip), %rsi       # 0x2309f
callq 0x10b30
movq 0x23843(%rip), %rdi     # 0x466b0
leaq 0x262(%rip), %rsi       # 0x230d6
callq 0xf4b0
movq 0x23830(%rip), %rdi     # 0x466b0
leaq 0x273(%rip), %rsi       # 0x230fa
popq %rax
jmp 0xff60
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: bio_write
static int bio_write(BIO *bio, const char *src, int len) {
	struct socket *so = BIO_get_data(bio);
	size_t count;

	assert(so);
	assert(len >= 0);

	BIO_clear_retry_flags(bio);
	so->bio.error = 0;

	if ((count = so_syswrite(so, src, len, &so->bio.error)))
		return (int)count;

	if (bio_nonfatal(so->bio.error))
		BIO_set_retry_write(bio);

	/*
	 * SSL_get_error will return SSL_ERROR_SYSCALL, expecting errno to
	 * be set.
	 */
	errno = so->bio.error;

	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x109d0
testq %rax, %rax
je 0x22f16
testl %ebp, %ebp
js 0x22f35
movq %rax, %r14
movq %rax, %r12
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x10580
addq $0xe8, %r14
andl $0x0, 0xe8(%r12)
movl %ebp, %edx
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x22879
testq %rax, %rax
jne 0x22f0d
movl (%r14), %ebp
movl %ebp, %edi
callq 0x2311e
testb %al, %al
je 0x22f03
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0xf180
movl (%r14), %ebp
callq 0xf0a0
movl %ebp, (%rax)
pushq $-0x1
popq %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xea4c(%rip), %rdi      # 0x31969
leaq 0xe9ca(%rip), %rsi      # 0x318ee
leaq 0xea41(%rip), %rcx      # 0x3196c
movl $0x9a2, %edx            # imm = 0x9A2
callq 0xf8e0
leaq 0xea58(%rip), %rdi      # 0x31994
leaq 0xe9ab(%rip), %rsi      # 0x318ee
leaq 0xea22(%rip), %rcx      # 0x3196c
movl $0x9a3, %edx            # imm = 0x9A3
callq 0xf8e0
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: bio_read
static int bio_read(BIO *bio, char *dst, int lim) {
	struct socket *so = BIO_get_data(bio);
	size_t count;

	assert(so);
	assert(lim >= 0);

	BIO_clear_retry_flags(bio);
	so->bio.error = 0;

	if (so->bio.ahead.p < so->bio.ahead.pe) {
		count = SO_MIN(so->bio.ahead.pe - so->bio.ahead.p, lim);
		memcpy(dst, so->bio.ahead.p, count);
		so->bio.ahead.p += count;

		return count;
	}

	if ((count = so_sysread(so, dst, lim, &so->bio.error)))
		return (int)count;

	if (bio_nonfatal(so->bio.error))
		BIO_set_retry_read(bio);

	/* see note about SSL_ERROR_SYSCALL at bio_write */
	errno = so->bio.error;

	return (so->bio.error == EPIPE)? 0 : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x109d0
testq %rax, %rax
je 0x23031
testl %ebp, %ebp
js 0x23050
movq %rax, %r12
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x10580
andl $0x0, 0xe8(%r12)
movq 0xf8(%r12), %rsi
movq 0x100(%r12), %r13
cmpq %r13, %rsi
jae 0x22fca
subq %rsi, %r13
movl %ebp, %eax
cmpq %rax, %r13
cmovgeq %rax, %r13
movq %r14, %rdi
movq %r13, %rdx
callq 0xfad0
addq %r13, 0xf8(%r12)
jmp 0x2301f
movq %r12, %r15
addq $0xe8, %r15
movl %ebp, %edx
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0x2213e
testq %rax, %rax
je 0x22fee
movq %rax, %r13
jmp 0x2301f
movl (%r15), %ebp
movl %ebp, %edi
callq 0x2311e
testb %al, %al
je 0x2300a
pushq $0x9
popq %rsi
movq %rbx, %rdi
callq 0xf180
movl (%r15), %ebp
callq 0xf0a0
movl %ebp, (%rax)
xorl %r13d, %r13d
cmpl $0x20, (%r15)
setne %r13b
negl %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe931(%rip), %rdi      # 0x31969
leaq 0xe8af(%rip), %rsi      # 0x318ee
leaq 0xe957(%rip), %rcx      # 0x3199d
movl $0x984, %edx            # imm = 0x984
callq 0xf8e0
leaq 0xe967(%rip), %rdi      # 0x319be
leaq 0xe890(%rip), %rsi      # 0x318ee
leaq 0xe938(%rip), %rcx      # 0x3199d
movl $0x985, %edx            # imm = 0x985
callq 0xf8e0
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: bio_create
static int bio_create(BIO *bio) {
	BIO_set_init(bio, 0);
	BIO_set_shutdown(bio, 0);
	BIO_set_data(bio, NULL);

	return 1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorl %esi, %esi
callq 0xf860
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10830
movq %rbx, %rdi
xorl %esi, %esi
callq 0xfea0
pushq $0x1
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: bio_nonfatal
static _Bool bio_nonfatal(int error) {
	switch (error) {
	case SO_EAGAIN:
	case SO_EALREADY:
	case SO_EINPROGRESS:
	case SO_EINTR:
	case SO_ENOTCONN: /* FIXME (bss_sock.c has this but is it correct?) */
		return 1;
	default:
		return 0;
	}
}

// Assembly:
movb $0x1, %al
leal -0x6b(%rdi), %ecx
cmpl $0x8, %ecx
ja 0x23133
movl $0x181, %edx            # imm = 0x181
btl %ecx, %edx
jae 0x23133
retq
cmpl $0x4, %edi
je 0x23132
cmpl $0xb, %edi
je 0x23132
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_needign
static _Bool so_needign(struct socket *so, _Bool rdonly) {
	if (!so->opts.fd_nosigpipe || (so->flags & SO_F_NOSIGPIPE))
		return 0;
	if (so->ssl.ctx && !so->bio.ctx)
		return 1;
	if (rdonly)
		return 0;
#if defined MSG_NOSIGNAL
	if (S_ISSOCK(so->mode))
		return 0;
#endif
	return 1;
}

// Assembly:
cmpb $0x1, 0x1e(%rdi)
jne 0x2316c
testb $-0x80, 0x6c(%rdi)
jne 0x2316c
cmpq $0x0, 0xc8(%rdi)
je 0x23167
cmpq $0x0, 0xe0(%rdi)
sete %al
orb %al, %sil
je 0x2316f
retq
testb %sil, %sil
je 0x2316f
xorl %eax, %eax
retq
movl $0xf000, %eax           # imm = 0xF000
andl 0x5c(%rdi), %eax
cmpl $0xc000, %eax           # imm = 0xC000
setne %al
retq
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_dump
static void so_dump(const unsigned char *src, size_t len, FILE *fp) {
	static const unsigned char hex[] = "0123456789abcdef";
	static const unsigned char tmp[] = "                                                            |                |\n";
	unsigned char ln[sizeof tmp];
	const unsigned char *p, *pe;
	unsigned char *h, *g;
	unsigned i, n;

	p  = src;
	pe = p + len;

	while (p < pe) {
		memcpy(ln, tmp, sizeof ln);

		h = &ln[2];
		g = &ln[61];

		n = p - src;
		h[0] = hex[0x0f & (n >> 20)];
		h[1] = hex[0x0f & (n >> 16)];
		h[2] = hex[0x0f & (n >> 12)];
		h[3] = hex[0x0f & (n >> 8)];
		h[4] = hex[0x0f & (n >> 4)];
		h[5] = hex[0x0f & (n >> 0)];
		h += 8;

		for (n = 0; n < 2; n++) {
			for (i = 0; i < 8 && pe - p > 0; i++, p++) {
				h[0] = hex[0x0f & (*p >> 4)];
				h[1] = hex[0x0f & (*p >> 0)];
				h += 3;

				*g++ = (isgraph(*p))? *p : '.';
			}

			h++;
		}

		fputs((char *)ln, fp);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x18(%rsp)
movq %rdi, %r15
addq %rdi, %rsi
movq %rsi, 0x8(%rsp)
leaq 0x20(%rsp), %rbx
leaq 0xe8c6(%rip), %r12      # 0x31a70
movq %rdi, 0x10(%rsp)
cmpq 0x8(%rsp), %r15
jae 0x232c6
pushq $0xa
popq %rcx
movq %rbx, %rdi
leaq 0xe8c9(%rip), %rsi      # 0x31a90
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rax
subq 0x10(%rsp), %rax
movl %eax, %ecx
shrl $0x14, %ecx
andl $0xf, %ecx
movb (%rcx,%r12), %cl
movb %cl, 0x22(%rsp)
movl %eax, %ecx
shrl $0x10, %ecx
andl $0xf, %ecx
movb (%rcx,%r12), %cl
movb %cl, 0x23(%rsp)
movl %eax, %ecx
shrl $0xc, %ecx
andl $0xf, %ecx
movb (%rcx,%r12), %cl
movb %cl, 0x24(%rsp)
movl %eax, %ecx
shrl $0x8, %ecx
andl $0xf, %ecx
movb (%rcx,%r12), %cl
movb %cl, 0x25(%rsp)
movl %eax, %ecx
shrl $0x4, %ecx
andl $0xf, %ecx
movb (%rcx,%r12), %cl
movb %cl, 0x26(%rsp)
andl $0xf, %eax
movb (%rax,%r12), %al
movb %al, 0x27(%rsp)
xorl %eax, %eax
leaq 0x2a(%rsp), %rbx
leaq 0x5d(%rsp), %r14
cmpl $0x2, %eax
je 0x232af
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rbp
subq %r15, %rbp
incq %rbx
xorl %r13d, %r13d
cmpl $0x7, %r13d
ja 0x232a1
testq %rbp, %rbp
jle 0x232a1
movzbl (%r15,%r13), %eax
shrl $0x4, %eax
movb (%rax,%r12), %al
movb %al, -0x1(%rbx)
movzbl (%r15,%r13), %eax
andl $0xf, %eax
movb (%rax,%r12), %al
movb %al, (%rbx)
callq 0xfec0
movq (%rax), %rcx
movzbl (%r15,%r13), %eax
cmpw $0x0, (%rcx,%rax,2)
pushq $0x2e
popq %rcx
jns 0x23291
movl %eax, %ecx
movb %cl, (%r14,%r13)
incq %r13
decq %rbp
addq $0x3, %rbx
jmp 0x23250
movl 0x4(%rsp), %eax
incl %eax
addq %r13, %r15
addq %r13, %r14
jmp 0x23239
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xff30
jmp 0x231af
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/dns.c
// Function: dns_random_
static unsigned dns_random_(void) {
#if DNS_RANDOM_OPENSSL
	unsigned r;
	_Bool ok;

	ok = (1 == RAND_bytes((unsigned char *)&r, sizeof r));
	assert(ok && "1 == RAND_bytes()");

	return r;
#else
	return DNS_RANDOM();
#endif
}

// Assembly:
pushq %rax
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x10470
cmpl $0x1, %eax
jne 0x2333c
movl 0x4(%rsp), %eax
popq %rcx
retq
leaq 0x10e45(%rip), %rdi     # 0x34188
leaq 0x10b23(%rip), %rsi     # 0x33e6d
leaq 0x10e51(%rip), %rcx     # 0x341a2
movl $0x1ca, %edx            # imm = 0x1CA
callq 0xf8e0