// File: /workspace/github_c_makefile_star2_O2/liuhaotian[P]xmppsh/libstrophe/src/conn.c
// Function: xmpp_conn_new
xmpp_conn_t *xmpp_conn_new(xmpp_ctx_t * const ctx)
{
    xmpp_conn_t *conn = NULL;
    xmpp_connlist_t *tail, *item;

    if (ctx == NULL) return NULL;
	conn = xmpp_alloc(ctx, sizeof(xmpp_conn_t));
    
    if (conn != NULL) {
	conn->ctx = ctx;

	conn->type = XMPP_UNKNOWN;
        conn->state = XMPP_STATE_DISCONNECTED;
	conn->sock = -1;
	conn->tls = NULL;
	conn->timeout_stamp = 0;
	conn->error = 0;
	conn->stream_error = NULL;

	/* default send parameters */
	conn->blocking_send = 0;
	conn->send_queue_max = DEFAULT_SEND_QUEUE_MAX;
	conn->send_queue_len = 0;
	conn->send_queue_head = NULL;
	conn->send_queue_tail = NULL;

	/* default timeouts */
	conn->connect_timeout = CONNECT_TIMEOUT;

	conn->lang = xmpp_strdup(conn->ctx, "en");
	if (!conn->lang) {
	    xmpp_free(conn->ctx, conn);
	    return NULL;
	}
	conn->domain = NULL;
	conn->jid = NULL;
	conn->pass = NULL;
	conn->stream_id = NULL;
        conn->bound_jid = NULL;

	conn->tls_support = 0;
	conn->tls_failed = 0;
	conn->sasl_support = 0;
        conn->secured = 0;

	conn->bind_required = 0;
	conn->session_required = 0;

	conn->parser = parser_new(conn->ctx, 
                                  _handle_stream_start,
                                  _handle_stream_end,
                                  _handle_stream_stanza,
                                  conn);
        conn->reset_parser = 0;
        conn_prepare_reset(conn, auth_handle_open);

	conn->authenticated = 0;
	conn->conn_handler = NULL;
	conn->userdata = NULL;
	conn->timed_handlers = NULL;
	/* we own (and will free) the hash values */
	conn->id_handlers = hash_new(conn->ctx, 32, NULL);
	conn->handlers = NULL;

	/* give the caller a reference to connection */
	conn->ref = 1;

	/* add connection to ctx->connlist */
	tail = conn->ctx->connlist;
	while (tail && tail->next) tail = tail->next;

	item = xmpp_alloc(conn->ctx, sizeof(xmpp_connlist_t));
	if (!item) {
	    xmpp_error(conn->ctx, "xmpp", "failed to allocate memory");
	    xmpp_free(conn->ctx, conn->lang);
            parser_free(conn->parser);
	    xmpp_free(conn->ctx, conn);
	    conn = NULL;
	} else {
	    item->conn = conn;
	    item->next = NULL;

	    if (tail) tail->next = item;
	    else conn->ctx->connlist = item;
	}
    }
    
    return conn;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x46de
movq %rdi, %r14
movl $0x108, %esi            # imm = 0x108
callq 0x518f
testq %rax, %rax
je 0x46de
movq %rax, %rbx
movq %r14, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
orl $-0x1, 0x30(%rax)
andq $0x0, 0x38(%rax)
andl $0x0, 0x20(%rax)
andq $0x0, 0x28(%rax)
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0x98(%rbx)
andl $0x0, 0xa0(%rbx)
movups %xmm0, 0xa8(%rbx)
movl $0x1388, 0xc8(%rbx)     # imm = 0x1388
leaq 0x83c1(%rip), %rsi      # 0xc980
movq %r14, %rdi
callq 0xbcd4
movq %rax, 0x58(%rbx)
testq %rax, %rax
je 0x46d2
andq $0x0, 0x60(%rbx)
andq $0x0, 0x50(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x88(%rbx)
movq 0x8(%rbx), %rdi
leaq 0xf7(%rip), %rsi        # 0x46f2
leaq 0x279(%rip), %rdx       # 0x487b
leaq 0x298(%rip), %rcx       # 0x48a1
movq %rbx, %r8
callq 0x733c
movq %rax, 0xc0(%rbx)
pushq $0x1
popq %rbp
movl %ebp, 0xb8(%rbx)
leaq -0x1768(%rip), %rax     # 0x2ec0
movq %rax, 0xd0(%rbx)
andl $0x0, 0xd8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xe0(%rbx)
andq $0x0, 0xf0(%rbx)
movq 0x8(%rbx), %rdi
pushq $0x20
popq %rsi
xorl %edx, %edx
callq 0x630c
movq %rax, 0xf8(%rbx)
andq $0x0, 0x100(%rbx)
movl %ebp, (%rbx)
movq 0x8(%rbx), %rdi
movq 0x18(%rdi), %rax
movq %rax, %r14
testq %rax, %rax
je 0x4680
movq 0x8(%r14), %rax
testq %rax, %rax
jne 0x466f
pushq $0x10
popq %rsi
callq 0x518f
testq %rax, %rax
je 0x46a0
andq $0x0, 0x8(%rax)
movq %rbx, (%rax)
testq %r14, %r14
je 0x46e8
movq %rax, 0x8(%r14)
jmp 0x46e0
movq 0x8(%rbx), %rdi
leaq 0x799e(%rip), %rsi      # 0xc049
leaq 0x82d1(%rip), %rdx      # 0xc983
xorl %eax, %eax
callq 0x52aa
movq 0x8(%rbx), %rdi
movq 0x58(%rbx), %rsi
callq 0x51a1
movq 0xc0(%rbx), %rdi
callq 0x7600
movq 0x8(%rbx), %rdi
movq %rbx, %rsi
callq 0x51a1
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8(%rbx), %rcx
movq %rax, 0x18(%rcx)
jmp 0x46e0