// File: /workspace/github_cpp_makefile_star2_O3/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 0xceeb
movq %rbx, -0x30(%rbp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x7d, %dil
movb $0x7b, %r8b
xorl %esi, %esi
xorl %r10d, %r10d
xorl %edx, %edx
xorl %r9d, %r9d
movb (%r15,%rsi), %r11b
testb $0x1, %r10b
je 0xcdeb
xorl %r12d, %r12d
cmpb %r8b, %r11b
sete %r12b
addl %r12d, %ecx
cmpb %dil, %r11b
jne 0xce16
movl %r10d, %ebx
jmp 0xce64
movzbl %r11b, %r13d
movb $0x1, %bl
cmpl $0x27, %r13d
je 0xce56
cmpl $0x7b, %r13d
je 0xce08
cmpl $0x5b, %r13d
jne 0xce16
movb $0x5d, %dil
jmp 0xce0b
movb $0x7d, %dil
movb $0x1, %r10b
movl %r11d, %r8d
movl $0x1, %ecx
cmpl %r14d, %r9d
sete %bl
andb %r10b, %bl
cmpb $0x1, %bl
jne 0xced8
cmpb %dil, %r8b
jne 0xce41
movl %ecx, %r9d
andl $0x1, %r9d
je 0xce41
movl %r14d, %r9d
movl %r8d, %edi
jmp 0xced8
movslq %edx, %rdx
movq -0x30(%rbp), %r9
movb %r11b, (%r9,%rdx)
incl %edx
movl %r14d, %r9d
jmp 0xced8
xorl %ecx, %ecx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl %r11d, %edi
movl %r11d, %r8d
xorl %r10d, %r10d
cmpb %r8b, %r11b
setne %r13b
cmpl %r14d, %r9d
jne 0xceb5
cmpb %r8b, %dil
je 0xceb5
movq %rcx, %r12
movl %ebx, %ecx
movslq %edx, %rbx
movl %r9d, -0x34(%rbp)
movl %r8d, %r9d
movl %edi, %r8d
movl %r14d, %edi
movq %rdx, %r14
movq %r15, %rdx
movq -0x30(%rbp), %r15
movb %r11b, (%r15,%rbx)
movl %ecx, %ebx
movq %r12, %rcx
movq %rdx, %r15
movq %r14, %rdx
movl %edi, %r14d
movl %r8d, %edi
movl %r9d, %r8d
movl -0x34(%rbp), %r9d
incl %edx
movb %r13b, %r10b
subl %r10d, %ecx
testl %ecx, %ecx
jle 0xcecd
cmpb %r8b, %r11b
jne 0xced5
movl %ecx, %r10d
andl $0x1, %r10d
jne 0xced5
cmpl %r14d, %r9d
jge 0xcee4
incl %r9d
movl %ebx, %r10d
incq %rsi
cmpq %rsi, %rax
jne 0xcdca
movslq %edx, %rcx
movq -0x30(%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 0x1a57a(%rip), %rax     # 0x27490
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
nop