// File: /workspace/github_c_makefile_star2_O3/erikdubbelboer[P]discnt/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) {
            /* 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)++;
            }
            fds[*count] = anetTcpServer(server.neterr,port,NULL,
                server.tcp_backlog);
            if (fds[*count] != ANET_ERR) {
                anetNonBlock(NULL,fds[*count]);
                (*count)++;
            }
            /* Exit the loop if we were able to bind * on IPv4 or IPv6,
             * otherwise fds[*count] will be ANET_ERR and we'll print an
             * error and return to the caller with an error. */
            if (*count) 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, %ebx
cmpl $0x0, 0x53b9c(%rip)     # 0x6f1c8
jne 0x1b639
movq $0x0, 0x53b0f(%rip) # 0x6f148
xorl %ebp, %ebp
leaq 0x53c5e(%rip), %r12     # 0x6f2a0
leaq 0x53a3f(%rip), %rax     # 0x6f088
movq 0xc0(%rax,%rbp,8), %r13
testq %r13, %r13
je 0x1b67d
movq %r13, %rdi
movl $0x3a, %esi
callq 0x122b0
movl 0x53ad7(%rip), %ecx     # 0x6f140
movq %r12, %rdi
movl %ebx, %esi
movq %r13, %rdx
testq %rax, %rax
je 0x1b6e6
callq 0x17edb
jmp 0x1b6eb
movl 0x53abd(%rip), %ecx     # 0x6f140
movq %r12, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x17edb
movslq (%r14), %rcx
movl %eax, (%r15,%rcx,4)
movslq (%r14), %rax
movl (%r15,%rax,4), %esi
cmpl $-0x1, %esi
je 0x1b6ac
xorl %edi, %edi
callq 0x17589
incl (%r14)
movl 0x53a8e(%rip), %ecx     # 0x6f140
movq %r12, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x17d57
movslq (%r14), %rcx
movl %eax, (%r15,%rcx,4)
movslq (%r14), %rax
movl (%r15,%rax,4), %esi
cmpl $-0x1, %esi
je 0x1b6e0
xorl %edi, %edi
callq 0x17589
movl (%r14), %eax
incl %eax
movl %eax, (%r14)
testl %eax, %eax
je 0x1b6f2
jmp 0x1b761
callq 0x17d57
movslq (%r14), %rcx
movl %eax, (%r15,%rcx,4)
movslq (%r14), %rax
movl (%r15,%rax,4), %esi
cmpl $-0x1, %esi
je 0x1b720
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x17589
incl (%r14)
incq %rbp
movslq 0x53ab3(%rip), %rax     # 0x6f1c8
cmpq %rax, %rbp
jl 0x1b642
jmp 0x1b764
leaq 0x53961(%rip), %rax     # 0x6f088
movq 0xc0(%rax,%rbp,8), %rax
testq %rax, %rax
leaq 0x377f4(%rip), %rdx     # 0x52f2d
cmovneq %rax, %rdx
leaq 0x377ba(%rip), %rsi     # 0x52efe
leaq 0x53b55(%rip), %r8      # 0x6f2a0
movl $0x3, %edi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x19c06
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x1b764
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq