// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20e0
movq %rax, %rdi
shlq %rdi
movl $0x8, %esi
callq 0x8140
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20e0
movq -0x30(%rbp), %rdi
movl %eax, %esi
callq 0x3740
movb $0x0, %al
callq 0x37c0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
je 0xad96
cmpl $-0x2, -0x1c(%rbp)
jne 0xabf5
movq -0x18(%rbp), %rdi
callq 0x8270
movq $0x0, -0x8(%rbp)
jmp 0xae09
cmpl $0x0, -0x1c(%rbp)
jl 0xac15
cmpl $0x7f, -0x1c(%rbp)
jg 0xac15
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movsbl %al, %esi
callq 0x8f00
jmp 0xad87
cmpl $0x10000, -0x1c(%rbp)   # imm = 0x10000
jl 0xacef
movl -0x1c(%rbp), %eax
subl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x3ff, %eax            # imm = 0x3FF
orl $0xdc00, %eax           # imm = 0xDC00
movzwl %ax, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
sarl $0xa, %eax
orl $0xd800, %eax           # imm = 0xD800
movzwl %ax, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x5145(%rip), %rsi      # 0xfda1
movl $0x2, %edx
callq 0x8aa0
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
sarl $0xc, %eax
movslq %eax, %rcx
leaq 0x5111(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf00, %eax            # imm = 0xF00
sarl $0x8, %eax
movslq %eax, %rcx
leaq 0x50ef(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf0, %eax
sarl $0x4, %eax
movslq %eax, %rcx
leaq 0x50cd(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x50b0(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x50a7(%rip), %rsi      # 0xfda1
movl $0x2, %edx
callq 0x8aa0
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
sarl $0xc, %eax
movslq %eax, %rcx
leaq 0x5073(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf00, %eax            # imm = 0xF00
sarl $0x8, %eax
movslq %eax, %rcx
leaq 0x5051(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf0, %eax
sarl $0x4, %eax
movslq %eax, %rcx
leaq 0x502f(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x5012(%rip), %rax      # 0xfd90
movsbl (%rax,%rcx), %esi
callq 0x8f00
movb $0x0, %al
callq 0x37c0
movl %eax, -0x1c(%rbp)
jmp 0xabcf
movq -0x18(%rbp), %rdi
callq 0x8330
movq %rax, %rdi
addq $0x1, %rdi
callq 0x23f8
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xadb8
jmp 0xadd7
leaq 0x4fe5(%rip), %rdi      # 0xfda4
leaq 0x4fe2(%rip), %rsi      # 0xfda8
movl $0xa0, %edx
leaq 0x4fe6(%rip), %rcx      # 0xfdb8
callq 0x2170
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8330
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movq -0x28(%rbp), %rdx
callq 0x8670
movq -0x18(%rbp), %rdi
callq 0x8270
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)