// File: /workspace/github_c_makefile_star2_O1/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 0x538c(%rip), %r15      # 0xd378
testq %r15, %r15
je 0x828f
leaq 0x10d0(%rip), %r14      # 0x90cc
xorl %ebp, %ebp
cmpl $0x0, 0x8(%r15)
jne 0x8280
movq (%r15), %r12
testq %r12, %r12
je 0x8242
xorl %ebx, %ebx
cmpl $-0x1, (%r12)
jne 0x822a
movzwl 0x8(%r12), %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2430
cmpl $-0x1, %eax
je 0x81ae
movl %eax, %r13d
cmpl 0x5367(%rip), %eax      # 0xd3b0
jge 0x8246
movl %r13d, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20e0
cmpl $-0x1, %eax
je 0x8255
movl %ebx, 0x4(%rsp)
movl %ebp, %ebx
movl %r13d, %edi
movl $0x1, %esi
movl $0x2, %edx
movq %r14, %rcx
movl $0x4, %r8d
callq 0x20d0
cmpl $-0x1, %eax
movq %r14, %rbp
jne 0x80a7
movq 0x38(%r15), %rsi
leaq 0x2d24(%rip), %rdi      # 0xadc4
xorl %eax, %eax
callq 0x2a00
leaq 0x8(%r12), %r14
movl %r13d, %edi
movl $0x1, %esi
movl $0xf, %edx
movq %rbp, %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 0x81c8
movl 0x48(%r15), %esi
movl %r13d, %edi
callq 0x22c0
cmpl $-0x1, %eax
movl %ebx, %ebp
je 0x81fb
movl %r13d, (%r12)
movl %r13d, %edi
movl $0x6, %esi
movl $0xc, %edx
leaq 0xfac(%rip), %rcx       # 0x90c8
movl $0x4, %r8d
callq 0x20d0
movq 0x5252(%rip), %rax      # 0xd380
movslq %r13d, %rdx
shlq $0x5, %rdx
leaq -0x4652(%rip), %rcx     # 0x3aea
movq %rcx, (%rax,%rdx)
movq 0x5239(%rip), %rax      # 0xd380
movq $0x0, 0x8(%rax,%rdx)
movq 0x5229(%rip), %rax      # 0xd380
movq %r15, 0x10(%rax,%rdx)
movq 0x521d(%rip), %rax      # 0xd380
movl $0x1, %esi
movl %r13d, %ecx
shll %cl, %esi
movl $0x1, 0x18(%rax,%rdx)
movq 0x527c(%rip), %rax      # 0xd3f8
movl %r13d, %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
orl %esi, (%rax,%rcx,4)
cmpl %r13d, 0x262bd(%rip)    # 0x2e44c
leaq 0xf36(%rip), %r14       # 0x90cc
jg 0x81a2
incl %r13d
movl %r13d, 0x262aa(%rip)    # 0x2e44c
incl 0x262a0(%rip)           # 0x2e448
movl 0x4(%rsp), %ebx
jmp 0x822a
cmpl $0x0, (%rsp)
je 0x8222
movq 0x38(%r15), %rsi
leaq 0x2b46(%rip), %rdi      # 0xad05
xorl %eax, %eax
callq 0x2a00
jmp 0x8222
cmpl $0x0, (%rsp)
movl %ebx, %ebp
je 0x81e2
movq 0x38(%r15), %rsi
leaq 0x2c1b(%rip), %rdi      # 0xadf6
xorl %eax, %eax
callq 0x2a00
movl %r13d, %edi
callq 0x21b0
orl $0x1, %ebp
movl $0x1, %ebx
leaq 0xed3(%rip), %r14       # 0x90cc
jmp 0x822a
cmpl $0x0, (%rsp)
leaq 0xec6(%rip), %r14       # 0x90cc
je 0x821a
movq 0x38(%r15), %rsi
leaq 0x2c0f(%rip), %rdi      # 0xae22
xorl %eax, %eax
callq 0x2a00
movl %r13d, %edi
callq 0x21b0
orl $0x1, %ebp
movl $0x1, %ebx
movq 0x88(%r12), %r12
testq %r12, %r12
jne 0x8017
testl %ebx, %ebx
sete %bl
jmp 0x8274
movb $0x1, %bl
jmp 0x8274
movq 0x38(%r15), %rsi
xorl %ebx, %ebx
leaq 0x2aea(%rip), %rdi      # 0xad3d
jmp 0x8262
movq 0x38(%r15), %rsi
xorl %ebx, %ebx
leaq 0x2b29(%rip), %rdi      # 0xad8b
xorl %eax, %eax
callq 0x2a00
movl %r13d, %edi
callq 0x21b0
orl $0x2, %ebp
testb %bl, %bl
je 0x8280
movl $0x2, 0x8(%r15)
movq 0x50(%r15), %r15
testq %r15, %r15
jne 0x7ffe
jmp 0x8291
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq