// File: /workspace/github_c_makefile_star2_O2/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, %r15 # imm = 0x7FFFFFFFFFFFFFFF
movups 0x120(%rdi), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x10(%rsp), %rax
xorq %r15, %rax
movq 0x18(%rsp), %rcx
xorq %r15, %rcx
orq %rax, %rcx
sete %dl
leaq 0x8(%rdi), %rsi
pushq $0x10
popq %rax
leaq 0xb8(%rsp), %rdi
movq %rax, %rcx
rep  movsq (%rsi), %es:(%rdi)
leaq 0x88(%rbx), %rsi
leaq 0x38(%rsp), %rdi
movq %rax, %rcx
rep  movsq (%rsi), %es:(%rdi)
movl 0x4(%rbx), %edi
cmpl $-0x1, %edi
sete %cl
xorl %eax, %eax
testb %cl, %dl
jne 0x6697
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 0x4510
testl %eax, %eax
js 0x6534
xorl %r14d, %r14d
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x42c0
testl %eax, %eax
je 0x655c
callq 0x40e0
movl (%rax), %edi
movl %edi, %ebp
negl %ebp
callq 0x47f0
leaq 0x4b46(%rip), %rsi      # 0xb05e
movl %ebp, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4610
testl %eax, %eax
je 0x666a
pushq $-0x1
popq %rax
jmp 0x6697
callq 0x40e0
movl (%rax), %edi
movl %edi, %ebx
negl %ebx
callq 0x47f0
leaq 0x4b13(%rip), %rsi      # 0xb05e
movl %ebx, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4610
jmp 0x6697
leaq 0x120(%rbx), %r12
movq %r15, 0x120(%rbx)
movq %r15, 0x128(%rbx)
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %rbp
leaq 0x8(%rsp), %r15
movl %r14d, %r14d
movq 0x118(%rbx), %rdi
callq 0x4250
cmpq %r14, %rax
jbe 0x666a
movq 0x118(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4860
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rax
cmpq %rax, %r13
jg 0x65c0
jne 0x661e
cmpq 0x18(%rcx), %rbp
jl 0x661b
movq 0x28(%rcx), %rdi
callq *0x20(%rcx)
testl %eax, %eax
je 0x65e6
movq 0x118(%rbx), %rdi
movq %r14, %rsi
callq 0x4580
movq 0x8(%rsp), %rdi
callq 0x44a0
jmp 0x6583
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 0x660e
movq %rax, (%r12)
jmp 0x6644
jne 0x664b
cmpq 0x128(%rbx), %rcx
jl 0x6608
jmp 0x664b
movq %r13, %rax
subq %r13, %rax
cmpq (%r12), %rax
jge 0x6653
movq 0x18(%rcx), %rdx
movq %rax, (%r12)
movq %rdx, %rcx
subq %rbp, %rcx
jge 0x6644
decq %rax
movq %rax, (%r12)
movq %rbp, %rcx
subq %rdx, %rcx
movq %rcx, 0x128(%rbx)
incl %r14d
jmp 0x6580
jne 0x664b
movq 0x18(%rcx), %rdx
movq %rdx, %rcx
subq %rbp, %rcx
cmpq 0x128(%rbx), %rcx
jl 0x662b
jmp 0x664b
movq 0x108(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movq %rbx, %rdi
callq 0x6c0d
movq 0x110(%rbx), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x6c0d
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq