// File: /workspace/github_c_makefile_star2_O2/mijallen[P]SimpleHTTPServer/lib/libyaml/tests/run-dumper.c
// Function: copy_document
int copy_document(yaml_document_t *document_to, yaml_document_t *document_from)
{
    yaml_node_t *node;
    yaml_node_item_t *item;
    yaml_node_pair_t *pair;

    if (!yaml_document_initialize(document_to, document_from->version_directive,
                document_from->tag_directives.start,
                document_from->tag_directives.end,
                document_from->start_implicit, document_from->end_implicit))
        return 0;

    for (node = document_from->nodes.start;
            node < document_from->nodes.top; node ++) {
        switch (node->type) {
            case YAML_SCALAR_NODE:
                if (!yaml_document_add_scalar(document_to, node->tag,
                            node->data.scalar.value, node->data.scalar.length,
                            node->data.scalar.style)) goto error;
                break;
            case YAML_SEQUENCE_NODE:
                if (!yaml_document_add_sequence(document_to, node->tag,
                            node->data.sequence.style)) goto error;
                break;
            case YAML_MAPPING_NODE:
                if (!yaml_document_add_mapping(document_to, node->tag,
                            node->data.mapping.style)) goto error;
                break;
            default:
                assert(0);
                break;
        }
    }

    for (node = document_from->nodes.start;
            node < document_from->nodes.top; node ++) {
        switch (node->type) {
            case YAML_SEQUENCE_NODE:
                for (item = node->data.sequence.items.start;
                        item < node->data.sequence.items.top; item ++) {
                    if (!yaml_document_append_sequence_item(document_to,
                                node - document_from->nodes.start + 1,
                                *item)) goto error;
                }
                break;
            case YAML_MAPPING_NODE:
                for (pair = node->data.mapping.pairs.start;
                        pair < node->data.mapping.pairs.top; pair ++) {
                    if (!yaml_document_append_mapping_pair(document_to,
                                node - document_from->nodes.start + 1,
                                pair->key, pair->value)) goto error;
                }
                break;
            default:
                break;
        }
    }
    return 1;

error:
    yaml_document_delete(document_to);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rsi), %rsi
movq 0x20(%r14), %rdx
movq 0x28(%r14), %rcx
movl 0x30(%r14), %r8d
movl 0x34(%r14), %r9d
callq 0x1140
xorl %ebp, %ebp
testl %eax, %eax
je 0x14a1
movq (%r14), %r15
movq 0x10(%r14), %rax
cmpq %rax, %r15
jae 0x140c
movl (%r15), %eax
cmpl $0x3, %eax
je 0x13ee
cmpl $0x2, %eax
je 0x13dc
cmpl $0x1, %eax
jne 0x14b7
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
movl 0x18(%r15), %ecx
movl 0x20(%r15), %r8d
movq %rbx, %rdi
callq 0x1160
jmp 0x13fe
movq 0x8(%r15), %rsi
movl 0x28(%r15), %edx
movq %rbx, %rdi
callq 0x11a0
jmp 0x13fe
movq 0x8(%r15), %rsi
movl 0x28(%r15), %edx
movq %rbx, %rdi
callq 0x10e0
testl %eax, %eax
je 0x1499
addq $0x60, %r15
jmp 0x13a3
movq (%r14), %r12
pushq $0x60
popq %r13
cmpq %rax, %r12
jae 0x14b2
movl (%r12), %eax
cmpl $0x3, %eax
je 0x1459
cmpl $0x2, %eax
jne 0x148c
movq 0x10(%r12), %r15
cmpq 0x20(%r12), %r15
jae 0x148c
movq %r12, %rax
subq (%r14), %rax
cqto
idivq %r13
leal 0x1(%rax), %esi
movl (%r15), %edx
movq %rbx, %rdi
callq 0x10d0
addq $0x4, %r15
testl %eax, %eax
jne 0x142f
jmp 0x1499
movq 0x10(%r12), %r15
cmpq 0x20(%r12), %r15
jae 0x148c
movq %r12, %rax
subq (%r14), %rax
cqto
idivq %r13
leal 0x1(%rax), %esi
movl (%r15), %edx
movl 0x4(%r15), %ecx
movq %rbx, %rdi
callq 0x1200
addq $0x8, %r15
testl %eax, %eax
jne 0x145e
jmp 0x1499
addq $0x60, %r12
movq 0x10(%r14), %rax
jmp 0x1413
movq %rbx, %rdi
callq 0x1130
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rbp
jmp 0x14a1
leaq 0xb46(%rip), %rdi       # 0x2004
leaq 0xb41(%rip), %rsi       # 0x2006
leaq 0xb47(%rip), %rcx       # 0x2013
pushq $0x2c
popq %rdx
callq 0x1120