// File: /workspace/github_cpp_makefile_star2_O3/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), %ecx
cmpl %esi, %ecx
jle 0xd515
movq (%rbx), %r15
xorl %edx, %edx
leaq 0xa75a(%rip), %r8       # 0x17b2c
movl %r12d, %eax
movslq %eax, %rsi
movb (%r15,%rsi), %r13b
testb $0x1, %dl
je 0xd3fe
movzbl %r13b, %edx
leal -0x6e(%rdx), %edi
cmpl $0x7, %edi
ja 0xd40f
movslq (%r8,%rdi,4), %rdx
addq %r8, %rdx
jmpq *%rdx
movb $0xa, %r13b
jmp 0xd4fc
movb $0x1, %dl
cmpb $0x5c, %r13b
jne 0xd4fc
jmp 0xd50b
cmpl $0x66, %edx
je 0xd4a5
cmpl $0x62, %edx
jne 0xd4fc
movb $0x8, %r13b
jmp 0xd4fc
leal 0x4(%rax), %edx
movb $0x75, %r13b
cmpl %ecx, %edx
jge 0xd4fc
movl %edx, -0x2c(%rbp)
addq %r15, %rsi
incq %rsi
movq %rsi, -0x40(%rbp)
movl $0x4, -0x38(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xdc0a
movq %rax, %r13
movq 0x10b72(%rip), %rdi     # 0x1dfd0
movq %rax, %rsi
callq 0x82d0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x82f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x81f0
cmpq $0x7f, %r13
jg 0xd4aa
movl -0x2c(%rbp), %eax
jmp 0xd4f5
movb $0xd, %r13b
jmp 0xd4fc
movb $0x9, %r13b
jmp 0xd4fc
movb $0xc, %r13b
jmp 0xd4fc
movslq %r12d, %rax
cmpq $0x7ff, %r13            # imm = 0x7FF
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
ja 0xd4cc
shrl $0x6, %ecx
orb $-0x40, %cl
leal 0x1(%rax), %r12d
movb %cl, (%r15,%rax)
jmp 0xd4eb
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
movl %edx, %eax
leaq 0xa630(%rip), %r8       # 0x17b2c
movslq %r12d, %rcx
incl %r12d
movb %r13b, (%r15,%rcx)
movl 0x8(%rbx), %ecx
xorl %edx, %edx
incl %eax
cmpl %ecx, %eax
jl 0xd3d5
movq %rbx, %rdi
xorl %esi, %esi
callq 0xc596
movl %r12d, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq