// File: /workspace/github_c_makefile_star2_O1/mruby-zest[P]osc-bridge/src/mm_json.h
// Function: mm_json_query_del
MM_JSON_API struct mm_json_token*
mm_json_query_del(struct mm_json_token *toks, mm_json_size count,
    const mm_json_char *path, mm_json_char delemiter)
{
    mm_json_size i = 0;
    mm_json_int begin = 1;
    struct mm_json_token *iter = NULL;
    /* iterator to step over each token in the toks array */
    struct mm_json_token name;
    /* current segment in the path to search in the tree for */
    struct mm_json_token array;
    /* array token to store the current path segment array index */
    struct mm_json_object {mm_json_size index, size;} obj;
    /* current object iterator with current pair index and total pairs in object */

    MM_JSON_ASSERT(toks);
    MM_JSON_ASSERT(count);
    if (!toks || !count) return iter;
    if (!path) return &toks[i];

    iter = &toks[i];
    array.len = 0;
    array.str = NULL;

    path = mm_json_path_parse_name(&name, path, delemiter);
    while (1) {
        if (iter->type == MM_JSON_OBJECT || iter->type == MM_JSON_ARRAY || begin) {
            /* setup iteration over elements inside a object or array */
            obj.index = 0;
            if (begin) {
                begin = 0;
                obj.size = count;
            } else if (iter->type == MM_JSON_OBJECT) {
                obj.size = iter->children;
                if ((i + 1) > count) return NULL;
                iter = &toks[++i];
            } else {
                mm_json_number n;
                mm_json_size j = 0;

                /* array object so set iterator to array index */
                if (!mm_json_path_parse_array(&array, &name))
                    return NULL;
                if ((i+1) >= count)
                    return NULL;
                if (array.len < 1)
                    return NULL;
                if (mm_json_convert(&n, &array) != MM_JSON_NUMBER)
                    return NULL;
                if ((mm_json_size)n >= iter->children)
                    return NULL;
                array.str = NULL;
                array.len = 0;

                /* iterate over each array element and find the correct index */
                iter++; i++;
                for (j = 0; j < n; ++j) {
                    if (iter->type == MM_JSON_ARRAY || iter->type == MM_JSON_OBJECT) {
                        i = i + (iter->sub) + 1;
                    } else i += 1;
                    if (i > count)
                        return NULL;
                    iter = &toks[i];
                }
                if (!path) return iter;
                path = mm_json_path_parse_name(&name, path, delemiter);
            }
            continue;
        }
        {
            /* check if current table element is equal to the current path  */
            if (!mm_json_lcmp(iter, name.str, name.len)) {
                /* correct token found and end of path */
                if (!path) {
                    if ((i + 1) > count)
                        return NULL;
                    return (iter + 1);
                }
                /* check if path points to invalid token */
                if ((i+1) > count)
                    return NULL;
                if(toks[i+1].type != MM_JSON_OBJECT && toks[i+1].type != MM_JSON_ARRAY)
                    return NULL;

                /* look deeper into child object/array */
                iter = &toks[++i];
                path = mm_json_path_parse_name(&name, path, delemiter);
            } else {
                /* key is not correct iterate until end of object */
                if (++obj.index >= obj.size)
                    return NULL;
                if ((i + 1) >= count)
                    return NULL;
                if (iter[1].type == MM_JSON_ARRAY || iter[1].type == MM_JSON_OBJECT) {
                    i = i + (iter[1].sub + 2);
                } else i = i + 2;
                if (i >= count)
                    return NULL;
                iter = &toks[i];
            }
        }
    }
    return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
jne 0x5359
movq %rdi, %r13
testq %rdx, %rdx
je 0x535d
xorpd %xmm0, %xmm0
leaq -0xa0(%rbp), %rax
movapd %xmm0, (%rax)
movsbl %cl, %eax
leaq -0x78(%rbp), %rdi
movq %rdx, %rsi
movl %eax, -0x34(%rbp)
movl %eax, %edx
callq 0x537e
movq %rax, %r10
movb $0x1, %dl
xorl %r12d, %r12d
xorl %ecx, %ecx
movq %r13, %r14
movq %r8, %rsi
movq %rsi, %r8
movl 0x20(%r14), %eax
testb $0x1, %dl
movq %rsi, -0x30(%rbp)
jne 0x50be
leal -0x1(%rax), %edx
cmpl $0x2, %edx
jb 0x50be
xorl %r15d, %r15d
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
testq %r14, %r14
sete %dl
testq %rax, %rax
sete %sil
orb %dl, %sil
testq %rcx, %rcx
sete %dl
orb %sil, %dl
jne 0x505a
movq 0x8(%r14), %rdx
cmpq %rdx, %rcx
cmovaeq %rdx, %rcx
testq %rdx, %rdx
je 0x500e
movq (%r14), %rdx
xorl %esi, %esi
movb (%rdx,%rsi), %dil
cmpb (%rax,%rsi), %dil
jne 0x505a
incq %rsi
cmpq %rsi, %rcx
jne 0x4ffc
incq %r12
testq %r10, %r10
je 0x536f
cmpq %rbx, %r12
ja 0x5359
leaq (%r12,%r12,4), %rax
movl 0x20(%r13,%rax,8), %ecx
decl %ecx
cmpl $0x1, %ecx
ja 0x5359
leaq (,%rax,8), %r14
addq %r13, %r14
leaq -0x78(%rbp), %rdi
movq %r10, %rsi
movl -0x34(%rbp), %edx
callq 0x537e
movq -0x30(%rbp), %r8
movq %rax, %r10
jmp 0x50ac
incq %r15
cmpq %r8, %r15
jae 0x5359
leaq 0x1(%r12), %rcx
movl $0x0, %eax
cmpq %rbx, %rcx
jae 0x5360
movl 0x48(%r14), %ecx
decl %ecx
movl $0x2, %eax
cmpl $0x1, %ecx
ja 0x5091
movq 0x40(%r14), %rax
addq $0x2, %rax
addq %rax, %r12
cmpq %rbx, %r12
jae 0x5359
leaq (%r12,%r12,4), %rax
leaq (,%rax,8), %r14
addq %r13, %r14
movl 0x20(%r14), %eax
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
jae 0x4fc4
movb $0x1, %cl
movl %ecx, %edi
movb $0x1, %cl
xorl %edx, %edx
movq %rbx, %rsi
testb $0x1, %dil
je 0x4fa1
cmpl $0x1, %eax
jne 0x50fc
incq %r12
cmpq %rbx, %r12
ja 0x5359
movq 0x10(%r14), %rsi
leaq (%r12,%r12,4), %rax
leaq (,%rax,8), %r14
addq %r13, %r14
xorl %edx, %edx
jmp 0x4fa1
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rax, -0xa0(%rbp)
testq %rax, %rax
je 0x5163
movb (%rax), %sil
movq %rax, %rdx
testb %sil, %sil
je 0x5152
movl %ecx, %edi
notl %edi
sarl $0x1f, %edi
testl %ecx, %ecx
movl $0x0, %r8d
cmovnsl %ecx, %r8d
addl %edi, %r8d
movq %rax, %rdx
cmpb $0x5b, %sil
je 0x515d
movb 0x1(%rdx), %sil
incq %rdx
testb %sil, %sil
je 0x5152
leal (%r8,%rdi), %r9d
testl %r8d, %r8d
movl %r9d, %r8d
jns 0x5134
testl %ecx, %ecx
movl $0x0, %esi
cmovnsq %rsi, %rdx
movq -0x30(%rbp), %r8
jmp 0x5165
xorl %edx, %edx
testq %rdx, %rdx
je 0x5318
movq %rdx, %rsi
subq %rax, %rsi
cmpq %rsi, %rcx
jbe 0x5318
movq %r10, -0x40(%rbp)
movl %ecx, %edi
subl %esi, %edi
movb (%rdx), %r8b
movq %rdx, %rsi
testb %r8b, %r8b
je 0x51ca
movl %edi, %r9d
notl %r9d
sarl $0x1f, %r9d
testl %edi, %edi
movl $0x0, %r10d
cmovnsl %edi, %r10d
addl %r9d, %r10d
movq %rdx, %rsi
cmpb $0x5d, %r8b
je 0x51d5
movb 0x1(%rsi), %r8b
incq %rsi
testb %r8b, %r8b
je 0x51ca
leal (%r10,%r9), %r11d
testl %r10d, %r10d
movl %r11d, %r10d
jns 0x51ac
testl %edi, %edi
movl $0x0, %edi
cmovnsq %rdi, %rsi
testq %rsi, %rsi
setne %dil
movq %rsi, %r8
subq %rax, %r8
cmpq %rcx, %r8
setb %al
andb %dil, %al
cmpb $0x1, %al
movq -0x40(%rbp), %r10
jne 0x531e
leaq 0x1(%rdx), %rax
movq %rax, -0xa0(%rbp)
decq %rsi
movq %rsi, %rax
subq %rdx, %rax
movq %rax, -0x98(%rbp)
leaq 0x1(%r12), %r15
xorl %edi, %edi
cmpq %rbx, %r15
movq -0x30(%rbp), %r8
jae 0x5328
cmpq %rdx, %rsi
je 0x5328
leaq -0x50(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4464
cmpl $0x3, %eax
jne 0x533d
movsd -0x50(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0x3dd3(%rip), %xmm1     # 0x9038
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
cmpq %rdx, 0x10(%r14)
movq -0x40(%rbp), %r10
movq -0x30(%rbp), %r8
jbe 0x5318
addq $0x28, %r14
ucomisd 0x4322(%rip), %xmm0     # 0x95b0
xorpd %xmm1, %xmm1
movapd %xmm1, -0xa0(%rbp)
jbe 0x52f5
movl $0x1, %eax
movl 0x20(%r14), %ecx
decl %ecx
cmpl $0x1, %ecx
ja 0x52b0
addq 0x18(%r14), %r15
incq %r15
cmpq %rbx, %r15
ja 0x5352
leaq (%r15,%r15,4), %rcx
leaq (,%rcx,8), %r14
addq %r13, %r14
movq %rax, %xmm1
punpckldq 0x3d38(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3d40(%rip), %xmm1     # 0x9020
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
incq %rax
ucomisd %xmm2, %xmm0
ja 0x52a1
testq %r10, %r10
je 0x5347
leaq -0x78(%rbp), %rdi
movq %r10, %rsi
movl -0x34(%rbp), %edx
callq 0x537e
movq %rax, %r10
movb $0x1, %dil
movq %r15, %r12
movq -0x48(%rbp), %rax
jmp 0x5322
xorl %eax, %eax
xorl %edi, %edi
jmp 0x532a
xorl %eax, %eax
xorl %edi, %edi
movq -0x30(%rbp), %r8
jmp 0x532a
xorl %eax, %eax
movb $0x1, %cl
xorl %edx, %edx
movq %rax, -0x48(%rbp)
testb %dil, %dil
jne 0x4f9e
jmp 0x5360
xorl %eax, %eax
xorl %edi, %edi
movq -0x40(%rbp), %r10
jmp 0x5322
xorl %r10d, %r10d
movq %r14, %rax
movq %r15, %r12
jmp 0x5320
xorl %eax, %eax
movq %r15, %r12
jmp 0x531a
xorl %eax, %eax
jmp 0x5360
movq %r13, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x28, %r14
xorl %eax, %eax
cmpq %rbx, %r12
cmovbeq %r14, %rax
jmp 0x5360