// File: /workspace/github_c_makefile_star2_O2/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: utf82ascii
char *utf82ascii(char *s)
{
    struct buffer *buf = buf_create(strlen(s) * 2);

    utf8_decode_init(s, strlen(s));
    int c = utf8_decode_next();
    while (c != UTF8_END)
    {
        if (c == UTF8_ERROR)
        {
            buf_release(buf);
            return NULL;
        }

        if (c >= 0 && c <= 127)
        {
            buf_appendInt8(buf, c);
        }
        else
        {
            /* From http://en.wikipedia.org/wiki/UTF16 */
            if (c >= 0x10000)
            {
                unsigned int next_c;
                c -= 0x10000;
                next_c = (unsigned short)((c & 0x3ff) | 0xdc00);
                c = (unsigned short)((c >> 10) | 0xd800);

                buf_append(buf, "\\u", 2);
                buf_appendInt8(buf, digits[(c & 0xf000) >> 12]);
                buf_appendInt8(buf, digits[(c & 0xf00) >> 8]);
                buf_appendInt8(buf, digits[(c & 0xf0) >> 4]);
                buf_appendInt8(buf, digits[(c & 0xf)]);
                c = next_c;
            }

            buf_append(buf, "\\u", 2);
            buf_appendInt8(buf, digits[(c & 0xf000) >> 12]);
            buf_appendInt8(buf, digits[(c & 0xf00) >> 8]);
            buf_appendInt8(buf, digits[(c & 0xf0) >> 4]);
            buf_appendInt8(buf, digits[(c & 0xf)]);
        }
        c = utf8_decode_next();
    }

    char *ret = malloc(buf_readable(buf) + 1);
    assert(ret);
    buf_retrieveAsString(buf, buf_readable(buf), ret);
    buf_release(buf);
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x20d0
leaq (%rax,%rax), %rdi
pushq $0x8
popq %rsi
callq 0x5164
movq %rax, %rbx
movq %r14, %rdi
callq 0x20d0
movq %r14, %rdi
movl %eax, %esi
callq 0x2dd0
leaq 0x316e(%rip), %r14      # 0x9b40
movq %rbx, -0x30(%rbp)
xorl %eax, %eax
callq 0x2e1a
cmpl $-0x2, %eax
je 0x6b50
movl %eax, %r12d
cmpl $-0x1, %eax
je 0x6b1f
cmpl $0x7f, %r12d
jbe 0x6b0e
cmpl $0x10000, %r12d         # imm = 0x10000
jl 0x6ab2
leal 0xff0000(%r12), %r14d
andl $0x3ff, %r12d           # imm = 0x3FF
orl $0xdc00, %r12d          # imm = 0xDC00
movl %r14d, %r13d
shrl $0xa, %r13d
movl %r13d, %r15d
orl $0xd800, %r15d          # imm = 0xD800
movzwl %r15w, %ebx
movq -0x30(%rbp), %rdi
leaq 0x3085(%rip), %rsi      # 0x9ac4
pushq $0x2
popq %rdx
callq 0x565b
shrl $0xc, %ebx
leaq 0x30ef(%rip), %rax      # 0x9b40
movsbl (%rbx,%rax), %esi
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x585c
shrl $0x8, %r15d
andl $0xf, %r15d
leaq 0x30d0(%rip), %rax      # 0x9b40
movsbl (%r15,%rax), %esi
movq %rbx, %rdi
callq 0x585c
shrl $0xe, %r14d
andl $0xf, %r14d
leaq 0x30b4(%rip), %rax      # 0x9b40
movsbl (%r14,%rax), %esi
leaq 0x30a8(%rip), %r14      # 0x9b40
movq %rbx, %rdi
callq 0x585c
andl $0xf, %r13d
movsbl (%r13,%r14), %esi
movq %rbx, %rdi
callq 0x585c
movq %rbx, %rdi
leaq 0x3008(%rip), %rsi      # 0x9ac4
pushq $0x2
popq %rdx
callq 0x565b
movl %r12d, %eax
shrl $0xc, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x585c
movl %r12d, %eax
shrl $0x8, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x585c
movl %r12d, %eax
shrl $0x4, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x585c
andl $0xf, %r12d
movb (%r12,%r14), %r12b
movsbl %r12b, %esi
movq %rbx, %rdi
callq 0x585c
jmp 0x69d6
movq %rbx, %rdi
callq 0x5255
leaq 0x1(%rax), %rdi
callq 0x23a8
testq %rax, %rax
je 0x6b6d
movq %rax, %r14
movq %rbx, %rdi
callq 0x5255
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x53f6
jmp 0x6b53
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x51e9
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f53(%rip), %rdi      # 0x9ac7
leaq 0x2f50(%rip), %rsi      # 0x9acb
leaq 0x2f59(%rip), %rcx      # 0x9adb
movl $0xa0, %edx
callq 0x2150