// File: /workspace/github_cpp_makefile_star2_O2/lega911[P]ijson/src/json.cpp
// Function: json::unescape(Buffer&, int)
void json::unescape(Buffer &s, int start) {
    char *p = s.ptr();
    int n = start;
    bool prefix = false;
    for(int i=start;i<s.size();i++) {
        char a = p[i];
        if(prefix) {
            switch(a) {
            case 'b':
                a = 8;
                break;
            case 't':
                a = 9;
                break;
            case 'n':
                a = '\n';
                break;
            case 'f':
                a = '\f';
                break;
            case 'r':
                a  ='\r';
                break;
            case 'u':
                if(i + 4 < s.size()) {
                    Slice hex(&p[i + 1], 4);
                    i += 4;
                    auto code = hex.hextoi();
                    std::cout << code << std::endl;
                    if(code <= 0x7f) a = code;
                    else if(code <= 0x7ff) {
                        p[n++] = 0xc0 | (code >> 6);
                        a = 0x80 | (code & 0x3f);
                    } else {
                        p[n++] = 0xe0 | (code >> 12);
                        p[n++] = 0x80 | ((code >> 6) & 0x3f);
                        a = 0x80 | (code & 0x3f);
                    }
                }

                break;
            // case '"':
            // case '/':
            // case '\\':
            };
            prefix = false;
        } else if(a == '\\') {
            prefix = true;
            continue;
        }
        p[n++] = a;
    }
    s.resize(0, n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq (%rdi), %r13
xorl %eax, %eax
leaq 0xa578(%rip), %r8       # 0x18b30
movl %esi, %r14d
movl 0x8(%rbx), %edx
cmpl %edx, %esi
jge 0xe6d8
movslq %esi, %rcx
movb (%r13,%rcx), %r12b
testb $0x1, %al
je 0xe5ef
movzbl %r12b, %eax
leal -0x6e(%rax), %edi
cmpl $0x7, %edi
ja 0xe600
movslq (%r8,%rdi,4), %rax
addq %r8, %rax
jmpq *%rax
movb $0xa, %r12b
jmp 0xe6c4
movb $0x1, %al
cmpb $0x5c, %r12b
jne 0xe6c4
jmp 0xe6d1
cmpl $0x66, %eax
je 0xe68d
cmpl $0x62, %eax
jne 0xe6c4
movb $0x8, %r12b
jmp 0xe6c4
leal 0x4(%rsi), %r15d
movb $0x75, %r12b
cmpl %edx, %r15d
jge 0xe6c4
addq %r13, %rcx
incq %rcx
movq %rcx, -0x38(%rbp)
movl $0x4, -0x30(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xebbe
movq %rax, %r12
movq 0x11982(%rip), %rdi     # 0x1ffd0
movq %rax, %rsi
callq 0xa2c0
movq %rax, %rdi
callq 0xa160
cmpq $0x7f, %r12
jle 0xe6ba
movslq %r14d, %rax
movl %r12d, %ecx
cmpq $0x7ff, %r12            # imm = 0x7FF
ja 0xe692
shrl $0x6, %ecx
orb $-0x40, %cl
incl %r14d
movb %cl, (%r13,%rax)
jmp 0xe6b2
movb $0xd, %r12b
jmp 0xe6c4
movb $0x9, %r12b
jmp 0xe6c4
movb $0xc, %r12b
jmp 0xe6c4
shrl $0xc, %ecx
orb $-0x20, %cl
movb %cl, (%r13,%rax)
movl %r12d, %ecx
shrl $0x6, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
addl $0x2, %r14d
movb %cl, 0x1(%r13,%rax)
andb $0x3f, %r12b
orb $-0x80, %r12b
movl %r15d, %esi
leaq 0xa46c(%rip), %r8       # 0x18b30
movslq %r14d, %rax
incl %r14d
movb %r12b, (%r13,%rax)
xorl %eax, %eax
incl %esi
jmp 0xe5bb
movq %rbx, %rdi
xorl %esi, %esi
callq 0xd7a2
movl %r14d, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq