// File: /workspace/github_cpp_makefile_star2_O1/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), %r9
testq %rax, %rax
cmovnsq %rax, %r9
sarq $0x6, %r9
leaq 0x30(%rdx), %r10
movq 0x2c8(%rdi), %r11
movl $0x0, -0x4(%rsp)
vpcmpeqd %xmm0, %xmm0, %xmm0
xorl %ecx, %ecx
cmpq 0x270(%rdi), %r9
jle 0x17f89
leaq (%r9,%r9), %r14
movw $0x0, 0x4(%r10)
movl $0x0, (%r10)
movq %r14, 0x88(%rdi)
movq %r9, 0x270(%rdi)
movq %r9, %r14
shlq $0x6, %r14
vmovdqu (%r11,%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(,%r9,2), %r14
movq %r14, 0x88(%rdi)
shlq $0x5, %r14
vmovdqu (%r11,%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), %r8
movq %r8, %r12
xorq %rbp, %r12
movq %r13, %rbx
andq %r12, %rbx
notq %r12
andq %r13, %r12
addq %r15, %rbx
xorl %r13d, %r13d
addq %r15, %r12
setb %r13b
movq %r13, 0x240(%rdi)
andq 0x258(%rdi), %rbx
orq %r8, %r12
andq %rbp, %r12
orq %rbx, %r12
notq %r12
orq %r15, %r12
andq %r14, %r12
movq %r12, 0xe0(%rdi)
vmovq %r12, %xmm1
vpclmulqdq $0x0, %xmm0, %xmm1, %xmm1
vmovq %xmm1, %r8
xorq 0x248(%rdi), %r8
movq %r8, (%rdi)
sarq $0x3f, %r8
movq %r8, 0x248(%rdi)
cmpb $0x0, 0x31(%rdx)
jne 0x17fcb
vmovdqa 0x1e0(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %r8d
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %ebx
shlq $0x20, %rbx
orq %r8, %rbx
movq %rbx, 0x8(%rdx)
movq (%rdi), %r8
notq %r8
andq %rbx, %r8
movq %r8, 0x8(%rdx)
movb $0x1, 0x31(%rdx)
testb $0x1, %cl
jne 0x17ff4
testb $0x1, -0x4(%rsp)
je 0x18026
movq 0x8(%rdx), %rcx
movq %rcx, %r8
negq %r8
setb %bpl
andq %rcx, %r8
leaq -0x1(%r8), %r14
orq %r8, %r14
jmp 0x1809e
movq 0x8(%rdx), %r8
movq %r8, %r15
negq %r15
andq %r8, %r15
leaq -0x1(%r8), %r14
andq %r8, %r14
movq %r14, 0x8(%rdx)
setne %bpl
je 0x18079
movq %r14, %r8
negq %r8
andq %r14, %r8
movq %r8, %r14
subq %r15, %r14
orq %r8, %r14
jmp 0x180a0
movq (%rsi), %rcx
leal 0x3f(%rcx), %r8d
testq %rcx, %rcx
cmovnsl %ecx, %r8d
andl $0xc0, %r8d
subl %r8d, %ecx
movl $0x1, %r12d
shlq %cl, %r12
movq %r12, %r14
negq %r14
movq %r14, %r15
btcq %rcx, %r15
movq 0x8(%rdx), %rcx
andq %r15, %rcx
movq %rcx, 0x8(%rdx)
setne %bpl
je 0x1808e
movq %rcx, %r8
negq %r8
andq %rcx, %r8
movq %r8, %r14
subq %r12, %r14
orq %r8, %r14
jmp 0x1809b
negq %r15
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
orq %r8, %r15
movq %r15, %r14
jmp 0x180a0
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
orq %rcx, %r14
andq %r15, %r14
movb $0x1, %cl
cmpb $0x0, 0x35(%rdx)
jne 0x180e2
vmovdqa 0x220(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %r8d
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %ebx
shlq $0x20, %rbx
orq %r8, %rbx
movq %rbx, 0x28(%rdx)
movq (%rdi), %r8
notq %r8
andq %rbx, %r8
movq %r8, 0x28(%rdx)
movb $0x1, 0x35(%rdx)
movq 0x28(%rdx), %r15
andq %r14, %r15
je 0x18107
movq 0x270(%rdi), %rax
shlq $0x6, %rax
bsfq %r15, %r8
orq %rax, %r8
movq %r8, (%rsi)
movl $0x3ea, %eax            # imm = 0x3EA
jmp 0x1812e
testb %bpl, %bpl
je 0x1813b
movq 0x270(%rdi), %rax
shlq $0x6, %rax
bsrq %r14, %r8
xorq $0x3f, %r8
subq %r8, %rax
addq $0x3e, %rax
movq %rax, (%rsi)
movl $0x3e9, %eax            # imm = 0x3E9
xorl %ebp, %ebp
testb %bpl, %bpl
jne 0x17e65
jmp 0x1814b
incq %r9
movb $0x1, %cl
movl %ecx, -0x4(%rsp)
xorl %ecx, %ecx
movb $0x1, %bpl
jmp 0x18130
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
nop