// File: /workspace/github_c_makefile_star2_O3/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, %r14
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
jne 0x52d9
movq %rdi, %r8
testq %rdx, %rdx
je 0x52e3
xorpd %xmm0, %xmm0
leaq -0xa0(%rbp), %rax
movapd %xmm0, (%rax)
movsbl %cl, %eax
leaq -0x70(%rbp), %rdi
movq %rdx, %rsi
movl %eax, -0x34(%rbp)
movl %eax, %edx
movq %r8, -0x40(%rbp)
callq 0x5313
movq -0x40(%rbp), %r8
movq %rax, %r10
movb $0x1, %al
movq $0x0, -0x30(%rbp)
xorl %r13d, %r13d
xorl %ecx, %ecx
movq %r8, %r15
movl 0x20(%r15), %edx
leal -0x1(%rdx), %esi
movq %rbx, %rdi
movq %rdi, %rbx
testb $0x1, %al
jne 0x4f94
cmpl $0x2, %esi
jae 0x4fa5
xorl %eax, %eax
movq %r14, %rdi
testb $0x1, %cl
movb $0x1, %cl
je 0x4f88
jmp 0x5091
xorl %r12d, %r12d
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
testq %rax, %rax
sete %dl
testq %rcx, %rcx
sete %sil
orb %dl, %sil
jne 0x5035
movq 0x8(%r15), %rdx
cmpq %rdx, %rcx
cmovaeq %rdx, %rcx
testq %rdx, %rdx
je 0x4fe9
movq (%r15), %rdx
xorl %esi, %esi
movb (%rdx,%rsi), %dil
cmpb (%rax,%rsi), %dil
jne 0x5035
incq %rsi
cmpq %rsi, %rcx
jne 0x4fd7
incq %r13
testq %r10, %r10
je 0x52fa
cmpq %r14, %r13
ja 0x52e7
leaq (,%r13,4), %rax
addq %r13, %rax
movl 0x20(%r8,%rax,8), %ecx
decl %ecx
cmpl $0x1, %ecx
ja 0x52e7
leaq (%r8,%rax,8), %r15
leaq -0x70(%rbp), %rdi
movq %r10, %rsi
movl -0x34(%rbp), %edx
callq 0x5313
movq -0x40(%rbp), %r8
movq %rax, %r10
jmp 0x5081
incq %r12
cmpq %rbx, %r12
jae 0x52e7
leaq 0x1(%r13), %rax
cmpq %r14, %rax
jae 0x52e7
movl 0x48(%r15), %ecx
decl %ecx
movl $0x2, %eax
cmpl $0x1, %ecx
ja 0x5066
movq 0x40(%r15), %rax
addq $0x2, %rax
addq %rax, %r13
cmpq %r14, %r13
jae 0x52e7
leaq (,%r13,4), %rax
addq %r13, %rax
leaq (%r8,%rax,8), %r15
movl 0x20(%r15), %edx
leal -0x1(%rdx), %eax
cmpl $0x2, %eax
jae 0x4fa8
cmpl $0x1, %edx
jne 0x50ba
incq %r13
cmpq %r14, %r13
ja 0x52e7
movq 0x10(%r15), %rbx
leaq (,%r13,4), %rax
addq %r13, %rax
leaq (%r8,%rax,8), %r15
jmp 0x52d0
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rax, -0xa0(%rbp)
testq %rax, %rax
je 0x52e7
movb (%rax), %sil
testb %sil, %sil
je 0x5116
movl %ecx, %edi
notl %edi
sarl $0x1f, %edi
testl %ecx, %ecx
movl $0x0, %r8d
cmovnsl %ecx, %r8d
addl %edi, %r8d
xorl %edx, %edx
cmpb $0x5b, %sil
je 0x5146
movb 0x1(%rax,%rdx), %sil
incq %rdx
testb %sil, %sil
je 0x5111
leal (%r8,%rdi), %r9d
testl %r8d, %r8d
movl %r9d, %r8d
jns 0x50f2
addq %rax, %rdx
jmp 0x511b
xorl %esi, %esi
movq %rax, %rdx
testl %ecx, %ecx
jns 0x52e7
movq %rdx, %rdi
subq %rax, %rdi
cmpq %rdi, %rcx
jbe 0x52e7
movl %ecx, %r9d
subl %edi, %r9d
setns %dil
movq %rdx, %r8
testb %sil, %sil
jne 0x5160
jmp 0x51a1
cmpq %rdx, %rcx
jbe 0x52e7
movl %ecx, %r9d
subl %edx, %r9d
leaq (%rax,%rdx), %rdx
setns %dil
movb $0x5b, %sil
movq %r10, %r12
movzbl %dil, %r8d
movl %r8d, %r10d
negl %r10d
testb %r8b, %r8b
movl $0x0, %r11d
cmovel %r11d, %r9d
subl %r8d, %r9d
movq %rdx, %r8
cmpb $0x5d, %sil
je 0x51ab
movb 0x1(%r8), %sil
incq %r8
testb %sil, %sil
je 0x519e
leal (%r9,%r10), %r11d
testl %r9d, %r9d
movl %r11d, %r9d
jns 0x5180
movq %r12, %r10
testb %dil, %dil
je 0x51ae
jmp 0x52e7
movq %r12, %r10
movq %r8, %rsi
subq %rax, %rsi
cmpq %rcx, %rsi
jae 0x52e7
movq %rdx, %rax
incq %rax
movq %rax, -0xa0(%rbp)
decq %r8
movq %r8, %rax
subq %rdx, %rax
movq %rax, -0x98(%rbp)
incq %r13
cmpq %r14, %r13
jae 0x52e7
cmpq %rdx, %r8
je 0x52e7
movq %r10, %r12
leaq -0x48(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4450
cmpl $0x3, %eax
jne 0x52e7
movsd -0x48(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0x3e10(%rip), %xmm1     # 0x9038
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
cmpq %rdx, 0x10(%r15)
jbe 0x52e7
addq $0x28, %r15
ucomisd 0x4367(%rip), %xmm0     # 0x95b0
xorpd %xmm1, %xmm1
movapd %xmm1, -0xa0(%rbp)
jbe 0x52b5
movl $0x1, %eax
movq -0x40(%rbp), %rdx
movq %r12, %rsi
movl 0x20(%r15), %ecx
decl %ecx
cmpl $0x1, %ecx
ja 0x5272
addq 0x18(%r15), %r13
incq %r13
cmpq %r14, %r13
ja 0x52e7
leaq (,%r13,4), %rcx
addq %r13, %rcx
leaq (%rdx,%rcx,8), %r15
movq %rax, %xmm1
punpckldq 0x3d7a(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3d82(%rip), %xmm1     # 0x9020
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
incq %rax
ucomisd %xmm2, %xmm0
ja 0x5263
jmp 0x52b8
movq %r12, %rsi
testq %rsi, %rsi
je 0x530d
leaq -0x70(%rbp), %rdi
movl -0x34(%rbp), %edx
callq 0x5313
movq -0x40(%rbp), %r8
movq %rax, %r10
movb $0x1, %cl
xorl %eax, %eax
jmp 0x4f7e
movq $0x0, -0x30(%rbp)
jmp 0x52e7
movq %r8, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x28, %r15
xorl %eax, %eax
cmpq %r14, %r13
cmovbeq %r15, %rax
movq %rax, -0x30(%rbp)
jmp 0x52e7
movq %r15, -0x30(%rbp)
jmp 0x52e7