// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/events/events.c
// Function: events_run_internal
static int
events_run_internal(void)
{
	struct eventrec * r;
	struct timeval * tv;
	struct timeval tv2;
	int rc = 0;

	/* If we have any immediate events, process them and return. */
	if ((r = events_immediate_get()) != NULL) {
		while (r != NULL) {
			/* Process the event. */
			if ((rc = doevent(r)) != 0)
				goto done;

			/* Interrupt loop if requested. */
			if (interrupt_requested)
				goto done;

			/* Get the next event. */
			r = events_immediate_get();
		}

		/* We've processed at least one event; time to return. */
		goto done;
	}

	/*
	 * Figure out the maximum duration to block, and wait up to that
	 * duration for network events to become available.
	 */
	if (events_timer_min(&tv))
		goto err0;
	if (events_network_select(tv, &interrupt_requested))
		goto err1;
	free(tv);

	/*
	 * Check for available immediate events, network events, and timer
	 * events, in that order of priority; exit only when no more events
	 * are available or when interrupted.
	 */
	do {
		/* Interrupt loop if requested. */
		if (interrupt_requested)
			goto done;

		/* Run an immediate event, if one is available. */
		if ((r = events_immediate_get()) != NULL) {
			if ((rc = doevent(r)) != 0)
				goto done;
			continue;
		}

		/* Run a network event, if one is available. */
		if ((r = events_network_get()) != NULL) {
			if ((rc = doevent(r)) != 0)
				goto done;
			continue;
		}

		/* Check if any new network events are available. */
		memcpy(&tv2, &tv_zero, sizeof(struct timeval));
		if (events_network_select(&tv2, &interrupt_requested))
			goto err0;
		if ((r = events_network_get()) != NULL) {
			if ((rc = doevent(r)) != 0)
				goto done;
			continue;
		}

		/* Run a timer event, if one is available. */
		if (events_timer_get(&r))
			goto err0;
		if (r != NULL) {
			if ((rc = doevent(r)) != 0)
				goto done;
			continue;
		}

		/* No events available. */
		break;
	} while (1);

done:
	/* Success! */
	return (rc);

err1:
	free(tv);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x2c(%rbp)
callq 0x2fc0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x28fd
jmp 0x28c0
cmpq $0x0, -0x10(%rbp)
je 0x28f8
movq -0x10(%rbp), %rdi
callq 0x2d70
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x28dd
jmp 0x2a21
movl 0xbbdd(%rip), %eax      # 0xe4c0
cmpl $0x0, %eax
je 0x28ed
jmp 0x2a21
callq 0x2fc0
movq %rax, -0x10(%rbp)
jmp 0x28c0
jmp 0x2a21
leaq -0x18(%rbp), %rdi
callq 0x4450
cmpl $0x0, %eax
je 0x2910
jmp 0x2a32
movq -0x18(%rbp), %rdi
leaq 0xbba5(%rip), %rsi      # 0xe4c0
callq 0x3b40
cmpl $0x0, %eax
je 0x292a
jmp 0x2a29
movq -0x18(%rbp), %rdi
callq 0x2040
movl 0xbb87(%rip), %eax      # 0xe4c0
cmpl $0x0, %eax
je 0x2943
jmp 0x2a21
callq 0x2fc0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x296d
movq -0x10(%rbp), %rdi
callq 0x2d70
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x2968
jmp 0x2a21
jmp 0x2a13
callq 0x3c70
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x2994
movq -0x10(%rbp), %rdi
callq 0x2d70
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x2992
jmp 0x2a21
jmp 0x2a13
movq 0x776d(%rip), %rax      # 0xa108
movq %rax, -0x28(%rbp)
movq 0x776a(%rip), %rax      # 0xa110
movq %rax, -0x20(%rbp)
leaq -0x28(%rbp), %rdi
leaq 0xbb0b(%rip), %rsi      # 0xe4c0
callq 0x3b40
cmpl $0x0, %eax
je 0x29c1
jmp 0x2a32
callq 0x3c70
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x29e5
movq -0x10(%rbp), %rdi
callq 0x2d70
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x29e3
jmp 0x2a21
jmp 0x2a13
leaq -0x10(%rbp), %rdi
callq 0x45a0
cmpl $0x0, %eax
je 0x29f5
jmp 0x2a32
cmpq $0x0, -0x10(%rbp)
je 0x2a11
movq -0x10(%rbp), %rdi
callq 0x2d70
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x2a0f
jmp 0x2a21
jmp 0x2a13
jmp 0x2a1f
movb $0x1, %al
testb $0x1, %al
jne 0x2933
jmp 0x2a1f
jmp 0x2a21
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2a39
movq -0x18(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)