// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x50(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x5da7
cmpq $0x0, -0x18(%rbp)
jne 0x5db3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5fba
movq -0x10(%rbp), %rdi
callq 0x3230
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3230
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
je 0x5de5
cmpl $0x1, -0x4c(%rbp)
je 0x5de5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5fba
movl -0x4c(%rbp), %eax
incl %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x7, %eax
ja 0x5fb3
movq -0x70(%rbp), %rax
leaq 0x3714(%rip), %rcx      # 0x9518
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0x2e80
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2e80
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3340
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x5e47
movl $0x0, -0x4(%rbp)
jmp 0x5fba
movq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x32e0
movq %rax, -0x20(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3340
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x5ebc
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x32e0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5d30
cmpl $-0x1, %eax
jne 0x5eac
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5fba
jmp 0x5eae
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x5e60
movl $0x0, -0x4(%rbp)
jmp 0x5fba
movq -0x10(%rbp), %rdi
callq 0x2e10
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2e10
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x30a0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x5f02
movl $0x0, -0x4(%rbp)
jmp 0x5fba
movq -0x48(%rbp), %rdi
callq 0x30a0
cmpq -0x68(%rbp), %rax
jae 0x5f1d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5fba
jmp 0x5f1f
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x5f9f
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x30d0
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x2be0
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x2be0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5f74
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5fba
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5d30
cmpl $-0x1, %eax
jne 0x5f8f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5fba
jmp 0x5f91
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x5f27
movl $0x0, -0x4(%rbp)
jmp 0x5fba
movl $0x0, -0x4(%rbp)
jmp 0x5fba
jmp 0x5fb3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)