// File: /workspace/github_c_makefile_star2_O0/liuhaotian[P]xmppsh/libstrophe/src/auth.c
// Function: handle_features_sasl
static int _handle_features_sasl(xmpp_conn_t * const conn,
				 xmpp_stanza_t * const stanza,
				 void * const userdata)
{
    xmpp_stanza_t *bind, *session, *iq, *res, *text;
    char *resource;

    /* remove missing features handler */
    xmpp_timed_handler_delete(conn, _handle_missing_features_sasl);

    /* we are expecting <bind/> and <session/> since this is a
       XMPP style connection */

    bind = xmpp_stanza_get_child_by_name(stanza, "bind");
    if (bind && strcmp(xmpp_stanza_get_ns(bind), XMPP_NS_BIND) == 0) {
	/* resource binding is required */
	conn->bind_required = 1;
    }

    session = xmpp_stanza_get_child_by_name(stanza, "session");
    if (session && strcmp(xmpp_stanza_get_ns(session), XMPP_NS_SESSION) == 0) {
	/* session establishment required */
	conn->session_required = 1;
    }

    /* if bind is required, go ahead and start it */
    if (conn->bind_required) {
	/* bind resource */
	
	/* setup response handlers */
	handler_add_id(conn, _handle_bind, "_xmpp_bind1", NULL);
	handler_add_timed(conn, _handle_missing_bind,
			  BIND_TIMEOUT, NULL);

	/* send bind 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_bind1");

	bind = xmpp_stanza_copy(bind);
	if (!bind) {
	    xmpp_stanza_release(iq);
	    disconnect_mem_error(conn);
	    return 0;
	}

	/* request a specific resource if we have one */
        resource = xmpp_jid_resource(conn->ctx, conn->jid);
	if ((resource != NULL) && (strlen(resource) == 0)) {
	    /* jabberd2 doesn't handle an empty resource */
	    xmpp_free(conn->ctx, resource);
	    resource = NULL;
	}

	/* if we have a resource to request, do it. otherwise the 
	   server will assign us one */
	if (resource) {
	    res = xmpp_stanza_new(conn->ctx);
	    if (!res) {
		xmpp_stanza_release(bind);
		xmpp_stanza_release(iq);
		disconnect_mem_error(conn);
		return 0;
	    }
	    xmpp_stanza_set_name(res, "resource");
	    text = xmpp_stanza_new(conn->ctx);
	    if (!text) {
		xmpp_stanza_release(res);
		xmpp_stanza_release(bind);
		xmpp_stanza_release(iq);
		disconnect_mem_error(conn);
		return 0;
	    }
	    xmpp_stanza_set_text(text, resource);
	    xmpp_stanza_add_child(res, text);
            xmpp_stanza_release(text);
	    xmpp_stanza_add_child(bind, res);
            xmpp_stanza_release(res);
	    xmpp_free(conn->ctx, resource);
	}

	xmpp_stanza_add_child(iq, bind);
	xmpp_stanza_release(bind);

	/* send bind request */
	xmpp_send(conn, iq);
	xmpp_stanza_release(iq);
    } else {
	/* can't bind, disconnect */
	xmpp_error(conn->ctx, "xmpp", "Stream features does not allow "\
		   "resource bind.");
	xmpp_disconnect(conn);
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x301(%rip), %rsi       # 0x4b00
callq 0x7c20
movq -0x18(%rbp), %rdi
leaq 0xfe38(%rip), %rsi      # 0x14647
callq 0x12b40
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4847
movq -0x28(%rbp), %rdi
callq 0x12a80
movq %rax, %rdi
leaq 0xfdf9(%rip), %rsi      # 0x1462b
callq 0x22e0
cmpl $0x0, %eax
jne 0x4847
movq -0x10(%rbp), %rax
movl $0x1, 0x50(%rax)
movq -0x18(%rbp), %rdi
leaq 0xfe16(%rip), %rsi      # 0x14668
callq 0x12b40
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x488a
movq -0x30(%rbp), %rdi
callq 0x12a80
movq %rax, %rdi
leaq 0xfdd7(%rip), %rsi      # 0x1464c
callq 0x22e0
cmpl $0x0, %eax
jne 0x488a
movq -0x10(%rbp), %rax
movl $0x1, 0x54(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x4abd
movq -0x10(%rbp), %rdi
leaq 0x29d(%rip), %rsi       # 0x4b40
leaq 0xfdc6(%rip), %rdx      # 0x14670
xorl %eax, %eax
movl %eax, %ecx
callq 0x82a0
movq -0x10(%rbp), %rdi
leaq 0x512(%rip), %rsi       # 0x4dd0
movl $0x3a98, %edx           # imm = 0x3A98
xorl %eax, %eax
movl %eax, %ecx
callq 0x80c0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x11cb0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x48f9
movq -0x10(%rbp), %rdi
callq 0x13650
movl $0x0, -0x4(%rbp)
jmp 0x4aea
movq -0x38(%rbp), %rdi
leaq 0xf722(%rip), %rsi      # 0x14026
callq 0x12550
movq -0x38(%rbp), %rdi
leaq 0x10516(%rip), %rsi     # 0x14e2a
callq 0x12e20
movq -0x38(%rbp), %rdi
leaq 0xfd4c(%rip), %rsi      # 0x14670
callq 0x12df0
movq -0x28(%rbp), %rdi
callq 0x11d70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x495b
movq -0x38(%rbp), %rdi
callq 0x11f80
movq -0x10(%rbp), %rdi
callq 0x13650
movl $0x0, -0x4(%rbp)
jmp 0x4aea
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rsi
callq 0x9040
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x49a3
movq -0x50(%rbp), %rdi
callq 0x2180
cmpq $0x0, %rax
jne 0x49a3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x66c0
movq $0x0, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x4a8f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x11cb0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x49ed
movq -0x28(%rbp), %rdi
callq 0x11f80
movq -0x38(%rbp), %rdi
callq 0x11f80
movq -0x10(%rbp), %rdi
callq 0x13650
movl $0x0, -0x4(%rbp)
jmp 0x4aea
movq -0x40(%rbp), %rdi
leaq 0xfb48(%rip), %rsi      # 0x14540
callq 0x12550
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x11cb0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x4a45
movq -0x40(%rbp), %rdi
callq 0x11f80
movq -0x28(%rbp), %rdi
callq 0x11f80
movq -0x38(%rbp), %rdi
callq 0x11f80
movq -0x10(%rbp), %rdi
callq 0x13650
movl $0x0, -0x4(%rbp)
jmp 0x4aea
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x128e0
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x12850
movq -0x48(%rbp), %rdi
callq 0x11f80
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x12850
movq -0x40(%rbp), %rdi
callq 0x11f80
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x66c0
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x12850
movq -0x28(%rbp), %rdi
callq 0x11f80
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6290
movq -0x38(%rbp), %rdi
callq 0x11f80
jmp 0x4ae3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xf57d(%rip), %rsi      # 0x14049
leaq 0xfba9(%rip), %rdx      # 0x1467c
movb $0x0, %al
callq 0x68a0
movq -0x10(%rbp), %rdi
callq 0x5f10
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)