// File: /workspace/github_c_makefile_star2_O1/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 0x19c5d
leaq 0x1abc8(%rip), %r15     # 0x33ed0
movq 0x18(%r15), %r8
leaq 0x4fc1(%rip), %rdx      # 0x1e2d4
leaq 0x4fd8(%rip), %r9       # 0x1e2f2
movl $0x3, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
addq $0x20, %rbx
leaq 0x4fd2(%rip), %rsi      # 0x1e308
leaq 0x4fd6(%rip), %rdx      # 0x1e313
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 0x19393
callq 0x19c5d
movq 0x10(%r15), %r8
leaq 0x4fba(%rip), %rdx      # 0x1e325
movq %rsp, %rbx
movl $0x2, %edi
xorl %esi, %esi
movq %rax, %rcx
movq %rbx, %r9
xorl %eax, %eax
callq 0x19ca8
movq %rbx, %rdi
callq 0xd080
cmpl $-0x1, %eax
je 0x19472
movl $0x1, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0xd470
testl %eax, %eax
js 0x19442
movl %eax, %ebx
xorps %xmm0, %xmm0
leaq 0x42(%rsp), %r14
movaps %xmm0, -0x2(%r14)
movups %xmm0, 0x5c(%r14)
movaps %xmm0, 0x4e(%r14)
movaps %xmm0, 0x3e(%r14)
movaps %xmm0, 0x2e(%r14)
movaps %xmm0, 0x1e(%r14)
movaps %xmm0, 0xe(%r14)
movw $0x1, -0x2(%r14)
movq %rsp, %rsi
movq %r14, %rdi
callq 0xd0b0
movq %r14, %rdi
callq 0xd110
leal 0x2(%rax), %edx
leaq 0x40(%rsp), %rsi
movl %ebx, %edi
callq 0xd2f0
testl %eax, %eax
js 0x19461
movl %ebx, %edi
movl $0x1, %esi
callq 0xd2a0
movl %eax, %ebp
callq 0x19c5d
testl %ebp, %ebp
js 0x19494
movq 0x18(%r15), %r8
leaq 0x20fc(%rip), %rdx      # 0x1b524
leaq 0x4ec3(%rip), %r9       # 0x1e2f2
movl $0x3, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
jmp 0x194b8
callq 0x19c5d
movq (%r15), %r8
leaq 0x4f43(%rip), %rdx      # 0x1e394
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
jmp 0x194b3
callq 0x19c5d
movq (%r15), %r8
leaq 0x4f4d(%rip), %rdx      # 0x1e3bd
jmp 0x1949e
callq 0x19c5d
movq (%r15), %r8
leaq 0x4eeb(%rip), %rdx      # 0x1e36c
movq %rsp, %r9
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
jmp 0x194b3
movq (%r15), %r8
leaq 0x4f41(%rip), %rdx      # 0x1e3df
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movl %ebx, %edi
callq 0xd1a0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq