// File: /workspace/github_c_makefile_star2_O1/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
movl $0x8, %esi
callq 0x6328
movq %rax, %rbx
movq %r14, %rdi
callq 0x20d0
movq %r14, %rdi
movl %eax, %esi
callq 0x3770
leaq 0x2ccc(%rip), %r14      # 0xa9f0
movq %rbx, -0x30(%rbp)
xorl %eax, %eax
callq 0x37b9
cmpl $-0x2, %eax
je 0x7e9e
movl %eax, %r15d
cmpl $-0x1, %eax
je 0x7e6d
cmpl $0x7f, %r15d
jbe 0x7e5c
cmpl $0x10000, %r15d         # imm = 0x10000
jl 0x7dfe
leal 0xff0000(%r15), %r13d
andl $0x3ff, %r15d           # imm = 0x3FF
orl $0xdc00, %r15d          # imm = 0xDC00
movl %r13d, %r12d
shrl $0xa, %r12d
movl %r12d, %r14d
orl $0xd800, %r14d          # imm = 0xD800
movzwl %r14w, %ebx
movl $0x2, %edx
movq -0x30(%rbp), %rdi
leaq 0x2be0(%rip), %rsi      # 0xa975
callq 0x6829
shrl $0xc, %ebx
leaq 0x2c4c(%rip), %rax      # 0xa9f0
movsbl (%rbx,%rax), %esi
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x6a5e
shrl $0x8, %r14d
andl $0xf, %r14d
leaq 0x2c2d(%rip), %rax      # 0xa9f0
movsbl (%r14,%rax), %esi
leaq 0x2c21(%rip), %r14      # 0xa9f0
movq %rbx, %rdi
callq 0x6a5e
shrl $0xe, %r13d
andl $0xf, %r13d
movsbl (%r13,%r14), %esi
movq %rbx, %rdi
callq 0x6a5e
andl $0xf, %r12d
movsbl (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x6a5e
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x2b68(%rip), %rsi      # 0xa975
callq 0x6829
movl %r15d, %eax
shrl $0xc, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x6a5e
movl %r15d, %eax
shrl $0x8, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x6a5e
movl %r15d, %eax
shrl $0x4, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x6a5e
andl $0xf, %r15d
movb (%r15,%r14), %r15b
movsbl %r15b, %esi
movq %rbx, %rdi
callq 0x6a5e
jmp 0x7d28
movq %rbx, %rdi
callq 0x642f
leaq 0x1(%rax), %rdi
callq 0x23a8
testq %rax, %rax
je 0x7ebb
movq %rax, %r14
movq %rbx, %rdi
callq 0x642f
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x65d5
jmp 0x7ea1
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x63bc
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2ab6(%rip), %rdi      # 0xa978
leaq 0x2ab3(%rip), %rsi      # 0xa97c
leaq 0x2abc(%rip), %rcx      # 0xa98c
movl $0xa0, %edx
callq 0x2150