// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movl $0x0, -0x1c(%rbp)
movq 0x57df(%rip), %rax      # 0x113a8
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xbef4
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0xbbe7
jmp 0xbee3
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xbed0
movq -0x18(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xbc12
jmp 0xbebc
movq -0x18(%rbp), %rax
movzwl 0x8(%rax), %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2470
movl %eax, -0x20(%rbp)
cmpl $-0x1, %eax
jne 0xbc64
cmpl $0x0, -0x4(%rbp)
je 0xbc4d
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
leaq 0x31de(%rip), %rdi      # 0xee24
movb $0x0, %al
callq 0x2d40
movl -0x1c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbebc
movl -0x20(%rbp), %eax
cmpl 0x5763(%rip), %eax      # 0x113d0
jl 0xbca4
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
leaq 0x31de(%rip), %rdi      # 0xee5c
movb $0x0, %al
callq 0x2d40
movl -0x20(%rbp), %edi
callq 0x21d0
movl -0x1c(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbed0
movl -0x20(%rbp), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x20d0
cmpl $-0x1, %eax
jne 0xbcf2
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
leaq 0x31de(%rip), %rdi      # 0xeeaa
movb $0x0, %al
callq 0x2d40
movl -0x20(%rbp), %edi
callq 0x21d0
movl -0x1c(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbed0
movl -0x20(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq 0x1496(%rip), %rcx      # 0xd19c
movl $0x4, %r8d
callq 0x20c0
cmpl $-0x1, %eax
jne 0xbd2c
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
leaq 0x31be(%rip), %rdi      # 0xeee3
movb $0x0, %al
callq 0x2d40
movl -0x20(%rbp), %edi
movl $0x1, %esi
movl $0xf, %edx
leaq 0x145c(%rip), %rcx      # 0xd19c
movl $0x4, %r8d
callq 0x20c0
movl -0x20(%rbp), %edi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rax
movzwl 0x8(%rax), %edx
movl $0x10, %eax
movl $0x1c, %ecx
cmpl $0xa, %edx
cmoveq %rcx, %rax
movl %eax, %edx
callq 0x2320
cmpl $-0x1, %eax
jne 0xbdb6
cmpl $0x0, -0x4(%rbp)
je 0xbd97
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
leaq 0x3185(%rip), %rdi      # 0xef15
movb $0x0, %al
callq 0x2d40
movl -0x20(%rbp), %edi
callq 0x21d0
movl -0x1c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbebc
movl -0x20(%rbp), %edi
movq -0x10(%rbp), %rax
movl 0x48(%rax), %esi
callq 0x22e0
cmpl $-0x1, %eax
jne 0xbe05
cmpl $0x0, -0x4(%rbp)
je 0xbde6
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
leaq 0x3162(%rip), %rdi      # 0xef41
movb $0x0, %al
callq 0x2d40
movl -0x20(%rbp), %edi
callq 0x21d0
movl -0x1c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbebc
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %edi
movl $0x6, %esi
movl $0xc, %edx
leaq 0x1376(%rip), %rcx      # 0xd198
movl $0x4, %r8d
callq 0x20c0
movq 0x557c(%rip), %rax      # 0x113b0
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
leaq -0x7536(%rip), %rcx     # 0x4910
movq %rcx, (%rax)
movq 0x5560(%rip), %rax      # 0x113b0
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq 0x5542(%rip), %rax      # 0x113b0
movslq -0x20(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq 0x552c(%rip), %rax      # 0x113b0
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x1, 0x18(%rax)
movl -0x20(%rbp), %edi
movq 0x5568(%rip), %rsi      # 0x11408
callq 0x4810
movl -0x20(%rbp), %edi
callq 0x5680
movl 0x265a5(%rip), %eax     # 0x32458
addl $0x1, %eax
movl %eax, 0x2659c(%rip)     # 0x32458
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xbbf9
cmpl $0x0, -0x24(%rbp)
jne 0xbee1
movq -0x10(%rbp), %rax
movl $0x2, 0x8(%rax)
jmp 0xbee3
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0xbbcd
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)