// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movl %edi, (%rsp)
movq 0x51ad(%rip), %r15      # 0xd378
testq %r15, %r15
je 0x8461
leaq 0xfe1(%rip), %r14       # 0x91bc
xorl %ebx, %ebx
cmpl $0x0, 0x8(%r15)
jne 0x8452
movq (%r15), %r12
testq %r12, %r12
je 0x841e
xorl %ebp, %ebp
cmpl $-0x1, (%r12)
jne 0x8409
movzwl 0x8(%r12), %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2430
cmpl $-0x1, %eax
je 0x838d
movl %eax, %r13d
cmpl 0x5188(%rip), %eax      # 0xd3b0
jge 0x8428
movl %r13d, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20e0
cmpl $-0x1, %eax
je 0x8435
movl %ebp, 0x4(%rsp)
movl %ebx, %ebp
movl %r13d, %edi
movl $0x1, %esi
movl $0x2, %edx
movq %r14, %rcx
movl $0x4, %r8d
callq 0x20d0
cmpl $-0x1, %eax
movq %r14, %rbx
jne 0x8286
movq 0x38(%r15), %rsi
leaq 0x2c35(%rip), %rdi      # 0xaeb4
xorl %eax, %eax
callq 0x29fa
leaq 0x8(%r12), %r14
movl %r13d, %edi
movl $0x1, %esi
movl $0xf, %edx
movq %rbx, %rcx
movl $0x4, %r8d
callq 0x20d0
cmpw $0xa, (%r14)
movl $0x10, %edx
movl $0x1c, %eax
cmovel %eax, %edx
movl %r13d, %edi
movq %r14, %rsi
callq 0x22f0
cmpl $-0x1, %eax
je 0x83a7
movl 0x48(%r15), %esi
movl %r13d, %edi
callq 0x22c0
cmpl $-0x1, %eax
movl %ebp, %ebx
je 0x83da
movl %r13d, (%r12)
movl %r13d, %edi
movl $0x6, %esi
movl $0xc, %edx
leaq 0xebd(%rip), %rcx       # 0x91b8
movl $0x4, %r8d
callq 0x20d0
movq 0x5073(%rip), %rax      # 0xd380
movslq %r13d, %rdx
shlq $0x5, %rdx
leaq -0x4868(%rip), %rcx     # 0x3ab3
movq %rcx, (%rax,%rdx)
movq 0x505a(%rip), %rax      # 0xd380
movq $0x0, 0x8(%rax,%rdx)
movq 0x504a(%rip), %rax      # 0xd380
movq %r15, 0x10(%rax,%rdx)
movq 0x503e(%rip), %rax      # 0xd380
movl $0x1, %esi
movl %r13d, %ecx
shll %cl, %esi
movl $0x1, 0x18(%rax,%rdx)
movq 0x509d(%rip), %rax      # 0xd3f8
movl %r13d, %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
orl %esi, (%rax,%rcx,4)
cmpl %r13d, 0x260de(%rip)    # 0x2e44c
leaq 0xe47(%rip), %r14       # 0x91bc
jg 0x8381
incl %r13d
movl %r13d, 0x260cb(%rip)    # 0x2e44c
incl 0x260c1(%rip)           # 0x2e448
movl 0x4(%rsp), %ebp
jmp 0x8409
cmpl $0x0, (%rsp)
je 0x8401
movq 0x38(%r15), %rsi
leaq 0x2a57(%rip), %rdi      # 0xadf5
xorl %eax, %eax
callq 0x29fa
jmp 0x8401
cmpl $0x0, (%rsp)
movl %ebp, %ebx
je 0x83c1
movq 0x38(%r15), %rsi
leaq 0x2b2c(%rip), %rdi      # 0xaee6
xorl %eax, %eax
callq 0x29fa
movl %r13d, %edi
callq 0x21b0
orl $0x1, %ebx
movl $0x1, %ebp
leaq 0xde4(%rip), %r14       # 0x91bc
jmp 0x8409
cmpl $0x0, (%rsp)
leaq 0xdd7(%rip), %r14       # 0x91bc
je 0x83f9
movq 0x38(%r15), %rsi
leaq 0x2b20(%rip), %rdi      # 0xaf12
xorl %eax, %eax
callq 0x29fa
movl %r13d, %edi
callq 0x21b0
orl $0x1, %ebx
movl $0x1, %ebp
movq 0x88(%r12), %r12
testq %r12, %r12
jne 0x81f6
testl %ebp, %ebp
jne 0x8452
movl $0x2, 0x8(%r15)
jmp 0x8452
movq 0x38(%r15), %rsi
leaq 0x29fa(%rip), %rdi      # 0xae2d
jmp 0x8440
movq 0x38(%r15), %rsi
leaq 0x2a3b(%rip), %rdi      # 0xae7b
xorl %eax, %eax
callq 0x29fa
movl %r13d, %edi
callq 0x21b0
orl $0x2, %ebx
movq 0x50(%r15), %r15
testq %r15, %r15
jne 0x81dd
jmp 0x8463
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq