// File: /workspace/github_c_makefile_star2_O2/lengjingzju[P]json/json.c
// Function: json_print_string
static int _json_print_string(json_print_t *print_ptr, json_string_t *jstr)
{
#define _JSON_PRINT_SEGMENT()     do {  \
    size = str - bak - 1;               \
    memcpy(print_ptr->cur, bak, size);  \
    print_ptr->cur += size;             \
    bak = str;                          \
} while(0)

    char ch = '\0';
    size_t len = 0, size = 0, alloced = 0;
    const char *str = NULL, *bak = NULL, *end = NULL;

    str = jstr->str;
    len = jstr->len;
    end = str + len;
    if (likely(!jstr->escaped)) {
        alloced = len + 3;
        _PRINT_PTR_REALLOC(alloced);
        *print_ptr->cur++ = '\"';
        memcpy(print_ptr->cur, str, len);
        print_ptr->cur += len;
        *print_ptr->cur++ = '\"';
        return 0;
    }

#if JSON_PRINT_UTF16_SUPPORT
    alloced = (len << 2) + (len << 1) + 3;
#else
    alloced = (len << 1) + 3;
#endif
    _PRINT_PTR_REALLOC(alloced);
    *print_ptr->cur++ = '\"';

    bak = str;
    while (str < end) {
        switch ((*str++)) {
        case '\"': ch = '\"'; break;
        case '\\': ch = '\\'; break;
        case '\b': ch = 'b' ; break;
        case '\f': ch = 'f' ; break;
        case '\n': ch = 'n' ; break;
        case '\r': ch = 'r' ; break;
        case '\t': ch = 't' ; break;
        case '\v': ch = 'v' ; break;
        default:
#if JSON_PRINT_UTF16_SUPPORT
            {
                unsigned char uc = (unsigned char)(*(str-1));
                if (uc < ' ') {
                    _JSON_PRINT_SEGMENT();
                    *print_ptr->cur++ = '\\';
                    *print_ptr->cur++ = 'u';
                    *print_ptr->cur++ = '0';
                    *print_ptr->cur++ = '0';
                    *print_ptr->cur++ = hex_array[uc >> 4 & 0xf];
                    *print_ptr->cur++ = hex_array[uc & 0xf];
                }
            }
#endif
            continue;
        }

        _JSON_PRINT_SEGMENT();
        *print_ptr->cur++ = '\\';
        *print_ptr->cur++ = ch;
    }

    ++str;
    _JSON_PRINT_SEGMENT();
    *print_ptr->cur++ = '\"';
    return 0;
err:
    JsonErr("malloc failed!\n");
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rsi), %r14
movl (%rsi), %eax
movl %eax, %r15d
shrl $0x8, %r15d
testb $0x10, %al
jne 0x3573
leaq 0x3(%r15), %rsi
movq 0x10(%rbx), %rax
movq 0x20(%rbx), %rcx
subq %rax, %rcx
addq 0x8(%rbx), %rcx
cmpq %rsi, %rcx
jae 0x3533
movq %rbx, %rdi
callq *0x18(%rbx)
testl %eax, %eax
js 0x3666
movq 0x10(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x10(%rbx)
movb $0x22, %bpl
movb %bpl, (%rax)
movq 0x10(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1140
movq 0x10(%rbx), %rax
addq %r15, %rax
incq %rax
movq %rax, 0x10(%rbx)
movb %bpl, -0x1(%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3(,%r15,2), %rsi
movq 0x10(%rbx), %rax
movq 0x20(%rbx), %rcx
subq %rax, %rcx
addq 0x8(%rbx), %rcx
cmpq %rsi, %rcx
jae 0x35a1
movq %rbx, %rdi
callq *0x18(%rbx)
testl %eax, %eax
js 0x3666
movq 0x10(%rbx), %rax
addq %r14, %r15
leaq 0x1(%rax), %rcx
movq %rcx, 0x10(%rbx)
movb $0x22, (%rax)
leaq 0x4e46(%rip), %r13      # 0x83fc
xorl %r12d, %r12d
leaq (%r14,%r12), %rax
cmpq %r15, %rax
jae 0x3640
movb (%rax), %bpl
incq %r12
movzbl %bpl, %eax
leal -0x8(%rax), %ecx
cmpl $0x5, %ecx
jbe 0x35e0
cmpl $0x22, %eax
je 0x3606
cmpl $0x5c, %eax
jne 0x35b9
jmp 0x3606
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movb $0x62, %bpl
jmp 0x3606
movb $0x66, %bpl
jmp 0x3606
movb $0x6e, %bpl
jmp 0x3606
movb $0x76, %bpl
jmp 0x3606
movb $0x74, %bpl
jmp 0x3606
movb $0x72, %bpl
leaq -0x1(%r12), %rdx
movq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x1140
movq 0x10(%rbx), %rax
leaq (%rax,%r12), %rcx
movq %rcx, 0x10(%rbx)
movb $0x5c, -0x1(%rax,%r12)
movq 0x10(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x10(%rbx)
movb %bpl, (%rax)
addq %r12, %r14
jmp 0x35b6
movq 0x10(%rbx), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1140
movq 0x10(%rbx), %rax
addq %r12, %rax
incq %rax
movq %rax, 0x10(%rbx)
movb $0x22, -0x1(%rax)
jmp 0x3562
leaq 0x4def(%rip), %rdi      # 0x845c
leaq 0x502c(%rip), %rsi      # 0x86a0
movl $0x62a, %edx            # imm = 0x62A
xorl %eax, %eax
callq 0x10c0
leaq 0x52d9(%rip), %rdi      # 0x8960
callq 0x1060
pushq $-0x1
popq %rax
jmp 0x3564