// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/anet.c
// Function: anetTcpServer
static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backlog)
{
    int s = -1, rv;
    char _port[6];  /* strlen("65535") */
    struct addrinfo hints, *servinfo, *p;

    snprintf(_port,6,"%d",port);
    memset(&hints,0,sizeof(hints));
    hints.ai_family = af;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_PASSIVE;    /* No effect if bindaddr != NULL */

    if ((rv = getaddrinfo(bindaddr,_port,&hints,&servinfo)) != 0) {
        anetSetError(err, "%s", gai_strerror(rv));
        return ANET_ERR;
    }
    for (p = servinfo; p != NULL; p = p->ai_next) {
        if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1)
            continue;

        if (af == AF_INET6 && anetV6Only(err,s) == ANET_ERR) goto error;
        if (anetSetReuseAddr(err,s) == ANET_ERR) goto error;
        if (anetListen(err,s,p->ai_addr,p->ai_addrlen,backlog) == ANET_ERR) goto error;
        goto end;
    }
    if (p == NULL) {
        anetSetError(err, "unable to bind socket, errno: %d", errno);
        goto error;
    }

error:
    if (s != -1) close(s);
    s = ANET_ERR;
end:
    freeaddrinfo(servinfo);
    return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
leaq -0x36(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x6, %esi
leaq 0x7599d(%rip), %rdx     # 0x87174
movb $0x0, %al
callq 0x101e0
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x10250
movl -0x24(%rbp), %eax
movl %eax, -0x64(%rbp)
movl $0x1, -0x60(%rbp)
movl $0x1, -0x68(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x36(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x10640
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
je 0x11850
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x30(%rbp), %edi
callq 0x10200
movq -0x80(%rbp), %rdi
movq %rax, %rdx
leaq 0x757f5(%rip), %rsi     # 0x87032
movb $0x0, %al
callq 0x10900
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x11942
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x118ec
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 0x10710
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
jne 0x11887
jmp 0x118db
cmpl $0xa, -0x24(%rbp)
jne 0x118a0
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x121f0
cmpl $-0x1, %eax
jne 0x118a0
jmp 0x1191e
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x12170
cmpl $-0x1, %eax
jne 0x118b3
jmp 0x1191e
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x78(%rbp), %rax
movl 0x10(%rax), %ecx
movl -0x28(%rbp), %r8d
callq 0x11a60
cmpl $-0x1, %eax
jne 0x118d9
jmp 0x1191e
jmp 0x11933
movq -0x78(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x11858
cmpq $0x0, -0x78(%rbp)
jne 0x1191c
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
callq 0x10080
movq -0x88(%rbp), %rdi
movl (%rax), %edx
leaq 0x75843(%rip), %rsi     # 0x87156
movb $0x0, %al
callq 0x10900
jmp 0x1191e
jmp 0x1191e
cmpl $-0x1, -0x2c(%rbp)
je 0x1192c
movl -0x2c(%rbp), %edi
callq 0x10280
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movq -0x70(%rbp), %rdi
callq 0x10700
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop