// File: /workspace/github_c_makefile_star2_O0/arachsys[P]init/daemon.c
// Function: listen_tcp
static void listen_tcp(const char *address) {
  struct addrinfo hints = { .ai_socktype = SOCK_STREAM }, *info, *list;
  char host[256], port[32];
  int fd, status;

  if (sscanf(address, "[%255[^]]]:%31[^:]", host, port) != 2) {
    if (sscanf(address, "%255[^:]:%31[^:]", host, port) != 2) {
      if (sscanf(address, ":%31[^:]", port) != 1)
        errx(EXIT_FAILURE, "%s: Invalid address", address);
      snprintf(host, sizeof(host), "::");
    }
  }

  if ((status = getaddrinfo(host, port, &hints, &list)) != 0)
    errx(EXIT_FAILURE, "getaddrinfo: %s", gai_strerror(status));

  for (info = list; info != NULL; info = info->ai_next) {
    if ((fd = socket(info->ai_family, info->ai_socktype, 0)) < 0)
      err(EXIT_FAILURE, "socket");
    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &(int) { 1 }, sizeof(int));
    fcntl(fd, F_SETFD, FD_CLOEXEC);
    fcntl(fd, F_SETFL, O_NONBLOCK);

    if (bind(fd, info->ai_addr, info->ai_addrlen) < 0)
      err(EXIT_FAILURE, "bind");
    if (listen(fd, SOMAXCONN) < 0)
      err(EXIT_FAILURE, "listen");
    listen_add(fd);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2150
movl $0x1, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x150(%rbp), %rdx
leaq -0x170(%rbp), %rcx
leaq 0x116e(%rip), %rsi      # 0x41ad
movb $0x0, %al
callq 0x2260
cmpl $0x2, %eax
je 0x30c1
movq -0x8(%rbp), %rdi
leaq -0x150(%rbp), %rdx
leaq -0x170(%rbp), %rcx
leaq 0x115c(%rip), %rsi      # 0x41c0
movb $0x0, %al
callq 0x2260
cmpl $0x2, %eax
je 0x30bf
movq -0x8(%rbp), %rdi
leaq -0x170(%rbp), %rdx
leaq 0x1146(%rip), %rsi      # 0x41c8
movb $0x0, %al
callq 0x2260
cmpl $0x1, %eax
je 0x30a5
movq -0x8(%rbp), %rdx
movl $0x1, %edi
leaq 0x1133(%rip), %rsi      # 0x41d1
movb $0x0, %al
callq 0x20e0
leaq -0x150(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
leaq 0x112d(%rip), %rdx      # 0x41e5
movb $0x0, %al
callq 0x2110
jmp 0x30c1
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
leaq -0x38(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x2370
movl %eax, -0x178(%rbp)
cmpl $0x0, %eax
je 0x3108
movl -0x178(%rbp), %edi
callq 0x2120
movq %rax, %rdx
movl $0x1, %edi
leaq 0x10e7(%rip), %rsi      # 0x41e8
movb $0x0, %al
callq 0x20e0
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x322c
movq -0x40(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x40(%rbp), %rax
movl 0x8(%rax), %esi
xorl %edx, %edx
callq 0x23d0
movl %eax, -0x174(%rbp)
cmpl $0x0, %eax
jge 0x314e
movl $0x1, %edi
leaq 0x1050(%rip), %rsi      # 0x4197
movb $0x0, %al
callq 0x2230
movl -0x174(%rbp), %edi
movl $0x1, -0x17c(%rbp)
movl $0x1, %esi
movl $0x2, %edx
leaq -0x17c(%rbp), %rcx
movl $0x4, %r8d
callq 0x2080
movl -0x174(%rbp), %edi
movl $0x2, %esi
movl $0x1, %edx
movb $0x0, %al
callq 0x2090
movl -0x174(%rbp), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x2090
movl -0x174(%rbp), %edi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x188(%rbp)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x188(%rbp), %rsi
callq 0x22b0
cmpl $0x0, %eax
jge 0x31e8
movl $0x1, %edi
leaq 0xfb1(%rip), %rsi       # 0x4192
movb $0x0, %al
callq 0x2230
movl -0x174(%rbp), %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x2270
cmpl $0x0, %eax
jge 0x3210
movl $0x1, %edi
leaq 0xf95(%rip), %rsi       # 0x419e
movb $0x0, %al
callq 0x2230
movl -0x174(%rbp), %edi
callq 0x3d40
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x3110
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopw %cs:(%rax,%rax)