// File: /workspace/github_c_makefile_star2_O1/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 0x599e
movl 0x8(%rdi), %eax
cmpl $0x1, %eax
je 0x59b2
cmpl 0x8(%rsi), %eax
je 0x59b2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decl %eax
cmpl $0x5, %eax
ja 0x599e
leaq 0x19a8(%rip), %rcx      # 0x7368
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
jmp 0x59a3
cmpl $0x5, 0x8(%rdi)
jne 0x59e5
movq 0x10(%rdi), %rcx
jmp 0x59e7
cmpl $0x4, 0x8(%rdi)
jne 0x5a19
movq 0x10(%rdi), %rbx
jmp 0x5a1b
xorl %ecx, %ecx
xorl %eax, %eax
cmpl $0x5, 0x8(%rsi)
jne 0x59f5
movq 0x10(%rsi), %r14
jmp 0x59f8
xorl %r14d, %r14d
testq %rcx, %rcx
je 0x59a3
cmpq $0x0, 0x10(%rcx)
je 0x59a3
testq %rcx, %rcx
je 0x5a4e
cmpq $0x0, 0x10(%rcx)
je 0x5a4e
movq 0x8(%rcx), %rax
movq (%rax), %rbx
jmp 0x5a50
xorl %ebx, %ebx
cmpl $0x4, 0x8(%rsi)
jne 0x5a27
movq 0x10(%rsi), %r14
jmp 0x5a2a
xorl %r14d, %r14d
xorl %eax, %eax
testq %rbx, %rbx
je 0x5a37
movq 0x18(%rbx), %r13
jmp 0x5a3a
xorl %r13d, %r13d
testq %r13, %r13
je 0x59a3
testq %r14, %r14
je 0x5a95
movq 0x18(%r14), %rax
jmp 0x5a97
xorl %ebx, %ebx
xorl %r15d, %r15d
testq %r14, %r14
je 0x5a5e
movq 0x10(%r14), %rax
jmp 0x5a60
xorl %eax, %eax
cmpq %rax, %r15
jae 0x59c9
testq %r14, %r14
je 0x5a7e
cmpq %r15, 0x10(%r14)
jbe 0x5a7e
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %rsi
jmp 0x5a80
xorl %esi, %esi
movq %rbx, %rdi
callq 0x5976
incq %r15
cmpl $-0x1, %eax
jne 0x5a53
jmp 0x599e
xorl %eax, %eax
cmpq %r13, %rax
jb 0x599e
cmpq $0x1, %r13
adcq $0x0, %r13
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x5abf
cmpq %rbp, 0x18(%rbx)
jbe 0x5abf
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %r15
jmp 0x5ac2
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3936
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x3936
testq %rax, %rax
je 0x599e
movq %r12, %rdi
movq %rax, %rsi
callq 0x5976
cmpl $-0x1, %eax
je 0x599e
incq %rbp
xorl %eax, %eax
cmpq %rbp, %r13
jne 0x5aaa
jmp 0x59a3