// File: /workspace/github_c_makefile_star2_O0/howerj[P]eweb/eweb.c
// Function: eweb_server
int eweb_server(eweb_os_t *w, unsigned port, responder_cb_t responder_func) {
	assert(w);
	if (w->init(w) < 0)
		return w->log(w, EWEB_ERROR, "initialization failed");

	if (!port) {
		port = 8080;
		w->log(w->file, EWEB_OK, "using default port (%u)", port);
	}

	w->log(w, EWEB_OK, "eweb server initialized (port = %u), (mode = %u)", port, w->threading_mode);

	const int listenfd = w->open(w, port);
	if (listenfd < 0)
		return w->log(w, EWEB_ERROR, "open failed");

	for (unsigned long hit = 1;;hit++) {
		const int socketfd = w->accept(w, listenfd);
		if (socketfd < 0) {
			/*if (!doing_shutdown) */
			w->log(w, EWEB_ERROR, "accept failed");
			continue;
		}

		eweb_os_hit_args_t *args = eweb_calloc_or_die(w, 1, sizeof(struct eweb_os_hit_args));
		if (!args) {
			w->close(w, socketfd);
			goto fail;
		}
		args->hit = hit;
		args->socketfd = socketfd;
		args->listenfd = listenfd;
		args->responder_function = responder_func;
		args->w = w;

		/* !! Who cleans up on failure? */
		const long rval = w->thread_new(w, args);
		if (rval != EWEB_OK) {
			w->log(w, EWEB_ERROR, "thread new failed");
			continue;
		}
	}
	return EWEB_OK;
fail:
	w->close(w, listenfd);
	return EWEB_ERROR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4bdc
jmp 0x4bfb
leaq 0x2952(%rip), %rdi      # 0x7535
leaq 0x2d5e(%rip), %rsi      # 0x7948
movl $0x170, %edx            # imm = 0x170
leaq 0x32b9(%rip), %rcx      # 0x7eaf
callq 0x2100
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
cmpq $0x0, %rax
jge 0x4c33
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x32c3(%rip), %rdx      # 0x7eea
movb $0x0, %al
callq *%rcx
movl %eax, -0x4(%rbp)
jmp 0x4de5
cmpl $0x0, -0x14(%rbp)
jne 0x4c64
movl $0x1f90, -0x14(%rbp)    # imm = 0x1F90
movq -0x10(%rbp), %rax
movq 0x50(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movl -0x14(%rbp), %ecx
xorl %esi, %esi
leaq 0x32a1(%rip), %rdx      # 0x7f00
movb $0x0, %al
callq *%r8
movq -0x10(%rbp), %rax
movq 0x50(%rax), %r9
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movb 0x98(%rax), %al
shrb %al
andb $0x3, %al
movzbl %al, %r8d
xorl %esi, %esi
leaq 0x328a(%rip), %rdx      # 0x7f18
movb $0x0, %al
callq *%r9
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq *%rax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x4cd1
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x3284(%rip), %rdx      # 0x7f49
movb $0x0, %al
callq *%rcx
movl %eax, -0x4(%rbp)
jmp 0x4de5
movq $0x1, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq *%rax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x4d14
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x324a(%rip), %rdx      # 0x7f55
movb $0x0, %al
callq *%rcx
jmp 0x4dbc
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x50, %edx
callq 0x4df0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x4d48
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq *%rax
jmp 0x4dcd
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x40(%rax)
movl -0x24(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq *%rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x4dba
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x31af(%rip), %rdx      # 0x7f63
movb $0x0, %al
callq *%rcx
jmp 0x4dbc
jmp 0x4dbc
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x4cd9
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq *%rax
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop