// File: /workspace/github_c_makefile_star2_O1/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 0x52c4
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x0, 0x80(%rdi)
je 0x4be5
movq 0xc0(%r14), %rax
cmpq 0xc8(%r14), %rax
je 0x5223
movl $0x1, %ebx
cmpq %r15, 0xa8(%r14)
jae 0x5260
cmpl $0x0, 0xd0(%r14)
je 0x4c74
movq 0x88(%r14), %rdi
movq 0x98(%r14), %rsi
cmpq %rsi, %rdi
jae 0x4cdc
movq 0xa0(%r14), %r12
cmpq %r12, %rsi
jae 0x4cdc
subq %rsi, %r12
movq %r12, %rdx
callq 0x21d0
movq 0x88(%r14), %rax
movq %rax, 0x98(%r14)
addq %rax, %r12
movq %r12, 0xa0(%r14)
jmp 0x4cf3
movq 0xc8(%r14), %rax
subq 0xc0(%r14), %rax
cmpq $0x2, %rax
jg 0x4c7e
movq %r14, %rdi
callq 0x52e3
testl %eax, %eax
je 0x525e
cmpl $0x0, 0x80(%r14)
je 0x4c50
movq 0xc0(%r14), %rax
movq 0xc8(%r14), %rcx
subq %rax, %rcx
cmpq $0x2, %rcx
jl 0x4caa
cmpw $0xfeff, (%rax)         # imm = 0xFEFF
je 0x5271
cmpw $-0x2, (%rax)
je 0x52a1
cmpq $0x3, %rcx
jl 0x4ccc
movzwl (%rax), %ecx
xorl $0xbbef, %ecx           # imm = 0xBBEF
movzbl 0x2(%rax), %edx
xorl $0xbf, %edx
orw %cx, %dx
je 0x527e
movl $0x1, 0xd0(%r14)
jmp 0x4c01
cmpq 0xa0(%r14), %rsi
jne 0x4cf3
movq %rdi, 0x98(%r14)
movq %rdi, 0xa0(%r14)
leaq 0x1418e(%rip), %r12     # 0x18e88
movl $0x2600, %r13d          # imm = 0x2600
leaq 0x140eb(%rip), %rbp     # 0x18df2
xorl %eax, %eax
cmpq %r15, 0xa8(%r14)
jae 0x522a
testb $0x1, %al
jne 0x4d2a
movq 0xc0(%r14), %rax
cmpq 0xc8(%r14), %rax
jne 0x4d3a
movq %r14, %rdi
callq 0x52e3
testl %eax, %eax
je 0x525e
movq 0xc0(%r14), %rcx
movq 0xc8(%r14), %rdi
cmpq %rdi, %rcx
je 0x51f5
subq %rcx, %rdi
movl 0xd0(%r14), %esi
movb $0x1, %dl
leal -0x2(%rsi), %eax
cmpl $0x2, %eax
jae 0x4d94
cmpq $0x1, %rdi
ja 0x4e28
cmpl $0x0, 0x80(%r14)
je 0x4e83
movq 0xd8(%r14), %rax
movl $0x2, (%r14)
movq %r12, 0x8(%r14)
jmp 0x4f25
xorl %eax, %eax
cmpl $0x1, %esi
jne 0x4e87
movzbl (%rcx), %eax
movl $0x1, %esi
testb %al, %al
jns 0x4dec
movl %eax, %r8d
andl $-0x20, %r8d
movl $0x2, %esi
cmpl $0xc0, %r8d
je 0x4dec
movl %eax, %r8d
andl $-0x10, %r8d
movl $0x3, %esi
cmpl $0xe0, %r8d
je 0x4dec
movl %eax, %r8d
andl $-0x8, %r8d
xorl %esi, %esi
cmpl $0xf0, %r8d
sete %sil
shll $0x2, %esi
testl %esi, %esi
je 0x4edd
movl %esi, %r8d
cmpq %r8, %rdi
jae 0x4f36
cmpl $0x0, 0x80(%r14)
je 0x5013
movq 0xd8(%r14), %rax
movl $0x2, (%r14)
leaq 0x13feb(%rip), %rcx     # 0x18e0e
jmp 0x4f21
xorl %r8d, %r8d
xorl %eax, %eax
cmpl $0x2, %esi
sete %r8b
setne %al
movzbl (%rcx,%rax), %eax
movzbl (%rcx,%r8), %r8d
shll $0x8, %r8d
orl %r8d, %eax
andl $0xfc00, %r8d           # imm = 0xFC00
cmpl $0xd800, %r8d           # imm = 0xD800
je 0x4ef4
movl $0x2, %esi
cmpl $0xdc00, %r8d           # imm = 0xDC00
jne 0x4e89
movq 0xd8(%r14), %rcx
movl $0x2, (%r14)
leaq 0x14026(%rip), %rdx     # 0x18ea4
jmp 0x5198
xorl %eax, %eax
xorl %edx, %edx
xorl %esi, %esi
movl $0x5, %edi
testb %dl, %dl
je 0x51a9
cmpl $0xd, %eax
ja 0x4f57
btl %eax, %r13d
jae 0x4f57
movl %esi, %edx
addq %rdx, %rcx
movq %rcx, 0xc0(%r14)
addq %rdx, 0xd8(%r14)
cmpl $0x7f, %eax
jbe 0x5076
movl %eax, %ecx
cmpl $0x7ff, %eax            # imm = 0x7FF
ja 0x4fb7
shrl $0x6, %ecx
orb $-0x40, %cl
jmp 0x505e
movq 0xd8(%r14), %rcx
movl $0x2, (%r14)
movq %rbp, 0x8(%r14)
jmp 0x519c
cmpq $0x3, %rdi
ja 0x4fc6
cmpl $0x0, 0x80(%r14)
je 0x50c2
movq 0xd8(%r14), %rax
movl $0x2, (%r14)
leaq 0x13fa1(%rip), %rcx     # 0x18ec2
movq %rcx, 0x8(%r14)
movq %rax, 0x10(%r14)
movl $0xffffffff, 0x18(%r14) # imm = 0xFFFFFFFF
jmp 0x51a4
testb %al, %al
jns 0x50f6
movl %eax, %edi
andl $-0x20, %edi
cmpl $0xc0, %edi
jne 0x50ce
andl $0x1f, %eax
jmp 0x50f6
leal -0xa0(%rax), %edx
cmpl $0xd760, %edx           # imm = 0xD760
jb 0x4ea9
cmpl $0x85, %eax
je 0x4ea9
leal -0x20(%rax), %edx
cmpl $0x5f, %edx
jb 0x4ea9
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0x4ea9
leal -0xe000(%rax), %edx
cmpl $0x1ffe, %edx           # imm = 0x1FFE
jb 0x4ea9
movq 0xd8(%r14), %rcx
movl $0x2, (%r14)
leaq 0x13f31(%rip), %rdx     # 0x18ee3
jmp 0x5198
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0x501a
shrl $0xc, %ecx
orb $-0x20, %cl
jmp 0x503f
xorl %edi, %edi
cmpl $0x2, %esi
setne %dil
movzbl 0x2(%rcx,%rdi), %r8d
xorq $0x3, %rdi
movzbl (%rcx,%rdi), %edi
movl %edi, %esi
shll $0x8, %esi
orl %r8d, %esi
andl $-0x4, %edi
cmpl $0xdc, %edi
jne 0x5098
shll $0xa, %eax
andl $0xffc00, %eax          # imm = 0xFFC00
andl $0x3ff, %esi            # imm = 0x3FF
addl %esi, %eax
addl $0x10000, %eax          # imm = 0x10000
movl $0x4, %esi
jmp 0x4e89
xorl %eax, %eax
jmp 0x50c7
shrl $0x12, %ecx
addb $-0x10, %cl
movq 0xa0(%r14), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0xa0(%r14)
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0xc, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
movq 0xa0(%r14), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0xa0(%r14)
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x6, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
movq 0xa0(%r14), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0xa0(%r14)
movb %cl, (%rdx)
andb $0x3f, %al
orb $-0x80, %al
movq 0xa0(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0xa0(%r14)
movb %al, (%rcx)
incq 0xa8(%r14)
xorl %edi, %edi
jmp 0x51a9
movq 0xd8(%r14), %rax
addq $0x2, %rax
movl $0x2, (%r14)
leaq 0x13df5(%rip), %rcx     # 0x18ea6
movq %rcx, 0x8(%r14)
movq %rax, 0x10(%r14)
movl %esi, 0x18(%r14)
jmp 0x51a4
movl $0x4, %esi
xorl %edx, %edx
jmp 0x4e89
movl %eax, %edi
andl $-0x10, %edi
cmpl $0xe0, %edi
jne 0x50e0
andl $0xf, %eax
jmp 0x50f6
movl %eax, %edi
andl $-0x8, %edi
andl $0x7, %eax
cmpl $0xf0, %edi
movl $0x0, %edi
cmovnel %edi, %eax
cmpl $0x1, %esi
je 0x5138
cmpq $0x3, %r8
movl $0x2, %edi
cmovbq %rdi, %r8
movl $0x1, %edi
movzbl (%rcx,%rdi), %r9d
movl %r9d, %r10d
andl $-0x40, %r10d
cmpl $0x80, %r10d
jne 0x51b3
shll $0x6, %eax
andl $0x3f, %r9d
orl %r9d, %eax
incq %rdi
cmpq %rdi, %r8
jne 0x510d
cmpl $0x1, %esi
je 0x515f
cmpl $0x2, %esi
jne 0x5147
cmpl $0x7f, %eax
ja 0x515f
cmpl $0x3, %esi
jne 0x5153
cmpl $0x7ff, %eax            # imm = 0x7FF
ja 0x515f
cmpl $0x4, %esi
jne 0x51d6
cmpl $0xffff, %eax           # imm = 0xFFFF
jbe 0x51d6
movl %eax, %edi
andl $0xfffff800, %edi       # imm = 0xFFFFF800
cmpl $0xd800, %edi           # imm = 0xD800
setne %dil
cmpl $0x110000, %eax         # imm = 0x110000
setb %r8b
testb %dil, %r8b
jne 0x4e89
movq 0xd8(%r14), %rcx
movl $0x2, (%r14)
leaq 0x13cd6(%rip), %rdx     # 0x18e6e
movq %rdx, 0x8(%r14)
movq %rcx, 0x10(%r14)
movl %eax, 0x18(%r14)
movl $0x1, %edi
testl %edi, %edi
je 0x4d3a
jmp 0x51f0
addq 0xd8(%r14), %rdi
movl $0x2, (%r14)
leaq 0x13c66(%rip), %rax     # 0x18e2e
movq %rax, 0x8(%r14)
movq %rdi, 0x10(%r14)
movl %r9d, 0x18(%r14)
jmp 0x51a4
movq 0xd8(%r14), %rax
movl $0x2, (%r14)
leaq 0x13c60(%rip), %rcx     # 0x18e4b
jmp 0x4f21
cmpl $0x5, %edi
jne 0x525e
movb $0x1, %al
cmpl $0x0, 0x80(%r14)
je 0x4d09
movq 0xa0(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xa0(%r14)
movb $0x0, (%rax)
incq 0xa8(%r14)
jmp 0x5260
movl $0x1, %ebx
jmp 0x5260
movabsq $0x7ffffffffffffffe, %rax # imm = 0x7FFFFFFFFFFFFFFE
cmpq %rax, 0xd8(%r14)
jbe 0x5260
movl $0x2, (%r14)
leaq 0x13cbb(%rip), %rcx     # 0x18f06
movq %rcx, 0x8(%r14)
incq %rax
movq %rax, 0x10(%r14)
movl $0xffffffff, 0x18(%r14) # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x2, 0xd0(%r14)
jmp 0x52ac
movl $0x1, 0xd0(%r14)
addq $0x3, %rax
movq %rax, 0xc0(%r14)
addq $0x3, 0xd8(%r14)
jmp 0x4c01
movl $0x3, 0xd0(%r14)
addq $0x2, %rax
movq %rax, 0xc0(%r14)
addq $0x2, 0xd8(%r14)
jmp 0x4c01
leaq 0x12e1c(%rip), %rdi     # 0x180e7
leaq 0x13ae0(%rip), %rsi     # 0x18db2
leaq 0x13ae2(%rip), %rcx     # 0x18dbb
movl $0x92, %edx
callq 0x2100