// File: /workspace/github_c_makefile_star2_O0/wuxb45[P]SLB/lib1.c
// Function: server_create
struct server *
server_create(const char * const host, const int port, void*(*worker)(void*), void * const priv)
{
  char portstr[6];
  snprintf(portstr, 6, "%d", port);
  struct addrinfo info0 = {.ai_family = AF_INET, .ai_socktype = SOCK_STREAM};
  struct addrinfo *info = NULL;
  if (getaddrinfo(host, portstr, &info0, &info) != 0) return NULL;
  int fd = -1;

  for (struct addrinfo * p = info; p != NULL; p = p->ai_next) {
    fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
    if (fd < 0) continue;
    int one = 1;
    (void)setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
    if (bind(fd, p->ai_addr, p->ai_addrlen) != 0) break;
    if (listen(fd, 64) != 0) break;
    struct server * const server = malloc(sizeof(*server));
    server->running = true;
    server->fd = fd;
    server->worker = worker;
    server->priv = priv;
    if (pthread_create(&(server->pt), NULL, __server_master, server) != 0) {
      free(server);
      break;
    }
    freeaddrinfo(info);
    return server;
  }
  if (fd >= 0) {
    close(fd);
  }
  if (info) {
    freeaddrinfo(info);
  }
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
leaq -0x2e(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x6, %esi
leaq 0xdc69(%rip), %rdx      # 0x1b216
movb $0x0, %al
callq 0x61e0
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x6200
movl $0x2, -0x5c(%rbp)
movl $0x1, -0x58(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x68(%rbp), %rcx
callq 0x6560
cmpl $0x0, %eax
je 0xd601
movq $0x0, -0x8(%rbp)
jmp 0xd774
movl $0xffffffff, -0x6c(%rbp) # imm = 0xFFFFFFFF
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xd74e
movq -0x78(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x78(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x78(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x65f0
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0xd643
jmp 0xd73d
movl $0x1, -0x7c(%rbp)
movl -0x6c(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x7c(%rbp), %rcx
movl $0x4, %r8d
callq 0x6100
movl -0x6c(%rbp), %edi
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x88(%rbp), %rsi
callq 0x63f0
cmpl $0x0, %eax
je 0xd695
jmp 0xd74e
movl -0x6c(%rbp), %edi
movl $0x40, %esi
callq 0x63a0
cmpl $0x0, %eax
je 0xd6ac
jmp 0xd74e
movl $0x20, %edi
callq 0x6380
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movb $0x1, 0x4(%rax)
movl -0x6c(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x90(%rbp), %rdi
addq $0x8, %rdi
movq -0x90(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq 0x81(%rip), %rdx        # 0xd790
callq 0x6400
cmpl $0x0, %eax
je 0xd727
movq -0x90(%rbp), %rdi
callq 0x6060
jmp 0xd74e
movq -0x68(%rbp), %rdi
callq 0x65e0
movq -0x90(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd774
movq -0x78(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0xd610
cmpl $0x0, -0x6c(%rbp)
jl 0xd75c
movl -0x6c(%rbp), %edi
callq 0x6210
cmpq $0x0, -0x68(%rbp)
je 0xd76c
movq -0x68(%rbp), %rdi
callq 0x65e0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)