// File: /workspace/github_c_makefile_star2_O1/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       # 0x441f
callq 0x5fdb
movq %r14, %rdi
callq 0xbd49
testq %rax, %rax
je 0x4279
movq %rax, %r15
leaq 0x99e6(%rip), %rsi      # 0xdc40
movq %rax, %rdi
callq 0x22e0
testl %eax, %eax
je 0x428d
leaq 0x8dbc(%rip), %rsi      # 0xd029
movq %r15, %rdi
callq 0x22e0
testl %eax, %eax
je 0x42b6
movq 0x8(%rbx), %rdi
leaq 0x8dc5(%rip), %rsi      # 0xd049
leaq 0x9452(%rip), %rdx      # 0xd6dd
jmp 0x429f
movq 0x8(%rbx), %rdi
leaq 0x8db1(%rip), %rsi      # 0xd049
leaq 0x940a(%rip), %rdx      # 0xd6a9
xorl %eax, %eax
callq 0x539c
movq %rbx, %rdi
callq 0x4f0c
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x9389(%rip), %rsi      # 0xd646
movq %r14, %rdi
callq 0xbd67
movq %rax, %r14
movq 0x8(%rbx), %rdi
leaq 0x8d76(%rip), %rsi      # 0xd049
leaq 0x93df(%rip), %rdx      # 0xd6b9
xorl %eax, %eax
callq 0x5546
testq %r14, %r14
je 0x4309
leaq 0x93dd(%rip), %rsi      # 0xd6ca
movq %r14, %rdi
callq 0xbd67
testq %rax, %rax
je 0x4309
movq %rax, %rdi
callq 0xbe0c
movq %rax, 0x88(%rbx)
cmpl $0x0, 0x54(%rbx)
je 0x43ed
leaq 0x12e(%rip), %rsi       # 0x4448
leaq 0x93ad(%rip), %rdx      # 0xd6ce
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x633f
leaq 0x1dc(%rip), %rsi       # 0x450e
movl $0x3a98, %edx           # imm = 0x3A98
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6244
movq 0x8(%rbx), %rdi
callq 0xb5a0
testq %rax, %rax
je 0x4412
movq %rax, %r14
leaq 0x8cc9(%rip), %rsi      # 0xd026
movq %rax, %rdi
callq 0xbac6
leaq 0x9aee(%rip), %rsi      # 0xde5a
movq %r14, %rdi
callq 0xbeea
leaq 0x9353(%rip), %rsi      # 0xd6ce
movq %r14, %rdi
callq 0xbedb
movq 0x8(%rbx), %rdi
callq 0xb5a0
movq %rax, %r15
testq %rax, %rax
jne 0x43a4
movq %r14, %rdi
callq 0xb73c
movq %rbx, %rdi
callq 0xc305
leaq 0x92bc(%rip), %rsi      # 0xd667
movq %r15, %rdi
callq 0xbac6
leaq 0x9291(%rip), %rsi      # 0xd64b
movq %r15, %rdi
callq 0xbc1d
movq %r14, %rdi
movq %r15, %rsi
callq 0xbc2c
movq %r15, %rdi
callq 0xb73c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5174
movq %r14, %rdi
callq 0xb73c
jmp 0x42ae
movl $0x1, 0xd8(%rbx)
movq 0xe8(%rbx), %r8
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0xe0(%rbx)
jmp 0x42ae
movq %rbx, %rdi
callq 0xc305
jmp 0x42ae