// File: /workspace/github_c_makefile_star2_O1/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 0xbd0d
testq %rax, %rax
je 0x5d43
movq %rax, %r15
movq 0xf8(%r14), %rdi
movq %rax, %rsi
callq 0x67a3
testq %rax, %rax
je 0x5d43
movq %rax, %r12
xorl %ebp, %ebp
movq 0x20(%r12), %r13
cmpl $0x0, (%r12)
je 0x5cd3
cmpl $0x0, 0xd8(%r14)
je 0x5d37
movq 0x10(%r12), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x8(%r12)
testl %eax, %eax
jne 0x5d30
testq %rbp, %rbp
je 0x5cf2
movq %r13, 0x20(%rbp)
jmp 0x5d13
movq 0xf8(%r14), %rdi
movq %r15, %rsi
callq 0x66c5
movq 0xf8(%r14), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x65fa
movq 0x8(%r14), %rdi
movq 0x28(%r12), %rsi
callq 0x5293
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x5293
xorl %r12d, %r12d
testq %r12, %r12
cmovneq %r12, %rbp
movq %r13, %r12
testq %r13, %r13
jne 0x5cbd
movq %rbx, %rdi
callq 0xbd2b
movq %rax, (%rsp)
movq %rbx, %rdi
callq 0xbb0e
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0xbd49
movq %rax, 0x8(%rsp)
leaq 0x100(%r14), %r12
movq 0x100(%r14), %rax
testq %rax, %rax
je 0x5d89
movl $0x1, 0x18(%rax)
movq 0x20(%rax), %rax
jmp 0x5d77
movq (%r12), %rbp
testq %rbp, %rbp
je 0x5ec1
xorl %r15d, %r15d
cmpl $0x0, 0x18(%rbp)
je 0x5eae
cmpl $0x0, (%rbp)
je 0x5db7
cmpl $0x0, 0xd8(%r14)
je 0x5eae
movq 0x28(%rbp), %r13
testq %r13, %r13
je 0x5deb
cmpq $0x0, (%rsp)
je 0x5dd7
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x22e0
testl %eax, %eax
je 0x5deb
movq %rbx, %rdi
movq %r13, %rsi
callq 0xbda1
testq %rax, %rax
je 0x5e92
movq 0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x5e0f
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5e92
callq 0x22e0
testl %eax, %eax
jne 0x5e92
movq 0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x5e2b
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5e92
callq 0x22e0
testl %eax, %eax
jne 0x5e92
movq 0x10(%rbp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x8(%rbp)
testl %eax, %eax
jne 0x5e92
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 0x5e60
movq 0x8(%r14), %rdi
callq 0x5293
movq 0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x5e72
movq 0x8(%r14), %rdi
callq 0x5293
movq 0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x5e84
movq 0x8(%r14), %rdi
callq 0x5293
movq 0x8(%r14), %rdi
movq %rbp, %rsi
callq 0x5293
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 0x5eb2
leaq 0x20(%rbp), %rax
movq %rbp, %r15
movq (%rax), %rbp
testq %rbp, %rbp
jne 0x5d99
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq