// File: /workspace/github_c_makefile_star2_O3/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 0x49e2
decl %eax
movl %eax, (%rbx)
xorl %eax, %eax
jmp 0x4bde
movq 0x8(%rbx), %r14
movq 0x18(%r14), %rsi
cmpq %rbx, (%rsi)
je 0x4a0a
movq %rsi, %rax
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x4a1c
cmpq %rbx, (%rsi)
jne 0x49ef
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
jmp 0x4a12
movq 0x8(%rsi), %rax
movq %rax, 0x18(%r14)
movq %r14, %rdi
callq 0x5263
jmp 0x4a34
leaq 0x8626(%rip), %rsi      # 0xd049
leaq 0x8f73(%rip), %rdx      # 0xd99d
movq %r14, %rdi
xorl %eax, %eax
callq 0x536c
movq 0xf0(%rbx), %rsi
testq %rsi, %rsi
je 0x4a54
movq 0x20(%rsi), %r15
movq %r14, %rdi
callq 0x5263
movq %r15, %rsi
testq %r15, %r15
jne 0x4a40
movq 0xf8(%rbx), %rdi
callq 0x67dd
movq %rax, %r15
movq %rax, %rdi
callq 0x6843
testq %rax, %rax
je 0x4ab3
movq 0xf8(%rbx), %rdi
movq %rax, %rsi
callq 0x6766
testq %rax, %rax
je 0x4aae
movq %rax, %r12
movq 0x20(%r12), %r13
movq 0x28(%r12), %rsi
movq 0x8(%rbx), %rdi
callq 0x5263
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x5263
movq %r13, %r12
testq %r13, %r13
jne 0x4a87
movq %r15, %rdi
jmp 0x4a66
movq %r15, %rdi
callq 0x6811
movq 0xf8(%rbx), %rdi
callq 0x651f
movq 0x100(%rbx), %r15
testq %r15, %r15
je 0x4b1d
movq 0x20(%r15), %r12
movq 0x28(%r15), %rsi
testq %rsi, %rsi
je 0x4ae8
movq %r14, %rdi
callq 0x5263
movq 0x30(%r15), %rsi
testq %rsi, %rsi
je 0x4af9
movq %r14, %rdi
callq 0x5263
movq 0x38(%r15), %rsi
testq %rsi, %rsi
je 0x4b0a
movq %r14, %rdi
callq 0x5263
movq %r14, %rdi
movq %r15, %rsi
callq 0x5263
movq %r12, %r15
testq %r12, %r12
jne 0x4ad3
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x4b53
movq 0x10(%rax), %rdi
callq 0xb5a8
movq 0x28(%rbx), %rsi
movq 0x8(%rsi), %rax
testq %rax, %rax
je 0x4b4b
movq %r14, %rdi
movq %rax, %rsi
callq 0x5263
movq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0x5263
movq 0xc0(%rbx), %rdi
callq 0x77c5
movq 0x60(%rbx), %rsi
testq %rsi, %rsi
je 0x4b70
movq %r14, %rdi
callq 0x5263
movq 0x78(%rbx), %rsi
testq %rsi, %rsi
je 0x4b81
movq %r14, %rdi
callq 0x5263
movq 0x88(%rbx), %rsi
testq %rsi, %rsi
je 0x4b95
movq %r14, %rdi
callq 0x5263
movq 0x80(%rbx), %rsi
testq %rsi, %rsi
je 0x4ba9
movq %r14, %rdi
callq 0x5263
movq 0x90(%rbx), %rsi
testq %rsi, %rsi
je 0x4bbd
movq %r14, %rdi
callq 0x5263
movq 0x58(%rbx), %rsi
testq %rsi, %rsi
je 0x4bce
movq %r14, %rdi
callq 0x5263
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5263
movl $0x1, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq