// File: /workspace/github_c_makefile_star2_O0/liuhaotian[P]xmppsh/libstrophe/src/stanza.c
// Function: xmpp_stanza_copy
xmpp_stanza_t *xmpp_stanza_copy(const xmpp_stanza_t * const stanza)
{
    xmpp_stanza_t *copy, *child, *copychild, *tail;
    hash_iterator_t *iter;
    const char *key;
    void *val;

    copy = xmpp_stanza_new(stanza->ctx);
    if (!copy) goto copy_error;

    copy->type = stanza->type;

    if (stanza->data) {
	copy->data = xmpp_strdup(stanza->ctx, stanza->data);
	if (!copy->data) goto copy_error;
    }

    if (stanza->attributes) {
	copy->attributes = hash_new(stanza->ctx, 8, xmpp_free);
	if (!copy->attributes) goto copy_error;
	iter = hash_iter_new(stanza->attributes);
	if (!iter) { printf("DEBUG HERE\n"); goto copy_error; }
	while ((key = hash_iter_next(iter))) {
	    val = xmpp_strdup(stanza->ctx,
			      (char *)hash_get(stanza->attributes, key));
	    if (!val) goto copy_error;
	    
	    if (hash_add(copy->attributes, key, val))
		goto copy_error;
	}
	hash_iter_release(iter);
    }

    tail = copy->children;
    for (child = stanza->children; child; child = child->next) {
	copychild = xmpp_stanza_copy(child);
	if (!copychild) goto copy_error;
	copychild->parent = copy;

	if (tail) {
	    copychild->prev = tail;
	    tail->next = copychild;
	} else
	    copy->children = copychild;
	tail = copychild;
    }

    return copy;

copy_error:
    /* release all the hitherto allocated memory */
    if (copy) xmpp_stanza_release(copy);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x11cb0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x11d99
jmp 0x11f58
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x11de4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x13560
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x11de2
jmp 0x11f58
jmp 0x11de4
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x11eca
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x8, %esi
leaq -0xb747(%rip), %rdx     # 0x66c0
callq 0x85f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x11e27
jmp 0x11f58
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x8b30
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x11e52
leaq 0x33a9(%rip), %rdi      # 0x151ef
movb $0x0, %al
callq 0x2030
jmp 0x11f58
jmp 0x11e54
movq -0x38(%rbp), %rdi
callq 0x8bf0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x11ec1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x8a80
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x13560
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x11ea0
jmp 0x11f58
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x87e0
cmpl $0x0, %eax
je 0x11ebf
jmp 0x11f58
jmp 0x11e54
movq -0x38(%rbp), %rdi
callq 0x8ba0
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x11f4e
movq -0x20(%rbp), %rdi
callq 0x11d70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x11eff
jmp 0x11f58
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
cmpq $0x0, -0x30(%rbp)
je 0x11f2c
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x11f38
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x11ee2
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x11f70
cmpq $0x0, -0x18(%rbp)
je 0x11f68
movq -0x18(%rbp), %rdi
callq 0x11f80
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)