// File: /workspace/github_c_makefile_star2_O0/DeforaOS[P]libSystem/src/event.c
// Function: event_register_timeout
int event_register_timeout(Event * event, struct timeval * timeout,
		EventTimeoutFunc func, void * data)
{
	EventTimeout * eventtimeout;
	struct timeval now;

	if(gettimeofday(&now, NULL) != 0)
		return error_set_code(-errno, "%s", strerror(errno));
	if((eventtimeout = (EventTimeout *)object_new(sizeof(*eventtimeout)))
			== NULL)
		return -1;
	eventtimeout->initial.tv_sec = timeout->tv_sec;
	eventtimeout->initial.tv_usec = timeout->tv_usec;
	eventtimeout->timeout.tv_sec = now.tv_sec + timeout->tv_sec;
	eventtimeout->timeout.tv_usec = now.tv_usec + timeout->tv_usec;
	eventtimeout->func = func;
	eventtimeout->data = data;
	if(array_append(event->timeouts, &eventtimeout) != 0)
	{
		object_delete(eventtimeout);
		return -1;
	}
	if(event->timeout.tv_sec > timeout->tv_sec
			|| (event->timeout.tv_sec == timeout->tv_sec
				&& event->timeout.tv_usec > timeout->tv_usec))
	{
#ifdef DEBUG
		fprintf(stderr, "DEBUG: %s%s%lld%s%ld%s", __func__, "() tv_sec=",
				(long long)timeout->tv_sec, ", tv_usec=",
				(long)timeout->tv_usec, "\n");
#endif
		event->timeout.tv_sec = timeout->tv_sec;
		event->timeout.tv_usec = timeout->tv_usec;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x42c0
cmpl $0x0, %eax
je 0x7b11
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 0x855c(%rip), %rsi      # 0x1005e
movb $0x0, %al
callq 0x4630
movl %eax, -0x4(%rbp)
jmp 0x7c22
movl $0x30, %edi
callq 0x4640
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x7b31
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7c22
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
addq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4290
cmpl $0x0, %eax
je 0x7bb9
movq -0x30(%rbp), %rdi
callq 0x44a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7c22
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jg 0x7bf6
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x7c1b
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jle 0x7c1b
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x120(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x128(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)