// File: /workspace/github_c_makefile_star2_O3/liuhaotian[P]xmppsh/libstrophe/src/auth.c
// Function: handle_bind
static int _handle_bind(xmpp_conn_t * const conn,
			xmpp_stanza_t * const stanza,
			void * const userdata)
{
    char *type;
    xmpp_stanza_t *iq, *session;

    /* delete missing bind handler */
    xmpp_timed_handler_delete(conn, _handle_missing_bind);

    /* server has replied to bind request */
    type = xmpp_stanza_get_type(stanza);
    if (type && strcmp(type, "error") == 0) {
	xmpp_error(conn->ctx, "xmpp", "Binding failed.");
	xmpp_disconnect(conn);
    } else if (type && strcmp(type, "result") == 0) {
        xmpp_stanza_t *binding = xmpp_stanza_get_child_by_name(stanza, "bind");
	xmpp_debug(conn->ctx, "xmpp", "Bind successful.");

        if (binding) {
            xmpp_stanza_t *jid_stanza = xmpp_stanza_get_child_by_name(binding,
                                                                      "jid");
            if (jid_stanza) {
                conn->bound_jid = xmpp_stanza_get_text(jid_stanza);
            }
        }

	/* establish a session if required */
	if (conn->session_required) {
	    /* setup response handlers */
	    handler_add_id(conn, _handle_session, "_xmpp_session1", NULL);
	    handler_add_timed(conn, _handle_missing_session, 
			      SESSION_TIMEOUT, NULL);

	    /* send session request */
	    iq = xmpp_stanza_new(conn->ctx);
	    if (!iq) {
		disconnect_mem_error(conn);
		return 0;
	    }

	    xmpp_stanza_set_name(iq, "iq");
	    xmpp_stanza_set_type(iq, "set");
	    xmpp_stanza_set_id(iq, "_xmpp_session1");

	    session = xmpp_stanza_new(conn->ctx);
	    if (!session) {
		xmpp_stanza_release(iq);
		disconnect_mem_error(conn);
	    }

	    xmpp_stanza_set_name(session, "session");
	    xmpp_stanza_set_ns(session, XMPP_NS_SESSION);

	    xmpp_stanza_add_child(iq, session);
	    xmpp_stanza_release(session);

	    /* send session establishment request */
	    xmpp_send(conn, iq);
	    xmpp_stanza_release(iq);
	} else {
	    conn->authenticated = 1;
	   
	    /* call connection handler */
	    conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, 
			       conn->userdata);
	}
    } else {
	xmpp_error(conn->ctx, "xmpp", "Server sent malformed bind reply.");
	xmpp_disconnect(conn);
    }

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1e1(%rip), %rsi       # 0x43e3
callq 0x5f99
movq %r14, %rdi
callq 0xbbb5
testq %rax, %rax
je 0x423d
movq %rax, %r15
leaq 0x9a22(%rip), %rsi      # 0xdc40
movq %rax, %rdi
callq 0x22e0
testl %eax, %eax
je 0x4251
leaq 0x8df8(%rip), %rsi      # 0xd029
movq %r15, %rdi
callq 0x22e0
testl %eax, %eax
je 0x427a
movq 0x8(%rbx), %rdi
leaq 0x8e01(%rip), %rsi      # 0xd049
leaq 0x948e(%rip), %rdx      # 0xd6dd
jmp 0x4263
movq 0x8(%rbx), %rdi
leaq 0x8ded(%rip), %rsi      # 0xd049
leaq 0x9446(%rip), %rdx      # 0xd6a9
xorl %eax, %eax
callq 0x536c
movq %rbx, %rdi
callq 0x4edd
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x93c5(%rip), %rsi      # 0xd646
movq %r14, %rdi
callq 0xbbd3
movq %rax, %r14
movq 0x8(%rbx), %rdi
leaq 0x8db2(%rip), %rsi      # 0xd049
leaq 0x941b(%rip), %rdx      # 0xd6b9
xorl %eax, %eax
callq 0x5516
testq %r14, %r14
je 0x42cd
leaq 0x9419(%rip), %rsi      # 0xd6ca
movq %r14, %rdi
callq 0xbbd3
testq %rax, %rax
je 0x42cd
movq %rax, %rdi
callq 0xbc7c
movq %rax, 0x88(%rbx)
cmpl $0x0, 0x54(%rbx)
je 0x43b1
leaq 0x12e(%rip), %rsi       # 0x440c
leaq 0x93e9(%rip), %rdx      # 0xd6ce
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x62fd
leaq 0x1dc(%rip), %rsi       # 0x44d2
movl $0x3a98, %edx           # imm = 0x3A98
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6202
movq 0x8(%rbx), %rdi
callq 0xb40c
testq %rax, %rax
je 0x43d6
movq %rax, %r14
leaq 0x8d05(%rip), %rsi      # 0xd026
movq %rax, %rdi
callq 0xb932
leaq 0x9b2a(%rip), %rsi      # 0xde5a
movq %r14, %rdi
callq 0xbd5d
leaq 0x938f(%rip), %rsi      # 0xd6ce
movq %r14, %rdi
callq 0xbd4e
movq 0x8(%rbx), %rdi
callq 0xb40c
movq %rax, %r15
testq %rax, %rax
jne 0x4368
movq %r14, %rdi
callq 0xb5a8
movq %rbx, %rdi
callq 0xc184
leaq 0x92f8(%rip), %rsi      # 0xd667
movq %r15, %rdi
callq 0xb932
leaq 0x92cd(%rip), %rsi      # 0xd64b
movq %r15, %rdi
callq 0xba89
movq %r14, %rdi
movq %r15, %rsi
callq 0xba98
movq %r15, %rdi
callq 0xb5a8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5145
movq %r14, %rdi
callq 0xb5a8
jmp 0x4272
movl $0x1, 0xd8(%rbx)
movq 0xe8(%rbx), %r8
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0xe0(%rbx)
jmp 0x4272
movq %rbx, %rdi
callq 0xc184
jmp 0x4272