// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x577e
movl 0x8(%rdi), %ecx
movl 0x8(%rsi), %edx
cmpl %edx, %ecx
setne %al
cmpl $0x1, %ecx
setne %r8b
testb %al, %r8b
je 0x5792
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decl %ecx
cmpl $0x5, %ecx
ja 0x577e
xorl %eax, %eax
leaq 0x1bb6(%rip), %r8       # 0x7358
movslq (%r8,%rcx,4), %rcx
addq %r8, %rcx
jmpq *%rcx
movq 0x10(%rdi), %rbx
xorl %eax, %eax
cmpl $0x4, %edx
jne 0x581b
movq 0x10(%rsi), %r14
jmp 0x581e
movq 0x10(%rdi), %rcx
xorl %eax, %eax
cmpl $0x5, %edx
jne 0x57cd
movq 0x10(%rsi), %rdx
jmp 0x57cf
xorl %edx, %edx
testq %rcx, %rcx
je 0x5783
cmpq $0x0, 0x10(%rcx)
je 0x5783
testq %rdx, %rdx
je 0x5783
movq 0x10(%rdx), %r14
testq %r14, %r14
je 0x5783
movq 0x8(%rcx), %rax
movq (%rax), %rbx
movq 0x8(%rdx), %r15
xorl %r12d, %r12d
movq (%r15,%r12,8), %rsi
movq %rbx, %rdi
callq 0x574c
cmpl $-0x1, %eax
je 0x577e
incq %r12
xorl %eax, %eax
cmpq %r12, %r14
jne 0x57f7
jmp 0x5783
xorl %r14d, %r14d
testq %rbx, %rbx
je 0x5783
movq 0x18(%rbx), %r13
testq %r13, %r13
je 0x5783
testq %r14, %r14
je 0x583f
movq 0x18(%r14), %rax
jmp 0x5841
xorl %eax, %eax
cmpq %r13, %rax
jb 0x577e
xorl %ebp, %ebp
cmpq %rbp, %r13
jbe 0x585b
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %r15
jmp 0x585e
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3826
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x3826
testq %rax, %rax
je 0x577e
movq %r12, %rdi
movq %rax, %rsi
callq 0x574c
cmpl $-0x1, %eax
je 0x577e
incq %rbp
xorl %eax, %eax
cmpq %rbp, %r13
jne 0x584c
jmp 0x5783