// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rcx, 0x1f8(%rsp)
movq %r8, 0x200(%rsp)
movq %r9, 0x208(%rsp)
testb %al, %al
je 0x22225
movaps %xmm0, 0x210(%rsp)
movaps %xmm1, 0x220(%rsp)
movaps %xmm2, 0x230(%rsp)
movaps %xmm3, 0x240(%rsp)
movaps %xmm4, 0x250(%rsp)
movaps %xmm5, 0x260(%rsp)
movaps %xmm6, 0x270(%rsp)
movaps %xmm7, 0x280(%rsp)
xorps %xmm0, %xmm0
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)
movaps %xmm0, 0x20(%rsp)
movl $0x80, 0x18(%rsp)
movq 0x22d4b(%rip), %rax     # 0x44fb0
cmpl $0x0, (%rax)
jne 0x22279
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rdx, %r14
movl %edi, %ebx
testq %rdx, %rdx
jne 0x2230a
cmpl $-0x1, %esi
je 0x22376
leaq 0x20(%rsp), %rax
leaq 0x18(%rsp), %rdx
movl %esi, %edi
movq %rax, %rsi
callq 0xf9c0
testl %eax, %eax
jne 0x22376
movl 0x18(%rsp), %esi
xorl %r15d, %r15d
leaq 0xa0(%rsp), %rdi
leaq 0x20(%rsp), %r14
leaq 0x1c(%rsp), %r8
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xf210
movzwl (%r14), %eax
cmpl $0xa, %eax
je 0x222dd
cmpl $0x2, %eax
jne 0x222e3
movzwl 0x22(%rsp), %r15d
rolw $0x8, %r15w
movzwl %r15w, %r8d
leaq 0xf6da(%rip), %rdx      # 0x319cd
leaq 0xe0(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
movl $0x100, %esi            # imm = 0x100
jmp 0x2236d
movq 0x18(%r14), %rdx
xorl %r15d, %r15d
leaq 0xa0(%rsp), %rdi
pushq $0x40
popq %rsi
leaq 0x1c(%rsp), %r8
xorl %ecx, %ecx
callq 0xf210
movq 0x18(%r14), %rax
movzwl (%rax), %ecx
orl $0x8, %ecx
cmpl $0xa, %ecx
jne 0x2233c
movzwl 0x2(%rax), %r15d
movq 0x20(%r14), %rcx
rolw $0x8, %r15w
movzwl %r15w, %r9d
testq %rcx, %rcx
jne 0x22391
leaq 0xf678(%rip), %rdx      # 0x319cd
leaq 0xe0(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
movl $0x100, %esi            # imm = 0x100
movl %r9d, %r8d
xorl %eax, %eax
callq 0x10670
jmp 0x223b4
leaq 0xf659(%rip), %rsi      # 0x319d6
leaq 0xe0(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
callq 0xf4f0
jmp 0x223b4
leaq 0xf62f(%rip), %rdx      # 0x319c7
leaq 0xe0(%rsp), %rdi
leaq 0xa0(%rsp), %r8
movl $0x100, %esi            # imm = 0x100
xorl %eax, %eax
callq 0x10670
leaq 0x1e0(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x2c0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rsp)
movq 0x22bdd(%rip), %r12     # 0x44fc0
movq (%r12), %rdi
callq 0xf4a0
movl (%rsp), %eax
movl %ebx, %ecx
leaq 0xf1a4(%rip), %rdx      # 0x3159c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x28, %eax
ja 0x2259e
movq %rax, %rcx
addq 0x10(%rsp), %rcx
addl $0x8, %eax
movl %eax, (%rsp)
jmp 0x225ac
cmpl $0x29, %eax
jae 0x224e5
movq 0x10(%rsp), %rcx
leaq 0x8(%rax), %rdx
movl %edx, (%rsp)
movq (%rcx,%rax), %rbx
cmpl $0x21, %eax
jae 0x224f6
movq 0x10(%rsp), %rsi
movq %rax, %rcx
addq $0x10, %rcx
movl %ecx, (%rsp)
movq (%rsi,%rdx), %r14
cmpl $0x18, %eax
ja 0x22507
addq 0x10(%rsp), %rcx
addl $0x18, %eax
movl %eax, (%rsp)
jmp 0x22515
cmpl $0x29, %eax
jae 0x22525
movq 0x10(%rsp), %rcx
leaq 0x8(%rax), %rdx
movl %edx, (%rsp)
movq (%rcx,%rax), %rbx
cmpl $0x21, %eax
jae 0x22536
movq 0x10(%rsp), %rsi
movq %rax, %rcx
addq $0x10, %rcx
movl %ecx, (%rsp)
movq (%rsi,%rdx), %r14
cmpl $0x18, %eax
ja 0x22547
addq 0x10(%rsp), %rcx
addl $0x18, %eax
movl %eax, (%rsp)
jmp 0x22555
cmpl $0x29, %eax
jae 0x225bc
movq %rax, %rcx
addq $0x8, %rcx
movl %ecx, (%rsp)
cmpl $0x20, %eax
ja 0x225c2
addq 0x10(%rsp), %rcx
addl $0x10, %eax
movl %eax, (%rsp)
jmp 0x225d0
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rbx
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %r14
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x8(%rsp)
movq (%rcx), %r15
movq (%r12), %rdi
leaq 0xf4da(%rip), %rsi      # 0x319fd
jmp 0x22563
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rbx
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %r14
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x8(%rsp)
movq (%rcx), %r15
movq (%r12), %rdi
leaq 0xf4a5(%rip), %rsi      # 0x31a08
leaq 0xe0(%rsp), %rdx
xorl %eax, %eax
callq 0x10380
movq (%r12), %rdi
movq %rsp, %rdx
movq %r15, %rsi
callq 0x101b0
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x10090
movq (%r12), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x23180
jmp 0x22608
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x8(%rsp)
movq (%rcx), %rbx
movq (%r12), %rdi
leaq 0xf426(%rip), %rsi      # 0x319e0
jmp 0x225de
addq $0x8, 0x8(%rsp)
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x8(%rsp)
movq (%rcx), %rbx
movq (%r12), %rdi
leaq 0xf410(%rip), %rsi      # 0x319ee
leaq 0xe0(%rsp), %rdx
xorl %eax, %eax
callq 0x10380
movq (%r12), %rdi
movq %rsp, %rdx
movq %rbx, %rsi
callq 0x101b0
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x10090
movq (%r12), %rdi
callq 0xfae0
jmp 0x2226a