// File: /workspace/github_c_makefile_star2_O3/xapi-project[P]rrd-client-lib/parson/parson.c
// Function: json_serialize_to_buffer_r
static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int level, int is_pretty, char *num_buf)
{
    const char *key = NULL, *string = NULL;
    JSON_Value *temp_value = NULL;
    JSON_Array *array = NULL;
    JSON_Object *object = NULL;
    size_t i = 0, count = 0;
    double num = 0.0;
    int written = -1, written_total = 0;

    switch (json_value_get_type(value)) {
        case JSONArray:
            array = json_value_get_array(value);
            count = json_array_get_count(array);
            APPEND_STRING("[");
            if (count > 0 && is_pretty) {
                APPEND_STRING("\n");
            }
            for (i = 0; i < count; i++) {
                if (is_pretty) {
                    APPEND_INDENT(level+1);
                }
                temp_value = json_array_get_value(array, i);
                written = json_serialize_to_buffer_r(temp_value, buf, level+1, is_pretty, num_buf);
                if (written < 0) {
                    return -1;
                }
                if (buf != NULL) {
                    buf += written;
                }
                written_total += written;
                if (i < (count - 1)) {
                    APPEND_STRING(",");
                }
                if (is_pretty) {
                    APPEND_STRING("\n");
                }
            }
            if (count > 0 && is_pretty) {
                APPEND_INDENT(level);
            }
            APPEND_STRING("]");
            return written_total;
        case JSONObject:
            object = json_value_get_object(value);
            count  = json_object_get_count(object);
            APPEND_STRING("{");
            if (count > 0 && is_pretty) {
                APPEND_STRING("\n");
            }
            for (i = 0; i < count; i++) {
                key = json_object_get_name(object, i);
                if (key == NULL) {
                    return -1;
                }
                if (is_pretty) {
                    APPEND_INDENT(level+1);
                }
                written = json_serialize_string(key, buf);
                if (written < 0) {
                    return -1;
                }
                if (buf != NULL) {
                    buf += written;
                }
                written_total += written;
                APPEND_STRING(":");
                if (is_pretty) {
                    APPEND_STRING(" ");
                }
                temp_value = json_object_get_value(object, key);
                written = json_serialize_to_buffer_r(temp_value, buf, level+1, is_pretty, num_buf);
                if (written < 0) {
                    return -1;
                }
                if (buf != NULL) {
                    buf += written;
                }
                written_total += written;
                if (i < (count - 1)) {
                    APPEND_STRING(",");
                }
                if (is_pretty) {
                    APPEND_STRING("\n");
                }
            }
            if (count > 0 && is_pretty) {
                APPEND_INDENT(level);
            }
            APPEND_STRING("}");
            return written_total;
        case JSONString:
            string = json_value_get_string(value);
            if (string == NULL) {
                return -1;
            }
            written = json_serialize_string(string, buf);
            if (written < 0) {
                return -1;
            }
            if (buf != NULL) {
                buf += written;
            }
            written_total += written;
            return written_total;
        case JSONBoolean:
            if (json_value_get_boolean(value)) {
                APPEND_STRING("true");
            } else {
                APPEND_STRING("false");
            }
            return written_total;
        case JSONNumber:
            num = json_value_get_number(value);
            if (buf != NULL) {
                num_buf = buf;
            }
            if (num == ((double)(int)num)) { /*  check if num is integer */
                written = sprintf(num_buf, "%d", (int)num);
	    } else if (num == ((double)(unsigned int)num)) {
                written = sprintf(num_buf, "%u", (unsigned int)num);
            } else {
                written = sprintf(num_buf, DOUBLE_SERIALIZATION_FORMAT, num);
            }
            if (written < 0) {
                return -1;
            }
            if (buf != NULL) {
                buf += written;
            }
            written_total += written;
            return written_total;
        case JSONNull:
            APPEND_STRING("null");
            return written_total;
        case JSONError:
            return -1;
        default:
            return -1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x4a29
movl 0x8(%rdi), %eax
decl %eax
cmpl $0x5, %eax
ja 0x4a29
movq %r8, %rbx
movl %ecx, %ebp
movl %edx, %r13d
movq %rsi, %r15
leaq 0x2f24(%rip), %rcx      # 0x7340
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x3067(%rip), %rsi      # 0x7493
jmp 0x462a
movq 0x10(%rdi), %r14
testq %r14, %r14
je 0x44dc
movq 0x10(%r14), %rax
movq %rax, 0x8(%rsp)
jmp 0x44e5
movsd 0x10(%rdi), %xmm0
testq %r15, %r15
cmovneq %r15, %rbx
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4563
jp 0x4563
cvttsd2si %xmm0, %edx
leaq 0x3029(%rip), %rsi      # 0x74a4
movq %rbx, %rdi
jmp 0x458c
movq 0x10(%rdi), %rax
testq %rax, %rax
movq %rax, 0x10(%rsp)
je 0x45a4
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x45ad
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
je 0x4a29
movq %r15, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x61b3
cmpl $0x0, 0x10(%rdi)
je 0x4623
leaq 0x2df5(%rip), %rsi      # 0x72cc
jmp 0x462a
movq $0x0, 0x8(%rsp)
leaq 0x2fac(%rip), %rsi      # 0x7498
movq %r15, %rdi
callq 0x6144
testl %eax, %eax
js 0x49c3
movl %eax, %r12d
movq %rbx, 0x28(%rsp)
movl %eax, %ebx
addq %r15, %rbx
testq %r15, %r15
cmoveq %r15, %rbx
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
setne %al
testl %ebp, %ebp
setne %r15b
andb %al, %r15b
cmpb $0x1, %r15b
jne 0x4641
leaq 0x2bba(%rip), %rsi      # 0x70ef
movq %rbx, %rdi
callq 0x6144
testl %eax, %eax
js 0x49c3
movb %r15b, 0x4(%rsp)
movq %r13, 0x18(%rsp)
movl %eax, %ecx
addq %rbx, %rcx
testq %rbx, %rbx
cmovneq %rcx, %rbx
addl %eax, %r12d
jmp 0x4654
cvttsd2si %xmm0, %rdx
movl %edx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4984
jp 0x4984
leaq 0x2f1e(%rip), %rsi      # 0x74a7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x22a0
testl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovnsl %eax, %ecx
movl %ecx, %eax
jmp 0x4a2c
movq $0x0, 0x8(%rsp)
leaq 0x2eea(%rip), %rsi      # 0x749e
movq %r15, %rdi
callq 0x6144
testl %eax, %eax
js 0x4a29
movl %eax, %r12d
movq %r13, 0x18(%rsp)
movl %eax, %r13d
addq %r15, %r13
testq %r15, %r15
cmoveq %r15, %r13
movq 0x8(%rsp), %r15
testq %r15, %r15
setne %al
testl %ebp, %ebp
setne %cl
andb %al, %cl
movb %cl, 0x3(%rsp)
cmpb $0x1, %cl
jne 0x4785
leaq 0x2af0(%rip), %rsi      # 0x70ef
movq %r13, %rdi
callq 0x6144
testl %eax, %eax
js 0x4a29
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
jmp 0x478e
leaq 0x2ca7(%rip), %rsi      # 0x72d1
movq %r15, %rdi
callq 0x6144
testl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovsl %ecx, %eax
jmp 0x4a2c
movb %r15b, 0x4(%rsp)
movq %r13, 0x18(%rsp)
testq %rcx, %rcx
je 0x49ce
movq 0x18(%rsp), %rax
incl %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
decq %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
movq %rbx, %r15
testl %ebp, %ebp
je 0x46c3
movq %r15, %rdi
movl 0x10(%rsp), %esi
callq 0x6161
testl %eax, %eax
movq 0x28(%rsp), %r8
js 0x49c3
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
testq %r14, %r14
je 0x46b0
cmpq %r13, 0x10(%r14)
jbe 0x46b0
movq 0x8(%r14), %rcx
movq (%rcx,%r13,8), %rdi
jmp 0x46b2
xorl %edi, %edi
addl %eax, %r12d
movq %r15, %rsi
movl 0x10(%rsp), %edx
movl $0x1, %ecx
jmp 0x46e8
testq %r14, %r14
movq 0x28(%rsp), %r8
je 0x46dd
cmpq %r13, 0x10(%r14)
jbe 0x46dd
movq 0x8(%r14), %rax
movq (%rax,%r13,8), %rdi
jmp 0x46df
xorl %edi, %edi
movq %r15, %rsi
movl 0x10(%rsp), %edx
xorl %ecx, %ecx
callq 0x43df
testl %eax, %eax
js 0x49c3
movl %eax, %ebx
addq %r15, %rbx
testq %r15, %r15
cmoveq %r15, %rbx
addl %eax, %r12d
cmpq 0x20(%rsp), %r13
jae 0x4731
movq %rbx, %rdi
leaq 0x2d85(%rip), %rsi      # 0x749a
callq 0x6144
testl %eax, %eax
js 0x49c3
movl %eax, %ecx
addq %rbx, %rcx
testq %rbx, %rbx
cmovneq %rcx, %rbx
addl %eax, %r12d
testl %ebp, %ebp
je 0x476f
movq %rbx, %rdi
leaq 0x29b0(%rip), %rsi      # 0x70ef
callq 0x6144
testl %eax, %eax
js 0x49c3
movl %eax, %r15d
addq %rbx, %r15
testq %rbx, %rbx
cmoveq %rbx, %r15
addl %eax, %r12d
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x4672
jmp 0x499a
incq %r13
movq %rbx, %r15
cmpq 0x8(%rsp), %r13
jne 0x4672
jmp 0x49ce
testq %r15, %r15
je 0x4a10
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
je 0x4a29
cmpq $0x0, 0x18(%rcx)
je 0x4a29
movq 0x18(%rsp), %rax
incl %eax
movl %eax, 0x4(%rsp)
leaq -0x1(%r15), %rax
movq %rax, 0x30(%rsp)
xorl %edx, %edx
movq %rbx, 0x28(%rsp)
movq 0x8(%rcx), %rax
movq (%rax,%rdx,8), %rbx
testq %rbx, %rbx
je 0x4a29
movq %rdx, 0x20(%rsp)
testl %ebp, %ebp
je 0x47ff
movq %r13, %rdi
movl 0x4(%rsp), %esi
callq 0x6161
testl %eax, %eax
js 0x4a29
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x61b3
testl %eax, %eax
js 0x49c3
movl %eax, %r15d
movl %eax, %r14d
addq %r13, %r14
testq %r13, %r13
cmoveq %r13, %r14
movq %r14, %rdi
leaq 0x2c74(%rip), %rsi      # 0x74a0
callq 0x6144
testl %eax, %eax
js 0x49c3
addl %r15d, %r12d
movl %eax, %r15d
addq %r14, %r15
testq %r14, %r14
cmoveq %r14, %r15
addl %eax, %r12d
testl %ebp, %ebp
je 0x48a4
movq %r15, %rdi
leaq 0x2c56(%rip), %rsi      # 0x74b0
callq 0x6144
testl %eax, %eax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
js 0x4a29
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x3826
movq %rax, %rdi
movq %r15, %rsi
movl 0x4(%rsp), %edx
movl $0x1, %ecx
movq 0x28(%rsp), %r8
callq 0x43df
jmp 0x48cd
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x3826
movq %rax, %rdi
movq %r15, %rsi
movl 0x4(%rsp), %edx
xorl %ecx, %ecx
movq 0x28(%rsp), %r8
callq 0x43df
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
movq 0x20(%rsp), %rdx
js 0x4a29
movl %eax, %r13d
addq %r15, %r13
testq %r15, %r15
cmoveq %r15, %r13
addl %eax, %r12d
cmpq 0x30(%rsp), %rdx
jae 0x4923
movq %r13, %rdi
leaq 0x2b9f(%rip), %rsi      # 0x749a
callq 0x6144
testl %eax, %eax
movq 0x8(%rsp), %r15
js 0x4a29
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
movq 0x20(%rsp), %rdx
jmp 0x4928
movq 0x8(%rsp), %r15
testl %ebp, %ebp
je 0x4964
movq %r13, %rdi
leaq 0x27b9(%rip), %rsi      # 0x70ef
callq 0x6144
testl %eax, %eax
js 0x4a29
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
movq 0x20(%rsp), %rdx
incq %rdx
cmpq %r15, %rdx
jne 0x4970
jmp 0x49e9
incq %rdx
cmpq %r15, %rdx
je 0x4a10
movq 0x10(%rsp), %rcx
cmpq %rdx, 0x18(%rcx)
ja 0x47c2
jmp 0x4a29
leaq 0x2b1f(%rip), %rsi      # 0x74aa
movq %rbx, %rdi
movb $0x1, %al
callq 0x22a0
jmp 0x4593
cmpb $0x0, 0x4(%rsp)
je 0x49cb
movq %r15, %rdi
movq 0x18(%rsp), %rsi
callq 0x6161
testl %eax, %eax
js 0x49c3
movl %eax, %ebx
addq %r15, %rbx
testq %r15, %r15
cmoveq %r15, %rbx
addl %eax, %r12d
jmp 0x49ce
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x4a29
movq %r15, %rbx
leaq 0x2ac7(%rip), %rsi      # 0x749c
movq %rbx, %rdi
callq 0x6144
testl %eax, %eax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jns 0x4a23
jmp 0x4a29
cmpb $0x0, 0x3(%rsp)
je 0x4a10
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq 0x6161
testl %eax, %eax
js 0x4a29
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
leaq 0x2a8b(%rip), %rsi      # 0x74a2
movq %r13, %rdi
callq 0x6144
testl %eax, %eax
js 0x4a29
addl %r12d, %eax
movl %eax, %r14d
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq