// File: /workspace/github_c_makefile_star2_O3/wahern[P]cqueues/src/lib/socket.c
// Function: so_trace
static void so_trace(enum so_trace event, int fd, const struct addrinfo *host, ...) {
	struct sockaddr_storage saddr = {0};
	socklen_t saddr_len = sizeof saddr;
	char addr[64], who[256];
	in_port_t port;
	va_list ap;
	SSL *ctx;
	const void *data;
	size_t count;
	const char *fmt;
	int error;

	if (!socket_debug)
		return;

	if (host) {
		sa_ntop(addr, sizeof addr, host->ai_addr, NULL, &error);
		port = *sa_port(host->ai_addr, SA_PORT_NONE, NULL);

		if (host->ai_canonname)
			snprintf(who, sizeof who, "%.96s/[%s]:%hu", host->ai_canonname, addr, ntohs(port));
		else
			snprintf(who, sizeof who, "[%s]:%hu", addr, ntohs(port));
	} else if (fd != -1 && 0 == getpeername(fd, (struct sockaddr *)&saddr, &saddr_len)) {
		sa_ntop(addr, saddr_len, &saddr, NULL, &error);
		port = *sa_port(&saddr, SA_PORT_NONE, NULL);

		snprintf(who, sizeof who, "[%s]:%hu", addr, ntohs(port));
	} else
		dns_strlcpy(who, "[unknown]", sizeof who);

	va_start(ap, host);

	flockfile(stderr);

	switch (event) {
	case SO_T_CONNECT:
		fmt = va_arg(ap, char *);

		fprintf(stderr, "connect(%s): ", who);
		vfprintf(stderr, fmt, ap);
		fputc('\n', stderr);

		break;
	case SO_T_STARTTLS:
		ctx = va_arg(ap, SSL *);
		fmt = va_arg(ap, char *);

		(void)ctx; /* unused for now */
		fprintf(stderr, "starttls(%s): ", who);
		vfprintf(stderr, fmt, ap);
		fputc('\n', stderr);

		break;
	case SO_T_READ:
		data  = va_arg(ap, void *);
		count = va_arg(ap, size_t);
		fmt   = va_arg(ap, char *);

		fprintf(stderr, "read(%s): ", who);
		vfprintf(stderr, fmt, ap);
		fputc('\n', stderr);

		so_dump(data, count, stderr);

		break;
	case SO_T_WRITE:
		data  = va_arg(ap, void *);
		count = va_arg(ap, size_t);
		fmt   = va_arg(ap, char *);

		fprintf(stderr, "write(%s): ", who);
		vfprintf(stderr, fmt, ap);
		fputc('\n', stderr);

		so_dump(data, count, stderr);

		break;
	} /* switch(event) */

	funlockfile(stderr);

	va_end(ap);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rcx, 0x208(%rsp)
movq %r8, 0x210(%rsp)
movq %r9, 0x218(%rsp)
testb %al, %al
je 0x2506c
movaps %xmm0, 0x220(%rsp)
movaps %xmm1, 0x230(%rsp)
movaps %xmm2, 0x240(%rsp)
movaps %xmm3, 0x250(%rsp)
movaps %xmm4, 0x260(%rsp)
movaps %xmm5, 0x270(%rsp)
movaps %xmm6, 0x280(%rsp)
movaps %xmm7, 0x290(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movl $0x80, 0x8(%rsp)
movq 0x21f01(%rip), %rax     # 0x46fb0
cmpl $0x0, (%rax)
jne 0x250c1
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbx
popq %r14
popq %r15
retq
movq %rdx, %r14
movl %edi, %ebx
testq %rdx, %rdx
jne 0x25152
cmpl $-0x1, %esi
je 0x251c0
leaq 0x30(%rsp), %rax
leaq 0x8(%rsp), %rdx
movl %esi, %edi
movq %rax, %rsi
callq 0xf970
testl %eax, %eax
jne 0x251c0
movl 0x8(%rsp), %esi
xorl %r15d, %r15d
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %r14
leaq 0xc(%rsp), %r8
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xf200
movzwl (%r14), %eax
cmpl $0xa, %eax
je 0x25125
cmpl $0x2, %eax
jne 0x2512b
movzwl 0x32(%rsp), %r15d
rolw $0x8, %r15w
movzwl %r15w, %r8d
leaq 0x11892(%rip), %rdx     # 0x369cd
leaq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %rcx
movl $0x100, %esi            # imm = 0x100
jmp 0x251b7
movq 0x18(%r14), %rdx
xorl %r15d, %r15d
leaq 0xb0(%rsp), %rdi
leaq 0xc(%rsp), %r8
movl $0x40, %esi
xorl %ecx, %ecx
callq 0xf200
movq 0x18(%r14), %rax
movzwl (%rax), %ecx
orl $0x8, %ecx
cmpl $0xa, %ecx
jne 0x25186
movzwl 0x2(%rax), %r15d
movq 0x20(%r14), %rcx
rolw $0x8, %r15w
movzwl %r15w, %r9d
testq %rcx, %rcx
jne 0x251db
leaq 0x1182e(%rip), %rdx     # 0x369cd
leaq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %rcx
movl $0x100, %esi            # imm = 0x100
movl %r9d, %r8d
xorl %eax, %eax
callq 0x105c0
jmp 0x251fe
leaq 0x1180f(%rip), %rsi     # 0x369d6
leaq 0xf0(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
callq 0xf4d0
jmp 0x251fe
leaq 0x117e5(%rip), %rdx     # 0x369c7
leaq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %r8
movl $0x100, %esi            # imm = 0x100
xorl %eax, %eax
callq 0x105c0
leaq 0x1f0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x2c0(%rsp), %rax
movq %rax, 0x18(%rsp)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, 0x10(%rsp)
movq 0x21d92(%rip), %r14     # 0x46fc0
movq (%r14), %rdi
callq 0xf480
movl 0x10(%rsp), %edx
movl %ebx, %eax
leaq 0x11359(%rip), %rcx     # 0x3659c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %edi, %edi
cmpl $0x29, %edx
setb %dil
leaq 0x10(%rsp), %rsi
leaq 0xf0(%rsp), %rcx
callq 0x10db7
jmp 0x252be
xorl %edi, %edi
cmpl $0x29, %edx
setb %dil
leaq 0x10(%rsp), %rsi
leaq 0xf0(%rsp), %rcx
callq 0x10c81
jmp 0x252be
xorl %edi, %edi
cmpl $0x29, %edx
setb %dil
leaq 0x10(%rsp), %rsi
leaq 0xf0(%rsp), %rcx
callq 0x10bbe
jmp 0x252be
xorl %edi, %edi
cmpl $0x29, %edx
setb %dil
leaq 0x10(%rsp), %rsi
leaq 0xf0(%rsp), %rcx
callq 0x10d44
movq (%r14), %rdi
callq 0xfa70
jmp 0x250b4