// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x586b
jmp 0x588a
leaq 0x1cc3(%rip), %rdi      # 0x7535
leaq 0x2b49(%rip), %rsi      # 0x83c2
movl $0x47, %edx
leaq 0x2b44(%rip), %rcx      # 0x83c9
callq 0x2100
leaq -0x24(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2130
cmpl $0x0, -0x14(%rbp)
jbe 0x58a2
jmp 0x58c1
leaq 0x2b4a(%rip), %rdi      # 0x83f3
leaq 0x2b12(%rip), %rsi      # 0x83c2
movl $0x49, %edx
leaq 0x2b0d(%rip), %rcx      # 0x83c9
callq 0x2100
callq 0x2050
movl $0x0, (%rax)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2340
cltq
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x5933
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x22f0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %r8
movq %rax, %rcx
movl $0x1, %esi
leaq 0x2adb(%rip), %rdx      # 0x83fc
movb $0x0, %al
callq *%r8
movq $-0x1, -0x8(%rbp)
jmp 0x5acb
movl $0x1, -0x34(%rbp)
callq 0x2050
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x34(%rbp), %rcx
movl $0x4, %r8d
callq 0x2090
cmpl $0x0, %eax
jge 0x59b2
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x22f0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %r8
movq %rax, %rcx
movl $0x1, %esi
leaq 0x2a6e(%rip), %rdx      # 0x840e
movb $0x0, %al
callq *%r8
movq $-0x1, -0x8(%rbp)
jmp 0x5acb
movl $0x2, %edi
leaq 0xa52(%rip), %rsi       # 0x6410
callq 0x21a0
movl $0xf, %edi
leaq 0xa41(%rip), %rsi       # 0x6410
callq 0x21a0
movw $0x2, -0x24(%rbp)
xorl %edi, %edi
callq 0x2120
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
movzwl %ax, %edi
callq 0x20c0
movw %ax, -0x22(%rbp)
callq 0x2050
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movl %eax, %edi
leaq -0x24(%rbp), %rsi
movl $0x10, %edx
callq 0x2260
cmpl $0x0, %eax
jge 0x5a5d
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x22f0
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %r8
movq %rax, %rcx
movl $0x1, %esi
leaq 0x29e4(%rip), %rdx      # 0x8432
movb $0x0, %al
callq *%r8
movq $-0x1, -0x8(%rbp)
jmp 0x5acb
callq 0x2050
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movl %eax, %edi
movl $0x40, %esi
callq 0x2230
cmpl $0x0, %eax
jge 0x5ac3
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x22f0
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %r8
movq %rax, %rcx
movl $0x1, %esi
leaq 0x298e(%rip), %rdx      # 0x8442
movb $0x0, %al
callq *%r8
movq $-0x1, -0x8(%rbp)
jmp 0x5acb
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)