// File: /workspace/github_c_makefile_star2_O2/liuhaotian[P]xmppsh/libstrophe/src/handler.c
// Function: handler_fire_stanza
void handler_fire_stanza(xmpp_conn_t * const conn,
			 xmpp_stanza_t * const stanza)
{
    xmpp_handlist_t *item, *prev;
    char *id, *ns, *name, *type;
    
    /* call id handlers */
    id = xmpp_stanza_get_id(stanza);
    if (id) {
	prev = NULL;
 	item = (xmpp_handlist_t *)hash_get(conn->id_handlers, id);
	while (item) {
	    xmpp_handlist_t *next = item->next;

	    if (item->user_handler && !conn->authenticated) {
		item = next;
 		continue;
	    }

	    if (!((xmpp_handler)(item->handler))(conn, stanza, item->userdata)) {
		/* handler is one-shot, so delete it */
		if (prev)
		    prev->next = next;
		else {
		    hash_drop(conn->id_handlers, id);
		    hash_add(conn->id_handlers, id, next);
		}
                xmpp_free(conn->ctx, item->id);
		xmpp_free(conn->ctx, item);
		item = NULL;
	    }
	    if (item)
		prev = item;
	    item = next;
	}
    }
    
    /* call handlers */
    ns = xmpp_stanza_get_ns(stanza);
    name = xmpp_stanza_get_name(stanza);
    type = xmpp_stanza_get_type(stanza);
    
    /* enable all added handlers */
    for (item = conn->handlers; item; item = item->next)
	item->enabled = 1;

    prev = NULL;
    item = conn->handlers;
    while (item) {
	/* skip newly added handlers */
	if (!item->enabled) {
	    prev = item;
	    item = item->next;
	    continue;
	}

	/* don't call user handlers until authentication succeeds */
	if (item->user_handler && !conn->authenticated) {
	    prev = item;
	    item = item->next;
	    continue;
	}

	if ((!item->ns || (ns && strcmp(ns, item->ns) == 0) ||
	     xmpp_stanza_get_child_by_ns(stanza, item->ns)) &&
	    (!item->name || (name && strcmp(name, item->name) == 0)) &&
	    (!item->type || (type && strcmp(type, item->type) == 0)))
	    if (!((xmpp_handler)(item->handler))(conn, stanza, item->userdata)) {
		/* handler is one-shot, so delete it */
		if (prev)
		    prev->next = item->next;
		else
		    conn->handlers = item->next;
                if (item->ns) xmpp_free(conn->ctx, item->ns);
                if (item->name) xmpp_free(conn->ctx, item->name);
                if (item->type) xmpp_free(conn->ctx, item->type);
		xmpp_free(conn->ctx, item);
		item = NULL;
	    }
	
	if (item) {
	    prev = item;
	    item = item->next;
	} else if (prev)
	    item = prev->next;
	else
	    item = conn->handlers;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq %rsi, (%rsp)
movq %rsi, %rdi
callq 0xb7c2
testq %rax, %rax
je 0x5bc6
movq %rax, %r15
movq 0xf8(%r14), %rdi
movq %rax, %rsi
callq 0x657f
movq %rax, %r12
xorl %ebx, %ebx
testq %r12, %r12
je 0x5bc6
movq %r12, %r13
movq 0x20(%r12), %r12
cmpl $0x0, (%r13)
je 0x5b5f
cmpl $0x0, 0xd8(%r14)
je 0x5b3d
movq 0x10(%r13), %rdx
movq %r14, %rdi
movq (%rsp), %rsi
callq *0x8(%r13)
testl %eax, %eax
jne 0x5bba
testq %rbx, %rbx
je 0x5b7d
movq %r12, 0x20(%rbx)
jmp 0x5b9e
movq 0xf8(%r14), %rdi
movq %r15, %rsi
callq 0x64d9
movq 0xf8(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x641a
movq 0x8(%r14), %rdi
movq 0x28(%r13), %rsi
callq 0x51a1
movq 0x8(%r14), %rdi
movq %r13, %rsi
callq 0x51a1
xorl %r13d, %r13d
testq %r13, %r13
cmovneq %r13, %rbx
jmp 0x5b3d
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0xb7e0
movq %rax, %r15
movq %rbx, %rdi
callq 0xb5c4
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0xb7fe
movq %rax, 0x8(%rsp)
leaq 0x100(%r14), %rbx
movq %rbx, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x5c0e
movl $0x1, 0x18(%rax)
addq $0x20, %rax
jmp 0x5bf9
xorl %r12d, %r12d
movq %rbx, %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0x5d45
cmpl $0x0, 0x18(%rbp)
je 0x5d39
cmpl $0x0, (%rbp)
je 0x5c3e
cmpl $0x0, 0xd8(%r14)
je 0x5d39
movq 0x28(%rbp), %r13
testq %r13, %r13
je 0x5c70
testq %r15, %r15
je 0x5c5b
movq %r15, %rdi
movq %r13, %rsi
callq 0x22e0
testl %eax, %eax
je 0x5c70
movq (%rsp), %rdi
movq %r13, %rsi
callq 0xb859
testq %rax, %rax
je 0x5d19
movq 0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x5c94
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5d19
callq 0x22e0
testl %eax, %eax
jne 0x5d19
movq 0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x5cb0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5d19
callq 0x22e0
testl %eax, %eax
jne 0x5d19
movq 0x10(%rbp), %rdx
movq %r14, %rdi
movq (%rsp), %rsi
callq *0x8(%rbp)
testl %eax, %eax
jne 0x5d19
leaq 0x20(%r12), %rax
testq %r12, %r12
cmoveq %rbx, %rax
movq 0x20(%rbp), %rcx
movq %rcx, (%rax)
movq 0x28(%rbp), %rsi
testq %rsi, %rsi
je 0x5ce7
movq 0x8(%r14), %rdi
callq 0x51a1
movq 0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x5cf9
movq 0x8(%r14), %rdi
callq 0x51a1
movq 0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x5d0b
movq 0x8(%r14), %rdi
callq 0x51a1
movq 0x8(%r14), %rdi
movq %rbp, %rsi
callq 0x51a1
xorl %ebp, %ebp
leaq 0x20(%rbp), %rcx
leaq 0x20(%r12), %rax
testq %r12, %r12
cmoveq %rbx, %rax
testq %rbp, %rbp
cmovneq %rbp, %r12
cmovneq %rcx, %rax
jmp 0x5c14
leaq 0x20(%rbp), %rax
movq %rbp, %r12
jmp 0x5c14
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq