// File: /workspace/github_c_makefile_star2_O1/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
movq %r8, %r15
movl %ecx, (%rsp)
movq %rsi, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x4626
movl 0x8(%rdi), %eax
decl %eax
cmpl $0x5, %eax
ja 0x4be3
leaq 0x2d18(%rip), %rcx      # 0x7350
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2e61(%rip), %rsi      # 0x74a9
jmp 0x46ed
testq %rdi, %rdi
je 0x4704
cmpl $0x5, 0x8(%rdi)
jne 0x4704
movq 0x10(%rdi), %r14
jmp 0x4707
xorpd %xmm0, %xmm0
testq %rdi, %rdi
je 0x467d
cmpl $0x3, 0x8(%rdi)
jne 0x467d
movsd 0x10(%rdi), %xmm0
testq %rbx, %rbx
cmovneq %rbx, %r15
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x47d4
jp 0x47d4
cvttsd2si %xmm0, %edx
leaq 0x2e13(%rip), %rsi      # 0x74ba
movq %r15, %rdi
jmp 0x47fd
testq %rdi, %rdi
je 0x471c
cmpl $0x4, 0x8(%rdi)
jne 0x471c
movq 0x10(%rdi), %r14
jmp 0x471f
testq %rdi, %rdi
je 0x4736
cmpl $0x2, 0x8(%rdi)
jne 0x4736
movq 0x10(%rdi), %rdi
jmp 0x4738
testq %rdi, %rdi
je 0x46e6
cmpl $0x6, 0x8(%rdi)
jne 0x46e6
cmpl $0x0, 0x10(%rdi)
je 0x4bba
leaq 0x2bbf(%rip), %rsi      # 0x72ac
movq %rbx, %rdi
callq 0x63a1
testl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovsl %ecx, %eax
jmp 0x4be5
xorl %r14d, %r14d
testq %r14, %r14
movq %rdx, 0x18(%rsp)
je 0x4757
movq 0x10(%r14), %rax
movq %rax, 0x8(%rsp)
jmp 0x4760
xorl %r14d, %r14d
testq %r14, %r14
movq %rdx, 0x18(%rsp)
je 0x4815
movq 0x18(%r14), %r13
jmp 0x4818
xorl %edi, %edi
testq %rdi, %rdi
je 0x4be3
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6410
movq $0x0, 0x8(%rsp)
leaq 0x2d47(%rip), %rsi      # 0x74ae
movq %rbx, %rdi
callq 0x63a1
testl %eax, %eax
js 0x4be3
movl %eax, %r12d
movl %eax, %r13d
addq %rbx, %r13
testq %rbx, %rbx
cmoveq %rbx, %r13
cmpq $0x0, 0x8(%rsp)
setne %al
cmpl $0x0, (%rsp)
setne %bl
andb %al, %bl
cmpb $0x1, %bl
jne 0x4a69
leaq 0x292a(%rip), %rsi      # 0x70d3
movq %r13, %rdi
callq 0x63a1
testl %eax, %eax
js 0x4be3
movb %bl, 0x10(%rsp)
movq %r15, %rbx
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
jmp 0x4a70
cvttsd2si %xmm0, %rdx
movl %edx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4b96
jp 0x4b96
leaq 0x2cc3(%rip), %rsi      # 0x74bd
movq %r15, %rdi
xorl %eax, %eax
callq 0x22b0
testl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovnsl %eax, %ecx
movl %ecx, %eax
jmp 0x4be5
xorl %r13d, %r13d
leaq 0x2c95(%rip), %rsi      # 0x74b4
movq %rbx, %rdi
callq 0x63a1
testl %eax, %eax
js 0x4be3
movl %eax, %r12d
movq %r15, 0x20(%rsp)
movl %eax, %r15d
addq %rbx, %r15
testq %rbx, %rbx
cmoveq %rbx, %r15
testq %r13, %r13
setne %al
cmpl $0x0, (%rsp)
setne %cl
andb %al, %cl
movb %cl, 0x7(%rsp)
cmpb $0x1, %cl
jne 0x4882
leaq 0x2870(%rip), %rsi      # 0x70d3
movq %r15, %rdi
callq 0x63a1
testl %eax, %eax
js 0x4be3
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
testq %r13, %r13
je 0x4a30
movq 0x18(%rsp), %rax
incl %eax
movl %eax, 0x8(%rsp)
leaq -0x1(%r13), %rax
movq %rax, 0x30(%rsp)
xorl %ebp, %ebp
movq %r13, 0x10(%rsp)
testq %r14, %r14
movq %rbp, 0x28(%rsp)
je 0x48c0
cmpq %rbp, 0x18(%r14)
jbe 0x48c0
movq 0x8(%r14), %rax
movq (%rax,%rbp,8), %rbp
jmp 0x48c2
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x4b5e
cmpl $0x0, (%rsp)
je 0x48f4
movq %r15, %rdi
movl 0x8(%rsp), %esi
callq 0x63be
testl %eax, %eax
js 0x4b5e
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
movq %rbp, %rdi
movq %r15, %rsi
callq 0x6410
testl %eax, %eax
js 0x4b5e
movl %eax, %r13d
movq %r14, %rbx
movl %eax, %r14d
addq %r15, %r14
testq %r15, %r15
cmoveq %r15, %r14
movq %r14, %rdi
leaq 0x2b92(%rip), %rsi      # 0x74b6
callq 0x63a1
testl %eax, %eax
js 0x4b5e
addl %r13d, %r12d
movl %eax, %r13d
addq %r14, %r13
testq %r14, %r14
cmoveq %r14, %r13
addl %eax, %r12d
cmpl $0x0, (%rsp)
je 0x4977
movq %r13, %rdi
leaq 0x2b72(%rip), %rsi      # 0x74c6
callq 0x63a1
testl %eax, %eax
movq 0x20(%rsp), %r14
js 0x4b5e
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
jmp 0x497c
movq 0x20(%rsp), %r14
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3936
movq %rax, %rdi
movq %r13, %rsi
movl 0x8(%rsp), %edx
movl (%rsp), %ecx
movq %r14, %r8
callq 0x45fd
testl %eax, %eax
js 0x4b5e
movl %eax, %r15d
addq %r13, %r15
testq %r13, %r13
cmoveq %r13, %r15
addl %eax, %r12d
movq 0x28(%rsp), %rbp
cmpq 0x30(%rsp), %rbp
jae 0x49f0
movq %r15, %rdi
leaq 0x2ae6(%rip), %rsi      # 0x74b0
callq 0x63a1
testl %eax, %eax
movq %rbx, %r14
movq 0x10(%rsp), %rbx
js 0x4b5e
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
jmp 0x49f8
movq %rbx, %r14
movq 0x10(%rsp), %rbx
cmpl $0x0, (%rsp)
je 0x4a24
movq %r15, %rdi
leaq 0x26cb(%rip), %rsi      # 0x70d3
callq 0x63a1
testl %eax, %eax
js 0x4b5e
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
incq %rbp
cmpq %rbp, %rbx
jne 0x48a6
cmpb $0x0, 0x7(%rsp)
je 0x4bc6
movq %r15, %rdi
movq 0x18(%rsp), %rsi
callq 0x63be
testl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
js 0x4be3
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
jmp 0x4bcb
movb %bl, 0x10(%rsp)
movq %r15, %rbx
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
je 0x4b65
movq 0x18(%rsp), %rax
incl %eax
movl %eax, 0x28(%rsp)
leaq -0x1(%rcx), %rax
movq %rax, 0x20(%rsp)
xorl %ebp, %ebp
cmpl $0x0, (%rsp)
je 0x4abd
movq %r13, %rdi
movl 0x28(%rsp), %esi
callq 0x63be
testl %eax, %eax
js 0x4b5e
movl %eax, %ecx
addq %r13, %rcx
testq %r13, %r13
cmovneq %rcx, %r13
addl %eax, %r12d
testq %r14, %r14
je 0x4ad2
cmpq %rbp, 0x10(%r14)
jbe 0x4ad2
movq 0x8(%r14), %rax
movq (%rax,%rbp,8), %rdi
jmp 0x4ad4
xorl %edi, %edi
movq %r13, %rsi
movl 0x28(%rsp), %edx
movl (%rsp), %ecx
movq %rbx, %r8
callq 0x45fd
testl %eax, %eax
js 0x4b5e
movl %eax, %r15d
addq %r13, %r15
testq %r13, %r13
cmoveq %r13, %r15
addl %eax, %r12d
cmpq 0x20(%rsp), %rbp
jae 0x4b23
movq %r15, %rdi
leaq 0x29a5(%rip), %rsi      # 0x74b0
callq 0x63a1
testl %eax, %eax
js 0x4b5e
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
cmpl $0x0, (%rsp)
je 0x4b4b
movq %r15, %rdi
leaq 0x25a0(%rip), %rsi      # 0x70d3
callq 0x63a1
testl %eax, %eax
js 0x4b5e
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
incq %rbp
movq %r15, %r13
cmpq %rbp, 0x8(%rsp)
jne 0x4a94
jmp 0x4b68
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4be3
movq %r13, %r15
cmpb $0x0, 0x10(%rsp)
je 0x4bac
movq %r15, %rdi
movq 0x18(%rsp), %rsi
callq 0x63be
testl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
js 0x4be3
movl %eax, %ecx
addq %r15, %rcx
testq %r15, %r15
cmovneq %rcx, %r15
addl %eax, %r12d
jmp 0x4bb1
leaq 0x2923(%rip), %rsi      # 0x74c0
movq %r15, %rdi
movb $0x1, %al
callq 0x22b0
jmp 0x4804
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x28fa(%rip), %rsi      # 0x74b2
jmp 0x4bd2
leaq 0x26f0(%rip), %rsi      # 0x72b1
jmp 0x46ed
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x28e6(%rip), %rsi      # 0x74b8
movq %r15, %rdi
callq 0x63a1
testl %eax, %eax
js 0x4be3
addl %r12d, %eax
movl %eax, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq