// File: /workspace/github_cpp_makefile_star2_O2/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 %rdx, %r8
movq (%rsi), %rax
movabsq $0x40, %rcx
cqto
idivq %rcx
movq %rax, %r9
leaq 0x30(%r8), %r11
movq 0x2c8(%rdi), %rax
movq %r9, %rcx
shlq $0x6, %rcx
leaq (%rcx,%rax), %rbx
addq $0x20, %rbx
movq %r9, %r14
addq %r9, %r14
xorl %eax, %eax
vpcmpeqd %xmm0, %xmm0, %xmm0
cmpq 0x270(%rdi), %r9
jle 0x17f94
andw $0x0, 0x4(%r11)
andl $0x0, (%r11)
movq %r14, 0x88(%rdi)
movq %r9, 0x270(%rdi)
vmovdqu -0x20(%rbx), %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(%r14), %rcx
movq %rcx, 0x88(%rdi)
vmovdqu (%rbx), %ymm1
vmovdqa %ymm1, 0xc0(%rdi)
vpcmpeqb %ymm1, %ymm2, %ymm2
vpmovmskb %ymm2, %ecx
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %edx
shlq $0x20, %rcx
orq %r12, %rcx
shlq $0x20, %rdx
orq %r13, %rdx
leaq (%rdx,%rdx), %r13
notq %r13
andq %rdx, %r13
movq 0x250(%rdi), %rbp
movq 0x240(%rdi), %r15
movq %r15, %r12
xorq %rbp, %r12
movq %r13, %r10
andq %r12, %r10
notq %r12
andq %r13, %r12
addq %rdx, %r10
xorl %r13d, %r13d
addq %rdx, %r12
setb %r13b
movq %r13, 0x240(%rdi)
andq 0x258(%rdi), %r10
orq %r15, %r12
andq %rbp, %r12
orq %r10, %r12
notq %r12
orq %rdx, %r12
andq %rcx, %r12
movq %r12, 0xe0(%rdi)
vmovq %r12, %xmm1
vpclmulqdq $0x0, %xmm0, %xmm1, %xmm1
vmovq %xmm1, %rcx
xorq 0x248(%rdi), %rcx
movq %rcx, (%rdi)
sarq $0x3f, %rcx
movq %rcx, 0x248(%rdi)
cmpb $0x0, 0x31(%r8)
jne 0x17fd4
vmovdqa 0x1e0(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %ecx
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %edx
shlq $0x20, %rdx
orq %rcx, %rdx
movq (%rdi), %rcx
notq %rcx
andq %rdx, %rcx
movq %rcx, 0x8(%r8)
movb $0x1, 0x31(%r8)
testb $0x1, %al
je 0x17ff1
movq 0x8(%r8), %rax
movq %rax, %r10
negq %r10
setb %cl
andq %rax, %r10
leaq -0x1(%r10), %rdx
orq %r10, %rdx
jmp 0x1804c
movq (%rsi), %rax
cqto
movabsq $0x40, %rcx
idivq %rcx
movq %rdx, %rcx
movabsq $0x1, %r12
shlq %cl, %r12
movq %r12, %rdx
negq %rdx
movq %rdx, %rax
btcq %rcx, %rax
movq 0x8(%r8), %r13
andq %rax, %r13
movq %r13, 0x8(%r8)
setne %cl
je 0x18044
movq %r13, %r10
negq %r10
andq %r13, %r10
movq %r10, %rdx
subq %r12, %rdx
orq %r10, %rdx
jmp 0x18049
btsq $0x3f, %rdx
andq %rax, %rdx
cmpb $0x0, 0x35(%r8)
je 0x18059
movq 0x28(%r8), %rax
jmp 0x18092
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 (%rdi), %rax
notq %rax
andq %r10, %rax
movq %rax, 0x28(%r8)
movb $0x1, 0x35(%r8)
andq %rdx, %rax
jne 0x180cd
incq %r9
addq $0x40, %rbx
addq $0x2, %r14
movb $0x1, %al
testb %cl, %cl
je 0x17e8a
movq 0x270(%rdi), %rcx
shlq $0x6, %rcx
bsrq %rdx, %rax
xorq $0x3f, %rax
subq %rax, %rcx
addq $0x3e, %rcx
movl $0x3e9, %eax            # imm = 0x3E9
jmp 0x180e4
movq 0x270(%rdi), %rdx
shlq $0x6, %rdx
bsfq %rax, %rcx
orq %rdx, %rcx
movl $0x3ea, %eax            # imm = 0x3EA
movq %rcx, (%rsi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
nop