// File: /workspace/github_c_makefile_star2_O3/howerj[P]eweb/unix.c
// Function: eweb_open
static long eweb_open(eweb_os_t *w, unsigned port) {
	assert(w);
	struct sockaddr_in serv_addr = { 0 };
	assert(port > 0);
	errno = 0;
	const long listenfd = socket(AF_INET, SOCK_STREAM, 0);
	if (listenfd < 0) {
		w->log(w, EWEB_ERROR, "socket failed: %s", strerror(errno));
		return -1;
	}

	/* For Linux support, MSG_NOSIGNAL is used: See <http://stackoverflow.com/questions/108183/> */
	int y = 1;
#ifdef SO_NOSIGPIPE
	errno = 0;
	/* use SO_NOSIGPIPE, to ignore any SIGPIPEs */
	if (setsockopt(listenfd, SOL_SOCKET, SO_NOSIGPIPE, &y, sizeof(y)) < 0) {
		w->log(w, EWEB_ERROR, "setsocketopt(SO_NOSIGPIPE) failed: %s", strerror(errno));
		return -1;
	}
	y = 1;
#endif

	errno = 0;
	/* use SO_REUSEADDR, so we can restart the server without waiting */
	if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &y, sizeof(y)) < 0) {
		w->log(w, EWEB_ERROR, "setsockopt(SO_REUSEADDR) failed: %s", strerror(errno));
		return -1;
	}
	/* as soon as listenfd is set, keep a handler so we can close it on exit */
	signal(SIGINT, inthandler);
	signal(SIGTERM, inthandler);

	serv_addr.sin_family = AF_INET;
	serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	serv_addr.sin_port = htons(port);

	errno = 0;
	if (bind(listenfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
		w->log(w, EWEB_ERROR, "bind failed: %s", strerror(errno));
		return -1;
	}

	errno = 0;
	if (listen(listenfd, 64) < 0) {
		w->log(w, EWEB_ERROR, "listen failed: %s", strerror(errno));
		return -1;
	}

	return listenfd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
testq %rdi, %rdi
je 0x45eb
movl %esi, %ebp
movq $0x0, 0x18(%rsp)
testl %esi, %esi
je 0x460a
movq %rdi, %rbx
callq 0x2050
movq %rax, %r14
movl $0x0, (%rax)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2330
testl %eax, %eax
js 0x457a
movl %eax, %r15d
leaq 0xc(%rsp), %rcx
movl $0x1, (%rcx)
movl $0x0, (%r14)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x2090
testl %eax, %eax
js 0x459f
leaq 0x6c2(%rip), %r12       # 0x4bda
movl $0x2, %edi
movq %r12, %rsi
callq 0x2180
movl $0xf, %edi
movq %r12, %rsi
callq 0x2180
leaq 0x10(%rsp), %rsi
movw $0x2, (%rsi)
xorl %eax, %eax
movl %eax, 0x4(%rsi)
rolw $0x8, %bp
movw %bp, 0x2(%rsi)
movl %eax, (%r14)
movl %r15d, %edi
movl $0x10, %edx
callq 0x2230
testl %eax, %eax
js 0x45a8
movl $0x0, (%r14)
movl %r15d, %edi
movl $0x40, %esi
callq 0x2200
testl %eax, %eax
js 0x45b1
movslq %r15d, %rax
jmp 0x45de
movq 0x50(%rbx), %r15
movl (%r14), %edi
callq 0x22d0
leaq 0x1d25(%rip), %rdx      # 0x62b2
movq %rbx, %rdi
movl $0x1, %esi
movq %rax, %rcx
xorl %eax, %eax
callq *%r15
jmp 0x45d7
leaq 0x1d1e(%rip), %r15      # 0x62c4
jmp 0x45b8
leaq 0x1d39(%rip), %r15      # 0x62e8
jmp 0x45b8
leaq 0x1d40(%rip), %r15      # 0x62f8
movq 0x50(%rbx), %r12
movl (%r14), %edi
callq 0x22d0
movq %rbx, %rdi
movl $0x1, %esi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq *%r12
movq $-0x1, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf3b(%rip), %rdi       # 0x552d
leaq 0x1c7f(%rip), %rsi      # 0x6278
leaq 0x1c7f(%rip), %rcx      # 0x627f
movl $0x47, %edx
callq 0x20e0
leaq 0x1c98(%rip), %rdi      # 0x62a9
leaq 0x1c60(%rip), %rsi      # 0x6278
leaq 0x1c60(%rip), %rcx      # 0x627f
movl $0x49, %edx
callq 0x20e0