// File: /workspace/github_c_makefile_star2_O2/intel[P]pf-bb-config/daemon.c
// Function: unix_channel_srv_init
int
unix_channel_srv_init(hw_device *dev)
{
	int	fd;
	int	rc;
	struct sockaddr_un serveraddr;
	char unix_channel_file[UNIX_CHANNEL_FILE_LEN];

	LOG(DEBUG, "cli channel init");
	sprintf(unix_channel_file, "%s.%s.sock", UNIX_CHANNEL_PATH, dev->pci_address);

	/* Check if the .sock file already exists */
	if (access(unix_channel_file, F_OK) == 0) {
		LOG(INFO, "pf_bb_config might have previously exited abruptly, removing %s",
				unix_channel_file);
		/* File exists, remove it */
		if (unlink(unix_channel_file) == -1) {
			LOG(ERR, "cli channel: failed to remove %s", unix_channel_file);
			return -1;
		}
	}

	fd = socket(AF_UNIX, SOCK_STREAM, 0);
	if (fd < 0) {
		LOG(ERR, "cli channel: socket() open failed");
		return -1;
	}

	memset(&serveraddr, 0, sizeof(serveraddr));
	serveraddr.sun_family = AF_UNIX;
	strcpy(serveraddr.sun_path, unix_channel_file);

	rc = bind(fd, (struct sockaddr *)&serveraddr, SUN_LEN(&serveraddr));
	if (rc < 0) {
		LOG(ERR, "cli channel: bind() failed");
		close(fd);
		return -1;
	}

	/* supports only one client connection at a time */
	rc = listen(fd, 1);
	if (rc < 0) {
		LOG(ERR, "cli channel: listen() failed");
		close(fd);
		return -1;
	}

	LOG(DEBUG, "Done");

	return fd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
callq 0x193b5
leaq 0x1c3f1(%rip), %r15     # 0x34ed0
movq 0x18(%r15), %r8
leaq 0x57fa(%rip), %rdx      # 0x1e2e4
leaq 0x5811(%rip), %r9       # 0x1e302
pushq $0x3
popq %rdi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
addq $0x20, %rbx
leaq 0x580d(%rip), %rsi      # 0x1e318
leaq 0x5811(%rip), %rdx      # 0x1e323
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xd3e0
movq %r14, %rdi
xorl %esi, %esi
callq 0xd310
testl %eax, %eax
jne 0x18b66
callq 0x193b5
movq 0x10(%r15), %r8
leaq 0x57f5(%rip), %rdx      # 0x1e335
pushq $0x2
popq %rdi
movq %rsp, %rbx
xorl %esi, %esi
movq %rax, %rcx
movq %rbx, %r9
xorl %eax, %eax
callq 0x19400
movq %rbx, %rdi
callq 0xd080
cmpl $-0x1, %eax
je 0x18c3b
pushq $0x1
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0xd470
testl %eax, %eax
js 0x18c0b
movl %eax, %ebx
leaq 0x4c(%rsp), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x5c(%r14)
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movw $0x1, -0x2(%r14)
movq %rsp, %rsi
movq %r14, %rdi
callq 0xd0b0
movq %r14, %rdi
callq 0xd110
leal 0x2(%rax), %edx
leaq 0x4a(%rsp), %rsi
movl %ebx, %edi
callq 0xd2f0
testl %eax, %eax
js 0x18c2a
pushq $0x1
popq %rsi
movl %ebx, %edi
callq 0xd2a0
movl %eax, %ebp
callq 0x193b5
testl %ebp, %ebp
js 0x18c5d
movq 0x18(%r15), %r8
leaq 0x2931(%rip), %rdx      # 0x1b524
leaq 0x5708(%rip), %r9       # 0x1e302
pushq $0x3
popq %rdi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
jmp 0x18c7f
callq 0x193b5
movq (%r15), %r8
leaq 0x578a(%rip), %rdx      # 0x1e3a4
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
jmp 0x18c7c
callq 0x193b5
movq (%r15), %r8
leaq 0x5794(%rip), %rdx      # 0x1e3cd
jmp 0x18c67
callq 0x193b5
movq (%r15), %r8
leaq 0x5732(%rip), %rdx      # 0x1e37c
movq %rsp, %r9
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
jmp 0x18c7c
movq (%r15), %r8
leaq 0x5788(%rip), %rdx      # 0x1e3ef
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
movl %ebx, %edi
callq 0xd1b0
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq