// File: /workspace/github_c_makefile_star2_O3/liuhaotian[P]xmppsh/libstrophe/src/conn.c
// Function: xmpp_connect_client
int xmpp_connect_client(xmpp_conn_t * const conn, 
			  const char * const altdomain,
			  unsigned short altport,
			  xmpp_conn_handler callback,
			  void * const userdata)
{
    char connectdomain[2048];
    int connectport;
    const char * domain;

    conn->type = XMPP_CLIENT;

    conn->domain = xmpp_jid_domain(conn->ctx, conn->jid);
    if (!conn->domain) return -1;

    if (altdomain) {
        xmpp_debug(conn->ctx, "xmpp", "Connecting via altdomain.");
        strcpy(connectdomain, altdomain);
        connectport = altport ? altport : 5222;
    } else if (!sock_srv_lookup("xmpp-client", "tcp", conn->domain,
                                connectdomain, 2048, &connectport)) {
	    xmpp_debug(conn->ctx, "xmpp", "SRV lookup failed.");
	    if (!altdomain)
		    domain = conn->domain;
	    else
		    domain = altdomain;
	    xmpp_debug(conn->ctx, "xmpp", "Using alternate domain %s, port %d",
                   altdomain, altport);
	    strcpy(connectdomain, domain);
	    connectport = altport ? altport : 5222;
    }
    conn->sock = sock_connect(connectdomain, connectport);
    xmpp_debug(conn->ctx, "xmpp", "sock_connect to %s:%d returned %d",
               connectdomain, connectport, conn->sock);
    if (conn->sock == -1) return -1;

    /* setup handler */
    conn->conn_handler = callback;
    conn->userdata = userdata;

    /* FIXME: it could happen that the connect returns immediately as
     * successful, though this is pretty unlikely.  This would be a little
     * hard to fix, since we'd have to detect and fire off the callback
     * from within the event loop */

    conn->state = XMPP_STATE_CONNECTING;
    conn->timeout_stamp = time_stamp();
    xmpp_debug(conn->ctx, "xmpp", "attempting to connect to %s", connectdomain);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movq %r8, %r14
movq %rcx, %r15
movl %edx, %r12d
movq %rsi, %r13
movq %rdi, %rbx
movl $0x1, 0x10(%rdi)
movq 0x8(%rdi), %rdi
movq 0x78(%rbx), %rsi
callq 0x6a66
movq %rax, 0x60(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x4da1
testq %r13, %r13
je 0x4cf7
movq 0x8(%rbx), %rdi
leaq 0x8383(%rip), %rsi      # 0xd049
leaq 0x8cf2(%rip), %rdx      # 0xd9bf
xorl %eax, %eax
callq 0x5516
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x2190
testw %r12w, %r12w
movl $0x1466, %eax           # imm = 0x1466
cmovnel %r12d, %eax
movzwl %ax, %esi
movl %esi, 0x4(%rsp)
jmp 0x4d29
leaq 0x8cdb(%rip), %rdi      # 0xd9d9
leaq 0x8ce0(%rip), %rsi      # 0xd9e5
leaq 0x10(%rsp), %rcx
leaq 0x4(%rsp), %r9
movq %rax, %rdx
movl $0x800, %r8d            # imm = 0x800
callq 0xb24c
testl %eax, %eax
je 0x4db5
movl 0x4(%rsp), %esi
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0xa9bc
movl %eax, 0x30(%rbx)
movq 0x8(%rbx), %rdi
movl 0x4(%rsp), %r8d
leaq 0x8300(%rip), %rsi      # 0xd049
leaq 0x8ccf(%rip), %rdx      # 0xda1f
movq %r12, %rcx
movl %eax, %r9d
xorl %eax, %eax
callq 0x5516
cmpl $-0x1, 0x30(%rbx)
je 0x4da1
movq %r15, 0xe0(%rbx)
movq %r14, 0xe8(%rbx)
movl $0x1, 0x14(%rbx)
callq 0xc13f
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rdi
leaq 0x82bd(%rip), %rsi      # 0xd049
leaq 0x8cae(%rip), %rdx      # 0xda41
leaq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x5516
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbx), %rdi
leaq 0x8289(%rip), %rsi      # 0xd049
leaq 0x8c22(%rip), %rdx      # 0xd9e9
xorl %eax, %eax
callq 0x5516
movq 0x8(%rbx), %rdi
movq 0x60(%rbx), %rax
movq %rax, 0x8(%rsp)
movzwl %r12w, %r13d
leaq 0x8c16(%rip), %rdx      # 0xd9fc
leaq 0x825c(%rip), %rsi      # 0xd049
xorl %ecx, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x5516
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2190
testw %r12w, %r12w
movl $0x1466, %esi           # imm = 0x1466
cmovnel %r13d, %esi
jmp 0x4cf1