// File: /workspace/github_c_makefile_star2_O1/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
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movl $0x100, %edi            # imm = 0x100
callq 0x2080
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x10912
movq %rax, 0x30(%rsp)
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x130(%rbx)
jne 0x107ce
movq %rbx, %rdi
callq 0x21b0
testl %eax, %eax
je 0x109f6
movq 0x118(%rbx), %r15
testq %r15, %r15
je 0x10918
movq %r13, 0x60(%rsp)
movq %r14, 0x38(%rsp)
xorl %r13d, %r13d
movl (%r15), %eax
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jae 0x10974
cmpl $0x4, %eax
je 0x1084f
cmpl $0x3, %eax
jne 0x108be
testq %r13, %r13
jne 0x10a39
cmpl $0x1, 0x8(%r15)
jne 0x109fe
cmpl $0x1, 0xc(%r15)
jne 0x109fe
movl $0x8, %edi
callq 0x2080
testq %rax, %rax
je 0x10912
movq %rax, %r13
movl 0x8(%r15), %eax
movl %eax, (%r13)
movl 0xc(%r15), %eax
movl %eax, 0x4(%r13)
jmp 0x108be
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 0x10ac0
testl %eax, %eax
je 0x1091b
movq 0x30(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x108a9
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x20e0
testl %eax, %eax
je 0x10a8c
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 0x10904
movq 0x118(%rbx), %r15
jmp 0x10907
xorl %r15d, %r15d
testq %r15, %r15
jne 0x107eb
jmp 0x1091b
movl $0x1, (%rbx)
xorl %r13d, %r13d
movq %r13, %rdi
callq 0x2140
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1094d
leaq -0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq -0x10(%rax), %rdi
movq -0x8(%rax), %rbx
callq 0x2140
movq %rbx, %rdi
jmp 0x1091e
callq 0x2140
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x20, %r15
leaq 0x8ea6(%rip), %rsi      # 0x19825
leaq 0xc43a(%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 0x10ac0
testl %eax, %eax
je 0x1091b
movq (%r14), %rsi
addq $0x10, %r14
testq %rsi, %rsi
jne 0x10986
testq %r12, %r12
je 0x109c5
movq %r13, (%r12)
movq 0x20(%rsp), %rdi
movq 0x60(%rsp), %rcx
testq %rcx, %rcx
je 0x10a74
movq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x10a97
movq %rdi, (%rcx)
movq 0x38(%rsp), %rcx
movq %rax, (%rcx)
jmp 0x10ab6
xorl %r15d, %r15d
jmp 0x107d5
movq 0x30(%r15), %rax
movq %rax, 0x50(%rsp)
movups 0x20(%r15), %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x4, (%rbx)
leaq 0x8e3c(%rip), %rax      # 0x1985a
movq %rax, 0x8(%rbx)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x20(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rbx)
jmp 0x10918
movq 0x30(%r15), %rax
movq %rax, 0x50(%rsp)
movups 0x20(%r15), %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x4, (%rbx)
leaq 0x8de1(%rip), %rax      # 0x1983a
movq %rax, 0x8(%rbx)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x20(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rbx)
jmp 0x1091b
callq 0x2140
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
jmp 0x10ab6
movl $0x1, (%rbx)
jmp 0x1091b
xorl %ebx, %ebx
movq 0x38(%rsp), %rax
movq %rbx, (%rax)
movq %rbx, (%rcx)
callq 0x2140
movq %rbx, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movl $0x1, %eax
jmp 0x10965