// File: /workspace/github_c_makefile_star2_O2/mijallen[P]SimpleHTTPServer/lib/libyaml/tests/run-emitter.c
// Function: main
int
main(int argc, char *argv[])
{
    int number;
    int canonical = 0;
    int unicode = 0;

    number = 1;
    while (number < argc) {
        if (strcmp(argv[number], "-c") == 0) {
            canonical = 1;
        }
        else if (strcmp(argv[number], "-u") == 0) {
            unicode = 1;
        }
        else if (argv[number][0] == '-') {
            printf("Unknown option: '%s'\n", argv[number]);
            return 0;
        }
        if (argv[number][0] == '-') {
            if (number < argc-1) {
                memmove(argv+number, argv+number+1, (argc-number-1)*sizeof(char *));
            }
            argc --;
        }
        else {
            number ++;
        }
    }

    if (argc < 2) {
        printf("Usage: %s [-c] [-u] file1.yaml ...\n", argv[0]);
        return 0;
    }

    for (number = 1; number < argc; number ++)
    {
        FILE *file;
        yaml_parser_t parser;
        yaml_emitter_t emitter;
        yaml_event_t event;
        unsigned char buffer[BUFFER_SIZE];
        size_t written = 0;
        yaml_event_t events[MAX_EVENTS];
        size_t event_number = 0;
        int done = 0;
        int count = 0;
        int error = 0;
        int k;
        memset(buffer, 0, BUFFER_SIZE);
        memset(events, 0, MAX_EVENTS*sizeof(yaml_event_t));

        printf("[%d] Parsing, emitting, and parsing again '%s': ", number, argv[number]);
        fflush(stdout);

        file = fopen(argv[number], "rb");
        assert(file);

        assert(yaml_parser_initialize(&parser));
        yaml_parser_set_input_file(&parser, file);
        assert(yaml_emitter_initialize(&emitter));
        if (canonical) {
            yaml_emitter_set_canonical(&emitter, 1);
        }
        if (unicode) {
            yaml_emitter_set_unicode(&emitter, 1);
        }
        yaml_emitter_set_output_string(&emitter, buffer, BUFFER_SIZE, &written);

        while (!done)
        {
            if (!yaml_parser_parse(&parser, &event)) {
                error = 1;
                break;
            }

            done = (event.type == YAML_STREAM_END_EVENT);
            assert(event_number < MAX_EVENTS);
            assert(copy_event(&(events[event_number++]), &event));
            assert(yaml_emitter_emit(&emitter, &event) || 
                    (yaml_emitter_flush(&emitter) && print_output(argv[number], buffer, written, count)));
            count ++;
        }

        yaml_parser_delete(&parser);
        assert(!fclose(file));
        yaml_emitter_delete(&emitter);

        if (!error)
        {
            count = done = 0;
            assert(yaml_parser_initialize(&parser));
            yaml_parser_set_input_string(&parser, buffer, written);

            while (!done)
            {
                assert(yaml_parser_parse(&parser, &event) || print_output(argv[number], buffer, written, count));
                done = (event.type == YAML_STREAM_END_EVENT);
                assert(compare_events(events+count, &event) || print_output(argv[number], buffer, written, count));
                yaml_event_delete(&event);
                count ++;
            }
            yaml_parser_delete(&parser);
        }

        for (k = 0; k < event_number; k ++) {
            yaml_event_delete(events+k);
        }

        printf("PASSED (length: %d)\n", written);
        print_output(argv[number], buffer, written, -1);
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a438, %rsp          # imm = 0x2A438
movq %rsi, %r12
movl %edi, %ebx
leal -0x1(%rbx), %r14d
movl $0x0, 0xc(%rsp)
pushq $0x1
popq %rbp
movl %ebp, %r15d
movl $0x0, 0x24(%rsp)
movq %rsi, 0x10(%rsp)
movslq %r15d, %r15
cmpl %ebx, %r15d
jge 0x184d
movq (%r12,%r15,8), %rsi
cmpb $0x2d, (%rsi)
je 0x17e8
incq %r15
jmp 0x17d5
cmpb $0x63, 0x1(%rsi)
jne 0x17f7
cmpb $0x0, 0x2(%rsi)
movl %ebp, %r12d
je 0x1814
cmpb $0x75, 0x1(%rsi)
jne 0x1afa
cmpb $0x0, 0x2(%rsi)
movl 0xc(%rsp), %r12d
movl %ebp, 0x24(%rsp)
jne 0x1afa
decl %ebx
cmpl %ebx, %r15d
jge 0x183e
movq 0x10(%rsp), %rax
leaq (%rax,%r15,8), %rdi
leaq (%rax,%r15,8), %rsi
addq $0x8, %rsi
movl %r14d, %eax
subl %r15d, %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x11e0
decq %r14
movl %r12d, 0xc(%rsp)
movq 0x10(%rsp), %r12
jmp 0x17d2
cmpl $0x2, %ebx
jge 0x1878
movq (%r12), %rsi
leaq 0x8cc(%rip), %rdi       # 0x2129
xorl %eax, %eax
callq 0x10f0
xorl %eax, %eax
addq $0x2a438, %rsp          # imm = 0x2A438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebx, %eax
movq %rax, 0x28(%rsp)
pushq $0x1
popq %r14
leaq 0x430(%rsp), %rbp
leaq 0x250(%rsp), %r13
leaq 0xa0(%rsp), %rbx
leaq 0x38(%rsp), %r15
cmpq 0x28(%rsp), %r14
je 0x1864
andq $0x0, (%rsp)
movl $0x10000, %edx          # imm = 0x10000
movq %rbp, %rdi
xorl %esi, %esi
callq 0x1120
movl $0x1a000, %edx          # imm = 0x1A000
leaq 0x10430(%rsp), %rdi
xorl %esi, %esi
callq 0x1120
movq (%r12,%r14,8), %rdx
leaq 0x873(%rip), %rdi       # 0x214d
movl %r14d, %esi
xorl %eax, %eax
callq 0x10f0
movq 0x26f5(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x11b0
movq (%r12,%r14,8), %rdi
leaq 0x76d(%rip), %rsi       # 0x206b
callq 0x1200
testq %rax, %rax
je 0x1c19
movq %rax, %r12
movq %r13, %rdi
callq 0x11a0
testl %eax, %eax
je 0x1c38
movq %r13, %rdi
movq %r12, %rsi
callq 0x1040
movq %rbx, %rdi
callq 0x10b0
testl %eax, %eax
je 0x1c57
cmpl $0x0, 0xc(%rsp)
je 0x194c
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x1210
movq %r12, 0x30(%rsp)
movq %r14, 0x18(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x1968
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x1240
movl $0x10000, %edx          # imm = 0x10000
movq %rbx, %rdi
movq %rbp, %rsi
movq %rsp, %rcx
callq 0x1250
xorl %r12d, %r12d
leaq 0x10430(%rsp), %r14
xorl %ebp, %ebp
testl %ebp, %ebp
jne 0x19eb
movq %r13, %rdi
movq %r15, %rsi
callq 0x1050
testl %eax, %eax
je 0x19eb
xorl %ebp, %ebp
cmpl $0x2, 0x38(%rsp)
sete %bl
cmpq $0x400, %r12            # imm = 0x400
je 0x1b86
movq %r14, %rdi
movq %r15, %rsi
callq 0x136c
testl %eax, %eax
je 0x1bfa
movb %bl, %bpl
incq %r12
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1100
addq $0x68, %r14
testl %eax, %eax
jne 0x1988
jmp 0x1ba5
movq %r13, %rdi
callq 0x1180
movq 0x30(%rsp), %rdi
callq 0x10c0
testl %eax, %eax
jne 0x1c76
movq %rbx, %rdi
callq 0x10d0
testl %ebp, %ebp
movq 0x18(%rsp), %r14
leaq 0x430(%rsp), %rbp
je 0x1aa4
movq %r13, %rdi
callq 0x11a0
testl %eax, %eax
je 0x1c95
movq (%rsp), %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x10a0
xorl %ebx, %ebx
leaq 0x10430(%rsp), %r14
xorl %ebp, %ebp
movq %r13, %rdi
testl %ebp, %ebp
jne 0x1a92
movq %r15, %rsi
callq 0x1050
testl %eax, %eax
je 0x1b46
movq %r14, %rdi
movq %r15, %rsi
callq 0x1427
testl %eax, %eax
je 0x1b06
xorl %ebp, %ebp
cmpl $0x2, 0x38(%rsp)
sete %bpl
movq %r15, %rdi
callq 0x1220
incl %ebx
addq $0x68, %r14
jmp 0x1a4d
callq 0x1180
movq 0x18(%rsp), %r14
leaq 0x430(%rsp), %rbp
leaq 0x10430(%rsp), %rbx
subq $0x1, %r12
jb 0x1ac0
movq %rbx, %rdi
callq 0x1220
addq $0x68, %rbx
jmp 0x1aac
movq (%rsp), %rsi
leaq 0x892(%rip), %rdi       # 0x235d
xorl %eax, %eax
callq 0x10f0
movq 0x10(%rsp), %r12
movq (%r12,%r14,8), %rdi
movq (%rsp), %rdx
movq %rbp, %rsi
pushq $-0x1
popq %rcx
callq 0x1650
incq %r14
leaq 0xa0(%rsp), %rbx
jmp 0x18a0
leaq 0x612(%rip), %rdi       # 0x2113
jmp 0x185d
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq (%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %ebx, %ecx
callq 0x1650
leaq 0x7d4(%rip), %rdi       # 0x2302
leaq 0x53e(%rip), %rsi       # 0x2073
leaq 0x642(%rip), %rcx       # 0x217e
movl $0x137, %edx            # imm = 0x137
callq 0x1110
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq (%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %ebx, %ecx
callq 0x1650
leaq 0x73b(%rip), %rdi       # 0x22a9
leaq 0x4fe(%rip), %rsi       # 0x2073
leaq 0x602(%rip), %rcx       # 0x217e
movl $0x135, %edx            # imm = 0x135
callq 0x1110
leaq 0x64a(%rip), %rdi       # 0x21d7
leaq 0x4df(%rip), %rsi       # 0x2073
leaq 0x5e3(%rip), %rcx       # 0x217e
movl $0x122, %edx            # imm = 0x122
callq 0x1110
leaq 0xa0(%rsp), %rdi
callq 0x1190
testl %eax, %eax
je 0x1bdb
decl %r12d
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq (%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %r12d, %ecx
callq 0x1650
leaq 0x63d(%rip), %rdi       # 0x221f
leaq 0x48a(%rip), %rsi       # 0x2073
leaq 0x58e(%rip), %rcx       # 0x217e
movl $0x125, %edx            # imm = 0x125
callq 0x1110
leaq 0x5f0(%rip), %rdi       # 0x21f1
leaq 0x46b(%rip), %rsi       # 0x2073
leaq 0x56f(%rip), %rcx       # 0x217e
movl $0x123, %edx            # imm = 0x123
callq 0x1110
leaq 0x44e(%rip), %rdi       # 0x206e
leaq 0x44c(%rip), %rsi       # 0x2073
leaq 0x550(%rip), %rcx       # 0x217e
movl $0x10d, %edx            # imm = 0x10D
callq 0x1110
leaq 0x556(%rip), %rdi       # 0x2195
leaq 0x42d(%rip), %rsi       # 0x2073
leaq 0x531(%rip), %rcx       # 0x217e
movl $0x10f, %edx            # imm = 0x10F
callq 0x1110
leaq 0x557(%rip), %rdi       # 0x21b5
leaq 0x40e(%rip), %rsi       # 0x2073
leaq 0x512(%rip), %rcx       # 0x217e
movl $0x111, %edx            # imm = 0x111
callq 0x1110
leaq 0x61e(%rip), %rdi       # 0x229b
leaq 0x3ef(%rip), %rsi       # 0x2073
leaq 0x4f3(%rip), %rcx       # 0x217e
movl $0x12a, %edx            # imm = 0x12A
callq 0x1110
leaq 0x4f9(%rip), %rdi       # 0x2195
leaq 0x3d0(%rip), %rsi       # 0x2073
leaq 0x4d4(%rip), %rcx       # 0x217e
movl $0x130, %edx            # imm = 0x130
callq 0x1110