// File: /workspace/github_c_makefile_star2_O1/DeforaOS[P]libSystem/src/event.c
// Function: event_loop_once
static int _event_loop_once(Event * event)
{
	struct timeval tv = event->timeout;
	struct timeval * timeout = (tv.tv_sec == (time_t)LONG_MAX
			&& tv.tv_usec == (suseconds_t)LONG_MAX) ? NULL : &tv;
	fd_set rfds = event->rfds;
	fd_set wfds = event->wfds;

	if(timeout != NULL || event->fdmax != -1)
	{
		if(select(event->fdmax + 1, &rfds, &wfds, NULL, timeout) < 0)
			return error_set_code(-errno, "%s", strerror(errno));
		if(_loop_timeout(event) != 0)
			return -1;
		_loop_io(event, event->reads, &rfds);
		_loop_io(event, event->writes, &wfds);
		if(event->timeout.tv_sec == (time_t)LONG_MAX
				&& event->timeout.tv_usec
				== (suseconds_t)LONG_MAX)
			timeout = NULL;
		else
			timeout = &event->timeout;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
movabsq $0x7fffffffffffffff, %r14 # imm = 0x7FFFFFFFFFFFFFFF
movups 0x120(%rdi), %xmm0
leaq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx)
movq (%rcx), %rdi
xorq %r14, %rdi
movq 0x8(%rcx), %r8
xorq %r14, %r8
leaq 0x8(%rbx), %rsi
leaq 0x88(%rbx), %rdx
xorl %eax, %eax
orq %rdi, %r8
movl $0x0, %r8d
cmovneq %rcx, %r8
leaq 0xb8(%rsp), %rdi
movl $0x10, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0x38(%rsp), %rdi
movl $0x10, %ecx
movq %rdx, %rsi
rep  movsq (%rsi), %es:(%rdi)
jne 0x652b
cmpl $-0x1, 0x4(%rbx)
je 0x66f7
movl 0x4(%rbx), %edi
incl %edi
leaq 0xb8(%rsp), %rsi
leaq 0x38(%rsp), %rdx
xorl %ecx, %ecx
callq 0x44d0
testl %eax, %eax
js 0x658f
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x42c0
testl %eax, %eax
je 0x65b7
callq 0x40e0
movl (%rax), %edi
movl %edi, %ebp
negl %ebp
callq 0x4790
leaq 0x4aef(%rip), %rsi      # 0xb05e
movl %ebp, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x45d0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x66f7
jmp 0x66ca
callq 0x40e0
movl (%rax), %edi
movl %edi, %ebx
negl %ebx
callq 0x4790
leaq 0x4ab8(%rip), %rsi      # 0xb05e
movl %ebx, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x45d0
jmp 0x66f7
movq %r14, 0x120(%rbx)
movq %r14, 0x128(%rbx)
movq 0x118(%rbx), %rdi
callq 0x4250
testq %rax, %rax
je 0x66ca
leaq 0x120(%rbx), %r12
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbp
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq 0x118(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x47f0
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rax
subq %r13, %rax
jl 0x661b
jne 0x6652
cmpq 0x18(%rcx), %rbp
jl 0x6652
movq 0x28(%rcx), %rdi
callq *0x20(%rcx)
testl %eax, %eax
je 0x6677
movq 0x118(%rbx), %rdi
movq %r14, %rsi
callq 0x4540
movq 0x8(%rsp), %rdi
callq 0x4460
movq 0x118(%rbx), %rdi
callq 0x4250
cmpq %r14, %rax
ja 0x65f3
jmp 0x66ca
cmpq (%r12), %rax
jge 0x66a9
movq %rax, (%r12)
movq 0x18(%rcx), %rdx
movq %rdx, %rcx
subq %rbp, %rcx
jge 0x669d
decq %rax
movq %rax, (%r12)
movq %rbp, %rcx
subq %rdx, %rcx
jmp 0x669d
movq 0x8(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
leaq (%rax,%r13), %rsi
movq %rsi, 0x10(%rdx)
leaq (%rcx,%rbp), %rsi
movq %rsi, 0x18(%rdx)
cmpq (%r12), %rax
jge 0x66bd
movq %rax, (%r12)
movq %rcx, 0x128(%rbx)
incl %r14d
jmp 0x663f
jne 0x66a4
movq 0x18(%rcx), %rdx
subq %rbp, %rdx
cmpq 0x128(%rbx), %rdx
jl 0x6658
jmp 0x66a4
jne 0x66a4
cmpq 0x128(%rbx), %rcx
jl 0x6699
jmp 0x66a4
movq 0x108(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movq %rbx, %rdi
callq 0x6cec
movq 0x110(%rbx), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x6cec
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq