// File: /workspace/github_cpp_makefile_star2_O1/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
movl %esi, %r12d
movq %rdi, %rbx
movl 0x8(%rdi), %edx
cmpl %esi, %edx
jle 0xd552
movq (%rbx), %r15
xorl %eax, %eax
leaq 0xa726(%rip), %r9       # 0x17b2c
movl %r12d, %ecx
movslq %ecx, %rsi
movb (%r15,%rsi), %r13b
testb $0x1, %al
je 0xd435
movzbl %r13b, %edi
xorl %eax, %eax
leal -0x6e(%rdi), %r8d
cmpl $0x7, %r8d
ja 0xd44a
movslq (%r9,%r8,4), %rdi
addq %r9, %rdi
jmpq *%rdi
movb $0xa, %r13b
jmp 0xd4fb
movb $0x1, %sil
movl %ecx, %r14d
cmpb $0x5c, %r13b
jne 0xd500
jmp 0xd50f
cmpl $0x66, %edi
je 0xd4f8
cmpl $0x62, %edi
jne 0xd4fd
movb $0x8, %r13b
jmp 0xd4fb
leal 0x4(%rcx), %r14d
cmpl %edx, %r14d
jge 0xd4fb
addq %r15, %rsi
incq %rsi
movq %rsi, -0x40(%rbp)
movl $0x4, -0x38(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xdc68
movq %rax, %r13
movq 0x10b3b(%rip), %rdi     # 0x1dfd0
movq %rax, %rsi
callq 0x82d0
movq %rax, -0x30(%rbp)
movq (%rax), %rcx
movq -0x18(%rcx), %rdi
addq %rax, %rdi
movl $0xa, %esi
callq 0x82f0
movsbl %al, %esi
movq -0x30(%rbp), %rdi
callq 0x8040
movq %rax, %rdi
callq 0x81f0
cmpq $0x7f, %r13
jle 0xd547
movslq %r12d, %rax
movl %r13d, %ecx
cmpq $0x7ff, %r13            # imm = 0x7FF
jg 0xd520
shrl $0x6, %ecx
orb $-0x40, %cl
leal 0x1(%rax), %r12d
movb %cl, (%r15,%rax)
jmp 0xd53f
movb $0xd, %r13b
jmp 0xd4fb
movb $0x9, %r13b
jmp 0xd4fb
movb $0xc, %r13b
xorl %eax, %eax
movl %ecx, %r14d
movslq %r12d, %rcx
incl %r12d
movb %r13b, (%r15,%rcx)
movl %eax, %esi
movl %r14d, %ecx
incl %ecx
movl 0x8(%rbx), %edx
movl %esi, %eax
cmpl %edx, %ecx
jl 0xd409
jmp 0xd552
shrl $0xc, %ecx
orb $-0x20, %cl
movb %cl, (%r15,%rax)
movl %r13d, %ecx
shrl $0x6, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
leal 0x2(%rax), %r12d
movb %cl, 0x1(%r15,%rax)
andb $0x3f, %r13b
orb $-0x80, %r13b
leaq 0xa5de(%rip), %r9       # 0x17b2c
xorl %eax, %eax
jmp 0xd500
movq %rbx, %rdi
xorl %esi, %esi
callq 0xc5a2
movl %r12d, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq