// File: /workspace/github_c_makefile_star2_O0/liuhaotian[P]xmppsh/libstrophe/src/stanza.c
// Function: render_stanza_recursive
static int _render_stanza_recursive(xmpp_stanza_t *stanza,
			     char * const buf, size_t const buflen)
{
    char *ptr = buf;
    size_t left = buflen;
    int ret, written;
    xmpp_stanza_t *child;
    hash_iterator_t *iter;
    const char *key;

    written = 0;

    if (stanza->type == XMPP_STANZA_UNKNOWN) return XMPP_EINVOP;

    if (stanza->type == XMPP_STANZA_TEXT) {
	if (!stanza->data) return XMPP_EINVOP;

	ret = xmpp_snprintf(ptr, left, "%s", stanza->data);
	if (ret < 0) return XMPP_EMEM;
	_render_update(&written, buflen, ret, &left, &ptr);
    } else { /* stanza->type == XMPP_STANZA_TAG */
	if (!stanza->data) return XMPP_EINVOP;

	/* write begining of tag and attributes */
	ret = xmpp_snprintf(ptr, left, "<%s", stanza->data);
	if (ret < 0) return XMPP_EMEM;
	_render_update(&written, buflen, ret, &left, &ptr);

	if (stanza->attributes && hash_num_keys(stanza->attributes) > 0) {
	    iter = hash_iter_new(stanza->attributes);
	    while ((key = hash_iter_next(iter))) {
		ret = xmpp_snprintf(ptr, left, " %s=\"%s\"", key,
			       (char *)hash_get(stanza->attributes, key));
		if (ret < 0) return XMPP_EMEM;
		_render_update(&written, buflen, ret, &left, &ptr);
	    }
	    hash_iter_release(iter);
	}

	if (!stanza->children) {
	    /* write end if singleton tag */
	    ret = xmpp_snprintf(ptr, left, "/>");
	    if (ret < 0) return XMPP_EMEM;
	    _render_update(&written, buflen, ret, &left, &ptr);
	} else {
	    /* this stanza has child stanzas */

	    /* write end of start tag */
	    ret = xmpp_snprintf(ptr, left, ">");
	    if (ret < 0) return XMPP_EMEM;
	    _render_update(&written, buflen, ret, &left, &ptr);
	    
	    /* iterate and recurse over child stanzas */
	    child = stanza->children;
	    while (child) {
		ret = _render_stanza_recursive(child, ptr, left);
		if (ret < 0) return ret;

		_render_update(&written, buflen, ret, &left, &ptr);

		child = child->next;
	    }

	    /* write end tag */
	    ret = xmpp_snprintf(ptr, left, "</%s>", stanza->data);
	    if (ret < 0) return XMPP_EMEM;
	    
	    _render_update(&written, buflen, ret, &left, &ptr);
	}
    }

    return written;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x12251
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1253d
movq -0x10(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x122c4
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x12272
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1253d
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
leaq 0x2802(%rip), %rdx      # 0x14a8b
movb $0x0, %al
callq 0x10030
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x122a5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1253d
movq -0x20(%rbp), %rax
movl %eax, %esi
movl -0x34(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12eb0
jmp 0x12537
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x122db
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1253d
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
leaq 0x2f0f(%rip), %rdx      # 0x15201
movb $0x0, %al
callq 0x10030
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x1230e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1253d
movq -0x20(%rbp), %rax
movl %eax, %esi
movl -0x34(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12eb0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x123f4
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x8b10
cmpl $0x0, %eax
jle 0x123f4
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x8b30
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x8bf0
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x123eb
movq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x8a80
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rcx
movq %rax, %r8
leaq 0x2e55(%rip), %rdx      # 0x15205
movb $0x0, %al
callq 0x10030
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x123cc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1253d
movq -0x20(%rbp), %rax
movl %eax, %esi
movl -0x34(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12eb0
jmp 0x1235e
movq -0x48(%rbp), %rdi
callq 0x8ba0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x12449
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x2e00(%rip), %rdx      # 0x1520e
movb $0x0, %al
callq 0x10030
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x1242a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1253d
movq -0x20(%rbp), %rax
movl %eax, %esi
movl -0x34(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12eb0
jmp 0x12535
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x269a(%rip), %rdx      # 0x14af2
movb $0x0, %al
callq 0x10030
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x12474
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1253d
movq -0x20(%rbp), %rax
movl %eax, %esi
movl -0x34(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12eb0
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x124eb
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x12210
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x124c3
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1253d
movq -0x20(%rbp), %rax
movl %eax, %esi
movl -0x34(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12eb0
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x1249a
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
leaq 0x2d0f(%rip), %rdx      # 0x15211
movb $0x0, %al
callq 0x10030
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x1251b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1253d
movq -0x20(%rbp), %rax
movl %eax, %esi
movl -0x34(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12eb0
jmp 0x12537
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)