// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x850, %rsp            # imm = 0x850
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rsi
callq 0x8f60
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0x5ba4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5db1
cmpq $0x0, -0x18(%rbp)
je 0x5c0b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe48f(%rip), %rsi      # 0x14049
leaq 0xede3(%rip), %rdx      # 0x149a4
movb $0x0, %al
callq 0x6a80
leaq -0x830(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2190
movzwl -0x1a(%rbp), %eax
cmpl $0x0, %eax
je 0x5bed
movzwl -0x1a(%rbp), %eax
movl %eax, -0x844(%rbp)
jmp 0x5bfa
movl $0x1466, %eax           # imm = 0x1466
movl %eax, -0x844(%rbp)
jmp 0x5bfa
movl -0x844(%rbp), %eax
movl %eax, -0x834(%rbp)
jmp 0x5cec
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdx
leaq -0x830(%rbp), %rcx
leaq 0xed9d(%rip), %rdi      # 0x149be
leaq 0xeda2(%rip), %rsi      # 0x149ca
movl $0x800, %r8d            # imm = 0x800
leaq -0x834(%rbp), %r9
callq 0x11a60
cmpl $0x0, %eax
jne 0x5cea
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe3f7(%rip), %rsi      # 0x14049
leaq 0xed75(%rip), %rdx      # 0x149ce
movb $0x0, %al
callq 0x6a80
cmpq $0x0, -0x18(%rbp)
jne 0x5c78
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x840(%rbp)
jmp 0x5c83
movq -0x18(%rbp), %rax
movq %rax, -0x840(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rcx
movzwl -0x1a(%rbp), %r8d
leaq 0xe3ae(%rip), %rsi      # 0x14049
leaq 0xed3f(%rip), %rdx      # 0x149e1
movb $0x0, %al
callq 0x6a80
leaq -0x830(%rbp), %rdi
movq -0x840(%rbp), %rsi
callq 0x2190
movzwl -0x1a(%rbp), %eax
cmpl $0x0, %eax
je 0x5cd1
movzwl -0x1a(%rbp), %eax
movl %eax, -0x848(%rbp)
jmp 0x5cde
movl $0x1466, %eax           # imm = 0x1466
movl %eax, -0x848(%rbp)
jmp 0x5cde
movl -0x848(%rbp), %eax
movl %eax, -0x834(%rbp)
jmp 0x5cec
leaq -0x830(%rbp), %rdi
movl -0x834(%rbp), %esi
callq 0x10bb0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x830(%rbp), %rcx
movl -0x834(%rbp), %r8d
movq -0x10(%rbp), %rax
movl 0x30(%rax), %r9d
leaq 0xe31d(%rip), %rsi      # 0x14049
leaq 0xecd1(%rip), %rdx      # 0x14a04
movb $0x0, %al
callq 0x6a80
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x30(%rax)
jne 0x5d4d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5db1
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xe0(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xe8(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x14(%rax)
callq 0x135f0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x830(%rbp), %rcx
leaq 0xe2ad(%rip), %rsi      # 0x14049
leaq 0xec83(%rip), %rdx      # 0x14a26
movb $0x0, %al
callq 0x6a80
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x850, %rsp            # imm = 0x850
popq %rbp
retq
nopl (%rax)