// File: /workspace/github_c_makefile_star2_O3/mijallen[P]SimpleHTTPServer/lib/libyaml/src/parser.c
// Function: yaml_parser_process_directives
static int
yaml_parser_process_directives(yaml_parser_t *parser,
        yaml_version_directive_t **version_directive_ref,
        yaml_tag_directive_t **tag_directives_start_ref,
        yaml_tag_directive_t **tag_directives_end_ref)
{
    yaml_tag_directive_t default_tag_directives[] = {
        {(yaml_char_t *)"!", (yaml_char_t *)"!"},
        {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
        {NULL, NULL}
    };
    yaml_tag_directive_t *default_tag_directive;
    yaml_version_directive_t *version_directive = NULL;
    struct {
        yaml_tag_directive_t *start;
        yaml_tag_directive_t *end;
        yaml_tag_directive_t *top;
    } tag_directives = { NULL, NULL, NULL };
    yaml_token_t *token;

    if (!STACK_INIT(parser, tag_directives, INITIAL_STACK_SIZE))
        goto error;

    token = PEEK_TOKEN(parser);
    if (!token) goto error;

    while (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
            token->type == YAML_TAG_DIRECTIVE_TOKEN)
    {
        if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) {
            if (version_directive) {
                yaml_parser_set_parser_error(parser,
                        "found duplicate %YAML directive", token->start_mark);
                goto error;
            }
            if (token->data.version_directive.major != 1
                    || token->data.version_directive.minor != 1) {
                yaml_parser_set_parser_error(parser,
                        "found incompatible YAML document", token->start_mark);
                goto error;
            }
            version_directive = yaml_malloc(sizeof(yaml_version_directive_t));
            if (!version_directive) {
                parser->error = YAML_MEMORY_ERROR;
                goto error;
            }
            version_directive->major = token->data.version_directive.major;
            version_directive->minor = token->data.version_directive.minor;
        }

        else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) {
            yaml_tag_directive_t value;
            value.handle = token->data.tag_directive.handle;
            value.prefix = token->data.tag_directive.prefix;

            if (!yaml_parser_append_tag_directive(parser, value, 0,
                        token->start_mark))
                goto error;
            if (!PUSH(parser, tag_directives, value))
                goto error;
        }

        SKIP_TOKEN(parser);
        token = PEEK_TOKEN(parser);
        if (!token) goto error;
    }
    
    for (default_tag_directive = default_tag_directives;
            default_tag_directive->handle; default_tag_directive++) {
        if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
                    token->start_mark))
            goto error;
    }

    if (version_directive_ref) {
        *version_directive_ref = version_directive;
    }
    if (tag_directives_start_ref) {
        if (STACK_EMPTY(parser, tag_directives)) {
            *tag_directives_start_ref = *tag_directives_end_ref = NULL;
            STACK_DEL(parser, tag_directives);
        }
        else {
            *tag_directives_start_ref = tag_directives.start;
            *tag_directives_end_ref = tag_directives.top;
        }
    }
    else {
        STACK_DEL(parser, tag_directives);
    }

    return 1;

error:
    yaml_free(version_directive);
    while (!STACK_EMPTY(parser, tag_directives)) {
        yaml_tag_directive_t tag_directive = POP(parser, tag_directives);
        yaml_free(tag_directive.handle);
        yaml_free(tag_directive.prefix);
    }
    STACK_DEL(parser, tag_directives);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movl $0x100, %edi            # imm = 0x100
callq 0x2080
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0xfd85
movq %rax, 0x30(%rsp)
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x130(%rbx)
jne 0xfc4f
movq %rbx, %rdi
callq 0x21b0
testl %eax, %eax
je 0xfd8b
movq 0x118(%rbx), %r15
testq %r15, %r15
je 0xfd8b
movq %r13, 0x60(%rsp)
movq %r14, 0x38(%rsp)
xorl %r13d, %r13d
movl (%r15), %eax
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jae 0xfdd6
cmpl $0x3, %eax
jne 0xfcc7
testq %r13, %r13
jne 0xfe8f
cmpl $0x1, 0x8(%r15)
jne 0xfe54
cmpl $0x1, 0xc(%r15)
jne 0xfe54
movl $0x8, %edi
callq 0x2080
testq %rax, %rax
je 0xfd85
movq %rax, %r13
movl 0x8(%r15), %eax
movl %eax, (%r13)
movl 0xc(%r15), %eax
movl %eax, 0x4(%r13)
jmp 0xfd36
movq 0x8(%r15), %rbp
movq 0x10(%r15), %r14
movq 0x30(%r15), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%r15), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xfef1
testl %eax, %eax
je 0xfd8e
movq 0x30(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0xfd26
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x20e0
testl %eax, %eax
je 0xfeca
movq 0x30(%rsp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rbp, (%rax)
movq %r14, 0x8(%rax)
movl $0x0, 0x130(%rbx)
incq 0x128(%rbx)
movq 0x118(%rbx), %rax
xorl %ecx, %ecx
cmpl $0x2, (%rax)
sete %cl
movl %ecx, 0xfc(%rbx)
addq $0x50, %rax
movq %rax, 0x118(%rbx)
movq %rbx, %rdi
callq 0x21b0
testl %eax, %eax
je 0xfd8e
movq 0x118(%rbx), %r15
testq %r15, %r15
jne 0xfc6c
jmp 0xfd8e
movl $0x1, (%rbx)
xorl %r13d, %r13d
movq %r13, %rdi
callq 0x2140
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xfdc0
leaq -0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq -0x10(%rax), %rdi
movq -0x8(%rax), %rbx
callq 0x2140
movq %rbx, %rdi
jmp 0xfd91
callq 0x2140
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x20, %r15
leaq 0x8ac0(%rip), %rsi      # 0x188a1
leaq 0xcfd8(%rip), %r14      # 0x1cdc0
movq -0x8(%r14), %rdx
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x1, %ecx
callq 0xfef1
testl %eax, %eax
je 0xfd8e
movq (%r14), %rsi
addq $0x10, %r14
testq %rsi, %rsi
jne 0xfde8
testq %r12, %r12
je 0xfe23
movq %r13, (%r12)
movq 0x20(%rsp), %rdi
movq 0x60(%rsp), %rdx
testq %rdx, %rdx
je 0xfee2
movq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xfed5
movq %rdi, (%rdx)
movq 0x38(%rsp), %rcx
movq %rax, (%rcx)
jmp 0xfee7
movq 0x30(%r15), %rax
movq %rax, 0x50(%rsp)
movups 0x20(%r15), %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x4, (%rbx)
leaq 0x8a62(%rip), %rax      # 0x188d6
movq %rax, 0x8(%rbx)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x20(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rbx)
jmp 0xfd8b
movq 0x30(%r15), %rax
movq %rax, 0x50(%rsp)
movups 0x20(%r15), %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x4, (%rbx)
leaq 0x8a07(%rip), %rax      # 0x188b6
movq %rax, 0x8(%rbx)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x20(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rbx)
jmp 0xfd8e
movl $0x1, (%rbx)
jmp 0xfd8e
xorl %eax, %eax
movq 0x38(%rsp), %rcx
movq %rax, (%rcx)
movq %rax, (%rdx)
callq 0x2140
movl $0x1, %eax
jmp 0xfdc7