// File: /workspace/github_c_makefile_star2_O1/mijallen[P]SimpleHTTPServer/lib/libyaml/src/writer.c
// Function: yaml_emitter_flush
YAML_DECLARE(int)
yaml_emitter_flush(yaml_emitter_t *emitter)
{
    int low, high;

    assert(emitter);    /* Non-NULL emitter object is expected. */
    assert(emitter->write_handler); /* Write handler must be set. */
    assert(emitter->encoding);  /* Output encoding must be set. */

    emitter->buffer.last = emitter->buffer.pointer;
    emitter->buffer.pointer = emitter->buffer.start;

    /* Check if the buffer is empty. */

    if (emitter->buffer.start == emitter->buffer.last) {
        return 1;
    }

    /* If the output encoding is UTF-8, we don't need to recode the buffer. */

    if (emitter->encoding == YAML_UTF8_ENCODING)
    {
        if (emitter->write_handler(emitter->write_handler_data,
                    emitter->buffer.start,
                    emitter->buffer.last - emitter->buffer.start)) {
            emitter->buffer.last = emitter->buffer.start;
            emitter->buffer.pointer = emitter->buffer.start;
            return 1;
        }
        else {
            return yaml_emitter_set_writer_error(emitter, "write error");
        }
    }

    /* Recode the buffer into the raw buffer. */

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

    while (emitter->buffer.pointer != emitter->buffer.last)
    {
        unsigned char octet;
        unsigned int width;
        unsigned int value;
        size_t k;

        /* 
         * See the "reader.c" code for more details on UTF-8 encoding.  Note
         * that we assume that the buffer contains a valid UTF-8 sequence.
         */

        /* Read the next UTF-8 character. */

        octet = emitter->buffer.pointer[0];

        width = (octet & 0x80) == 0x00 ? 1 :
                (octet & 0xE0) == 0xC0 ? 2 :
                (octet & 0xF0) == 0xE0 ? 3 :
                (octet & 0xF8) == 0xF0 ? 4 : 0;

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

        for (k = 1; k < width; k ++) {
            octet = emitter->buffer.pointer[k];
            value = (value << 6) + (octet & 0x3F);
        }

        emitter->buffer.pointer += width;

        /* Write the character. */

        if (value < 0x10000)
        {
            emitter->raw_buffer.last[high] = value >> 8;
            emitter->raw_buffer.last[low] = value & 0xFF;

            emitter->raw_buffer.last += 2;
        }
        else
        {
            /* Write the character using a surrogate pair (check "reader.c"). */

            value -= 0x10000;
            emitter->raw_buffer.last[high] = 0xD8 + (value >> 18);
            emitter->raw_buffer.last[low] = (value >> 10) & 0xFF;
            emitter->raw_buffer.last[high+2] = 0xDC + ((value >> 8) & 0xFF);
            emitter->raw_buffer.last[low+2] = value & 0xFF;

            emitter->raw_buffer.last += 4;
        }
    }

    /* Write the raw buffer. */

    if (emitter->write_handler(emitter->write_handler_data,
                emitter->raw_buffer.start,
                emitter->raw_buffer.last - emitter->raw_buffer.start)) {
        emitter->buffer.last = emitter->buffer.start;
        emitter->buffer.pointer = emitter->buffer.start;
        emitter->raw_buffer.last = emitter->raw_buffer.start;
        emitter->raw_buffer.pointer = emitter->raw_buffer.start;
        return 1;
    }
    else {
        return yaml_emitter_set_writer_error(emitter, "write error");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x119df
movq %rdi, %rbx
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x119fe
movl 0x78(%rbx), %edi
testl %edi, %edi
je 0x11a1d
movq 0x38(%rbx), %rsi
movq 0x48(%rbx), %rdx
movq %rdx, 0x50(%rbx)
movq %rsi, 0x48(%rbx)
movl $0x1, %ebp
cmpq %rdx, %rsi
je 0x119d2
cmpl $0x1, %edi
jne 0x11824
movq 0x18(%rbx), %rdi
subq %rsi, %rdx
callq *%rax
testl %eax, %eax
je 0x119bf
movq 0x38(%rbx), %rax
movq %rax, 0x50(%rbx)
movq %rax, 0x48(%rbx)
jmp 0x119d2
movq 0x48(%rbx), %r9
cmpq 0x50(%rbx), %r9
je 0x1198f
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $0x2, %edi
setne %al
sete %cl
movq %rax, %rdx
xorq $0x3, %rdx
leaq 0x2(%rax), %rsi
xorl %edi, %edi
movzbl (%r9), %r8d
movl $0x1, %r10d
testb %r8b, %r8b
jns 0x118a0
movl %r8d, %r11d
andl $-0x20, %r11d
movl $0x2, %r10d
cmpl $0xc0, %r11d
je 0x118a0
movl %r8d, %r11d
andl $-0x10, %r11d
movl $0x3, %r10d
cmpl $0xe0, %r11d
je 0x118a0
movl %r8d, %r11d
andl $-0x8, %r11d
xorl %r10d, %r10d
cmpl $0xf0, %r11d
sete %r10b
shll $0x2, %r10d
testb %r8b, %r8b
jns 0x118e7
movl %r8d, %r11d
andl $-0x20, %r11d
cmpl $0xc0, %r11d
jne 0x118bb
andl $0x1f, %r8d
jmp 0x118e7
movl %r8d, %r11d
andl $-0x10, %r11d
cmpl $0xe0, %r11d
jne 0x118d1
andl $0xf, %r8d
jmp 0x118e7
movl %r8d, %r11d
andl $-0x8, %r11d
andl $0x7, %r8d
cmpl $0xf0, %r11d
cmovnel %edi, %r8d
cmpl $0x2, %r10d
jb 0x1190b
movl $0x1, %r11d
movzbl (%r9,%r11), %r14d
shll $0x6, %r8d
andl $0x3f, %r14d
orl %r14d, %r8d
incq %r11
cmpq %r11, %r10
jne 0x118f3
addq %r10, %r9
movq %r9, 0x48(%rbx)
cmpl $0xffff, %r8d           # imm = 0xFFFF
ja 0x11930
movl %r8d, %r9d
shrl $0x8, %r9d
movl $0x2, %r10d
movq %rcx, %r11
movq %rax, %r14
jmp 0x1196d
leal -0x10000(%r8), %r9d
movl %r9d, %r10d
shrl $0x12, %r10d
addb $-0x28, %r10b
movq 0x70(%rbx), %r11
movb %r10b, (%r11,%rcx)
shrl $0xa, %r9d
movq 0x70(%rbx), %r10
movb %r9b, (%r10,%rax)
movl %r8d, %r9d
shrl $0x8, %r9d
addb $-0x24, %r9b
movl $0x4, %r10d
movq %rdx, %r11
movq %rsi, %r14
movq 0x70(%rbx), %r15
movb %r9b, (%r15,%r11)
movq 0x70(%rbx), %r9
movb %r8b, (%r9,%r14)
addq %r10, 0x70(%rbx)
movq 0x48(%rbx), %r9
cmpq 0x50(%rbx), %r9
jne 0x1184c
movq 0x18(%rbx), %rdi
movq 0x58(%rbx), %rsi
movq 0x70(%rbx), %rdx
subq %rsi, %rdx
callq *0x10(%rbx)
testl %eax, %eax
je 0x119bf
movq 0x38(%rbx), %rax
movq 0x58(%rbx), %rcx
movq %rax, 0x50(%rbx)
movq %rax, 0x48(%rbx)
movq %rcx, 0x70(%rbx)
movq %rcx, 0x68(%rbx)
jmp 0x119d2
movl $0x6, (%rbx)
leaq 0x821c(%rip), %rax      # 0x19be8
movq %rax, 0x8(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x67f7(%rip), %rdi      # 0x181dd
leaq 0x81c9(%rip), %rsi      # 0x19bb6
leaq 0x81cb(%rip), %rcx      # 0x19bbf
movl $0x24, %edx
callq 0x2100
leaq 0x6893(%rip), %rdi      # 0x18298
leaq 0x81aa(%rip), %rsi      # 0x19bb6
leaq 0x81ac(%rip), %rcx      # 0x19bbf
movl $0x25, %edx
callq 0x2100
leaq 0x6960(%rip), %rdi      # 0x18384
leaq 0x818b(%rip), %rsi      # 0x19bb6
leaq 0x818d(%rip), %rcx      # 0x19bbf
movl $0x26, %edx
callq 0x2100