// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r14d
movq %rdi, %r15
callq 0x7100
movl %eax, %ecx
movq %rsp, %rbx
addq $0xf, %rcx
andq $-0x10, %rcx
subq %rcx, %rbx
movq %rbx, %rsp
xorl %ecx, %ecx
testl %eax, %eax
jle 0xd128
movq %rbx, -0x38(%rbp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
decq %rax
movb $0x7d, %sil
movb $0x7b, %r10b
xorl %edx, %edx
xorl %r8d, %r8d
xorl %edi, %edi
xorl %r9d, %r9d
movb (%r15,%rdx), %r11b
testb $0x1, %r8b
je 0xd032
xorl %r12d, %r12d
cmpb %r10b, %r11b
sete %r12b
addl %r12d, %ecx
jmp 0xd06e
movzbl %r11b, %r12d
cmpl $0x27, %r12d
je 0xd05d
cmpl $0x5b, %r12d
je 0xd050
cmpl $0x7b, %r12d
jne 0xd06e
movb $0x1, %r8b
movb $0x7d, %sil
jmp 0xd056
movb $0x1, %r8b
movb $0x5d, %sil
movl $0x1, %ecx
jmp 0xd06b
movb $0x1, %r8b
movb $0x27, %sil
xorl %ecx, %ecx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl %r11d, %r10d
cmpb %sil, %r11b
jne 0xd0e2
testb $0x1, %r8b
je 0xd0e2
xorl %r12d, %r12d
cmpb %r10b, %r11b
setne %r13b
cmpl %r14d, %r9d
jne 0xd0ba
cmpb %r10b, %sil
je 0xd0ba
movslq %edi, %rbx
movb %sil, -0x29(%rbp)
movq %r9, %rsi
movq %rdi, %r9
movl %r14d, %edi
movq %r15, %r14
movq -0x38(%rbp), %r15
movb %r11b, (%r15,%rbx)
movq %r14, %r15
movl %edi, %r14d
movq %r9, %rdi
movq %rsi, %r9
movb -0x29(%rbp), %sil
incl %edi
movb %r13b, %r12b
subl %r12d, %ecx
testl %ecx, %ecx
jle 0xd0d5
xorl %r12d, %r12d
cmpb %r10b, %r11b
jne 0xd10c
movl %ecx, %r11d
andl $0x1, %r11d
jne 0xd10c
cmpl %r14d, %r9d
leal 0x1(%r9), %r9d
setge %r12b
jmp 0xd10c
cmpl %r14d, %r9d
sete %bl
andb %r8b, %bl
cmpb $0x1, %bl
jne 0xd109
cmpb %sil, %r10b
jne 0xd0fc
movl %ecx, %ebx
andl $0x1, %ebx
jne 0xd109
movslq %edi, %rdi
movq -0x38(%rbp), %rbx
movb %r11b, (%rbx,%rdi)
incl %edi
xorl %r12d, %r12d
testb %r12b, %r12b
jne 0xd121
leaq 0x1(%rdx), %r11
cmpq %rdx, %rax
movq %r11, %rdx
jne 0xd019
movslq %edi, %rcx
movq -0x38(%rbp), %rbx
movb $0x0, (%rbx,%rcx)
movl $0x20, %edi
callq 0x7230
movq %rax, %r14
movq %rbx, %rdi
callq 0x7100
movq %rax, %r15
movq $0x0, 0x8(%r14)
leaq 0x1b305(%rip), %rax     # 0x28458
movq %rax, (%r14)
movq %r15, 0x10(%r14)
leaq 0x1(%r15), %r12
movq %r12, %rdi
callq 0x7030
movq %rax, %r13
movq %rax, 0x18(%r14)
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x71a0
movb $0x0, (%r13,%r15)
movq %r14, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x7200
movq %rbx, %rdi
callq 0x73b0