// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/server.c
// Function: listenToPort
int listenToPort(int port, int *fds, int *count) {
    int j;

    /* Force binding of 0.0.0.0 if no bind address is specified, always
     * entering the loop if j == 0. */
    if (server.bindaddr_count == 0) server.bindaddr[0] = NULL;
    for (j = 0; j < server.bindaddr_count || j == 0; j++) {
        if (server.bindaddr[j] == NULL) {
            int unsupported = 0;
            /* Bind * for both IPv6 and IPv4, we enter here only if
             * server.bindaddr_count == 0. */
            fds[*count] = anetTcp6Server(server.neterr,port,NULL,
                server.tcp_backlog);
            if (fds[*count] != ANET_ERR) {
                anetNonBlock(NULL,fds[*count]);
                (*count)++;
            } else if (errno == EAFNOSUPPORT) {
                unsupported++;
                serverLog(LL_WARNING,"Not listening to IPv6: unsupproted");
            }

            if (*count == 1 || unsupported) {
                /* Bind the IPv4 address as well. */
                fds[*count] = anetTcpServer(server.neterr,port,NULL,
                    server.tcp_backlog);
                if (fds[*count] != ANET_ERR) {
                    anetNonBlock(NULL,fds[*count]);
                    (*count)++;
                } else if (errno == EAFNOSUPPORT) {
                    unsupported++;
                    serverLog(LL_WARNING,"Not listening to IPv4: unsupproted");
                }
            }
            /* Exit the loop if we were able to bind * on IPv4 and IPv6,
             * otherwise fds[*count] will be ANET_ERR and we'll print an
             * error and return to the caller with an error. */
            if (*count + unsupported == 2) break;
        } else if (strchr(server.bindaddr[j],':')) {
            /* Bind IPv6 address. */
            fds[*count] = anetTcp6Server(server.neterr,port,server.bindaddr[j],
                server.tcp_backlog);
        } else {
            /* Bind IPv4 address. */
            fds[*count] = anetTcpServer(server.neterr,port,server.bindaddr[j],
                server.tcp_backlog);
        }
        if (fds[*count] == ANET_ERR) {
            serverLog(LL_WARNING,
                "Creating Server TCP listening socket %s:%d: %s",
                server.bindaddr[j] ? server.bindaddr[j] : "*",
                port, server.neterr);
            return C_ERR;
        }
        anetNonBlock(NULL,fds[*count]);
        (*count)++;
    }
    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r12
movl %edi, %ebx
movl 0xcc1b8(%rip), %eax     # 0xf99d0
testl %eax, %eax
jne 0x2d824
andq $0x0, 0xcc12c(%rip)     # 0xf9950
leaq 0xcc07d(%rip), %r13     # 0xf98a8
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x2d83d
cltq
cmpq %rax, %rbp
jge 0x2d979
movq 0xa8(%r13,%rbp,8), %r14
testq %r14, %r14
je 0x2d873
movq %r14, %rdi
pushq $0x3a
popq %rsi
callq 0x267f0
movl 0xcc0f1(%rip), %ecx     # 0xf994c
leaq 0xcc24e(%rip), %rdi     # 0xf9ab0
movl %ebx, %esi
movq %r14, %rdx
testq %rax, %rax
je 0x2d8ae
callq 0x29bb7
jmp 0x2d8b3
movl 0xcc0d3(%rip), %ecx     # 0xf994c
leaq 0xcc230(%rip), %rdi     # 0xf9ab0
movl %ebx, %esi
xorl %edx, %edx
callq 0x29bb7
movslq (%r15), %rcx
movl %eax, (%r12,%rcx,4)
movslq (%r15), %r13
movl (%r12,%r13,4), %esi
cmpl $-0x1, %esi
je 0x2d8bf
xorl %edi, %edi
callq 0x2929c
movl (%r15), %r13d
incl %r13d
movl %r13d, (%r15)
jmp 0x2d8e0
callq 0x29a3a
movslq (%r15), %rcx
movl %eax, (%r12,%rcx,4)
jmp 0x2d955
callq 0x26880
cmpl $0x61, (%rax)
jne 0x2d8e0
pushq $0x3
popq %rdi
leaq 0x81a42(%rip), %rsi     # 0xaf315
xorl %eax, %eax
callq 0x2b699
pushq $0x1
popq %r14
jmp 0x2d8e9
xorl %r14d, %r14d
cmpl $0x1, %r13d
jne 0x2d945
movl 0xcc05d(%rip), %ecx     # 0xf994c
leaq 0xcc1ba(%rip), %rdi     # 0xf9ab0
movl %ebx, %esi
xorl %edx, %edx
callq 0x29a3a
movslq (%r15), %rcx
movl %eax, (%r12,%rcx,4)
movslq (%r15), %r13
movl (%r12,%r13,4), %esi
cmpl $-0x1, %esi
je 0x2d924
xorl %edi, %edi
callq 0x2929c
movl (%r15), %r13d
incl %r13d
movl %r13d, (%r15)
jmp 0x2d945
callq 0x26880
cmpl $0x61, (%rax)
jne 0x2d945
incl %r14d
pushq $0x3
popq %rdi
leaq 0x819fd(%rip), %rsi     # 0xaf338
xorl %eax, %eax
callq 0x2b699
movl (%r15), %r13d
addl %r14d, %r13d
cmpl $0x2, %r13d
leaq 0xcbf55(%rip), %r13     # 0xf98a8
je 0x2d979
movslq (%r15), %rax
movl (%r12,%rax,4), %esi
cmpl $-0x1, %esi
je 0x2d97d
xorl %edi, %edi
callq 0x2929c
incl (%r15)
incq %rbp
movl 0xcc05c(%rip), %eax     # 0xf99d0
jmp 0x2d82d
xorl %eax, %eax
jmp 0x2d9b0
movq 0xa8(%r13,%rbp,8), %rax
testq %rax, %rax
leaq 0x8115c(%rip), %rdx     # 0xaeaeb
cmovneq %rax, %rdx
leaq 0x819c1(%rip), %rsi     # 0xaf35b
leaq 0xcc10f(%rip), %r8      # 0xf9ab0
pushq $0x3
popq %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2b699
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq