// File: /workspace/github_c_makefile_star2_O2/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, (%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r14
movl 0x50(%rsp), %r12d
leaq 0x100(%rdi), %rax
movq %rax, 0x8(%rsp)
movq (%rax), %rcx
testq %rcx, %rcx
je 0x61e2
leaq 0x20(%rcx), %rax
cmpq %r15, 0x8(%rcx)
jne 0x61cb
jmp 0x62f0
movq 0x8(%r14), %rdi
pushq $0x40
popq %rsi
callq 0x518f
testq %rax, %rax
je 0x62f0
movq %rax, %rbx
movl %r12d, (%rax)
movq %r15, 0x8(%rax)
movq %rbp, 0x10(%rax)
andl $0x0, 0x18(%rax)
andq $0x0, 0x20(%rax)
testq %r13, %r13
je 0x622a
movq 0x8(%r14), %rdi
movq %r13, %rsi
callq 0xbcd4
movq %rax, 0x28(%rbx)
testq %rax, %rax
jne 0x622f
jmp 0x625d
andq $0x0, 0x28(%rbx)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x6277
movq 0x8(%r14), %rdi
callq 0xbcd4
movq %rax, 0x30(%rbx)
testq %rax, %rax
jne 0x627c
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x625d
movq 0x8(%r14), %rdi
callq 0x51a1
movq 0x8(%r14), %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51a1
andq $0x0, 0x30(%rbx)
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x62c9
movq 0x8(%r14), %rdi
callq 0xbcd4
movq %rax, 0x38(%rbx)
testq %rax, %rax
jne 0x62ce
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x62a9
movq 0x8(%r14), %rdi
callq 0x51a1
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x62bb
movq 0x8(%r14), %rdi
callq 0x51a1
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x51a1
jmp 0x62ce
andq $0x0, 0x38(%rbx)
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
testq %rax, %rax
je 0x62ed
movq %rax, %rcx
movq 0x20(%rax), %rax
testq %rax, %rax
jne 0x62db
movq %rbx, 0x20(%rcx)
jmp 0x62f0
movq %rbx, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq