// File: /workspace/github_c_makefile_star2_O3/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 0x61f0
movq %rax, %rbx
movq %r14, %rdi
callq 0x20d0
movq %r14, %rdi
movl %eax, %esi
callq 0x3744
leaq 0x2e14(%rip), %r14      # 0xa9f0
movq %rbx, -0x30(%rbp)
xorl %eax, %eax
callq 0x378d
cmpl $-0x2, %eax
je 0x7d56
movl %eax, %r15d
cmpl $-0x1, %eax
je 0x7d25
cmpl $0x7f, %r15d
jbe 0x7d14
cmpl $0x10000, %r15d         # imm = 0x10000
jl 0x7cb6
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 0x2d28(%rip), %rsi      # 0xa975
callq 0x66e7
shrl $0xc, %ebx
leaq 0x2d94(%rip), %rax      # 0xa9f0
movsbl (%rbx,%rax), %esi
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x691c
shrl $0x8, %r14d
andl $0xf, %r14d
leaq 0x2d75(%rip), %rax      # 0xa9f0
movsbl (%r14,%rax), %esi
leaq 0x2d69(%rip), %r14      # 0xa9f0
movq %rbx, %rdi
callq 0x691c
shrl $0xe, %r13d
andl $0xf, %r13d
movsbl (%r13,%r14), %esi
movq %rbx, %rdi
callq 0x691c
andl $0xf, %r12d
movsbl (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x691c
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x2cb0(%rip), %rsi      # 0xa975
callq 0x66e7
movl %r15d, %eax
shrl $0xc, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x691c
movl %r15d, %eax
shrl $0x8, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x691c
movl %r15d, %eax
shrl $0x4, %eax
andl $0xf, %eax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x691c
andl $0xf, %r15d
movb (%r15,%r14), %r15b
movsbl %r15b, %esi
movq %rbx, %rdi
callq 0x691c
jmp 0x7be0
movq %rbx, %rdi
callq 0x62f0
leaq 0x1(%rax), %rdi
callq 0x23a8
testq %rax, %rax
je 0x7d73
movq %rax, %r14
movq %rbx, %rdi
callq 0x62f0
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x6496
jmp 0x7d59
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x627d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2bfe(%rip), %rdi      # 0xa978
leaq 0x2bfb(%rip), %rsi      # 0xa97c
leaq 0x2c04(%rip), %rcx      # 0xa98c
movl $0xa0, %edx
callq 0x2150