// File: /workspace/github_c_makefile_star2_O2/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 0x439d
movl %esi, %ebp
andq $0x0, 0x18(%rsp)
testl %esi, %esi
je 0x43b6
movq %rdi, %rbx
callq 0x2050
movq %rax, %r14
andl $0x0, (%rax)
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x2330
testl %eax, %eax
js 0x4334
movl %eax, %r15d
leaq 0xc(%rsp), %rcx
movl $0x1, (%rcx)
andl $0x0, (%r14)
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %r8
movl %eax, %edi
callq 0x2090
testl %eax, %eax
js 0x4357
leaq 0x670(%rip), %r12       # 0x494d
pushq $0x2
popq %rdi
movq %r12, %rsi
callq 0x2180
pushq $0xf
popq %rdi
movq %r12, %rsi
callq 0x2180
leaq 0x10(%rsp), %rsi
movw $0x2, (%rsi)
andl $0x0, 0x4(%rsi)
rolw $0x8, %bp
movw %bp, 0x2(%rsi)
andl $0x0, (%r14)
pushq $0x10
popq %rdx
movl %r15d, %edi
callq 0x2230
testl %eax, %eax
js 0x4360
andl $0x0, (%r14)
pushq $0x40
popq %rsi
movl %r15d, %edi
callq 0x2200
testl %eax, %eax
js 0x4369
movslq %r15d, %rax
jmp 0x4390
movq 0x50(%rbx), %r15
movl (%r14), %edi
callq 0x22d0
leaq 0x1f6b(%rip), %rdx      # 0x62b2
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq *%r15
jmp 0x438d
leaq 0x1f66(%rip), %r15      # 0x62c4
jmp 0x4370
leaq 0x1f81(%rip), %r15      # 0x62e8
jmp 0x4370
leaq 0x1f88(%rip), %r15      # 0x62f8
movq 0x50(%rbx), %r12
movl (%r14), %edi
callq 0x22d0
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq *%r12
pushq $-0x1
popq %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1189(%rip), %rdi      # 0x552d
leaq 0x1ecd(%rip), %rsi      # 0x6278
leaq 0x1ecd(%rip), %rcx      # 0x627f
pushq $0x47
jmp 0x43cd
leaq 0x1eec(%rip), %rdi      # 0x62a9
leaq 0x1eb4(%rip), %rsi      # 0x6278
leaq 0x1eb4(%rip), %rcx      # 0x627f
pushq $0x49
popq %rdx
callq 0x20e0