// File: yasz24[P]eau2/src/network/./../serialize/jsonHelper.h
// Function: JSONHelper::getArrayValueAt(char*, int)
static String* getArrayValueAt(char* s, int index) {
       int len = strlen( s );
        bool valueStarted = false;
        char objStart = '{';
        char objEnd = '}';
        int startCharDepth = 0;
        char buff[len];
        int loc = 0;
        int currIndex = 0;
        //pull the top level object-value from the serialzed string
        for (int i = 0; i < len; i++){
            char temp = s[i];

            if(!valueStarted) {
                //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;
                    valueStarted = true;
                    if(temp == '{') {
                        objEnd = '}';
                    } else if(temp == '[') {
                        objEnd = ']';
                    } else if(temp == '\'') {
                        objEnd = '\'';
                        startCharDepth = 0;
                        //due to issue with indexing with apostrophes
                        currIndex = -1;
                    }   
                }
            } else if(temp == objStart) {
                startCharDepth++;
            }

            if(temp == objEnd && valueStarted) {
                if(temp != objStart) {
                    startCharDepth--;
                }
                if(index == currIndex && objEnd != objStart) {
                    buff[loc] = temp;
                    loc++;
                }
                //if we've reached the final level of end character, break out of loop
                if(startCharDepth <= 0  || (temp == objStart && startCharDepth % 2 == 0)) {
                    currIndex++;
                    if(currIndex > index) {
                        break;
                    }
                }
            } else if(valueStarted && index == currIndex) {
                if(objStart != objEnd || startCharDepth % 2 == 0) {
                    buff[loc] = temp;
                    loc++;
                }
            }
        }
        buff[loc] = '\0';
        char* classValue = buff;
        String* str = new String(classValue);
        return str;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8130
movl %eax, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movb $0x7b, -0x12(%rbp)
movb $0x7d, -0x13(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x10(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x20(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x60(%rbp)
movq %rcx, %rsp
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x1362d
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x35(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x13536
movsbl -0x35(%rbp), %eax
cmpl $0x7b, %eax
je 0x134e4
movsbl -0x35(%rbp), %eax
cmpl $0x5b, %eax
je 0x134e4
movsbl -0x35(%rbp), %eax
cmpl $0x27, %eax
jne 0x13534
movb -0x35(%rbp), %al
movb %al, -0x12(%rbp)
movl $0x1, -0x18(%rbp)
movb $0x1, -0x11(%rbp)
movsbl -0x35(%rbp), %eax
cmpl $0x7b, %eax
jne 0x13504
movb $0x7d, -0x13(%rbp)
jmp 0x13532
movsbl -0x35(%rbp), %eax
cmpl $0x5b, %eax
jne 0x13513
movb $0x5d, -0x13(%rbp)
jmp 0x13530
movsbl -0x35(%rbp), %eax
cmpl $0x27, %eax
jne 0x1352e
movb $0x27, -0x13(%rbp)
movl $0x0, -0x18(%rbp)
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
jmp 0x13530
jmp 0x13532
jmp 0x13534
jmp 0x1354d
movsbl -0x35(%rbp), %eax
movsbl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jne 0x1354b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1354d
movsbl -0x35(%rbp), %eax
movsbl -0x13(%rbp), %ecx
cmpl %ecx, %eax
jne 0x135d8
testb $0x1, -0x11(%rbp)
je 0x135d8
movsbl -0x35(%rbp), %eax
movsbl -0x12(%rbp), %ecx
cmpl %ecx, %eax
je 0x13574
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x1359f
movsbl -0x13(%rbp), %eax
movsbl -0x12(%rbp), %ecx
cmpl %ecx, %eax
je 0x1359f
movq -0x60(%rbp), %rax
movb -0x35(%rbp), %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x18(%rbp)
jle 0x135c1
movsbl -0x35(%rbp), %eax
movsbl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jne 0x135d6
movl -0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x135d6
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jle 0x135d4
jmp 0x1362d
jmp 0x135d6
jmp 0x1361d
testb $0x1, -0x11(%rbp)
je 0x1361b
movl -0xc(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x1361b
movsbl -0x12(%rbp), %eax
movsbl -0x13(%rbp), %ecx
cmpl %ecx, %eax
jne 0x13602
movl -0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x13619
movq -0x60(%rbp), %rax
movb -0x35(%rbp), %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1361b
jmp 0x1361d
jmp 0x1361f
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x134a9
movq -0x60(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq %rax, -0x40(%rbp)
movl $0x20, %edi
callq 0x8290
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rsi
callq 0xc630
jmp 0x1365c
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rsp
movq %rbp, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x8260
movq -0x50(%rbp), %rdi
callq 0x8400
nopw %cs:(%rax,%rax)
nopl (%rax)