// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rsi, %r12
movl %edi, %ebx
movl 0x52f12(%rip), %eax     # 0x6a1c8
testl %eax, %eax
jne 0x172c2
andq $0x0, 0x52e86(%rip)     # 0x6a148
leaq 0x52fd7(%rip), %r13     # 0x6a2a0
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x172db
cltq
cmpq %rax, %rbp
jge 0x173ad
leaq 0x52da6(%rip), %rax     # 0x6a088
movq 0xc0(%rax,%rbp,8), %r14
testq %r14, %r14
je 0x17314
movq %r14, %rdi
pushq $0x3a
popq %rsi
callq 0x122b0
movl 0x52e40(%rip), %ecx     # 0x6a140
movq %r13, %rdi
movl %ebx, %esi
movq %r14, %rdx
testq %rax, %rax
je 0x1737d
callq 0x140da
jmp 0x17382
movl 0x52e26(%rip), %ecx     # 0x6a140
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x140da
movslq (%r15), %rcx
movl %eax, (%r12,%rcx,4)
movslq (%r15), %rax
movl (%r12,%rax,4), %esi
cmpl $-0x1, %esi
je 0x17343
xorl %edi, %edi
callq 0x1382c
incl (%r15)
movl 0x52df7(%rip), %ecx     # 0x6a140
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x13f6c
movslq (%r15), %rcx
movl %eax, (%r12,%rcx,4)
movslq (%r15), %rax
movl (%r12,%rax,4), %esi
cmpl $-0x1, %esi
je 0x17377
xorl %edi, %edi
callq 0x1382c
movl (%r15), %eax
incl %eax
movl %eax, (%r15)
testl %eax, %eax
je 0x17389
jmp 0x173ad
callq 0x13f6c
movslq (%r15), %rcx
movl %eax, (%r12,%rcx,4)
movslq (%r15), %rax
movl (%r12,%rax,4), %esi
cmpl $-0x1, %esi
je 0x173b1
xorl %edi, %edi
callq 0x1382c
incl (%r15)
incq %rbp
movl 0x52e20(%rip), %eax     # 0x6a1c8
jmp 0x172cb
xorl %eax, %eax
jmp 0x173eb
leaq 0x52cd0(%rip), %rax     # 0x6a088
movq 0xc0(%rax,%rbp,8), %rax
testq %rax, %rax
leaq 0x35a83(%rip), %rdx     # 0x4ce4d
cmovneq %rax, %rdx
leaq 0x35a49(%rip), %rsi     # 0x4ce1e
leaq 0x52ec4(%rip), %r8      # 0x6a2a0
pushq $0x3
popq %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x15b9e
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq