// File: /workspace/github_c_makefile_star2_O2/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       # 0x4378
callq 0x5e3e
movq %r14, %rdi
callq 0xb7fe
testq %rax, %rax
je 0x41d2
movq %rax, %r15
leaq 0x8a8d(%rip), %rsi      # 0xcc40
movq %rax, %rdi
callq 0x22e0
testl %eax, %eax
je 0x41e6
leaq 0x7e63(%rip), %rsi      # 0xc029
movq %r15, %rdi
callq 0x22e0
testl %eax, %eax
je 0x420f
movq 0x8(%rbx), %rdi
leaq 0x7e6c(%rip), %rsi      # 0xc049
leaq 0x84f9(%rip), %rdx      # 0xc6dd
jmp 0x41f8
movq 0x8(%rbx), %rdi
leaq 0x7e58(%rip), %rsi      # 0xc049
leaq 0x84b1(%rip), %rdx      # 0xc6a9
xorl %eax, %eax
callq 0x52aa
movq %rbx, %rdi
callq 0x4e1e
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x8430(%rip), %rsi      # 0xc646
movq %r14, %rdi
callq 0xb81c
movq %rax, %r14
movq 0x8(%rbx), %rdi
leaq 0x7e1d(%rip), %rsi      # 0xc049
leaq 0x8486(%rip), %rdx      # 0xc6b9
xorl %eax, %eax
callq 0x544e
testq %r14, %r14
je 0x4262
leaq 0x8484(%rip), %rsi      # 0xc6ca
movq %r14, %rdi
callq 0xb81c
testq %rax, %rax
je 0x4262
movq %rax, %rdi
callq 0xb8ae
movq %rax, 0x88(%rbx)
cmpl $0x0, 0x54(%rbx)
je 0x4346
leaq 0x12e(%rip), %rsi       # 0x43a1
leaq 0x8454(%rip), %rdx      # 0xc6ce
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6180
leaq 0x1dc(%rip), %rsi       # 0x4467
movl $0x3a98, %edx           # imm = 0x3A98
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x608f
movq 0x8(%rbx), %rdi
callq 0xb0b4
testq %rax, %rax
je 0x436b
movq %rax, %r14
leaq 0x7d70(%rip), %rsi      # 0xc026
movq %rax, %rdi
callq 0xb57d
leaq 0x8b95(%rip), %rsi      # 0xce5a
movq %r14, %rdi
callq 0xb995
leaq 0x83fa(%rip), %rsi      # 0xc6ce
movq %r14, %rdi
callq 0xb986
movq 0x8(%rbx), %rdi
callq 0xb0b4
movq %rax, %r15
testq %rax, %rax
jne 0x42fd
movq %r14, %rdi
callq 0xb220
movq %rbx, %rdi
callq 0xbd7a
leaq 0x8363(%rip), %rsi      # 0xc667
movq %r15, %rdi
callq 0xb57d
leaq 0x8338(%rip), %rsi      # 0xc64b
movq %r15, %rdi
callq 0xb6d6
movq %r14, %rdi
movq %r15, %rsi
callq 0xb6e5
movq %r15, %rdi
callq 0xb220
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5084
movq %r14, %rdi
callq 0xb220
jmp 0x4207
movl $0x1, 0xd8(%rbx)
movq 0xe8(%rbx), %r8
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0xe0(%rbx)
jmp 0x4207
movq %rbx, %rdi
callq 0xbd7a
jmp 0x4207