// File: /workspace/github_c_makefile_star2_O3/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 0x19969
leaq 0x1aee8(%rip), %r15     # 0x33ed0
movq 0x18(%r15), %r8
leaq 0x5341(%rip), %rdx      # 0x1e334
leaq 0x5358(%rip), %r9       # 0x1e352
movl $0x3, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x199b4
addq $0x20, %rbx
leaq 0x5352(%rip), %rsi      # 0x1e368
leaq 0x5356(%rip), %rdx      # 0x1e373
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xd3d0
movq %r14, %rdi
xorl %esi, %esi
callq 0xd300
testl %eax, %eax
jne 0x19073
callq 0x19969
movq 0x10(%r15), %r8
leaq 0x533a(%rip), %rdx      # 0x1e385
movq %rsp, %rbx
movl $0x2, %edi
xorl %esi, %esi
movq %rax, %rcx
movq %rbx, %r9
xorl %eax, %eax
callq 0x199b4
movq %rbx, %rdi
callq 0xd080
cmpl $-0x1, %eax
je 0x19151
movl $0x1, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0xd460
testl %eax, %eax
js 0x19121
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 0xd2e0
testl %eax, %eax
js 0x19140
movl %ebx, %edi
movl $0x1, %esi
callq 0xd290
movl %eax, %ebp
callq 0x19969
testl %ebp, %ebp
js 0x19173
movq 0x18(%r15), %r8
leaq 0x241d(%rip), %rdx      # 0x1b524
leaq 0x5244(%rip), %r9       # 0x1e352
movl $0x3, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x199b4
jmp 0x19197
callq 0x19969
movq (%r15), %r8
leaq 0x52c4(%rip), %rdx      # 0x1e3f4
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x199b4
jmp 0x19192
callq 0x19969
movq (%r15), %r8
leaq 0x52ce(%rip), %rdx      # 0x1e41d
jmp 0x1917d
callq 0x19969
movq (%r15), %r8
leaq 0x526c(%rip), %rdx      # 0x1e3cc
movq %rsp, %r9
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x199b4
jmp 0x19192
movq (%r15), %r8
leaq 0x52c2(%rip), %rdx      # 0x1e43f
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x199b4
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