// File: /workspace/github_c_makefile_star2_O3/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
movaps %xmm0, 0x10(%rsp)
movq 0x10(%rsp), %rax
xorq %r14, %rax
movq 0x18(%rsp), %rcx
xorq %r14, %rcx
orq %rax, %rcx
sete %dl
leaq 0x8(%rdi), %rsi
leaq 0xb8(%rsp), %rdi
movl $0x10, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0x88(%rbx), %rsi
leaq 0x38(%rsp), %rdi
movl $0x10, %ecx
rep  movsq (%rsi), %es:(%rdi)
movl 0x4(%rbx), %edi
cmpl $-0x1, %edi
sete %cl
xorl %eax, %eax
testb %cl, %dl
jne 0x6770
xorl %eax, %eax
testb %dl, %dl
leaq 0x10(%rsp), %r8
cmovneq %rax, %r8
incl %edi
leaq 0xb8(%rsp), %rsi
leaq 0x38(%rsp), %rdx
xorl %ecx, %ecx
callq 0x44d0
testl %eax, %eax
js 0x65fc
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x42c0
testl %eax, %eax
je 0x6624
callq 0x40e0
movl (%rax), %edi
movl %edi, %ebp
negl %ebp
callq 0x47a0
leaq 0x4a82(%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 0x6770
jmp 0x6743
callq 0x40e0
movl (%rax), %edi
movl %edi, %ebx
negl %ebx
callq 0x47a0
leaq 0x4a4b(%rip), %rsi      # 0xb05e
movl %ebx, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x45d0
jmp 0x6770
movq %r14, 0x120(%rbx)
movq %r14, 0x128(%rbx)
movq 0x118(%rbx), %rdi
callq 0x4250
testq %rax, %rax
je 0x6743
leaq 0x120(%rbx), %r12
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %rbp
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq 0x118(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4800
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rax
cmpq %rax, %r13
jg 0x6688
jne 0x66fa
cmpq 0x18(%rcx), %rbp
jl 0x66f7
movq 0x28(%rcx), %rdi
callq *0x20(%rcx)
testl %eax, %eax
je 0x66c2
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 0x6660
jmp 0x6743
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 0x66ea
movq %rax, (%r12)
jmp 0x6720
jne 0x6727
cmpq 0x128(%rbx), %rcx
jl 0x66e4
jmp 0x6727
movq %r13, %rax
subq %r13, %rax
cmpq (%r12), %rax
jge 0x672c
movq 0x18(%rcx), %rdx
movq %rax, (%r12)
movq %rdx, %rcx
subq %rbp, %rcx
jge 0x6720
decq %rax
movq %rax, (%r12)
movq %rbp, %rcx
subq %rdx, %rcx
movq %rcx, 0x128(%rbx)
incl %r14d
jmp 0x66ac
jne 0x6727
movq 0x18(%rcx), %rdx
movq %rdx, %rcx
subq %rbp, %rcx
cmpq 0x128(%rbx), %rcx
jl 0x6707
jmp 0x6727
movq 0x108(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movq %rbx, %rdi
callq 0x6d4f
movq 0x110(%rbx), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x6d4f
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq