// File: mh0fm4[P]SCDC/src/components/transport/transport_uds.cc
// Function: scdc_transport_uds::open(char const*)
bool scdc_transport_uds::open(const char *socketfile)
{
  SCDC_TRACE("open: socketfile: '" << socketfile << "'");

  uds_server = new scdc_transport_uds_server_t();

  uds_server->server_socket = ::socket(AF_LOCAL, SOCK_STREAM, 0);
  if (uds_server->server_socket == -1)
  {
    SCDC_ERROR("open: creating server socket failed: '" << strerror(errno) << "'");
    return false;
  }

  uds_server->uds_filename = socketfile;

  ::unlink(uds_server->uds_filename.c_str());

  uds_server->saddr.sun_family = AF_LOCAL;
  strcpy(uds_server->saddr.sun_path, uds_server->uds_filename.c_str());

  if (::bind(uds_server->server_socket, (struct sockaddr *) &uds_server->saddr, sizeof(uds_server->saddr)) == -1)
  {
    SCDC_ERROR("open: binding server socket failed: '" << strerror(errno) << "'");
    ::close(uds_server->server_socket);
    return false;
  }

  ::chmod(uds_server->uds_filename.c_str(), S_IRWXU|S_IRWXG|S_IRWXO);

  if (::listen(uds_server->server_socket, TRANSPORT_UDS_LISTEN_BACKLOG) == -1)
  {
    SCDC_ERROR("open: listen server socket failed: '" << strerror(errno) << "'");
    ::close(uds_server->server_socket);
    return false;
  }

  return scdc_transport::open();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9c46a
movl $0x98, %edi
callq 0xc690
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x38(%rbp)
callq 0x9d210
jmp 0x9c485
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl $0x1, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0xc130
movl %eax, %edx
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rcx
movl %edx, 0x70(%rcx)
movq 0x40(%rax), %rax
cmpl $-0x1, 0x70(%rax)
jne 0x9c595
jmp 0x9c4bc
leaq 0x381e5(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
cmpq $0x0, %rax
je 0x9c58a
leaq 0x381cc(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e900
leaq 0x381bd(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
movq %rax, %rdi
leaq 0x9fab(%rip), %rsi      # 0xa64a8
callq 0xc670
movq %rax, %rdi
leaq 0xd870(%rip), %rsi      # 0xa9d7c
callq 0xc670
movq %rax, %rdi
leaq 0xd6ee(%rip), %rsi      # 0xa9c09
callq 0xc670
movq %rax, -0x40(%rbp)
callq 0xc080
movl (%rax), %edi
callq 0xc1d0
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0xc670
movq %rax, %rdi
leaq 0xbe8d(%rip), %rsi      # 0xa83d3
callq 0xc670
movq %rax, %rdi
movq 0x37a6b(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0x38147(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e920
jmp 0x9c58a
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x98, %esi
callq 0xc6a0
jmp 0x9c7fd
jmp 0x9c58c
movb $0x0, -0x1(%rbp)
jmp 0x9c7f2
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rsi
movq 0x40(%rax), %rdi
addq $0x78, %rdi
callq 0xc920
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdi
addq $0x78, %rdi
callq 0xc260
movq %rax, %rdi
callq 0xc2c0
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rcx
movw $0x1, (%rcx)
movq 0x40(%rax), %rcx
addq $0x2, %rcx
movq %rcx, -0x48(%rbp)
movq 0x40(%rax), %rdi
addq $0x78, %rdi
callq 0xc260
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0xc610
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rcx
movl 0x70(%rcx), %edi
movq 0x40(%rax), %rsi
movl $0x6e, %edx
callq 0xc0c0
cmpl $-0x1, %eax
jne 0x9c6e1
jmp 0x9c619
leaq 0x38088(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
cmpq $0x0, %rax
je 0x9c6c6
leaq 0x3806f(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e900
leaq 0x38060(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
movq %rax, %rdi
leaq 0x9e4e(%rip), %rsi      # 0xa64a8
callq 0xc670
movq %rax, %rdi
leaq 0xd713(%rip), %rsi      # 0xa9d7c
callq 0xc670
movq %rax, %rdi
leaq 0xd5d6(%rip), %rsi      # 0xa9c4e
callq 0xc670
movq %rax, -0x50(%rbp)
callq 0xc080
movl (%rax), %edi
callq 0xc1d0
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0xc670
movq %rax, %rdi
leaq 0xbd30(%rip), %rsi      # 0xa83d3
callq 0xc670
movq %rax, %rdi
movq 0x3790e(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0x37fea(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e920
jmp 0x9c6c8
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x70(%rax), %edi
callq 0xccd0
movb $0x0, -0x1(%rbp)
jmp 0x9c7f2
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdi
addq $0x78, %rdi
callq 0xc260
movq %rax, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0xc5f0
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x70(%rax), %edi
movl $0x10, %esi
callq 0xc7b0
cmpl $-0x1, %eax
jne 0x9c7e4
jmp 0x9c71f
leaq 0x37f82(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
cmpq $0x0, %rax
je 0x9c7cc
leaq 0x37f69(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e900
leaq 0x37f5a(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
movq %rax, %rdi
leaq 0x9d48(%rip), %rsi      # 0xa64a8
callq 0xc670
movq %rax, %rdi
leaq 0xd60d(%rip), %rsi      # 0xa9d7c
callq 0xc670
movq %rax, %rdi
leaq 0xd4f6(%rip), %rsi      # 0xa9c74
callq 0xc670
movq %rax, -0x58(%rbp)
callq 0xc080
movl (%rax), %edi
callq 0xc1d0
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0xc670
movq %rax, %rdi
leaq 0xbc2a(%rip), %rsi      # 0xa83d3
callq 0xc670
movq %rax, %rdi
movq 0x37808(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0x37ee4(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e920
jmp 0x9c7ce
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x70(%rax), %edi
callq 0xccd0
movb $0x0, -0x1(%rbp)
jmp 0x9c7f2
movq -0x30(%rbp), %rdi
callq 0x98640
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0xcba0
nopw %cs:(%rax,%rax)