// File: /workspace/github_cpp_makefile_star2_O3/AutomataLab[P]JSONSki/src/QueryProcessor.cpp
// Function: QueryProcessor::goOverPriElem(long&, bitmap&)
__attribute__((always_inline)) int QueryProcessor::goOverPriElem(long& pos, bitmap& bm) {
    long word_id = pos / 64;
    bool first_interval = false;
    bool new_word = false;
    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_comma(bm);
        IntervalInfo interval;
        if (first_interval == false) {
            if (new_word == true) {
                interval = get_interval_new_word(bm.commabit);
            } else {
                interval = get_interval(pos, bm.commabit);
            }
            first_interval = true;
        } else {
            interval = next_interval(bm.commabit);
        }
        get_bitmap_rbracket(bm);
        unsigned long bitmap_rbracket = bm.rbracketbit & interval.intervalbit;
        if (bitmap_rbracket) {
            pos = get_position(bitmap_rbracket, 1);
            return ARRAY_END;
        }
        if (interval.is_complete) {
            // position before comma
            pos = interval_end(interval.intervalbit);
            pos = pos - 1;
            return SUCCESS;
        }
        // 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), %rax
leaq 0x3f(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
movq %rcx, %rax
sarq $0x6, %rax
leaq 0x30(%rdx), %r8
movq 0x2c8(%rdi), %r9
andq $-0x40, %rcx
addq %rcx, %r9
addq $0x20, %r9
leaq (%rax,%rax), %r10
xorl %ecx, %ecx
vpcmpeqd %xmm0, %xmm0, %xmm0
cmpq 0x270(%rdi), %rax
jle 0x1805b
movw $0x0, 0x4(%r8)
movl $0x0, (%r8)
movq %r10, 0x88(%rdi)
movq %rax, 0x270(%rdi)
vmovdqu -0x20(%r9), %ymm1
vmovdqa %ymm1, 0xa0(%rdi)
vmovdqa 0x140(%rdi), %ymm2
vmovdqa 0x180(%rdi), %ymm3
vpcmpeqb %ymm1, %ymm2, %ymm4
vpmovmskb %ymm4, %r14d
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %r15d
leaq 0x1(%r10), %r11
movq %r11, 0x88(%rdi)
vmovdqu (%r9), %ymm1
vmovdqa %ymm1, 0xc0(%rdi)
vpcmpeqb %ymm1, %ymm2, %ymm2
vpmovmskb %ymm2, %r11d
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %ebx
shlq $0x20, %r11
orq %r14, %r11
shlq $0x20, %rbx
orq %r15, %rbx
leaq (%rbx,%rbx), %r15
notq %r15
andq %rbx, %r15
movq 0x250(%rdi), %r12
movq 0x240(%rdi), %r13
movq %r13, %r14
xorq %r12, %r14
movq %r15, %rbp
andq %r14, %rbp
notq %r14
andq %r15, %r14
addq %rbx, %rbp
xorl %r15d, %r15d
addq %rbx, %r14
setb %r15b
movq %r15, 0x240(%rdi)
andq 0x258(%rdi), %rbp
orq %r13, %r14
andq %r12, %r14
orq %rbp, %r14
notq %r14
orq %rbx, %r14
andq %r11, %r14
movq %r14, 0xe0(%rdi)
vmovq %r14, %xmm1
vpclmulqdq $0x0, %xmm0, %xmm1, %xmm1
vmovq %xmm1, %r11
xorq 0x248(%rdi), %r11
movq %r11, (%rdi)
sarq $0x3f, %r11
movq %r11, 0x248(%rdi)
cmpb $0x0, 0x31(%rdx)
jne 0x18099
vmovdqa 0x1e0(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %r11d
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %ebx
shlq $0x20, %rbx
orq %r11, %rbx
movq (%rdi), %r11
notq %r11
andq %rbx, %r11
movq %r11, 0x8(%rdx)
movb $0x1, 0x31(%rdx)
testb $0x1, %cl
je 0x180b7
movq 0x8(%rdx), %rcx
movq %rcx, %r14
negq %r14
setb %bl
andq %rcx, %r14
leaq -0x1(%r14), %r11
orq %r14, %r11
jmp 0x18111
movq (%rsi), %rcx
leal 0x3f(%rcx), %r11d
testq %rcx, %rcx
cmovnsl %ecx, %r11d
andl $0xc0, %r11d
subl %r11d, %ecx
movl $0x1, %r15d
shlq %cl, %r15
movq %r15, %r11
negq %r11
movq %r11, %r14
btcq %rcx, %r14
movq 0x8(%rdx), %rcx
andq %r14, %rcx
movq %rcx, 0x8(%rdx)
setne %bl
je 0x18109
movq %rcx, %r12
negq %r12
andq %rcx, %r12
movq %r12, %r11
subq %r15, %r11
orq %r12, %r11
jmp 0x1810e
btsq $0x3f, %r11
andq %r14, %r11
cmpb $0x0, 0x35(%rdx)
je 0x1811d
movq 0x28(%rdx), %rcx
jmp 0x18155
vmovdqa 0x220(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %ecx
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %r14d
shlq $0x20, %r14
orq %rcx, %r14
movq (%rdi), %rcx
notq %rcx
andq %r14, %rcx
movq %rcx, 0x28(%rdx)
movb $0x1, 0x35(%rdx)
andq %r11, %rcx
jne 0x18190
incq %rax
addq $0x40, %r9
addq $0x2, %r10
movb $0x1, %cl
testb %bl, %bl
je 0x17f4b
movq 0x270(%rdi), %rcx
shlq $0x6, %rcx
bsrq %r11, %rax
xorq $0x3f, %rax
subq %rax, %rcx
addq $0x3e, %rcx
movl $0x3e9, %eax            # imm = 0x3E9
jmp 0x181a7
movq 0x270(%rdi), %rax
shlq $0x6, %rax
bsfq %rcx, %rcx
orq %rax, %rcx
movl $0x3ea, %eax            # imm = 0x3EA
movq %rcx, (%rsi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq