// File: /workspace/github_c_makefile_star2_O1/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 0x6aa9
movq %rax, 0x60(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x4dd0
testq %r13, %r13
je 0x4d26
movq 0x8(%rbx), %rdi
leaq 0x8354(%rip), %rsi      # 0xd049
leaq 0x8cc3(%rip), %rdx      # 0xd9bf
xorl %eax, %eax
callq 0x5546
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x2190
testw %r12w, %r12w
movl $0x1466, %eax           # imm = 0x1466
cmovnel %r12d, %eax
movzwl %ax, %eax
movl %eax, 0x4(%rsp)
jmp 0x4d54
leaq 0x8cac(%rip), %rdi      # 0xd9d9
leaq 0x8cb1(%rip), %rsi      # 0xd9e5
leaq 0x10(%rsp), %rcx
leaq 0x4(%rsp), %r9
movq %rax, %rdx
movl $0x800, %r8d            # imm = 0x800
callq 0xb3dc
testl %eax, %eax
je 0x4de4
movl 0x4(%rsp), %esi
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0xab8c
movl %eax, 0x30(%rbx)
movq 0x8(%rbx), %rdi
movl 0x4(%rsp), %r8d
leaq 0x82d1(%rip), %rsi      # 0xd049
leaq 0x8ca0(%rip), %rdx      # 0xda1f
movq %r12, %rcx
movl %eax, %r9d
xorl %eax, %eax
callq 0x5546
cmpl $-0x1, 0x30(%rbx)
je 0x4dd0
movq %r15, 0xe0(%rbx)
movq %r14, 0xe8(%rbx)
movl $0x1, 0x14(%rbx)
callq 0xc2c0
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rdi
leaq 0x828e(%rip), %rsi      # 0xd049
leaq 0x8c7f(%rip), %rdx      # 0xda41
leaq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x5546
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 0x825a(%rip), %rsi      # 0xd049
leaq 0x8bf3(%rip), %rdx      # 0xd9e9
xorl %eax, %eax
callq 0x5546
movq 0x8(%rbx), %rdi
movq 0x60(%rbx), %rax
movq %rax, 0x8(%rsp)
movzwl %r12w, %r13d
leaq 0x8be7(%rip), %rdx      # 0xd9fc
leaq 0x822d(%rip), %rsi      # 0xd049
xorl %ecx, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x5546
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2190
testw %r12w, %r12w
movl $0x1466, %eax           # imm = 0x1466
cmovnel %r13d, %eax
jmp 0x4d20