// File: /workspace/github_c_makefile_star2_O2/xapi-project[P]rrd-client-lib/parson/parson.c
// Function: json_validate
JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value) {
    JSON_Value *temp_schema_value = NULL, *temp_value = NULL;
    JSON_Array *schema_array = NULL, *value_array = NULL;
    JSON_Object *schema_object = NULL, *value_object = NULL;
    JSON_Value_Type schema_type = JSONError, value_type = JSONError;
    const char *key = NULL;
    size_t i = 0, count = 0;
    if (schema == NULL || value == NULL) {
        return JSONFailure;
    }
    schema_type = json_value_get_type(schema);
    value_type = json_value_get_type(value);
    if (schema_type != value_type && schema_type != JSONNull) { /* null represents all values */
        return JSONFailure;
    }
    switch (schema_type) {
        case JSONArray:
            schema_array = json_value_get_array(schema);
            value_array = json_value_get_array(value);
            count = json_array_get_count(schema_array);
            if (count == 0) {
                return JSONSuccess; /* Empty array allows all types */
            }
            /* Get first value from array, rest is ignored */
            temp_schema_value = json_array_get_value(schema_array, 0);
            for (i = 0; i < json_array_get_count(value_array); i++) {
                temp_value = json_array_get_value(value_array, i);
                if (json_validate(temp_schema_value, temp_value) == JSONFailure) {
                    return JSONFailure;
                }
            }
            return JSONSuccess;
        case JSONObject:
            schema_object = json_value_get_object(schema);
            value_object = json_value_get_object(value);
            count = json_object_get_count(schema_object);
            if (count == 0) {
                return JSONSuccess; /* Empty object allows all objects */
            } else if (json_object_get_count(value_object) < count) {
                return JSONFailure; /* Tested object mustn't have less name-value pairs than schema */
            }
            for (i = 0; i < count; i++) {
                key = json_object_get_name(schema_object, i);
                temp_schema_value = json_object_get_value(schema_object, key);
                temp_value = json_object_get_value(value_object, key);
                if (temp_value == NULL) {
                    return JSONFailure;
                }
                if (json_validate(temp_schema_value, temp_value) == JSONFailure) {
                    return JSONFailure;
                }
            }
            return JSONSuccess;
        case JSONString: case JSONNumber: case JSONBoolean: case JSONNull:
            return JSONSuccess; /* equality already tested before switch */
        case JSONError: default:
            return JSONFailure;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
pushq $-0x1
popq %rbp
jne 0x408f
movl 0x8(%rdi), %ecx
movl 0x8(%rsi), %eax
cmpl %eax, %ecx
setne %dl
cmpl $0x1, %ecx
setne %r8b
testb %dl, %r8b
je 0x40a2
movl %ebp, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decl %ecx
cmpl $0x5, %ecx
ja 0x408f
xorl %ebx, %ebx
leaq 0x12c6(%rip), %rdx      # 0x5378
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq 0x10(%rdi), %r14
xorl %ebx, %ebx
cmpl $0x4, %eax
jne 0x4123
movq 0x10(%rsi), %rcx
jmp 0x4125
movq 0x10(%rdi), %rcx
xorl %ebx, %ebx
cmpl $0x5, %eax
jne 0x40dd
movq 0x10(%rsi), %r15
jmp 0x40e0
xorl %r15d, %r15d
testq %rcx, %rcx
je 0x4091
cmpq $0x0, 0x10(%rcx)
je 0x4091
testq %r15, %r15
je 0x4091
movq 0x8(%rcx), %rax
movq (%rax), %r14
movq 0x10(%r15), %r12
xorl %ebx, %ebx
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x4091
movq 0x8(%r15), %rax
movq (%rax,%r13,8), %rsi
movq %r14, %rdi
callq 0x4057
incq %r13
cmpl $-0x1, %eax
jne 0x4101
jmp 0x408f
xorl %ecx, %ecx
testq %r14, %r14
je 0x4091
movq 0x18(%r14), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x4091
testq %rcx, %rcx
je 0x414b
movq 0x18(%rcx), %rax
jmp 0x414d
xorl %eax, %eax
cmpq 0x8(%rsp), %rax
jb 0x408f
movq %rcx, 0x10(%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
cmpq %r15, 0x8(%rsp)
je 0x4091
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x25cc
movq %rax, %r12
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x25cc
testq %rax, %rax
je 0x408f
movq %r12, %rdi
movq %rax, %rsi
callq 0x4057
incq %r15
cmpl $-0x1, %eax
jne 0x4162
jmp 0x408f