// File: /workspace/github_c_makefile_star2_O2/mijallen[P]SimpleHTTPServer/lib/libyaml/src/reader.c
// Function: yaml_parser_update_buffer
YAML_DECLARE(int)
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
{
    int first = 1;

    assert(parser->read_handler);   /* Read handler must be set. */

    /* If the EOF flag is set and the raw buffer is empty, do nothing. */

    if (parser->eof && parser->raw_buffer.pointer == parser->raw_buffer.last)
        return 1;

    /* Return if the buffer contains enough characters. */

    if (parser->unread >= length)
        return 1;

    /* Determine the input encoding if it is not known yet. */

    if (!parser->encoding) {
        if (!yaml_parser_determine_encoding(parser))
            return 0;
    }

    /* Move the unread characters to the beginning of the buffer. */

    if (parser->buffer.start < parser->buffer.pointer
            && parser->buffer.pointer < parser->buffer.last) {
        size_t size = parser->buffer.last - parser->buffer.pointer;
        memmove(parser->buffer.start, parser->buffer.pointer, size);
        parser->buffer.pointer = parser->buffer.start;
        parser->buffer.last = parser->buffer.start + size;
    }
    else if (parser->buffer.pointer == parser->buffer.last) {
        parser->buffer.pointer = parser->buffer.start;
        parser->buffer.last = parser->buffer.start;
    }

    /* Fill the buffer until it has enough characters. */

    while (parser->unread < length)
    {
        /* Fill the raw buffer if necessary. */

        if (!first || parser->raw_buffer.pointer == parser->raw_buffer.last) {
            if (!yaml_parser_update_raw_buffer(parser)) return 0;
        }
        first = 0;

        /* Decode the raw buffer. */

        while (parser->raw_buffer.pointer != parser->raw_buffer.last)
        {
            unsigned int value = 0, value2 = 0;
            int incomplete = 0;
            unsigned char octet;
            unsigned int width = 0;
            int low, high;
            size_t k;
            size_t raw_unread = parser->raw_buffer.last - parser->raw_buffer.pointer;

            /* Decode the next character. */

            switch (parser->encoding)
            {
                case YAML_UTF8_ENCODING:

                    /*
                     * Decode a UTF-8 character.  Check RFC 3629
                     * (http://www.ietf.org/rfc/rfc3629.txt) for more details.
                     *
                     * The following table (taken from the RFC) is used for
                     * decoding.
                     *
                     *    Char. number range |        UTF-8 octet sequence
                     *      (hexadecimal)    |              (binary)
                     *   --------------------+------------------------------------
                     *   0000 0000-0000 007F | 0xxxxxxx
                     *   0000 0080-0000 07FF | 110xxxxx 10xxxxxx
                     *   0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
                     *   0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
                     *
                     * Additionally, the characters in the range 0xD800-0xDFFF
                     * are prohibited as they are reserved for use with UTF-16
                     * surrogate pairs.
                     */

                    /* Determine the length of the UTF-8 sequence. */

                    octet = parser->raw_buffer.pointer[0];
                    width = (octet & 0x80) == 0x00 ? 1 :
                            (octet & 0xE0) == 0xC0 ? 2 :
                            (octet & 0xF0) == 0xE0 ? 3 :
                            (octet & 0xF8) == 0xF0 ? 4 : 0;

                    /* Check if the leading octet is valid. */

                    if (!width)
                        return yaml_parser_set_reader_error(parser,
                                "invalid leading UTF-8 octet",
                                parser->offset, octet);

                    /* Check if the raw buffer contains an incomplete character. */

                    if (width > raw_unread) {
                        if (parser->eof) {
                            return yaml_parser_set_reader_error(parser,
                                    "incomplete UTF-8 octet sequence",
                                    parser->offset, -1);
                        }
                        incomplete = 1;
                        break;
                    }

                    /* Decode the leading octet. */

                    value = (octet & 0x80) == 0x00 ? octet & 0x7F :
                            (octet & 0xE0) == 0xC0 ? octet & 0x1F :
                            (octet & 0xF0) == 0xE0 ? octet & 0x0F :
                            (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;

                    /* Check and decode the trailing octets. */

                    for (k = 1; k < width; k ++)
                    {
                        octet = parser->raw_buffer.pointer[k];

                        /* Check if the octet is valid. */

                        if ((octet & 0xC0) != 0x80)
                            return yaml_parser_set_reader_error(parser,
                                    "invalid trailing UTF-8 octet",
                                    parser->offset+k, octet);

                        /* Decode the octet. */

                        value = (value << 6) + (octet & 0x3F);
                    }

                    /* Check the length of the sequence against the value. */

                    if (!((width == 1) ||
                            (width == 2 && value >= 0x80) ||
                            (width == 3 && value >= 0x800) ||
                            (width == 4 && value >= 0x10000)))
                        return yaml_parser_set_reader_error(parser,
                                "invalid length of a UTF-8 sequence",
                                parser->offset, -1);

                    /* Check the range of the value. */

                    if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF)
                        return yaml_parser_set_reader_error(parser,
                                "invalid Unicode character",
                                parser->offset, value);

                    break;
                
                case YAML_UTF16LE_ENCODING:
                case YAML_UTF16BE_ENCODING:

                    low = (parser->encoding == YAML_UTF16LE_ENCODING ? 0 : 1);
                    high = (parser->encoding == YAML_UTF16LE_ENCODING ? 1 : 0);

                    /*
                     * The UTF-16 encoding is not as simple as one might
                     * naively think.  Check RFC 2781
                     * (http://www.ietf.org/rfc/rfc2781.txt).
                     *
                     * Normally, two subsequent bytes describe a Unicode
                     * character.  However a special technique (called a
                     * surrogate pair) is used for specifying character
                     * values larger than 0xFFFF.
                     *
                     * A surrogate pair consists of two pseudo-characters:
                     *      high surrogate area (0xD800-0xDBFF)
                     *      low surrogate area (0xDC00-0xDFFF)
                     *
                     * The following formulas are used for decoding
                     * and encoding characters using surrogate pairs:
                     * 
                     *  U  = U' + 0x10000   (0x01 00 00 <= U <= 0x10 FF FF)
                     *  U' = yyyyyyyyyyxxxxxxxxxx   (0 <= U' <= 0x0F FF FF)
                     *  W1 = 110110yyyyyyyyyy
                     *  W2 = 110111xxxxxxxxxx
                     *
                     * where U is the character value, W1 is the high surrogate
                     * area, W2 is the low surrogate area.
                     */

                    /* Check for incomplete UTF-16 character. */

                    if (raw_unread < 2) {
                        if (parser->eof) {
                            return yaml_parser_set_reader_error(parser,
                                    "incomplete UTF-16 character",
                                    parser->offset, -1);
                        }
                        incomplete = 1;
                        break;
                    }

                    /* Get the character. */

                    value = parser->raw_buffer.pointer[low]
                        + (parser->raw_buffer.pointer[high] << 8);

                    /* Check for unexpected low surrogate area. */

                    if ((value & 0xFC00) == 0xDC00)
                        return yaml_parser_set_reader_error(parser,
                                "unexpected low surrogate area",
                                parser->offset, value);

                    /* Check for a high surrogate area. */

                    if ((value & 0xFC00) == 0xD800) {

                        width = 4;

                        /* Check for incomplete surrogate pair. */

                        if (raw_unread < 4) {
                            if (parser->eof) {
                                return yaml_parser_set_reader_error(parser,
                                        "incomplete UTF-16 surrogate pair",
                                        parser->offset, -1);
                            }
                            incomplete = 1;
                            break;
                        }

                        /* Get the next character. */

                        value2 = parser->raw_buffer.pointer[low+2]
                            + (parser->raw_buffer.pointer[high+2] << 8);

                        /* Check for a low surrogate area. */

                        if ((value2 & 0xFC00) != 0xDC00)
                            return yaml_parser_set_reader_error(parser,
                                    "expected low surrogate area",
                                    parser->offset+2, value2);

                        /* Generate the value of the surrogate pair. */

                        value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF);
                    }

                    else {
                        width = 2;
                    }

                    break;

                default:
                    assert(1);      /* Impossible. */
            }

            /* Check if the raw buffer contains enough bytes to form a character. */

            if (incomplete) break;

            /*
             * Check if the character is in the allowed range:
             *      #x9 | #xA | #xD | [#x20-#x7E]               (8 bit)
             *      | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD]    (16 bit)
             *      | [#x10000-#x10FFFF]                        (32 bit)
             */

            if (! (value == 0x09 || value == 0x0A || value == 0x0D
                        || (value >= 0x20 && value <= 0x7E)
                        || (value == 0x85) || (value >= 0xA0 && value <= 0xD7FF)
                        || (value >= 0xE000 && value <= 0xFFFD)
                        || (value >= 0x10000 && value <= 0x10FFFF)))
                return yaml_parser_set_reader_error(parser,
                        "control characters are not allowed",
                        parser->offset, value);

            /* Move the raw pointers. */

            parser->raw_buffer.pointer += width;
            parser->offset += width;

            /* Finally put the character into the buffer. */

            /* 0000 0000-0000 007F -> 0xxxxxxx */
            if (value <= 0x7F) {
                *(parser->buffer.last++) = value;
            }
            /* 0000 0080-0000 07FF -> 110xxxxx 10xxxxxx */
            else if (value <= 0x7FF) {
                *(parser->buffer.last++) = 0xC0 + (value >> 6);
                *(parser->buffer.last++) = 0x80 + (value & 0x3F);
            }
            /* 0000 0800-0000 FFFF -> 1110xxxx 10xxxxxx 10xxxxxx */
            else if (value <= 0xFFFF) {
                *(parser->buffer.last++) = 0xE0 + (value >> 12);
                *(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
                *(parser->buffer.last++) = 0x80 + (value & 0x3F);
            }
            /* 0001 0000-0010 FFFF -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
            else {
                *(parser->buffer.last++) = 0xF0 + (value >> 18);
                *(parser->buffer.last++) = 0x80 + ((value >> 12) & 0x3F);
                *(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
                *(parser->buffer.last++) = 0x80 + (value & 0x3F);
            }

            parser->unread ++;
        }

        /* On EOF, put NUL into the buffer and return. */

        if (parser->eof) {
            *(parser->buffer.last++) = '\0';
            parser->unread ++;
            return 1;
        }

    }

    if (parser->offset >= PTRDIFF_MAX)
        return yaml_parser_set_reader_error(parser, "input is too long",
                PTRDIFF_MAX, -1);

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0x58(%rdi)
je 0x4f71
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x0, 0x80(%rdi)
pushq $0x1
popq %rax
je 0x4918
movq 0xc0(%rbx), %rcx
cmpq 0xc8(%rbx), %rcx
je 0x4de0
cmpq %r14, 0xa8(%rbx)
jae 0x4de0
cmpl $0x0, 0xd0(%rbx)
je 0x4998
movq 0x88(%rbx), %rdi
movq 0x98(%rbx), %rsi
cmpq %rsi, %rdi
setb %al
movq 0xa0(%rbx), %r15
cmpq %r15, %rsi
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x49fe
subq %rsi, %r15
movq %r15, %rdx
callq 0x21e0
movq 0x88(%rbx), %rax
movq %rax, 0x98(%rbx)
addq %rax, %r15
movq %r15, 0xa0(%rbx)
jmp 0x4a11
cmpq $0x2, %rax
jg 0x49b8
movq %rbx, %rdi
callq 0x4f90
testl %eax, %eax
je 0x4dde
movq 0xc0(%rbx), %r15
movq 0xc8(%rbx), %rax
subq %r15, %rax
cmpl $0x0, 0x80(%rbx)
je 0x4982
cmpq $0x2, %rax
jl 0x49ef
cmpw $0xfeff, (%r15)         # imm = 0xFEFF
je 0x4def
cmpw $-0x2, (%r15)
je 0x4e14
cmpq $0x2, %rax
je 0x49ef
leaq 0x12542(%rip), %rsi     # 0x16f1e
pushq $0x3
popq %rdx
movq %r15, %rdi
callq 0x21c0
testl %eax, %eax
je 0x4ec4
movl $0x1, 0xd0(%rbx)
jmp 0x492e
cmpq %r15, %rsi
jne 0x4a11
movq %rdi, 0x98(%rbx)
movq %rdi, 0xa0(%rbx)
pushq $0x2
popq %r15
pushq $0x4
popq %r11
movl $0x2600, %ebp           # imm = 0x2600
pushq $0x1
popq %r13
pushq $0x1
popq %r10
xorl %eax, %eax
cmpq %r14, 0xa8(%rbx)
jae 0x4e74
testb $0x1, %al
jne 0x4a49
movq 0xc0(%rbx), %rax
cmpq 0xc8(%rbx), %rax
jne 0x4a70
movq %rbx, %rdi
movl %r10d, %r12d
movl %r15d, %ebp
movl %r11d, %r15d
callq 0x4f90
movl %r15d, %r11d
movl %ebp, %r15d
movl $0x2600, %ebp           # imm = 0x2600
movl %r12d, %r10d
testl %eax, %eax
je 0x4dde
movq 0xc0(%rbx), %rcx
movq 0xc8(%rbx), %rsi
cmpq %rsi, %rcx
je 0x4d5a
subq %rcx, %rsi
movl 0xd0(%rbx), %edi
leal -0x2(%rdi), %eax
cmpl $0x2, %eax
jae 0x4add
cmpq $0x1, %rsi
jbe 0x4d6e
xorl %edx, %edx
xorl %eax, %eax
cmpl $0x2, %edi
sete %dl
setne %al
movzbl (%rcx,%rax), %eax
movzbl (%rcx,%rdx), %edx
shll $0x8, %edx
orl %edx, %eax
andl $0xfc00, %edx           # imm = 0xFC00
cmpw $0xd800, %dx            # imm = 0xD800
je 0x4aff
cmpl $0xdc00, %edx           # imm = 0xDC00
je 0x4e36
movl %r15d, %edx
jmp 0x4c32
xorl %edx, %edx
movl $0x0, %eax
cmpl $0x1, %edi
jne 0x4c3c
movzbl (%rcx), %eax
testb %al, %al
js 0x4b51
movl %r10d, %edx
movq %r13, %rdi
jmp 0x4bb4
cmpq $0x3, %rsi
jbe 0x4d82
xorl %edx, %edx
cmpl $0x2, %edi
setne %dl
movzbl 0x2(%rcx,%rdx), %esi
xorq $0x3, %rdx
movzbl (%rcx,%rdx), %edi
movl %edi, %edx
shll $0x8, %edx
orl %esi, %edx
andl $-0x4, %edi
cmpl $0xdc, %edi
jne 0x4e4c
shll $0xa, %eax
andl $0xffc00, %eax          # imm = 0xFFC00
andl $0x3ff, %edx            # imm = 0x3FF
addl %edx, %eax
addl $0x10000, %eax          # imm = 0x10000
movl %r11d, %edx
jmp 0x4c32
movl %eax, %r8d
andl $-0x20, %r8d
cmpl $0xc0, %r8d
jne 0x4b72
movl %r15d, %edx
pushq $0x2
popq %rdi
cmpq $0x1, %rsi
ja 0x4bb1
jmp 0x4d96
movl %eax, %r9d
andl $-0x10, %r9d
pushq $0x3
popq %rdx
cmpl $0xe0, %r9d
je 0x4b99
movl %eax, %edi
andl $-0x8, %edi
movl %r11d, %edx
cmpl $0xf0, %edi
jne 0x4f0a
movl %edx, %edi
cmpq %rdi, %rsi
jb 0x4d96
cmpl $0xc0, %r8d
jne 0x4d2e
andl $0x1f, %eax
movq %r13, %rsi
cmpq %rsi, %rdi
je 0x4be4
movzbl (%rcx,%rsi), %r8d
movl %r8d, %r9d
andl $-0x40, %r9d
cmpl $0x80, %r9d
jne 0x4dbe
shll $0x6, %eax
andl $0x3f, %r8d
orl %r8d, %eax
incq %rsi
jmp 0x4bb7
cmpl $0x1, %edx
je 0x4c13
cmpl $0x2, %edx
jne 0x4bf3
cmpl $0x7f, %eax
ja 0x4c13
cmpl $0x3, %edx
jne 0x4bff
cmpl $0x7ff, %eax            # imm = 0x7FF
ja 0x4c13
cmpl $0x4, %edx
jne 0x4f20
cmpl $0xffff, %eax           # imm = 0xFFFF
jbe 0x4f20
cmpl $0x10ffff, %eax         # imm = 0x10FFFF
ja 0x4ea0
movl %eax, %esi
andl $0xfffff800, %esi       # imm = 0xFFFFF800
cmpl $0xd800, %esi           # imm = 0xD800
je 0x4ea0
cmpl $0xd, %eax
ja 0x4c3c
btl %eax, %ebp
jb 0x4c72
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0x4c72
leal -0xa0(%rax), %esi
cmpl $0xd760, %esi           # imm = 0xD760
jb 0x4c72
cmpl $0x85, %eax
je 0x4c72
leal -0x20(%rax), %esi
cmpl $0x5f, %esi
jb 0x4c72
leal -0xe000(%rax), %esi
cmpl $0x1ffe, %esi           # imm = 0x1FFE
jae 0x4dfb
movl %edx, %edx
addq %rdx, %rcx
movq %rcx, 0xc0(%rbx)
addq %rdx, 0xd8(%rbx)
cmpl $0x7f, %eax
jbe 0x4d0e
cmpl $0x7ff, %eax            # imm = 0x7FF
ja 0x4c9f
movl %eax, %ecx
shrl $0x6, %ecx
orb $-0x40, %cl
jmp 0x4cf6
movq 0xa0(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0xa0(%rbx)
movl %eax, %edx
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0x4cc4
shrl $0xc, %edx
orb $-0x20, %dl
movb %dl, (%rcx)
jmp 0x4ceb
shrl $0x12, %edx
addb $-0x10, %dl
movb %dl, (%rcx)
movl %eax, %ecx
shrl $0xc, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
movq 0xa0(%rbx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0xa0(%rbx)
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x6, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
movq 0xa0(%rbx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0xa0(%rbx)
movb %cl, (%rdx)
andb $0x3f, %al
orb $-0x80, %al
movq 0xa0(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0xa0(%rbx)
movb %al, (%rcx)
incq 0xa8(%rbx)
jmp 0x4a70
cmpl $0xe0, %r9d
jne 0x4d3f
andl $0xf, %eax
jmp 0x4bb4
movl %eax, %esi
andl $-0x8, %esi
andl $0x7, %eax
cmpl $0xf0, %esi
movl $0x0, %esi
cmovnel %esi, %eax
jmp 0x4bb4
movb $0x1, %al
cmpl $0x0, 0x80(%rbx)
je 0x4a28
jmp 0x4ee6
movb $0x1, %al
cmpl $0x0, 0x80(%rbx)
je 0x4a28
jmp 0x4f36
movb $0x1, %al
cmpl $0x0, 0x80(%rbx)
je 0x4a28
jmp 0x4f4c
movb $0x1, %al
cmpl $0x0, 0x80(%rbx)
je 0x4a28
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12055(%rip), %rcx     # 0x16e0e
jmp 0x4f60
addq 0xd8(%rbx), %rsi
movl $0x2, (%rbx)
leaq 0x1205c(%rip), %rax     # 0x16e2e
movq %rax, 0x8(%rbx)
movq %rsi, 0x10(%rbx)
movl %r8d, 0x18(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x2, 0xd0(%rbx)
jmp 0x4e1e
movq 0xd8(%rbx), %rcx
movl $0x2, (%rbx)
leaq 0x120d4(%rip), %rdx     # 0x16ee3
jmp 0x4eb4
movl $0x3, 0xd0(%rbx)
addq $0x2, %r15
movq %r15, 0xc0(%rbx)
addq $0x2, 0xd8(%rbx)
jmp 0x492e
movq 0xd8(%rbx), %rcx
movl $0x2, (%rbx)
leaq 0x1205a(%rip), %rdx     # 0x16ea4
jmp 0x4eb4
movq 0xd8(%rbx), %rax
addq $0x2, %rax
movl $0x2, (%rbx)
leaq 0x12042(%rip), %rcx     # 0x16ea6
movq %rcx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movl %edx, 0x18(%rbx)
jmp 0x4dde
movabsq $0x7ffffffffffffffe, %rax # imm = 0x7FFFFFFFFFFFFFFE
cmpq %rax, 0xd8(%rbx)
jbe 0x4f02
movl $0x2, (%rbx)
leaq 0x12072(%rip), %rcx     # 0x16f06
movq %rcx, 0x8(%rbx)
incq %rax
jmp 0x4f64
movq 0xd8(%rbx), %rcx
movl $0x2, (%rbx)
leaq 0x11fba(%rip), %rdx     # 0x16e6e
movq %rdx, 0x8(%rbx)
movq %rcx, 0x10(%rbx)
movl %eax, 0x18(%rbx)
jmp 0x4dde
movl $0x1, 0xd0(%rbx)
addq $0x3, %r15
movq %r15, 0xc0(%rbx)
addq $0x3, 0xd8(%rbx)
jmp 0x492e
movq 0xa0(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xa0(%rbx)
movb $0x0, (%rax)
incq 0xa8(%rbx)
pushq $0x1
popq %rax
jmp 0x4de0
movq 0xd8(%rbx), %rcx
movl $0x2, (%rbx)
leaq 0x11ed4(%rip), %rdx     # 0x16df2
jmp 0x4eb4
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x11f17(%rip), %rcx     # 0x16e4b
jmp 0x4f60
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x11f3e(%rip), %rcx     # 0x16e88
jmp 0x4f60
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x11f62(%rip), %rcx     # 0x16ec2
movq %rcx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
orl $-0x1, 0x18(%rbx)
jmp 0x4dde
leaq 0x1116f(%rip), %rdi     # 0x160e7
leaq 0x11e33(%rip), %rsi     # 0x16db2
leaq 0x11e35(%rip), %rcx     # 0x16dbb
movl $0x92, %edx
callq 0x2100