// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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, %r14
movq %rsi, %r15
movl %edi, 0x4(%rsp)
cmpl $0x0, 0xd1552(%rip)     # 0x106980
jne 0x3543b
movq $0x0, 0xd14c5(%rip) # 0x106900
leaq 0xd1416(%rip), %rbx     # 0x106858
xorl %r13d, %r13d
movq 0xa8(%rbx,%r13,8), %rbp
testq %rbp, %rbp
je 0x3547f
movq %rbp, %rdi
movl $0x3a, %esi
callq 0x26800
movl 0xd1497(%rip), %ecx     # 0x1068fc
leaq 0xd15f4(%rip), %rdi     # 0x106a60
testq %rax, %rax
je 0x354bb
movl 0x4(%rsp), %esi
movq %rbp, %rdx
callq 0x3111a
jmp 0x354c7
movl 0xd1477(%rip), %ecx     # 0x1068fc
leaq 0xd15d4(%rip), %rdi     # 0x106a60
movl 0x4(%rsp), %esi
xorl %edx, %edx
callq 0x3111a
movslq (%r14), %rcx
movl %eax, (%r15,%rcx,4)
movslq (%r14), %rax
movl (%r15,%rax,4), %esi
cmpl $-0x1, %esi
je 0x354d3
xorl %r12d, %r12d
xorl %edi, %edi
callq 0x30779
incl (%r14)
xorl %ebp, %ebp
jmp 0x35500
movl 0x4(%rsp), %esi
movq %rbp, %rdx
callq 0x30f94
movslq (%r14), %rcx
movl %eax, (%r15,%rcx,4)
jmp 0x3556d
callq 0x26890
xorl %r12d, %r12d
cmpl $0x61, (%rax)
movl $0x0, %ebp
jne 0x35500
movl $0x3, %edi
leaq 0x8aec2(%rip), %rsi     # 0xc03b3
xorl %eax, %eax
callq 0x32ea6
movl $0x1, %ebp
movb $0x1, %r12b
testb %r12b, %r12b
jne 0x3550d
xorl %eax, %eax
cmpl $0x1, (%r14)
jne 0x35565
movl 0xd13e9(%rip), %ecx     # 0x1068fc
leaq 0xd1546(%rip), %rdi     # 0x106a60
movl 0x4(%rsp), %esi
xorl %edx, %edx
callq 0x30f94
movslq (%r14), %rcx
movl %eax, (%r15,%rcx,4)
movslq (%r14), %rax
movl (%r15,%rax,4), %esi
cmpl $-0x1, %esi
je 0x35544
xorl %edi, %edi
callq 0x30779
incl (%r14)
jmp 0x35563
callq 0x26890
cmpl $0x61, (%rax)
jne 0x35563
incl %ebp
movl $0x3, %edi
leaq 0x8ae7a(%rip), %rsi     # 0xc03d6
xorl %eax, %eax
callq 0x32ea6
movl %ebp, %eax
addl (%r14), %eax
cmpl $0x2, %eax
je 0x355d5
movslq (%r14), %rax
movl (%r15,%rax,4), %esi
cmpl $-0x1, %esi
je 0x3559a
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x30779
incl (%r14)
incq %r13
movslq 0xd13f1(%rip), %rax     # 0x106980
cmpq %rax, %r13
jl 0x35445
jmp 0x355d7
movq 0xa8(%rbx,%r13,8), %rax
testq %rax, %rax
leaq 0x8a5dd(%rip), %rdx     # 0xbfb89
cmovneq %rax, %rdx
leaq 0x8ae42(%rip), %rsi     # 0xc03f9
leaq 0xd14a2(%rip), %r8      # 0x106a60
movl $0x3, %edi
movl 0x4(%rsp), %ecx
xorl %eax, %eax
callq 0x32ea6
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x355d7
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq