// File: /workspace/github_c_makefile_star2_O2/liuhaotian[P]xmppsh/libstrophe/src/conn.c
// Function: xmpp_conn_release
int xmpp_conn_release(xmpp_conn_t * const conn)
{
    xmpp_ctx_t *ctx;
    xmpp_connlist_t *item, *prev;
    xmpp_handlist_t *hlitem, *thli;
    hash_iterator_t *iter;
    const char *key;
    int released = 0;

    if (conn->ref > 1) 
	conn->ref--;
    else {
	ctx = conn->ctx;

	/* remove connection from context's connlist */
	if (ctx->connlist->conn == conn) {
	    item = ctx->connlist;
	    ctx->connlist = item->next;
	    xmpp_free(ctx, item);
	} else {
	    prev = NULL;
	    item = ctx->connlist;
	    while (item && item->conn != conn) {
		prev = item;
		item = item->next;
	    }

	    if (!item) {
		xmpp_error(ctx, "xmpp", "Connection not in context's list\n");
	    } else {
		prev->next = item->next;
		xmpp_free(ctx, item);
	    }
	}

	/* free handler stuff
	 * note that userdata is the responsibility of the client
	 * and the handler pointers don't need to be freed since they
	 * are pointers to functions */

	hlitem = conn->timed_handlers;
	while (hlitem) {
	    thli = hlitem;
	    hlitem = hlitem->next;

	    xmpp_free(ctx, thli);
	}

	/* id handlers
	 * we have to traverse the hash table freeing list elements 
	 * then release the hash table */
	iter = hash_iter_new(conn->id_handlers);
	while ((key = hash_iter_next(iter))) {
	    hlitem = (xmpp_handlist_t *)hash_get(conn->id_handlers, key);
	    while (hlitem) {
		thli = hlitem;
		hlitem = hlitem->next;
		xmpp_free(conn->ctx, thli->id);
		xmpp_free(conn->ctx, thli);
	    }
	}
	hash_iter_release(iter);
	hash_release(conn->id_handlers);

	hlitem = conn->handlers;
	while (hlitem) {
	    thli = hlitem;
	    hlitem = hlitem->next;

	    if (thli->ns) xmpp_free(ctx, thli->ns);
	    if (thli->name) xmpp_free(ctx, thli->name);
	    if (thli->type) xmpp_free(ctx, thli->type);
	    xmpp_free(ctx, thli);
	}

	if (conn->stream_error) {
	    xmpp_stanza_release(conn->stream_error->stanza);
	    if (conn->stream_error->text)
		xmpp_free(ctx, conn->stream_error->text);
	    xmpp_free(ctx, conn->stream_error);
	}

        parser_free(conn->parser);
	
	if (conn->domain) xmpp_free(ctx, conn->domain);
	if (conn->jid) xmpp_free(ctx, conn->jid);
    if (conn->bound_jid) xmpp_free(ctx, conn->bound_jid);
	if (conn->pass) xmpp_free(ctx, conn->pass);
	if (conn->stream_id) xmpp_free(ctx, conn->stream_id);
	if (conn->lang) xmpp_free(ctx, conn->lang);
	xmpp_free(ctx, conn);
	released = 1;
    }

    return released;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x2, %eax
jb 0x4936
decl %eax
movl %eax, (%rbx)
xorl %eax, %eax
jmp 0x4b2c
movq 0x8(%rbx), %r14
movq 0x18(%r14), %rsi
cmpq %rbx, (%rsi)
je 0x4968
xorl %edx, %edx
testq %rsi, %rsi
je 0x497a
movq %rsi, %rax
movq %rdx, %rcx
movq 0x8(%rsi), %rsi
movq %rax, %rdx
cmpq %rbx, (%rax)
jne 0x4945
movq %rsi, 0x8(%rcx)
movq %r14, %rdi
movq %rax, %rsi
jmp 0x4973
movq 0x8(%rsi), %rax
movq %rax, 0x18(%r14)
movq %r14, %rdi
callq 0x51a1
jmp 0x4992
leaq 0x76c8(%rip), %rsi      # 0xc049
leaq 0x8015(%rip), %rdx      # 0xc99d
movq %r14, %rdi
xorl %eax, %eax
callq 0x52aa
movq 0xf0(%rbx), %rsi
testq %rsi, %rsi
je 0x49af
movq 0x20(%rsi), %r15
movq %r14, %rdi
callq 0x51a1
movq %r15, %rsi
jmp 0x4999
movq 0xf8(%rbx), %rdi
callq 0x65c6
movq %rax, %r15
movq %r15, %rdi
callq 0x6624
testq %rax, %rax
je 0x4a06
movq 0xf8(%rbx), %rdi
movq %rax, %rsi
callq 0x657f
movq %rax, %r12
testq %r12, %r12
je 0x49be
movq 0x20(%r12), %r13
movq 0x28(%r12), %rsi
movq 0x8(%rbx), %rdi
callq 0x51a1
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x51a1
movq %r13, %r12
jmp 0x49dd
movq %r15, %rdi
callq 0x65f2
movq 0xf8(%rbx), %rdi
callq 0x638a
movq 0x100(%rbx), %r15
testq %r15, %r15
je 0x4a6d
movq 0x20(%r15), %r12
movq 0x28(%r15), %rsi
testq %rsi, %rsi
je 0x4a3b
movq %r14, %rdi
callq 0x51a1
movq 0x30(%r15), %rsi
testq %rsi, %rsi
je 0x4a4c
movq %r14, %rdi
callq 0x51a1
movq 0x38(%r15), %rsi
testq %rsi, %rsi
je 0x4a5d
movq %r14, %rdi
callq 0x51a1
movq %r14, %rdi
movq %r15, %rsi
callq 0x51a1
movq %r12, %r15
jmp 0x4a21
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x4aa3
movq 0x10(%rax), %rdi
callq 0xb220
movq 0x28(%rbx), %rsi
movq 0x8(%rsi), %rax
testq %rax, %rax
je 0x4a9b
movq %r14, %rdi
movq %rax, %rsi
callq 0x51a1
movq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0x51a1
movq 0xc0(%rbx), %rdi
callq 0x7600
movq 0x60(%rbx), %rsi
testq %rsi, %rsi
je 0x4ac0
movq %r14, %rdi
callq 0x51a1
movq 0x78(%rbx), %rsi
testq %rsi, %rsi
je 0x4ad1
movq %r14, %rdi
callq 0x51a1
movq 0x88(%rbx), %rsi
testq %rsi, %rsi
je 0x4ae5
movq %r14, %rdi
callq 0x51a1
movq 0x80(%rbx), %rsi
testq %rsi, %rsi
je 0x4af9
movq %r14, %rdi
callq 0x51a1
movq 0x90(%rbx), %rsi
testq %rsi, %rsi
je 0x4b0d
movq %r14, %rdi
callq 0x51a1
movq 0x58(%rbx), %rsi
testq %rsi, %rsi
je 0x4b1e
movq %r14, %rdi
callq 0x51a1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x51a1
pushq $0x1
popq %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq