// File: /workspace/github_c_makefile_star2_O0/xapi-project[P]rrd-client-lib/parson/parson.c
// Function: parse_utf16
static int parse_utf16(const char **unprocessed, char **processed) {
    unsigned int cp, lead, trail;
    int parse_succeeded = 0;
    char *processed_ptr = *processed;
    const char *unprocessed_ptr = *unprocessed;
    unprocessed_ptr++; /* skips u */
    parse_succeeded = parse_utf16_hex(unprocessed_ptr, &cp);
    if (!parse_succeeded) {
        return JSONFailure;
    }
    if (cp < 0x80) {
        *processed_ptr = (char)cp; /* 0xxxxxxx */
    } else if (cp < 0x800) {
        *processed_ptr++ = ((cp >> 6) & 0x1F) | 0xC0; /* 110xxxxx */
        *processed_ptr   = ((cp     ) & 0x3F) | 0x80; /* 10xxxxxx */
    } else if (cp < 0xD800 || cp > 0xDFFF) {
        *processed_ptr++ = ((cp >> 12) & 0x0F) | 0xE0; /* 1110xxxx */
        *processed_ptr++ = ((cp >> 6)  & 0x3F) | 0x80; /* 10xxxxxx */
        *processed_ptr   = ((cp     )  & 0x3F) | 0x80; /* 10xxxxxx */
    } else if (cp >= 0xD800 && cp <= 0xDBFF) { /* lead surrogate (0xD800..0xDBFF) */
        lead = cp;
        unprocessed_ptr += 4; /* should always be within the buffer, otherwise previous sscanf would fail */
        if (*unprocessed_ptr++ != '\\' || *unprocessed_ptr++ != 'u') {
            return JSONFailure;
        }
        parse_succeeded = parse_utf16_hex(unprocessed_ptr, &trail);
        if (!parse_succeeded || trail < 0xDC00 || trail > 0xDFFF) { /* valid trail surrogate? (0xDC00..0xDFFF) */
            return JSONFailure;
        }
        cp = ((((lead-0xD800)&0x3FF)<<10)|((trail-0xDC00)&0x3FF))+0x010000;
        *processed_ptr++ = (((cp >> 18) & 0x07) | 0xF0); /* 11110xxx */
        *processed_ptr++ = (((cp >> 12) & 0x3F) | 0x80); /* 10xxxxxx */
        *processed_ptr++ = (((cp >> 6)  & 0x3F) | 0x80); /* 10xxxxxx */
        *processed_ptr   = (((cp     )  & 0x3F) | 0x80); /* 10xxxxxx */
    } else { /* trail surrogate before lead surrogate */
        return JSONFailure;
    }
    unprocessed_ptr += 3;
    *processed = processed_ptr;
    *unprocessed = unprocessed_ptr;
    return JSONSuccess;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x72e0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x709b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x72d5
cmpl $0x80, -0x1c(%rbp)
jae 0x70b4
movl -0x1c(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
jmp 0x72ac
cmpl $0x800, -0x1c(%rbp)     # imm = 0x800
jae 0x70f6
movl -0x1c(%rbp), %eax
shrl $0x6, %eax
andl $0x1f, %eax
orl $0xc0, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
jmp 0x72aa
cmpl $0xd800, -0x1c(%rbp)    # imm = 0xD800
jb 0x7108
cmpl $0xdfff, -0x1c(%rbp)    # imm = 0xDFFF
jbe 0x7162
movl -0x1c(%rbp), %eax
shrl $0xc, %eax
andl $0xf, %eax
orl $0xe0, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
jmp 0x72a8
cmpl $0xd800, -0x1c(%rbp)    # imm = 0xD800
jb 0x729d
cmpl $0xdbff, -0x1c(%rbp)    # imm = 0xDBFF
ja 0x729d
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x71bc
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movsbl (%rax), %eax
cmpl $0x75, %eax
je 0x71c8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x72d5
movq -0x38(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x72e0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x71f0
cmpl $0xdc00, -0x24(%rbp)    # imm = 0xDC00
jb 0x71f0
cmpl $0xdfff, -0x24(%rbp)    # imm = 0xDFFF
jbe 0x71fc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x72d5
movl -0x20(%rbp), %eax
subl $0xd800, %eax           # imm = 0xD800
andl $0x3ff, %eax            # imm = 0x3FF
shll $0xa, %eax
movl -0x24(%rbp), %ecx
subl $0xdc00, %ecx           # imm = 0xDC00
andl $0x3ff, %ecx            # imm = 0x3FF
orl %ecx, %eax
addl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x12, %eax
andl $0x7, %eax
orl $0xf0, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
shrl $0xc, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
jmp 0x72a6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x72d5
jmp 0x72a8
jmp 0x72aa
jmp 0x72ac
movq -0x38(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop