// File: yasz24[P]eau2/src/network/../serialize/jsonHelper.h
// Function: JSONHelper::arrayLen(char*)
static int arrayLen(char* s) {
        int len = strlen( s );
        bool valuesFound = false;
        char objStart = '{';
        char objEnd = '}';
        int count = 0;
        int startCharDepth = -1;
        //pull the top level object-value from the serialzed string
        for (int i = 0; i < len; i++){
            char temp = s[i];
            if(!valuesFound) {
                //the three ways a payload in our JSON can start, will rely on this to know what character closes the value
                //also keeps track of depth if there are nested objects
                if(temp == '{' || temp == '[' || temp == '\'') {
                    objStart = temp;
                    startCharDepth = 1;
                    valuesFound = true;
                    if(temp == '{') {
                        objEnd = '}';
                    } else if(temp == '[') {
                        objEnd = ']';
                    } else if(temp == '\'') {
                        objEnd = '\'';
                        startCharDepth = 0;
                    }   
                }
            } else if(temp == objStart) {
                startCharDepth++;
            } 
            if(temp == objEnd && valuesFound) {
                if(temp != objStart) {
                    startCharDepth--;
                }
                //if we've reached the final level of end character, break out of loop
                if(startCharDepth <= 0  || (temp == objStart && startCharDepth % 2 == 0)) {
                    count++;
                }
            }
        }
        return count;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8130
movl %eax, -0xc(%rbp)
movb $0x0, -0xd(%rbp)
movb $0x7b, -0xe(%rbp)
movb $0x7d, -0xf(%rbp)
movl $0x0, -0x14(%rbp)
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2bc9a
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x1d(%rbp)
testb $0x1, -0xd(%rbp)
jne 0x2bc1f
movsbl -0x1d(%rbp), %eax
cmpl $0x7b, %eax
je 0x2bbd4
movsbl -0x1d(%rbp), %eax
cmpl $0x5b, %eax
je 0x2bbd4
movsbl -0x1d(%rbp), %eax
cmpl $0x27, %eax
jne 0x2bc1d
movb -0x1d(%rbp), %al
movb %al, -0xe(%rbp)
movl $0x1, -0x18(%rbp)
movb $0x1, -0xd(%rbp)
movsbl -0x1d(%rbp), %eax
cmpl $0x7b, %eax
jne 0x2bbf4
movb $0x7d, -0xf(%rbp)
jmp 0x2bc1b
movsbl -0x1d(%rbp), %eax
cmpl $0x5b, %eax
jne 0x2bc03
movb $0x5d, -0xf(%rbp)
jmp 0x2bc19
movsbl -0x1d(%rbp), %eax
cmpl $0x27, %eax
jne 0x2bc17
movb $0x27, -0xf(%rbp)
movl $0x0, -0x18(%rbp)
jmp 0x2bc19
jmp 0x2bc1b
jmp 0x2bc1d
jmp 0x2bc36
movsbl -0x1d(%rbp), %eax
movsbl -0xe(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2bc34
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2bc36
movsbl -0x1d(%rbp), %eax
movsbl -0xf(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2bc8a
testb $0x1, -0xd(%rbp)
je 0x2bc8a
movsbl -0x1d(%rbp), %eax
movsbl -0xe(%rbp), %ecx
cmpl %ecx, %eax
je 0x2bc5d
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jle 0x2bc7f
movsbl -0x1d(%rbp), %eax
movsbl -0xe(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2bc88
movl -0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2bc88
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2bc8a
jmp 0x2bc8c
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2bb99
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)