// File: /workspace/github_c_makefile_star2_O1/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
movl %edi, %ebx
movb $0x1, 0xf(%rsp)
cmpl $0x2, %edi
movq %rsi, 0x18(%rsp)
jl 0x18b2
movl $0x1, %r13d
movl $0x0, 0x10(%rsp)
leaq 0x907(%rip), %r14       # 0x2115
xorl %ebp, %ebp
movslq %r13d, %r15
movq 0x18(%rsp), %rax
movq (%rax,%r15,8), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x1140
testl %eax, %eax
je 0x184a
movq %r12, %rdi
leaq 0x8e3(%rip), %rsi       # 0x2118
callq 0x1140
testl %eax, %eax
je 0x1851
cmpb $0x2d, (%r12)
jne 0x1859
jmp 0x1b74
movl $0x1, %ebp
jmp 0x1859
movl $0x1, 0x10(%rsp)
cmpb $0x2d, (%r12)
jne 0x188e
leal -0x1(%rbx), %r12d
cmpl %r12d, %r13d
jge 0x1889
movq 0x18(%rsp), %rax
leaq (%rax,%r15,8), %rdi
leaq 0x8(%rdi), %rsi
movl %r13d, %eax
notl %eax
addl %eax, %ebx
movslq %ebx, %rdx
shlq $0x3, %rdx
callq 0x11e0
movl %r12d, %ebx
jmp 0x1891
incl %r13d
cmpl %ebx, %r13d
jl 0x1810
testl %ebp, %ebp
sete 0xf(%rsp)
cmpl $0x0, 0x10(%rsp)
sete 0xe(%rsp)
movq 0x18(%rsp), %r14
jmp 0x18ba
movq %rsi, %r14
movb $0x1, 0xe(%rsp)
cmpl $0x2, %ebx
jge 0x18ce
movq (%r14), %rsi
leaq 0x868(%rip), %rdi       # 0x2131
jmp 0x1b7e
movl %ebx, %eax
movq %rax, 0x28(%rsp)
movl $0x1, %ebx
leaq 0x430(%rsp), %r15
leaq 0x250(%rsp), %r13
leaq 0x38(%rsp), %r12
movq $0x0, 0x20(%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 0x82f(%rip), %rdi       # 0x2155
movl %ebx, %esi
xorl %eax, %eax
callq 0x10f0
movq 0x26aa(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x11b0
movq (%r14,%rbx,8), %rdi
leaq 0x724(%rip), %rsi       # 0x206d
callq 0x1200
testq %rax, %rax
je 0x1cac
movq %rax, %rbp
movq %r13, %rdi
callq 0x11a0
testl %eax, %eax
je 0x1ccb
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1040
leaq 0xa0(%rsp), %rdi
callq 0x10b0
testl %eax, %eax
je 0x1cea
cmpb $0x0, 0xf(%rsp)
jne 0x19a3
leaq 0xa0(%rsp), %rdi
movl $0x1, %esi
callq 0x1210
cmpb $0x0, 0xe(%rsp)
jne 0x19bc
leaq 0xa0(%rsp), %rdi
movl $0x1, %esi
callq 0x1240
movq %rbx, 0x10(%rsp)
movl $0x10000, %edx          # imm = 0x10000
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
leaq 0x20(%rsp), %rcx
callq 0x1250
movq %r13, %rdi
movq %r12, %rsi
callq 0x1050
testl %eax, %eax
je 0x1a65
movq %rbp, 0x30(%rsp)
leaq 0x10430(%rsp), %rbp
xorl %ecx, %ecx
movl 0x38(%rsp), %ebx
cmpl $0x2, %ebx
setne %r14b
cmpq $0x400, %rcx            # imm = 0x400
je 0x1c1b
movq %rcx, %r15
movq %rbp, %rdi
movq %r12, %rsi
callq 0x136c
testl %eax, %eax
je 0x1c3a
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x1100
testl %eax, %eax
je 0x1c59
cmpl $0x2, %ebx
je 0x1a5b
movq %r13, %rdi
movq %r12, %rsi
callq 0x1050
addq $0x68, %rbp
leaq 0x1(%r15), %rcx
testl %eax, %eax
jne 0x19f9
incq %r15
movq 0x30(%rsp), %rbp
jmp 0x1a6b
movb $0x1, %r14b
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x1180
movq %rbp, %rdi
callq 0x10c0
testl %eax, %eax
jne 0x1d09
leaq 0xa0(%rsp), %rdi
callq 0x10d0
testb %r14b, %r14b
jne 0x1b0b
movq %r13, %rdi
callq 0x11a0
testl %eax, %eax
je 0x1d28
movq 0x20(%rsp), %rdx
movq %r13, %rdi
leaq 0x430(%rsp), %rsi
callq 0x10a0
xorl %ebx, %ebx
leaq 0x10430(%rsp), %rbp
movq %r13, %rdi
movq %r12, %rsi
callq 0x1050
testl %eax, %eax
je 0x1bda
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1429
testl %eax, %eax
je 0x1b99
movl 0x38(%rsp), %r14d
movq %r12, %rdi
callq 0x1220
incl %ebx
addq $0x68, %rbp
cmpl $0x2, %r14d
jne 0x1ac4
movq %r13, %rdi
callq 0x1180
testq %r15, %r15
je 0x1b29
leaq 0x10430(%rsp), %rbx
movq %rbx, %rdi
callq 0x1220
addq $0x68, %rbx
decq %r15
jne 0x1b18
movq 0x20(%rsp), %rsi
leaq 0x830(%rip), %rdi       # 0x2365
xorl %eax, %eax
callq 0x10f0
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rbx
movq (%r14,%rbx,8), %rdi
movq 0x20(%rsp), %rdx
leaq 0x430(%rsp), %r15
movq %r15, %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x1687
incq %rbx
cmpq 0x28(%rsp), %rbx
jne 0x18ef
jmp 0x1b85
leaq 0x5a0(%rip), %rdi       # 0x211b
movq %r12, %rsi
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
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x20(%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %ebx, %ecx
callq 0x1687
leaq 0x748(%rip), %rdi       # 0x230a
leaq 0x4ac(%rip), %rsi       # 0x2075
leaq 0x5b6(%rip), %rcx       # 0x2186
movl $0x137, %edx            # imm = 0x137
callq 0x1110
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x20(%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %ebx, %ecx
callq 0x1687
leaq 0x6ae(%rip), %rdi       # 0x22b1
leaq 0x46b(%rip), %rsi       # 0x2075
leaq 0x575(%rip), %rcx       # 0x2186
movl $0x135, %edx            # imm = 0x135
callq 0x1110
leaq 0x5bd(%rip), %rdi       # 0x21df
leaq 0x44c(%rip), %rsi       # 0x2075
leaq 0x556(%rip), %rcx       # 0x2186
movl $0x122, %edx            # imm = 0x122
callq 0x1110
leaq 0x5b8(%rip), %rdi       # 0x21f9
leaq 0x42d(%rip), %rsi       # 0x2075
leaq 0x537(%rip), %rcx       # 0x2186
movl $0x123, %edx            # imm = 0x123
callq 0x1110
leaq 0xa0(%rsp), %rdi
callq 0x1190
testl %eax, %eax
je 0x1c8d
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x20(%rsp), %rdx
leaq 0x430(%rsp), %rsi
movl %r15d, %ecx
callq 0x1687
leaq 0x593(%rip), %rdi       # 0x2227
leaq 0x3da(%rip), %rsi       # 0x2075
leaq 0x4e4(%rip), %rcx       # 0x2186
movl $0x125, %edx            # imm = 0x125
callq 0x1110
leaq 0x3bd(%rip), %rdi       # 0x2070
leaq 0x3bb(%rip), %rsi       # 0x2075
leaq 0x4c5(%rip), %rcx       # 0x2186
movl $0x10d, %edx            # imm = 0x10D
callq 0x1110
leaq 0x4cb(%rip), %rdi       # 0x219d
leaq 0x39c(%rip), %rsi       # 0x2075
leaq 0x4a6(%rip), %rcx       # 0x2186
movl $0x10f, %edx            # imm = 0x10F
callq 0x1110
leaq 0x4cc(%rip), %rdi       # 0x21bd
leaq 0x37d(%rip), %rsi       # 0x2075
leaq 0x487(%rip), %rcx       # 0x2186
movl $0x111, %edx            # imm = 0x111
callq 0x1110
leaq 0x593(%rip), %rdi       # 0x22a3
leaq 0x35e(%rip), %rsi       # 0x2075
leaq 0x468(%rip), %rcx       # 0x2186
movl $0x12a, %edx            # imm = 0x12A
callq 0x1110
leaq 0x46e(%rip), %rdi       # 0x219d
leaq 0x33f(%rip), %rsi       # 0x2075
leaq 0x449(%rip), %rcx       # 0x2186
movl $0x130, %edx            # imm = 0x130
callq 0x1110