// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1ea45
jmp 0x1ea64
leaq 0xc7c9(%rip), %rdi      # 0x2b215
leaq 0xe1ef(%rip), %rsi      # 0x2cc42
movl $0x24, %edx
leaq 0xe1ec(%rip), %rcx      # 0x2cc4b
callq 0x2100
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1ea71
jmp 0x1ea90
leaq 0xc858(%rip), %rdi      # 0x2b2d0
leaq 0xe1c3(%rip), %rsi      # 0x2cc42
movl $0x25, %edx
leaq 0xe1c0(%rip), %rcx      # 0x2cc4b
callq 0x2100
movq -0x10(%rbp), %rax
cmpl $0x0, 0x78(%rax)
je 0x1ea9c
jmp 0x1eabb
leaq 0xc919(%rip), %rdi      # 0x2b3bc
leaq 0xe198(%rip), %rsi      # 0x2cc42
movl $0x26, %edx
leaq 0xe195(%rip), %rcx      # 0x2cc4b
callq 0x2100
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x1eaf9
movl $0x1, -0x4(%rbp)
jmp 0x1eea4
movq -0x10(%rbp), %rax
cmpl $0x1, 0x78(%rax)
jne 0x1eb79
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rdi
movq -0x10(%rbp), %rcx
movq 0x38(%rcx), %rsi
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdx
movq -0x10(%rbp), %rcx
movq 0x38(%rcx), %rcx
subq %rcx, %rdx
callq *%rax
cmpl $0x0, %eax
je 0x1eb61
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x1eea4
movq -0x10(%rbp), %rdi
leaq 0xe108(%rip), %rsi      # 0x2cc74
callq 0x1eeb0
movl %eax, -0x4(%rbp)
jmp 0x1eea4
movq -0x10(%rbp), %rax
movl 0x78(%rax), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x78(%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
je 0x1ee16
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movb (%rax), %al
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x1ebe2
movl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1ec3f
movzbl -0x19(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x1ebfc
movl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x1ec39
movzbl -0x19(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x1ec16
movl $0x3, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1ec33
movzbl -0x19(%rbp), %edx
andl $0xf8, %edx
xorl %eax, %eax
movl $0x4, %ecx
cmpl $0xf0, %edx
cmovel %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x20(%rbp)
movzbl -0x19(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x1ec5f
movzbl -0x19(%rbp), %eax
andl $0x7f, %eax
movl %eax, -0x40(%rbp)
jmp 0x1eccc
movzbl -0x19(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x1ec7b
movzbl -0x19(%rbp), %eax
andl $0x1f, %eax
movl %eax, -0x44(%rbp)
jmp 0x1ecc6
movzbl -0x19(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x1ec97
movzbl -0x19(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x48(%rbp)
jmp 0x1ecc0
movzbl -0x19(%rbp), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0x1ecb3
movzbl -0x19(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1ecba
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1ecba
movl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x24(%rbp)
movq $0x1, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
cmpq %rcx, %rax
jae 0x1ed18
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x19(%rbp)
movl -0x24(%rbp), %eax
shll $0x6, %eax
movzbl -0x19(%rbp), %ecx
andl $0x3f, %ecx
addl %ecx, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1ecda
movl -0x20(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movl %edx, %edx
addq %rdx, %rcx
movq %rcx, 0x48(%rax)
cmpl $0x10000, -0x24(%rbp)   # imm = 0x10000
jae 0x1ed7a
movl -0x24(%rbp), %eax
shrl $0x8, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movslq -0x14(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x70(%rax)
jmp 0x1ee11
movl -0x24(%rbp), %eax
subl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
shrl $0x12, %eax
addl $0xd8, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
shrl $0xa, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movslq -0x14(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
addl $0xdc, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x18(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
addq $0x4, %rcx
movq %rcx, 0x70(%rax)
jmp 0x1eba7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rdi
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rsi
movq -0x10(%rbp), %rcx
movq 0x70(%rcx), %rdx
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
subq %rcx, %rdx
callq *%rax
cmpl $0x0, %eax
je 0x1ee91
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x68(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x1eea4
movq -0x10(%rbp), %rdi
leaq 0xddd8(%rip), %rsi      # 0x2cc74
callq 0x1eeb0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)