// File: /workspace/github_c_makefile_star2_O1/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 0x4792
movq %rdi, %r14
movl $0x108, %esi            # imm = 0x108
callq 0x5281
movq %rax, %rbx
xorl %eax, %eax
testq %rbx, %rbx
je 0x4792
movq %r14, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
movq %rax, 0x38(%rbx)
movl %eax, 0x20(%rbx)
movq %rax, 0x28(%rbx)
movabsq $0x4000000000, %rcx     # imm = 0x4000000000
movq %rcx, 0x98(%rbx)
movl %eax, 0xa0(%rbx)
movups %xmm0, 0xa8(%rbx)
movl $0x1388, 0xc8(%rbx)     # imm = 0x1388
leaq 0x9318(%rip), %rsi      # 0xd980
movq %r14, %rdi
callq 0xc264
movq %rax, 0x58(%rbx)
testq %rax, %rax
je 0x4786
xorl %r14d, %r14d
movq %r14, 0x60(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movq %r14, 0x50(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x88(%rbx)
movq 0x8(%rbx), %rdi
leaq 0x101(%rip), %rsi       # 0x47a6
leaq 0x29e(%rip), %rdx       # 0x494a
leaq 0x2cc(%rip), %rcx       # 0x497f
movq %rbx, %r8
callq 0x75ec
movq %rax, 0xc0(%rbx)
movl $0x1, %ebp
movl %ebp, 0xb8(%rbx)
leaq -0x17c4(%rip), %rax     # 0x2f10
movq %rax, 0xd0(%rbx)
movl $0x0, 0xd8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xe0(%rbx)
movq %r14, 0xf0(%rbx)
movq 0x8(%rbx), %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x64dc
movq %rax, 0xf8(%rbx)
movq %r14, 0x100(%rbx)
movl %ebp, (%rbx)
movq 0x8(%rbx), %rdi
movq 0x18(%rdi), %rax
movq %rax, %r14
testq %rax, %rax
je 0x472f
movq 0x8(%r14), %rax
testq %rax, %rax
jne 0x471e
movl $0x10, %esi
callq 0x5281
testq %rax, %rax
je 0x4754
movq %rbx, (%rax)
movq $0x0, 0x8(%rax)
testq %r14, %r14
je 0x479c
movq %rax, 0x8(%r14)
jmp 0x4794
movq 0x8(%rbx), %rdi
leaq 0x88ea(%rip), %rsi      # 0xd049
leaq 0x921d(%rip), %rdx      # 0xd983
xorl %eax, %eax
callq 0x539c
movq 0x8(%rbx), %rdi
movq 0x58(%rbx), %rsi
callq 0x5293
movq 0xc0(%rbx), %rdi
callq 0x78c1
movq 0x8(%rbx), %rdi
movq %rbx, %rsi
callq 0x5293
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8(%rbx), %rcx
movq %rax, 0x18(%rcx)
jmp 0x4794