// File: /workspace/github_c_makefile_star2_O0/liuhaotian[P]xmppsh/libstrophe/src/handler.c
// Function: handler_fire_timed
uint64_t handler_fire_timed(xmpp_ctx_t * const ctx)
{
    xmpp_connlist_t *connitem;
    xmpp_handlist_t *handitem, *temp;
    int ret, fired;
    uint64_t elapsed, min;

    min = (uint64_t)(-1);

    connitem = ctx->connlist;
    while (connitem) {
	if (connitem->conn->state != XMPP_STATE_CONNECTED) {
	    connitem = connitem->next;
	    continue;
	}
	
	/* enable all handlers that were added */
	for (handitem = connitem->conn->timed_handlers; handitem;
	     handitem = handitem->next)
	    handitem->enabled = 1;

	handitem = connitem->conn->timed_handlers;
	while (handitem) {
	    /* skip newly added handlers */
	    if (!handitem->enabled) {
		handitem = handitem->next;
		continue;
	    }

	    /* only fire user handlers after authentication */
	    if (handitem->user_handler && !connitem->conn->authenticated) {
		handitem = handitem->next;
		continue;
	    }

	    fired = 0;
	    elapsed = time_elapsed(handitem->last_stamp, time_stamp());
	    if (elapsed >= handitem->period) {
		/* fire! */
		fired = 1;
		handitem->last_stamp = time_stamp();
		ret = ((xmpp_timed_handler)handitem->handler)(connitem->conn, handitem->userdata);
	    } else if (min > (handitem->period - elapsed))
		min = handitem->period - elapsed;
		
	    temp = handitem;
	    handitem = handitem->next;

	    /* delete handler if it returned false */
	    if (fired && !ret)
		xmpp_timed_handler_delete(connitem->conn, temp->handler);
	}

	connitem = connitem->next;
    }

    return min;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $-0x1, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x7c10
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, 0x14(%rax)
je 0x7aa6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x7a80
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x7ad8
movq -0x18(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x7ab8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x7bff
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x7b0d
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x7aea
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x7b34
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x0, 0xd8(%rax)
jne 0x7b34
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x7aea
movl $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x135f0
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x13630
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x7b9f
movl $0x1, -0x28(%rbp)
callq 0x135f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rsi
callq *%rax
movl %eax, -0x24(%rbp)
jmp 0x7bc6
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq -0x30(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x7bc4
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x7bc6
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x7bfa
cmpl $0x0, -0x24(%rbp)
jne 0x7bfa
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x7c20
jmp 0x7aea
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x7a80
movq -0x38(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)