// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
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
cmpq 0x10(%r14), %r15
jae 0x1406
movl (%r15), %eax
cmpl $0x3, %eax
je 0x13e8
cmpl $0x2, %eax
je 0x13d6
cmpl $0x1, %eax
jne 0x14ac
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
movl 0x18(%r15), %ecx
movl 0x20(%r15), %r8d
movq %rbx, %rdi
callq 0x1160
jmp 0x13f8
movq 0x8(%r15), %rsi
movl 0x28(%r15), %edx
movq %rbx, %rdi
callq 0x11a0
jmp 0x13f8
movq 0x8(%r15), %rsi
movl 0x28(%r15), %edx
movq %rbx, %rdi
callq 0x10e0
testl %eax, %eax
je 0x1492
addq $0x60, %r15
jmp 0x13a0
movq (%r14), %r15
cmpq 0x10(%r14), %r15
jae 0x149c
movl (%r15), %eax
cmpl $0x3, %eax
je 0x1452
cmpl $0x2, %eax
jne 0x1489
movq 0x10(%r15), %r12
cmpq 0x20(%r15), %r12
jae 0x1489
movq %r15, %rax
subq (%r14), %rax
shrq $0x5, %rax
imull $0xaaaaaaab, %eax, %esi # imm = 0xAAAAAAAB
incl %esi
movl (%r12), %edx
movq %rbx, %rdi
callq 0x10d0
testl %eax, %eax
je 0x1492
addq $0x4, %r12
jmp 0x1424
movq 0x10(%r15), %r12
cmpq 0x20(%r15), %r12
jae 0x1489
movq %r15, %rax
subq (%r14), %rax
shrq $0x5, %rax
imull $0xaaaaaaab, %eax, %esi # imm = 0xAAAAAAAB
incl %esi
movl (%r12), %edx
movl 0x4(%r12), %ecx
movq %rbx, %rdi
callq 0x1200
testl %eax, %eax
je 0x1492
addq $0x8, %r12
jmp 0x1456
addq $0x60, %r15
jmp 0x1409
movq %rbx, %rdi
callq 0x1130
jmp 0x14a1
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb51(%rip), %rdi       # 0x2004
leaq 0xb4c(%rip), %rsi       # 0x2006
leaq 0xb52(%rip), %rcx       # 0x2013
movl $0x2c, %edx
callq 0x1120