// File: /workspace/github_cpp_makefile_star2_O3/Eba-M[P]E3DC-Control/cJSON.c
// Function: cJSON_Compare
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive)
{
    if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)))
    {
        return false;
    }

    /* check if type is valid */
    switch (a->type & 0xFF)
    {
        case cJSON_False:
        case cJSON_True:
        case cJSON_NULL:
        case cJSON_Number:
        case cJSON_String:
        case cJSON_Raw:
        case cJSON_Array:
        case cJSON_Object:
            break;

        default:
            return false;
    }

    /* identical objects are equal */
    if (a == b)
    {
        return true;
    }

    switch (a->type & 0xFF)
    {
        /* in these cases and equal type is enough */
        case cJSON_False:
        case cJSON_True:
        case cJSON_NULL:
            return true;

        case cJSON_Number:
            if (compare_double(a->valuedouble, b->valuedouble))
            {
                return true;
            }
            return false;

        case cJSON_String:
        case cJSON_Raw:
            if ((a->valuestring == NULL) || (b->valuestring == NULL))
            {
                return false;
            }
            if (strcmp(a->valuestring, b->valuestring) == 0)
            {
                return true;
            }

            return false;

        case cJSON_Array:
        {
            cJSON *a_element = a->child;
            cJSON *b_element = b->child;

            for (; (a_element != NULL) && (b_element != NULL);)
            {
                if (!cJSON_Compare(a_element, b_element, case_sensitive))
                {
                    return false;
                }

                a_element = a_element->next;
                b_element = b_element->next;
            }

            /* one of the arrays is longer than the other */
            if (a_element != b_element) {
                return false;
            }

            return true;
        }

        case cJSON_Object:
        {
            cJSON *a_element = NULL;
            cJSON *b_element = NULL;
            cJSON_ArrayForEach(a_element, a)
            {
                /* TODO This has O(n^2) runtime, which is horrible! */
                b_element = get_object_item(b, a_element->string, case_sensitive);
                if (b_element == NULL)
                {
                    return false;
                }

                if (!cJSON_Compare(a_element, b_element, case_sensitive))
                {
                    return false;
                }
            }

            /* doing this twice, once on a and b to prevent true comparison if a subset of b
             * TODO: Do this the proper way, this is just a fix for now */
            cJSON_ArrayForEach(b_element, b)
            {
                a_element = get_object_item(a, b_element->string, case_sensitive);
                if (a_element == NULL)
                {
                    return false;
                }

                if (!cJSON_Compare(b_element, a_element, case_sensitive))
                {
                    return false;
                }
            }

            return true;
        }

        default:
            return false;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x2e4c6
movq %rsi, %rbx
movq %rdi, %r14
movl 0x18(%rdi), %eax
movb 0x18(%rsi), %cl
xorb %al, %cl
je 0x2e4d6
xorl %r12d, %r12d
movzbl %r12b, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %edx, %ebp
movzbl %al, %eax
leal -0x1(%rax), %ecx
cmpl $0x3f, %ecx
ja 0x2e5a3
movabsq $-0x7fffffff7fff7f75, %rdx # imm = 0x800000008000808B
btq %rcx, %rdx
jae 0x2e5a3
movb $0x1, %r12b
cmpq %rbx, %r14
je 0x2e4c9
cmpl $0xf, %eax
jg 0x2e557
cmpl $0x2, %ecx
jb 0x2e4c9
cmpl $0x4, %eax
je 0x2e4c9
cmpl $0x8, %eax
jne 0x2e4c6
movsd 0x30(%r14), %xmm0
movsd 0x30(%rbx), %xmm1
movapd 0x4576(%rip), %xmm2     # 0x32aa0
movapd %xmm0, %xmm3
andpd %xmm2, %xmm3
subsd %xmm1, %xmm0
andpd %xmm2, %xmm1
maxsd %xmm1, %xmm3
mulsd 0x454a(%rip), %xmm3     # 0x32a90
andpd %xmm2, %xmm0
ucomisd %xmm0, %xmm3
setae %r12b
jmp 0x2e4c9
cmpl $0x3f, %eax
jg 0x2e5b3
cmpl $0x10, %eax
je 0x2e5c3
cmpl $0x20, %eax
jne 0x2e4c6
addq $0x10, %r14
addq $0x10, %rbx
xorl %r12d, %r12d
movq (%rbx), %rbx
movq (%r14), %r14
testq %r14, %r14
je 0x2e622
testq %rbx, %rbx
je 0x2e622
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x2e49e
testl %eax, %eax
jne 0x2e575
jmp 0x2e4c9
cmpl $0x80, %eax
jne 0x2e4c6
jmp 0x2e4fb
cmpl $0x40, %eax
je 0x2e5e6
cmpl $0x80, %eax
jne 0x2e4c6
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x2e4c6
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x2e4c6
callq 0x2390
testl %eax, %eax
jmp 0x2e625
leaq 0x10(%r14), %r15
xorl %r12d, %r12d
movq (%r15), %r15
testq %r15, %r15
je 0x2e62e
movq 0x38(%r15), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x2d0f3
testq %rax, %rax
je 0x2e4c6
movq %r15, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x2e49e
testl %eax, %eax
jne 0x2e5ed
jmp 0x2e4c9
cmpq %rbx, %r14
sete %r12b
jmp 0x2e4c9
addq $0x10, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
sete %r12b
je 0x2e4c9
movq 0x38(%rbx), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x2d0f3
testq %rax, %rax
je 0x2e4c9
movq %rbx, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x2e49e
testl %eax, %eax
jne 0x2e632
jmp 0x2e4c9