// File: /workspace/github_c_makefile_star2_O1/liuhaotian[P]xmppsh/libstrophe/src/handler.c
// Function: handler_add
static void _handler_add(xmpp_conn_t * const conn,
			 xmpp_handler handler,
			 const char * const ns,
			 const char * const name,
			 const char * const type,
			 void * const userdata, int user_handler)
{
    xmpp_handlist_t *item, *tail;

    /* check if handler already in list */
    for (item = conn->handlers; item; item = item->next) {
	if (item->handler == (void *)handler)
	    break;
    }
    if (item) return;

    /* build new item */
    item = (xmpp_handlist_t *)xmpp_alloc(conn->ctx, sizeof(xmpp_handlist_t));
    if (!item) return;

    item->user_handler = user_handler;
    item->handler = (void *)handler;
    item->userdata = userdata;
    item->enabled = 0;
    item->next = NULL;
    
    if (ns) {
	item->ns = xmpp_strdup(conn->ctx, ns);
	if (!item->ns) {
	    xmpp_free(conn->ctx, item);
	    return;
	}
    } else
	item->ns = NULL;
    if (name) {
	item->name = xmpp_strdup(conn->ctx, name);
	if (!item->name) {
	    if (item->ns) xmpp_free(conn->ctx, item->ns);
	    xmpp_free(conn->ctx, item);
	    return;
	}
    } else
	item->name = NULL;
    if (type) {
	item->type = xmpp_strdup(conn->ctx, type);
	if (!item->type) {
	    if (item->ns) xmpp_free(conn->ctx, item->ns);
	    if (item->name) xmpp_free(conn->ctx, item->name);
	    xmpp_free(conn->ctx, item);
	}
    } else
	item->type = NULL;

    /* append to list */
    if (!conn->handlers)
	conn->handlers = item;
    else {
	tail = conn->handlers;
	while (tail->next) 
	    tail = tail->next;
	tail->next = item;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbp
movq %r8, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
movl 0x50(%rsp), %r12d
movq 0x100(%rdi), %rax
testq %rax, %rax
je 0x639b
cmpq %r15, 0x8(%rax)
je 0x64be
movq 0x20(%rax), %rax
jmp 0x6386
movq 0x8(%rbx), %rdi
movl $0x40, %esi
callq 0x5281
testq %rax, %rax
je 0x64be
movq %rax, %r14
movl %r12d, (%rax)
movq %r15, 0x8(%rax)
movq %rbp, 0x10(%rax)
movl $0x0, 0x18(%rax)
movq $0x0, 0x20(%rax)
testq %r13, %r13
je 0x63eb
movq 0x8(%rbx), %rdi
movq %r13, %rsi
callq 0xc264
movq %rax, 0x28(%r14)
testq %rax, %rax
jne 0x63f3
jmp 0x6421
movq $0x0, 0x28(%r14)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x643b
movq 0x8(%rbx), %rdi
callq 0xc264
movq %rax, 0x30(%r14)
testq %rax, %rax
jne 0x6443
movq 0x28(%r14), %rsi
testq %rsi, %rsi
je 0x6421
movq 0x8(%rbx), %rdi
callq 0x5293
movq 0x8(%rbx), %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5293
movq $0x0, 0x30(%r14)
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x6491
movq 0x8(%rbx), %rdi
callq 0xc264
movq %rax, 0x38(%r14)
testq %rax, %rax
jne 0x6499
movq 0x28(%r14), %rsi
testq %rsi, %rsi
je 0x6471
movq 0x8(%rbx), %rdi
callq 0x5293
movq 0x30(%r14), %rsi
testq %rsi, %rsi
je 0x6483
movq 0x8(%rbx), %rdi
callq 0x5293
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x5293
jmp 0x6499
movq $0x0, 0x38(%r14)
movq 0x100(%rbx), %rax
testq %rax, %rax
je 0x64b7
movq %rax, %rcx
movq 0x20(%rax), %rax
testq %rax, %rax
jne 0x64a5
movq %r14, 0x20(%rcx)
jmp 0x64be
movq %r14, 0x100(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq