// File: /workspace/github_c_makefile_star2_O1/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 0x4a14
decl %eax
movl %eax, (%rbx)
xorl %eax, %eax
jmp 0x4c0d
movq 0x8(%rbx), %r14
movq 0x18(%r14), %rsi
cmpq %rbx, (%rsi)
je 0x4a3c
movq %rsi, %rax
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x4a4e
cmpq %rbx, (%rsi)
jne 0x4a21
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
jmp 0x4a44
movq 0x8(%rsi), %rax
movq %rax, 0x18(%r14)
movq %r14, %rdi
callq 0x5293
jmp 0x4a66
leaq 0x85f4(%rip), %rsi      # 0xd049
leaq 0x8f41(%rip), %rdx      # 0xd99d
movq %r14, %rdi
xorl %eax, %eax
callq 0x539c
movq 0xf0(%rbx), %rsi
testq %rsi, %rsi
je 0x4a86
movq 0x20(%rsi), %r15
movq %r14, %rdi
callq 0x5293
movq %r15, %rsi
testq %r15, %r15
jne 0x4a72
movq 0xf8(%rbx), %rdi
callq 0x681a
movq %rax, %r15
movq %rax, %rdi
callq 0x6880
testq %rax, %rax
je 0x4ae5
movq 0xf8(%rbx), %rdi
movq %rax, %rsi
callq 0x67a3
testq %rax, %rax
je 0x4ae0
movq %rax, %r12
movq 0x20(%r12), %r13
movq 0x28(%r12), %rsi
movq 0x8(%rbx), %rdi
callq 0x5293
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x5293
movq %r13, %r12
testq %r13, %r13
jne 0x4ab9
movq %r15, %rdi
jmp 0x4a98
movq %r15, %rdi
callq 0x684e
movq 0xf8(%rbx), %rdi
callq 0x655f
movq 0x100(%rbx), %r15
testq %r15, %r15
je 0x4b4f
movq 0x20(%r15), %r12
movq 0x28(%r15), %rsi
testq %rsi, %rsi
je 0x4b1a
movq %r14, %rdi
callq 0x5293
movq 0x30(%r15), %rsi
testq %rsi, %rsi
je 0x4b2b
movq %r14, %rdi
callq 0x5293
movq 0x38(%r15), %rsi
testq %rsi, %rsi
je 0x4b3c
movq %r14, %rdi
callq 0x5293
movq %r14, %rdi
movq %r15, %rsi
callq 0x5293
movq %r12, %r15
testq %r12, %r12
jne 0x4b05
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x4b82
movq 0x10(%rax), %rdi
callq 0xb73c
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x4b76
movq %r14, %rdi
callq 0x5293
movq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0x5293
movq 0xc0(%rbx), %rdi
callq 0x78c1
movq 0x60(%rbx), %rsi
testq %rsi, %rsi
je 0x4b9f
movq %r14, %rdi
callq 0x5293
movq 0x78(%rbx), %rsi
testq %rsi, %rsi
je 0x4bb0
movq %r14, %rdi
callq 0x5293
movq 0x88(%rbx), %rsi
testq %rsi, %rsi
je 0x4bc4
movq %r14, %rdi
callq 0x5293
movq 0x80(%rbx), %rsi
testq %rsi, %rsi
je 0x4bd8
movq %r14, %rdi
callq 0x5293
movq 0x90(%rbx), %rsi
testq %rsi, %rsi
je 0x4bec
movq %r14, %rdi
callq 0x5293
movq 0x58(%rbx), %rsi
testq %rsi, %rsi
je 0x4bfd
movq %r14, %rdi
callq 0x5293
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5293
movl $0x1, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq