// File: /workspace/github_c_makefile_star2_O3/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 %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0xbb79
testq %rax, %rax
je 0x5d1b
movq %rax, %r15
movq 0xf8(%r14), %rdi
movq %rax, %rsi
callq 0x6766
testq %rax, %rax
je 0x5d1b
movq %rax, %r12
xorl %ebp, %ebp
movq 0x20(%r12), %r13
cmpl $0x0, (%r12)
je 0x5cab
cmpl $0x0, 0xd8(%r14)
je 0x5d0f
movq 0x10(%r12), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x8(%r12)
testl %eax, %eax
jne 0x5d08
testq %rbp, %rbp
je 0x5cca
movq %r13, 0x20(%rbp)
jmp 0x5ceb
movq 0xf8(%r14), %rdi
movq %r15, %rsi
callq 0x6688
movq 0xf8(%r14), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x65bd
movq 0x8(%r14), %rdi
movq 0x28(%r12), %rsi
callq 0x5263
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x5263
xorl %r12d, %r12d
testq %r12, %r12
cmovneq %r12, %rbp
movq %r13, %r12
testq %r13, %r13
jne 0x5c95
movq %rbx, %rdi
callq 0xbb97
movq %rax, (%rsp)
movq %rbx, %rdi
callq 0xb97a
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0xbbb5
movq %rax, 0x8(%rsp)
movq 0x100(%r14), %rbp
testq %rbp, %rbp
je 0x5e9f
leaq 0x100(%r14), %r12
movq %rbp, %rax
movl $0x1, 0x18(%rax)
movq 0x20(%rax), %rax
testq %rax, %rax
jne 0x5d5b
testq %rbp, %rbp
je 0x5e9f
xorl %r15d, %r15d
cmpl $0x0, 0x18(%rbp)
je 0x5e8c
cmpl $0x0, (%rbp)
je 0x5d95
cmpl $0x0, 0xd8(%r14)
je 0x5e8c
movq 0x28(%rbp), %r13
testq %r13, %r13
je 0x5dc9
cmpq $0x0, (%rsp)
je 0x5db5
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x22e0
testl %eax, %eax
je 0x5dc9
movq %rbx, %rdi
movq %r13, %rsi
callq 0xbc0f
testq %rax, %rax
je 0x5e70
movq 0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x5ded
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5e70
callq 0x22e0
testl %eax, %eax
jne 0x5e70
movq 0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x5e09
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5e70
callq 0x22e0
testl %eax, %eax
jne 0x5e70
movq 0x10(%rbp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x8(%rbp)
testl %eax, %eax
jne 0x5e70
leaq 0x20(%r15), %rax
testq %r15, %r15
cmoveq %r12, %rax
movq 0x20(%rbp), %rcx
movq %rcx, (%rax)
movq 0x28(%rbp), %rsi
testq %rsi, %rsi
je 0x5e3e
movq 0x8(%r14), %rdi
callq 0x5263
movq 0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x5e50
movq 0x8(%r14), %rdi
callq 0x5263
movq 0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x5e62
movq 0x8(%r14), %rdi
callq 0x5263
movq 0x8(%r14), %rdi
movq %rbp, %rsi
callq 0x5263
xorl %ebp, %ebp
leaq 0x20(%rbp), %rcx
leaq 0x20(%r15), %rax
testq %r15, %r15
cmoveq %r12, %rax
testq %rbp, %rbp
cmoveq %r15, %rbp
cmovneq %rcx, %rax
jmp 0x5e90
leaq 0x20(%rbp), %rax
movq %rbp, %r15
movq (%rax), %rbp
testq %rbp, %rbp
jne 0x5d77
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq