// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
callq 0x21530
movq %rax, %rcx
leaq 0x1afd2(%rip), %rax     # 0x3b8d0
movq 0x18(%rax), %r8
movl $0x3, %edi
xorl %esi, %esi
leaq 0x59e0(%rip), %rdx      # 0x262f0
leaq 0x59f7(%rip), %r9       # 0x2630e
movb $0x0, %al
callq 0x216e0
leaq -0xd0(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0x20, %rcx
leaq 0x59f0(%rip), %rsi      # 0x26324
leaq 0x59f4(%rip), %rdx      # 0x2632f
movb $0x0, %al
callq 0xd3e0
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
callq 0xd310
cmpl $0x0, %eax
jne 0x209ce
callq 0x21530
movq %rax, %rcx
leaq 0x1af6c(%rip), %rax     # 0x3b8d0
movq 0x10(%rax), %r8
leaq -0xd0(%rbp), %r9
movl $0x2, %edi
xorl %esi, %esi
leaq 0x59c4(%rip), %rdx      # 0x26341
movb $0x0, %al
callq 0x216e0
leaq -0xd0(%rbp), %rdi
callq 0xd070
cmpl $-0x1, %eax
jne 0x209cc
callq 0x21530
movq %rax, %rcx
leaq 0x1af2c(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
leaq -0xd0(%rbp), %r9
xorl %esi, %esi
leaq 0x59d1(%rip), %rdx      # 0x26388
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x20b42
jmp 0x209ce
movl $0x1, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0xd460
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x20a15
callq 0x21530
movq %rax, %rcx
leaq 0x1aedc(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x59b0(%rip), %rdx      # 0x263b0
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x20b42
leaq -0x86(%rbp), %rdi
xorl %esi, %esi
movl $0x6e, %edx
callq 0xd170
movw $0x1, -0x86(%rbp)
leaq -0x86(%rbp), %rdi
addq $0x2, %rdi
leaq -0xd0(%rbp), %rsi
callq 0xd0a0
movl -0x14(%rbp), %eax
movl %eax, -0xd4(%rbp)
leaq -0x86(%rbp), %rdi
addq $0x2, %rdi
callq 0xd0f0
movl -0xd4(%rbp), %edi
movq %rax, %rcx
xorl %eax, %eax
addq $0x2, %rax
addq %rcx, %rax
movl %eax, %edx
leaq -0x86(%rbp), %rsi
callq 0xd2f0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x20ac2
callq 0x21530
movq %rax, %rcx
leaq 0x1ae37(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x5934(%rip), %rdx      # 0x263d9
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl -0x14(%rbp), %edi
callq 0xd190
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x20b42
movl -0x14(%rbp), %edi
movl $0x1, %esi
callq 0xd2a0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x20b0d
callq 0x21530
movq %rax, %rcx
leaq 0x1ade9(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x5908(%rip), %rdx      # 0x263fb
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl -0x14(%rbp), %edi
callq 0xd190
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x20b42
callq 0x21530
movq %rax, %rcx
leaq 0x1adb4(%rip), %rax     # 0x3b8d0
movq 0x18(%rax), %r8
movl $0x3, %edi
xorl %esi, %esi
leaq 0x2b94(%rip), %rdx      # 0x236c2
leaq 0x57d9(%rip), %r9       # 0x2630e
movb $0x0, %al
callq 0x216e0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nop