// File: /workspace/github_c_makefile_star2_O0/DeforaOS[P]libSystem/src/event.c
// Function: event_unregister_timeout
int event_unregister_timeout(Event * event, EventTimeoutFunc func)
{
	unsigned int i = 0;
	EventTimeout * et;
	struct timeval now;

	while(i < array_count(event->timeouts))
	{
		array_get_copy(event->timeouts, i, &et);
		if(et->func != func)
		{
			i++;
			continue;
		}
		array_remove_pos(event->timeouts, i);
		object_delete(et);
	}
	if(gettimeofday(&now, NULL) != 0)
		return error_set_code(-errno, "%s", strerror(errno));
	/* XXX will fail in 2038 on 32-bit platforms */
	event->timeout.tv_sec = (time_t)LONG_MAX;
	event->timeout.tv_usec = (suseconds_t)LONG_MAX;
	for(i = 0; i < array_count(event->timeouts); i++)
	{
		array_get_copy(event->timeouts, i, &et);
		if(et->timeout.tv_sec < event->timeout.tv_sec
				|| (et->timeout.tv_sec == event->timeout.tv_sec
					&& et->timeout.tv_usec
					< event->timeout.tv_usec))
		{
			if((event->timeout.tv_sec = et->timeout.tv_sec
						- now.tv_sec) < 0)
			{
				event->timeout.tv_sec = 0;
				event->timeout.tv_usec = 0;
				break;
			}
			event->timeout.tv_usec = et->timeout.tv_usec
				- now.tv_usec;
			if(event->timeout.tv_usec >= 0)
				continue;
			event->timeout.tv_sec = max(0, event->timeout.tv_sec-1);
			event->timeout.tv_usec = -event->timeout.tv_usec;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
callq 0x4250
movq %rax, %rcx
movq -0x40(%rbp), %rax
cmpq %rcx, %rax
jae 0x815c
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdx
callq 0x48a0
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
cmpq -0x18(%rbp), %rax
je 0x813c
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x80e7
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x4590
movq -0x28(%rbp), %rdi
callq 0x44a0
jmp 0x80e7
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x42c0
cmpl $0x0, %eax
je 0x81a5
callq 0x40d0
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x44(%rbp)
callq 0x40d0
movl (%rax), %edi
callq 0x4840
movl -0x44(%rbp), %edi
movq %rax, %rdx
leaq 0x7ec8(%rip), %rsi      # 0x1005e
movb $0x0, %al
callq 0x4630
movl %eax, -0x4(%rbp)
jmp 0x8333
movq -0x10(%rbp), %rax
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
movq %rcx, 0x120(%rax)
movq -0x10(%rbp), %rax
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
movq %rcx, 0x128(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
callq 0x4250
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
jae 0x832c
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdx
callq 0x48a0
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x120(%rcx), %rax
jl 0x825d
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x120(%rcx), %rax
jne 0x831c
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x128(%rcx), %rax
jge 0x831c
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
subq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rax, 0x120(%rcx)
cmpq $0x0, %rax
jge 0x829d
movq -0x10(%rbp), %rax
movq $0x0, 0x120(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x128(%rax)
jmp 0x832c
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rcx
subq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x128(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
jl 0x82c4
jmp 0x831e
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rcx
subq $0x1, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jl 0x82e2
xorl %eax, %eax
movq %rax, -0x58(%rbp)
jmp 0x82f5
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rax
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x120(%rax)
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
subq 0x128(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x128(%rax)
jmp 0x831e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x81d6
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)