// File: /workspace/github_c_makefile_star2_O2/wtarreau[P]httpterm/httpterm.c
// Function: start_proxies
int start_proxies(int verbose) {
    struct proxy *curproxy;
    struct listener *listener;
    int err = ERR_NONE;
    int fd, pxerr;

    for (curproxy = proxy; curproxy != NULL; curproxy = curproxy->next) {
        if (curproxy->state != PR_STNEW)
	    continue; /* already initialized */

	pxerr = 0;
	for (listener = curproxy->listen; listener != NULL; listener = listener->next) {
	    if (listener->fd != -1)
		continue; /* already initialized */

	    if ((fd = socket(listener->addr.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
		if (verbose)
		    Alert("cannot create listening socket for proxy %s. Aborting.\n",
			  curproxy->id);
		err |= ERR_RETRYABLE;
		pxerr |= 1;
	        continue;
	    }
	
	    if (fd >= global.maxsock) {
		Alert("socket(): not enough free sockets for proxy %s. Raise -n argument. Aborting.\n",
		      curproxy->id);
		close(fd);
		err |= ERR_FATAL;
		pxerr |= 1;
		break;
	    }

	    if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
		Alert("cannot make socket non-blocking for proxy %s. Aborting.\n",
		      curproxy->id);
		close(fd);
		err |= ERR_FATAL;
		pxerr |= 1;
		break;
	    }

	    if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one)) == -1) {
		Alert("cannot do so_reuseaddr for proxy %s. Continuing.\n",
		      curproxy->id);
	    }

	    /* this one may silently fail */
#ifdef SO_REUSEPORT
	    setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (char *) &one, sizeof(one));
#endif

	    if (bind(fd,
		     (struct sockaddr *)&listener->addr,
		     listener->addr.ss_family == AF_INET6 ?
		     sizeof(struct sockaddr_in6) :
		     sizeof(struct sockaddr_in)) == -1) {
		if (verbose)
		    Alert("cannot bind socket for proxy %s. Aborting.\n",
			  curproxy->id);
		close(fd);
		err |= ERR_RETRYABLE;
		pxerr |= 1;
		continue;
	    }
	
	    if (listen(fd, curproxy->maxconn) == -1) {
		if (verbose)
		    Alert("cannot listen to socket for proxy %s. Aborting.\n",
			  curproxy->id);
		close(fd);
		err |= ERR_RETRYABLE;
		pxerr |= 1;
		continue;
	    }
	
	    /* the socket is ready */
	    listener->fd = fd;

#ifdef TCP_QUICKACK
	    /* we don't want quick ACKs there */
	    setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, (char *) &zero, sizeof(zero));
#endif
#ifdef TCP_CORK
	    /* don't send partial frames, and merge FIN with last ACK */
	    if (!MSG_MORE)
		setsockopt(fd, IPPROTO_TCP, TCP_CORK, (char *) &one, sizeof(one));
#endif

	    /* the function for the accept() event */
	    fdtab[fd].read  = &event_accept;
	    fdtab[fd].write = NULL; /* never called */
	    fdtab[fd].owner = (struct task *)curproxy; /* reference the proxy instead of a task */
	    fdtab[fd].state = FD_STLISTEN;
	    my_fd_set(fd, StaticReadEvent);
	    fd_insert(fd);
	    listeners++;
	}

	if (!pxerr) {
	    curproxy->state = PR_STRUN;
	}
    }

    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, 0x8(%rsp)
leaq 0x6947(%rip), %r15      # 0xe378
pushq $0x1
popq %r14
pushq $0x6
popq %rdx
xorl %r12d, %r12d
movq (%r15), %r15
testq %r15, %r15
je 0x7ce6
cmpl $0x0, 0x8(%r15)
jne 0x7cdd
movl $0x0, 0x4(%rsp)
movq %r15, %rbx
movq %r15, 0x10(%rsp)
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x7c9e
cmpl $-0x1, (%rbx)
jne 0x7c92
movzwl 0x8(%rbx), %edi
movl %r14d, %esi
callq 0x2430
cmpl $-0x1, %eax
je 0x7bf2
movl %eax, %r13d
cmpl 0x691b(%rip), %eax      # 0xe3b0
pushq $0x4
popq %rsi
jge 0x7caf
movl %r13d, %edi
movl %esi, %ebp
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20e0
cmpl $-0x1, %eax
je 0x7cbc
movl %r12d, 0xc(%rsp)
movl %r13d, %edi
movl %r14d, %esi
pushq $0x2
popq %rdx
leaq 0x15ff(%rip), %r12      # 0x90cc
movq %r12, %rcx
movl %ebp, %r8d
callq 0x20d0
cmpl $-0x1, %eax
movl %r14d, %r15d
jne 0x7af7
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rsi
leaq 0x32d4(%rip), %rdi      # 0xadc4
xorl %eax, %eax
callq 0x29aa
leaq 0x8(%rbx), %r14
movl %r13d, %edi
movl %r15d, %esi
pushq $0xf
popq %rdx
movq %r12, %rcx
movl %ebp, %r15d
movl %ebp, %r8d
callq 0x20d0
cmpw $0xa, (%r14)
pushq $0x10
popq %rdx
pushq $0x1c
popq %rax
cmovel %eax, %edx
movl %r13d, %edi
movq %r14, %rsi
callq 0x22f0
cmpl $-0x1, %eax
je 0x7c16
movq 0x10(%rsp), %r12
movl 0x48(%r12), %esi
movl %r13d, %edi
callq 0x22c0
cmpl $-0x1, %eax
pushq $0x6
popq %rsi
je 0x7c58
movl %r13d, (%rbx)
movl %r13d, %edi
movl %esi, %ebp
pushq $0xc
popq %rdx
leaq 0x1564(%rip), %rcx      # 0x90c8
movl %r15d, %r8d
callq 0x20d0
movq 0x680d(%rip), %rax      # 0xe380
movslq %r13d, %rdx
shlq $0x5, %rdx
leaq -0x4211(%rip), %rcx     # 0x3970
movq %rcx, (%rax,%rdx)
movq 0x67f4(%rip), %rax      # 0xe380
andq $0x0, 0x8(%rax,%rdx)
movq 0x67e7(%rip), %rax      # 0xe380
movq %r12, 0x10(%rax,%rdx)
movq 0x67db(%rip), %rax      # 0xe380
pushq $0x1
popq %r14
movl %r14d, %esi
movl %r13d, %ecx
shll %cl, %esi
movl $0x1, 0x18(%rax,%rdx)
movq 0x6838(%rip), %rax      # 0xe3f8
movl %r13d, %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
orl %esi, (%rax,%rcx,4)
cmpl %r13d, 0x27879(%rip)    # 0x2f44c
movq %r12, %r15
jg 0x7be2
incl %r13d
movl %r13d, 0x2786a(%rip)    # 0x2f44c
incl 0x27860(%rip)           # 0x2f448
movl 0xc(%rsp), %r12d
jmp 0x7c90
cmpl $0x0, 0x8(%rsp)
je 0x7c0b
movq 0x38(%r15), %rsi
leaq 0x3101(%rip), %rdi      # 0xad05
xorl %eax, %eax
callq 0x29aa
orl $0x1, %r12d
movl %r14d, 0x4(%rsp)
jmp 0x7c53
cmpl $0x0, 0x8(%rsp)
je 0x7c34
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rsi
leaq 0x31c9(%rip), %rdi      # 0xadf6
xorl %eax, %eax
callq 0x29aa
movl %r13d, %edi
callq 0x21b0
movl 0xc(%rsp), %r12d
orl $0x1, %r12d
pushq $0x1
popq %r14
movl %r14d, 0x4(%rsp)
movq 0x10(%rsp), %r15
pushq $0x6
popq %rdx
jmp 0x7c92
movl %esi, %ebp
cmpl $0x0, 0x8(%rsp)
pushq $0x1
popq %r14
movq %r12, %r15
je 0x7c7a
movq 0x38(%r15), %rsi
leaq 0x31af(%rip), %rdi      # 0xae22
xorl %eax, %eax
callq 0x29aa
movl %r13d, %edi
callq 0x21b0
movl 0xc(%rsp), %r12d
orl $0x1, %r12d
movl %r14d, 0x4(%rsp)
movl %ebp, %edx
addq $0x88, %rbx
jmp 0x7a62
cmpl $0x0, 0x4(%rsp)
jne 0x7cdd
movl $0x2, 0x8(%r15)
jmp 0x7cdd
movq 0x38(%r15), %rsi
leaq 0x3083(%rip), %rdi      # 0xad3d
jmp 0x7cc7
movq 0x38(%r15), %rsi
leaq 0x30c4(%rip), %rdi      # 0xad8b
xorl %eax, %eax
callq 0x29aa
movl %r13d, %edi
callq 0x21b0
orl $0x2, %r12d
pushq $0x6
popq %rdx
addq $0x50, %r15
jmp 0x7a3b
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq