// File: /workspace/github_c_makefile_star2_O3/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 %rbx
pushq %rax
cmpq $0x0, 0x58(%rdi)
je 0x4d83
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x0, 0x80(%rdi)
je 0x4c09
movq 0xc0(%rbx), %rax
cmpq 0xc8(%rbx), %rax
je 0x4cf0
movl $0x1, %ebp
cmpq %r14, 0xa8(%rbx)
jae 0x52a1
cmpl $0x0, 0xd0(%rbx)
je 0x4c8e
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 0x4cfa
subq %rsi, %r15
movq %r15, %rdx
callq 0x21d0
movq 0x88(%rbx), %rax
movq %rax, 0x98(%rbx)
addq %rax, %r15
movq %r15, 0xa0(%rbx)
jmp 0x4d0d
cmpq $0x2, %rcx
jg 0x4cae
movq %rbx, %rdi
callq 0x52ff
testl %eax, %eax
je 0x529f
movq 0xc0(%rbx), %rax
movq 0xc8(%rbx), %rcx
subq %rax, %rcx
cmpl $0x0, 0x80(%rbx)
je 0x4c78
cmpq $0x2, %rcx
jl 0x4ce1
cmpw $0xfeff, (%rax)         # imm = 0xFEFF
je 0x4d33
cmpw $-0x2, (%rax)
je 0x4d3f
cmpq $0x2, %rcx
je 0x4ce1
movzwl (%rax), %ecx
xorl $0xbbef, %ecx           # imm = 0xBBEF
movzbl 0x2(%rax), %edx
xorl $0xbf, %edx
orw %cx, %dx
je 0x4d61
movl $0x1, 0xd0(%rbx)
jmp 0x4c24
movl $0x1, %ebp
jmp 0x52a1
cmpq %r15, %rsi
jne 0x4d0d
movq %rdi, 0x98(%rbx)
movq %rdi, 0xa0(%rbx)
cmpq %r14, 0xa8(%rbx)
jae 0x515e
movq 0xc0(%rbx), %rsi
movq 0xc8(%rbx), %rdi
cmpq %rdi, %rsi
jne 0x4dc0
jmp 0x4da2
movl $0x2, 0xd0(%rbx)
jmp 0x4d49
movl $0x3, 0xd0(%rbx)
addq $0x2, %rax
movq %rax, 0xc0(%rbx)
addq $0x2, 0xd8(%rbx)
jmp 0x4c24
movl $0x1, 0xd0(%rbx)
addq $0x3, %rax
movq %rax, 0xc0(%rbx)
addq $0x3, 0xd8(%rbx)
jmp 0x4c24
leaq 0x1235d(%rip), %rdi     # 0x170e7
leaq 0x13021(%rip), %rsi     # 0x17db2
leaq 0x13023(%rip), %rcx     # 0x17dbb
movl $0x92, %edx
callq 0x2100
movq %rbx, %rdi
callq 0x52ff
testl %eax, %eax
je 0x529f
movq 0xc0(%rbx), %rsi
movq 0xc8(%rbx), %rdi
cmpq %rdi, %rsi
je 0x5144
movl $0x2600, %eax           # imm = 0x2600
xorl %ecx, %ecx
movq %rdi, %r9
subq %rsi, %r9
movl 0xd0(%rbx), %r10d
leal -0x2(%r10), %edx
cmpl $0x2, %edx
jae 0x4e31
cmpq $0x1, %r9
jbe 0x51be
xorl %edi, %edi
xorl %edx, %edx
cmpl $0x2, %r10d
sete %dil
setne %dl
movzbl (%rsi,%rdx), %edx
movzbl (%rsi,%rdi), %edi
shll $0x8, %edi
orl %edi, %edx
andl $0xfc00, %edi           # imm = 0xFC00
cmpl $0xd800, %edi           # imm = 0xD800
je 0x4e81
movl $0x2, %r8d
cmpl $0xdc00, %edi           # imm = 0xDC00
jne 0x4edb
jmp 0x521f
movl $0x0, %r8d
movl $0x0, %edx
cmpl $0x1, %r10d
jne 0x4efe
movzbl (%rsi), %edx
testb %dl, %dl
js 0x4f91
movl $0x1, %r8d
cmpq %rsi, %rdi
je 0x51f9
cmpl $0x10ffff, %edx         # imm = 0x10FFFF
ja 0x5280
movl %edx, %edi
andl $0xfffff800, %edi       # imm = 0xFFFFF800
cmpl $0xd800, %edi           # imm = 0xD800
jne 0x4edb
jmp 0x5280
cmpq $0x3, %r9
jbe 0x5235
xorl %edi, %edi
cmpl $0x2, %r10d
setne %dil
movzbl 0x2(%rsi,%rdi), %r8d
xorq $0x3, %rdi
movzbl (%rsi,%rdi), %r9d
movl %r9d, %edi
shll $0x8, %edi
orl %r8d, %edi
andl $-0x4, %r9d
cmpl $0xdc, %r9d
jne 0x525b
shll $0xa, %edx
andl $0xffc00, %edx          # imm = 0xFFC00
andl $0x3ff, %edi            # imm = 0x3FF
addl %edi, %edx
addl $0x10000, %edx          # imm = 0x10000
movl $0x4, %r8d
cmpl $0xd, %edx
ja 0x4efe
btl %edx, %eax
jae 0x4efe
movl %r8d, %edi
addq %rdi, %rsi
movq %rsi, 0xc0(%rbx)
addq %rdi, 0xd8(%rbx)
jmp 0x5013
cmpl $0xffff, %edx           # imm = 0xFFFF
ja 0x4f36
leal -0xa0(%rdx), %edi
cmpl $0xd760, %edi           # imm = 0xD760
jb 0x4f36
cmpl $0x85, %edx
je 0x4f36
leal -0x20(%rdx), %edi
cmpl $0x5f, %edi
jb 0x4f36
leal -0xe000(%rdx), %edi
cmpl $0x1ffe, %edi           # imm = 0x1FFE
jae 0x51e0
movl %r8d, %edi
addq %rdi, %rsi
movq %rsi, 0xc0(%rbx)
addq %rdi, 0xd8(%rbx)
cmpl $0x7f, %edx
jbe 0x5013
cmpl $0x7ff, %edx            # imm = 0x7FF
ja 0x4f69
movl %edx, %esi
shrl $0x6, %esi
orb $-0x40, %sil
jmp 0x4ff8
movq 0xa0(%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0xa0(%rbx)
movl %edx, %edi
cmpl $0xffff, %edx           # imm = 0xFFFF
ja 0x4fbf
shrl $0xc, %edi
orb $-0x20, %dil
movb %dil, (%rsi)
jmp 0x4feb
movl %edx, %r10d
andl $-0x20, %r10d
cmpl $0xc0, %r10d
jne 0x504a
cmpq $0x2, %r9
jb 0x51f9
movl $0x2, %r8d
movl $0x2, %edi
jmp 0x5091
shrl $0x12, %edi
addb $-0x10, %dil
movb %dil, (%rsi)
movl %edx, %esi
shrl $0xc, %esi
andb $0x3f, %sil
orb $-0x80, %sil
movq 0xa0(%rbx), %rdi
leaq 0x1(%rdi), %r8
movq %r8, 0xa0(%rbx)
movb %sil, (%rdi)
movl %edx, %esi
shrl $0x6, %esi
andb $0x3f, %sil
orb $-0x80, %sil
movq 0xa0(%rbx), %rdi
leaq 0x1(%rdi), %r8
movq %r8, 0xa0(%rbx)
movb %sil, (%rdi)
andb $0x3f, %dl
orb $-0x80, %dl
movq 0xa0(%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0xa0(%rbx)
movb %dl, (%rsi)
incq 0xa8(%rbx)
movq 0xc0(%rbx), %rsi
movq 0xc8(%rbx), %rdi
cmpq %rdi, %rsi
jne 0x4dd0
jmp 0x5144
movl %edx, %r11d
andl $-0x10, %r11d
movl $0x3, %edi
cmpl $0xe0, %r11d
je 0x5078
movl %edx, %r8d
andl $-0x8, %r8d
movl $0x4, %edi
cmpl $0xf0, %r8d
jne 0x52cc
movl %edi, %r8d
cmpq %r8, %r9
jb 0x51f9
cmpl $0xc0, %r10d
jne 0x511a
andl $0x1f, %edx
movl $0x1, %r10d
movzbl (%rsi,%r10), %r11d
movl %r11d, %r9d
andl $-0x40, %r9d
cmpl $0x80, %r9d
jne 0x5199
movl %edx, %r9d
shll $0x6, %r9d
andl $0x3f, %r11d
movl %r11d, %edx
orl %r9d, %edx
incq %r10
cmpq %r10, %r8
jne 0x509a
cmpl $0x2, %edi
jne 0x50e1
movl $0x2, %r8d
cmpl $0x7f, %r9d
ja 0x4e60
cmpl $0x3, %edi
jne 0x50f9
movl $0x3, %r8d
cmpl $0x7ff, %r9d            # imm = 0x7FF
ja 0x4e60
cmpl $0x4, %edi
jne 0x52e2
movl $0x4, %r8d
cmpl $0xffff, %r9d           # imm = 0xFFFF
ja 0x4e60
jmp 0x52e2
cmpl $0xe0, %r11d
jne 0x512b
andl $0xf, %edx
jmp 0x5094
movl %edx, %r9d
andl $-0x8, %r9d
andl $0x7, %edx
cmpl $0xf0, %r9d
cmovnel %ecx, %edx
jmp 0x5094
cmpl $0x0, 0x80(%rbx)
jne 0x52ae
cmpq %r14, 0xa8(%rbx)
jb 0x4da2
movabsq $0x7ffffffffffffffe, %rax # imm = 0x7FFFFFFFFFFFFFFE
cmpq %rax, 0xd8(%rbx)
jbe 0x52a1
movl $0x2, (%rbx)
leaq 0x12d84(%rip), %rcx     # 0x17f06
movq %rcx, 0x8(%rbx)
incq %rax
movq %rax, 0x10(%rbx)
movl $0xffffffff, 0x18(%rbx) # imm = 0xFFFFFFFF
jmp 0x529f
addq 0xd8(%rbx), %r10
movl $0x2, (%rbx)
leaq 0x12c81(%rip), %rax     # 0x17e2e
movq %rax, 0x8(%rbx)
movq %r10, 0x10(%rbx)
movl %r11d, 0x18(%rbx)
jmp 0x529f
cmpl $0x0, 0x80(%rbx)
je 0x5151
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12cad(%rip), %rcx     # 0x17e88
jmp 0x52f6
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12cef(%rip), %rcx     # 0x17ee3
jmp 0x5294
cmpl $0x0, 0x80(%rbx)
je 0x5151
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12bf4(%rip), %rcx     # 0x17e0e
jmp 0x52f6
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12c71(%rip), %rcx     # 0x17ea4
jmp 0x5294
cmpl $0x0, 0x80(%rbx)
je 0x5151
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12c6c(%rip), %rcx     # 0x17ec2
jmp 0x52f6
movq 0xd8(%rbx), %rax
addq $0x2, %rax
movl $0x2, (%rbx)
leaq 0x12c33(%rip), %rcx     # 0x17ea6
movq %rcx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movl %edi, 0x18(%rbx)
jmp 0x529f
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12bda(%rip), %rcx     # 0x17e6e
movq %rcx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movl %edx, 0x18(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xa0(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xa0(%rbx)
movb $0x0, (%rax)
incq 0xa8(%rbx)
jmp 0x52a1
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12b12(%rip), %rcx     # 0x17df2
jmp 0x5294
movq 0xd8(%rbx), %rax
movl $0x2, (%rbx)
leaq 0x12b55(%rip), %rcx     # 0x17e4b
movq %rcx, 0x8(%rbx)
jmp 0x5189