// File: /workspace/github_c_makefile_star2_O3/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, %r14
cmpl $0x2, %edi
jl 0x1821
movl $0x1, %ebx
movl $0x0, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movslq %ebx, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x180a
cmpb $0x63, 0x1(%rsi)
jne 0x17ce
cmpb $0x0, 0x2(%rsi)
je 0x1812
cmpb $0x75, 0x1(%rsi)
jne 0x182d
movl $0x1, 0x14(%rsp)
cmpb $0x0, 0x2(%rsi)
jne 0x182d
leal -0x1(%rdi), %ebp
cmpl %ebp, %ebx
jge 0x1806
leaq (%r14,%rax,8), %rax
leaq 0x8(%rax), %rsi
movl %ebx, %ecx
notl %ecx
addl %ecx, %edi
movslq %edi, %rdx
shlq $0x3, %rdx
movq %rax, %rdi
callq 0x11e0
movl %ebp, %edi
jmp 0x180c
incl %ebx
cmpl %edi, %ebx
jl 0x17b6
jmp 0x181c
movl $0x1, 0x10(%rsp)
jmp 0x17e2
cmpl $0x2, %edi
jge 0x184f
movq (%r14), %rsi
leaq 0x8fe(%rip), %rdi       # 0x2129
jmp 0x1834
leaq 0x8df(%rip), %rdi       # 0x2113
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 %edi, %eax
movq %rax, 0x30(%rsp)
movl $0x1, %ebx
leaq 0x430(%rsp), %r15
leaq 0x280(%rsp), %rbp
leaq 0x38(%rsp), %r12
movq %r14, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movl $0x10000, %edx          # imm = 0x10000
movq %r15, %rdi
xorl %esi, %esi
callq 0x1120
movl $0x1a000, %edx          # imm = 0x1A000
leaq 0x10430(%rsp), %rdi
xorl %esi, %esi
callq 0x1120
movq (%r14,%rbx,8), %rdx
leaq 0x8a1(%rip), %rdi       # 0x214d
movl %ebx, %esi
xorl %eax, %eax
callq 0x10f0
movq 0x2724(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x11b0
movq (%r14,%rbx,8), %rdi
leaq 0x79c(%rip), %rsi       # 0x206b
callq 0x1200
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x1c2f
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
callq 0x11a0
testl %eax, %eax
je 0x1c10
movq %r13, %rdi
movq 0x28(%rsp), %rsi
callq 0x1040
movq %rbp, %rdi
callq 0x10b0
testl %eax, %eax
je 0x1bf1
cmpl $0x0, 0x10(%rsp)
je 0x192b
movq %rbp, %rdi
movl $0x1, %esi
callq 0x1210
movq %rbx, 0x20(%rsp)
cmpl $0x0, 0x14(%rsp)
je 0x1944
movq %rbp, %rdi
movl $0x1, %esi
callq 0x1240
movl $0x10000, %edx          # imm = 0x10000
movq %rbp, %r13
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x8(%rsp), %rcx
callq 0x1250
leaq 0x10430(%rsp), %r14
xorl %r15d, %r15d
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1050
movl %eax, %ebp
testl %eax, %eax
je 0x19cb
cmpq $0x400, %r15            # imm = 0x400
je 0x1b7f
movl 0x38(%rsp), %ebx
movq %r14, %rdi
movq %r12, %rsi
callq 0x136c
testl %eax, %eax
je 0x1b60
movq %r13, %rdi
movq %r12, %rsi
callq 0x1100
testl %eax, %eax
je 0x1b9e
addq $0x68, %r14
incq %r15
cmpl $0x2, %ebx
leaq 0xa0(%rsp), %rbx
jne 0x196f
movq %rbx, %rdi
callq 0x1180
movq 0x28(%rsp), %rdi
callq 0x10c0
testl %eax, %eax
jne 0x1c4e
movq %r13, %rdi
callq 0x10d0
testl %ebp, %ebp
je 0x1a6f
movq %rbx, %rdi
callq 0x11a0
testl %eax, %eax
je 0x1c6d
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
leaq 0x430(%rsp), %rsi
callq 0x10a0
xorl %ebx, %ebx
leaq 0x10430(%rsp), %r14
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x1050
testl %eax, %eax
je 0x1ade
movq %r14, %rdi
movq %r12, %rsi
callq 0x1429
testl %eax, %eax
je 0x1b1f
movl 0x38(%rsp), %ebp
movq %r12, %rdi
callq 0x1220
incl %ebx
addq $0x68, %r14
cmpl $0x2, %ebp
jne 0x1a20
leaq 0xa0(%rsp), %rdi
callq 0x1180
testq %r15, %r15
je 0x1a8d
leaq 0x10430(%rsp), %rbx
movq %rbx, %rdi
callq 0x1220
addq $0x68, %rbx
decq %r15
jne 0x1a7c
movq 0x8(%rsp), %rsi
leaq 0x8c4(%rip), %rdi       # 0x235d
xorl %eax, %eax
callq 0x10f0
movq 0x18(%rsp), %r14
movq 0x20(%rsp), %rbx
movq (%r14,%rbx,8), %rdi
movq 0x8(%rsp), %rdx
leaq 0x430(%rsp), %r15
movq %r15, %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x1638
incq %rbx
cmpq 0x30(%rsp), %rbx
movq %r13, %rbp
jne 0x1875
jmp 0x183b
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x8(%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %ebx, %ecx
callq 0x1638
leaq 0x7a2(%rip), %rdi       # 0x22a9
leaq 0x565(%rip), %rsi       # 0x2073
leaq 0x669(%rip), %rcx       # 0x217e
movl $0x135, %edx            # imm = 0x135
callq 0x1110
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x8(%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %ebx, %ecx
callq 0x1638
leaq 0x7ba(%rip), %rdi       # 0x2302
leaq 0x524(%rip), %rsi       # 0x2073
leaq 0x628(%rip), %rcx       # 0x217e
movl $0x137, %edx            # imm = 0x137
callq 0x1110
leaq 0x68a(%rip), %rdi       # 0x21f1
leaq 0x505(%rip), %rsi       # 0x2073
leaq 0x609(%rip), %rcx       # 0x217e
movl $0x123, %edx            # imm = 0x123
callq 0x1110
leaq 0x651(%rip), %rdi       # 0x21d7
leaq 0x4e6(%rip), %rsi       # 0x2073
leaq 0x5ea(%rip), %rcx       # 0x217e
movl $0x122, %edx            # imm = 0x122
callq 0x1110
leaq 0x280(%rsp), %rdi
callq 0x1190
testl %eax, %eax
je 0x1bd2
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x8(%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %r15d, %ecx
callq 0x1638
leaq 0x646(%rip), %rdi       # 0x221f
leaq 0x493(%rip), %rsi       # 0x2073
leaq 0x597(%rip), %rcx       # 0x217e
movl $0x125, %edx            # imm = 0x125
callq 0x1110
leaq 0x5bd(%rip), %rdi       # 0x21b5
leaq 0x474(%rip), %rsi       # 0x2073
leaq 0x578(%rip), %rcx       # 0x217e
movl $0x111, %edx            # imm = 0x111
callq 0x1110
leaq 0x57e(%rip), %rdi       # 0x2195
leaq 0x455(%rip), %rsi       # 0x2073
leaq 0x559(%rip), %rcx       # 0x217e
movl $0x10f, %edx            # imm = 0x10F
callq 0x1110
leaq 0x438(%rip), %rdi       # 0x206e
leaq 0x436(%rip), %rsi       # 0x2073
leaq 0x53a(%rip), %rcx       # 0x217e
movl $0x10d, %edx            # imm = 0x10D
callq 0x1110
leaq 0x646(%rip), %rdi       # 0x229b
leaq 0x417(%rip), %rsi       # 0x2073
leaq 0x51b(%rip), %rcx       # 0x217e
movl $0x12a, %edx            # imm = 0x12A
callq 0x1110
leaq 0x521(%rip), %rdi       # 0x2195
leaq 0x3f8(%rip), %rsi       # 0x2073
leaq 0x4fc(%rip), %rcx       # 0x217e
movl $0x130, %edx            # imm = 0x130
callq 0x1110