// File: /workspace/github_c_makefile_star2_O2/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 0xf224
movq %rax, 0x30(%rsp)
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x130(%rbx)
jne 0xf0f3
movq %rbx, %rdi
callq 0x21b0
testl %eax, %eax
je 0xf22a
movq 0x118(%rbx), %r15
testq %r15, %r15
je 0xf22a
movq %r13, 0x60(%rsp)
movq %r14, 0x38(%rsp)
xorl %r13d, %r13d
movl (%r15), %eax
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jae 0xf277
cmpl $0x3, %eax
jne 0xf169
testq %r13, %r13
jne 0xf326
cmpl $0x1, 0x8(%r15)
jne 0xf2b9
cmpl $0x1, 0xc(%r15)
jne 0xf2b9
pushq $0x8
popq %rdi
callq 0x2080
testq %rax, %rax
je 0xf224
movq %rax, %r13
movl 0x8(%r15), %eax
movl %eax, (%r13)
movl 0xc(%r15), %eax
movl %eax, 0x4(%r13)
jmp 0xf1d8
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 0xf383
testl %eax, %eax
je 0xf22d
movq 0x30(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0xf1c8
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x20e0
testl %eax, %eax
je 0xf361
movq 0x30(%rsp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rbp, (%rax)
movq %r14, 0x8(%rax)
andl $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 0xf22d
movq 0x118(%rbx), %r15
testq %r15, %r15
jne 0xf110
jmp 0xf22d
movl $0x1, (%rbx)
xorl %r13d, %r13d
movq %r13, %rdi
callq 0x2140
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xf25f
leaq -0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq -0x10(%rax), %rdi
movq -0x8(%rax), %rbx
callq 0x2140
movq %rbx, %rdi
jmp 0xf230
callq 0x2140
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x20, %r15
leaq 0xdb2e(%rip), %r14      # 0x1cdb0
pushq $0x1
popq %rbp
movq (%r14), %rsi
testq %rsi, %rsi
je 0xf2f4
movq 0x8(%r14), %rdx
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %ecx
callq 0xf383
addq $0x10, %r14
testl %eax, %eax
jne 0xf285
jmp 0xf22d
movq 0x30(%r15), %rax
movq %rax, 0x50(%rsp)
movups 0x20(%r15), %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x4, (%rbx)
leaq 0x85ed(%rip), %rax      # 0x178c6
movq %rax, 0x8(%rbx)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x20(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rbx)
jmp 0xf22a
testq %r12, %r12
je 0xf2fd
movq %r13, (%r12)
movq 0x20(%rsp), %rdi
movq 0x60(%rsp), %rcx
testq %rcx, %rcx
je 0xf379
movq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xf36c
movq %rdi, (%rcx)
movq 0x38(%rsp), %rcx
movq %rax, (%rcx)
jmp 0xf266
movq 0x30(%r15), %rax
movq %rax, 0x50(%rsp)
movups 0x20(%r15), %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x4, (%rbx)
leaq 0x8560(%rip), %rax      # 0x178a6
movq %rax, 0x8(%rbx)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x20(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rbx)
jmp 0xf22d
movl $0x1, (%rbx)
jmp 0xf22d
movq 0x38(%rsp), %rax
andq $0x0, (%rax)
andq $0x0, (%rcx)
callq 0x2140
jmp 0xf266