// File: /workspace/github_cpp_makefile_star2_O1/AutomataLab[P]JSONSki/src/QueryProcessor.cpp
// Function: QueryProcessor::goOverAry(long&, bitmap&)
__attribute__((always_inline)) void QueryProcessor::goOverAry(long& pos, bitmap& bm) {
    int num_open = 1;
    int num_close = 0;
    long word_id = pos / 64;
    bool first_interval = false;
    bool new_word = false;
    while (true) {
        while (word_id < mNumWords) {
            if (word_id > top_word) {
                // build basic bitmaps for the next word
                resetBitmap(bm);
                start_id = word_id * 2;
                build_bitmap_basic();
            }
            get_bitmap_lbracket(bm);
            IntervalInfo interval;
            if (first_interval == false) {
                if (new_word == true) {
                    interval = get_interval_new_word(bm.lbracketbit);
                } else {
                    interval = get_interval(pos, bm.lbracketbit);
                } 
                first_interval = true;
            } else {
                interval = next_interval(bm.lbracketbit);
            } 
            get_bitmap_rbracket(bm);
            unsigned long bitmap_rbracket = bm.rbracketbit & interval.intervalbit;
            bitset<64> tempbit1(bm.rbracketbit);
            num_close = __builtin_popcountl(bitmap_rbracket);
            if (num_close < num_open) {
                if (interval.is_complete == true) {
                    num_open = num_open - num_close + 1;
                    break;
                } else {
                    num_open = num_open - num_close;
                }
            } else {  // results found
                pos = get_position(bitmap_rbracket, num_open);  //bm.rbracebit
                return;
            }
            // interval is incomplete in the current word
            ++word_id;
            first_interval = false;
            new_word = true;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rsi), %rcx
leaq 0x3f(%rcx), %r8
testq %rcx, %rcx
cmovnsq %rcx, %r8
sarq $0x6, %r8
leaq 0x30(%rdx), %r9
movl $0x1, %r11d
movl $0x0, -0x4(%rsp)
vpcmpeqd %xmm0, %xmm0, %xmm0
xorl %ecx, %ecx
movq 0x2c8(%rdi), %rbx
cmpq 0x2e0(%rdi), %r8
jge 0x1718e
cmpq 0x270(%rdi), %r8
jle 0x172c2
leaq (%r8,%r8), %r14
movw $0x0, 0x4(%r9)
movl $0x0, (%r9)
movq %r14, 0x88(%rdi)
movq %r8, 0x270(%rdi)
movq %r8, %r14
shlq $0x6, %r14
vmovdqu (%rbx,%r14), %ymm1
vmovdqa %ymm1, 0xa0(%rdi)
vmovdqa 0x140(%rdi), %ymm2
vmovdqa 0x180(%rdi), %ymm3
vpcmpeqb %ymm1, %ymm2, %ymm4
vpmovmskb %ymm4, %r12d
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %r13d
leaq 0x1(,%r8,2), %r14
movq %r14, 0x88(%rdi)
shlq $0x5, %r14
vmovdqu (%rbx,%r14), %ymm1
vmovdqa %ymm1, 0xc0(%rdi)
vpcmpeqb %ymm1, %ymm2, %ymm2
vpmovmskb %ymm2, %r14d
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %r15d
shlq $0x20, %r14
orq %r12, %r14
shlq $0x20, %r15
orq %r13, %r15
leaq (%r15,%r15), %r13
notq %r13
andq %r15, %r13
movq 0x250(%rdi), %rbp
movq 0x240(%rdi), %rax
movq %rax, %r12
xorq %rbp, %r12
movq %r13, %r10
andq %r12, %r10
notq %r12
andq %r13, %r12
addq %r15, %r10
xorl %r13d, %r13d
addq %r15, %r12
setb %r13b
movq %r13, 0x240(%rdi)
andq 0x258(%rdi), %r10
orq %rax, %r12
andq %rbp, %r12
orq %r10, %r12
notq %r12
orq %r15, %r12
andq %r14, %r12
movq %r12, 0xe0(%rdi)
vmovq %r12, %xmm1
vpclmulqdq $0x0, %xmm0, %xmm1, %xmm1
vmovq %xmm1, %rax
xorq 0x248(%rdi), %rax
movq %rax, (%rdi)
sarq $0x3f, %rax
movq %rax, 0x248(%rdi)
cmpb $0x0, 0x34(%rdx)
jne 0x17304
vmovdqa 0x200(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %eax
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %r10d
shlq $0x20, %r10
orq %rax, %r10
movq %r10, 0x20(%rdx)
movq (%rdi), %rax
notq %rax
andq %r10, %rax
movq %rax, 0x20(%rdx)
movb $0x1, 0x34(%rdx)
testb $0x1, %cl
jne 0x1732d
testb $0x1, -0x4(%rsp)
je 0x1735f
movq 0x20(%rdx), %rax
movq %rax, %rcx
negq %rcx
setb %bpl
andq %rax, %rcx
leaq -0x1(%rcx), %r14
orq %rcx, %r14
jmp 0x173cf
movq 0x20(%rdx), %rax
movq %rax, %r15
negq %r15
andq %rax, %r15
leaq -0x1(%rax), %r14
andq %rax, %r14
movq %r14, 0x20(%rdx)
setne %bpl
je 0x173aa
movq %r14, %rax
negq %rax
andq %r14, %rax
movq %rax, %r14
subq %r15, %r14
orq %rax, %r14
jmp 0x173d1
movq (%rsi), %rcx
leal 0x3f(%rcx), %eax
testq %rcx, %rcx
cmovnsl %ecx, %eax
andl $0xc0, %eax
subl %eax, %ecx
movl $0x1, %r12d
shlq %cl, %r12
movq %r12, %r14
negq %r14
movq %r14, %r15
btcq %rcx, %r15
movq 0x20(%rdx), %rcx
andq %r15, %rcx
movq %rcx, 0x20(%rdx)
setne %bpl
je 0x173bf
movq %rcx, %rax
negq %rax
andq %rcx, %rax
movq %rax, %r14
subq %r12, %r14
jmp 0x173c9
negq %r15
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
orq %rax, %r15
movq %r15, %r14
jmp 0x173d1
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
orq %rax, %r14
andq %r15, %r14
movb $0x1, %cl
cmpb $0x0, 0x35(%rdx)
jne 0x17413
vmovdqa 0x220(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %eax
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %r10d
shlq $0x20, %r10
orq %rax, %r10
movq %r10, 0x28(%rdx)
movq (%rdi), %rax
notq %rax
andq %r10, %rax
movq %rax, 0x28(%rdx)
movb $0x1, 0x35(%rdx)
andq 0x28(%rdx), %r14
popcntq %r14, %r12
movl %r11d, %r15d
subl %r12d, %r15d
jle 0x17436
testb %bpl, %bpl
je 0x1746a
subl %r12d, %r11d
incl %r11d
movl $0x5, %ebp
jmp 0x1747a
cmpl $0x2, %r11d
jl 0x1744e
leal 0x1(%r11), %ebp
leaq -0x1(%r14), %rax
andq %rax, %r14
decl %ebp
cmpl $0x2, %ebp
jg 0x17440
movq 0x270(%rdi), %rax
shlq $0x6, %rax
bsfq %r14, %r10
orq %rax, %r10
movq %r10, (%rsi)
movl $0x1, %ebp
jmp 0x1747a
incq %r8
xorl %ecx, %ecx
movb $0x1, %al
movl %eax, -0x4(%rsp)
movl %r15d, %r11d
xorl %ebp, %ebp
testl %ebp, %ebp
je 0x17195
cmpl $0x5, %ebp
je 0x1718e
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
nop