// File: /workspace/github_cpp_makefile_star2_O1/AutomataLab[P]JSONSki/src/QueryProcessor.cpp
// Function: QueryProcessor::goOverPrimElemsInRange(long&, int, bitmap&)
__attribute__((always_inline)) JumpInfo QueryProcessor::goOverPrimElemsInRange(long& pos, int num_elements, bitmap& bm) {
    int word_id = pos / 64;
    bool new_word = false;
    int num_comma = 0;
    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_lbrace(bm);
        get_bitmap_lbracket(bm);
        unsigned long bitmap_bracket = bm.lbracebit | bm.lbracketbit;
        IntervalInfo interval;
        if (new_word == true) {
            interval = get_interval_new_word(bitmap_bracket);
        } else {
            interval = get_interval(pos, bitmap_bracket);
        }
        build_bitmap_rbracket(bm);
        unsigned long bitmap_rbracket = bm.rbracketbit & interval.intervalbit;
        get_bitmap_comma(bm);
        unsigned long bitmap_comma = bm.commabit & interval.intervalbit;
        if (bitmap_rbracket) {
            bitmap_comma = bitmap_comma & (bitmap_rbracket ^ (bitmap_rbracket - 1));
        }
        num_comma = num_comma +__builtin_popcountl(bitmap_comma);
        if (num_comma >= num_elements) {
            long temp_pos = word_id * 64 + __builtin_ctzll(bitmap_comma);
            pos = get_position(bitmap_comma, num_elements);
            JumpInfo ji(SUCCESS);
            return ji;
        }
        if (bitmap_rbracket) {
            // end of array
            pos = get_position(bitmap_rbracket, 1);
            JumpInfo ji(ARRAY_END);
            return ji;
        } else {
            if (interval.is_complete) {
                pos = interval_end(interval.intervalbit);// + 1;
                JumpInfo ji(PARTIAL_SKIP, num_comma);
                return ji;
            }
            num_elements -= num_comma;
        }
        // interval is incomplete in the current word
        ++word_id;
        new_word = true;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rax
movq (%rsi), %rcx
leaq 0x3f(%rcx), %r8
testq %rcx, %rcx
cmovnsq %rcx, %r8
shrq $0x6, %r8
leaq 0x30(%rax), %rcx
movq %rcx, -0x8(%rsp)
movq 0x2c8(%rdi), %rcx
movq %rcx, -0x10(%rsp)
xorl %r11d, %r11d
vpcmpeqd %xmm0, %xmm0, %xmm0
xorl %ebx, %ebx
movslq %r8d, %rcx
cmpq %rcx, 0x270(%rdi)
jge 0x1aff8
leal (%r8,%r8), %ecx
movslq %ecx, %rcx
movq -0x8(%rsp), %r9
movw $0x0, 0x4(%r9)
movl $0x0, (%r9)
movq %rcx, 0x88(%rdi)
movq %rcx, %r9
sarq %r9
movq %r9, 0x270(%rdi)
movq %rcx, %r9
shlq $0x5, %r9
movq -0x10(%rsp), %r10
vmovdqu (%r10,%r9), %ymm1
vmovdqa %ymm1, 0xa0(%rdi)
vmovdqa 0x140(%rdi), %ymm2
vmovdqa 0x180(%rdi), %ymm3
vpcmpeqb %ymm1, %ymm2, %ymm4
vpmovmskb %ymm4, %r9d
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %r12d
incq %rcx
movq %rcx, 0x88(%rdi)
shlq $0x5, %rcx
vmovdqu (%r10,%rcx), %ymm1
vmovdqa %ymm1, 0xc0(%rdi)
vpcmpeqb %ymm1, %ymm2, %ymm2
vpmovmskb %ymm2, %ecx
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %r15d
shlq $0x20, %rcx
orq %r9, %rcx
shlq $0x20, %r15
orq %r12, %r15
leaq (%r15,%r15), %r9
notq %r9
andq %r15, %r9
movq 0x250(%rdi), %r13
movq 0x240(%rdi), %r10
movq %r10, %r12
xorq %r13, %r12
movq %r9, %rbp
andq %r12, %rbp
notq %r12
andq %r9, %r12
addq %r15, %rbp
xorl %r9d, %r9d
addq %r15, %r12
setb %r9b
movq %r9, 0x240(%rdi)
andq 0x258(%rdi), %rbp
orq %r10, %r12
andq %r13, %r12
orq %rbp, %r12
notq %r12
orq %r15, %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, 0x32(%rax)
jne 0x1b03a
vmovdqa 0x1a0(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %ecx
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %r9d
shlq $0x20, %r9
orq %rcx, %r9
movq %r9, 0x10(%rax)
movq (%rdi), %rcx
notq %rcx
andq %r9, %rcx
movq %rcx, 0x10(%rax)
movb $0x1, 0x32(%rax)
cmpb $0x0, 0x34(%rax)
jne 0x1b07c
vmovdqa 0x200(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %ecx
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %r9d
shlq $0x20, %r9
orq %rcx, %r9
movq %r9, 0x20(%rax)
movq (%rdi), %rcx
notq %rcx
andq %r9, %rcx
movq %rcx, 0x20(%rax)
movb $0x1, 0x34(%rax)
movq 0x20(%rax), %r12
orq 0x10(%rax), %r12
testb $0x1, %bl
je 0x1b09e
movq %r12, %r9
negq %r9
setb %cl
andq %r12, %r9
leaq -0x1(%r9), %r15
orq %r9, %r15
jmp 0x1b0f0
movq (%rsi), %rcx
leal 0x3f(%rcx), %r9d
testq %rcx, %rcx
cmovnsl %ecx, %r9d
andl $0xc0, %r9d
subl %r9d, %ecx
movl $0x1, %r9d
shlq %cl, %r9
movq %r9, %r15
negq %r15
movq %r15, %r13
btcq %rcx, %r13
andq %r13, %r12
setne %cl
je 0x1b0e8
movq %r12, %r10
negq %r10
andq %r12, %r10
movq %r10, %r15
subq %r9, %r15
orq %r10, %r15
jmp 0x1b0ed
btsq $0x3f, %r15
andq %r13, %r15
vmovdqa 0x220(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %r9d
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %r13d
shlq $0x20, %r13
orq %r9, %r13
movq %r13, 0x28(%rax)
movq (%rdi), %r9
notq %r9
andq %r9, %r13
movq %r13, 0x28(%rax)
cmpb $0x0, 0x31(%rax)
jne 0x1b160
vmovdqa 0x1e0(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %r10d
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %r12d
shlq $0x20, %r12
orq %r10, %r12
andq %r9, %r12
movq %r12, 0x8(%rax)
movb $0x1, 0x31(%rax)
movq %r13, %r9
andq %r15, %r9
leaq -0x1(%r9), %r12
xorq %r13, %r12
andq 0x8(%rax), %r12
andq %r15, %r12
popcntq %r12, %r10
addl %r10d, %r11d
movl %edx, %r13d
subl %r11d, %r13d
jle 0x1b1a8
testq %r9, %r9
je 0x1b1eb
movq 0x270(%rdi), %rcx
shlq $0x6, %rcx
bsfq %r9, %r9
orq %rcx, %r9
movq %r9, (%rsi)
movl $0x3ea, -0x14(%rsp)     # imm = 0x3EA
jmp 0x1b1dc
cmpl $0x2, %edx
jl 0x1b1bf
leal 0x1(%rdx), %ecx
leaq -0x1(%r12), %r9
andq %r9, %r12
decl %ecx
cmpl $0x2, %ecx
jg 0x1b1b0
movq 0x270(%rdi), %rcx
shlq $0x6, %rcx
bsfq %r12, %r9
orq %rcx, %r9
movq %r9, (%rsi)
movl $0x3e9, -0x14(%rsp)     # imm = 0x3E9
xorl %r14d, %r14d
xorl %ecx, %ecx
testb %cl, %cl
jne 0x1aec3
jmp 0x1b227
testb %cl, %cl
je 0x1b21b
movq 0x270(%rdi), %rcx
shlq $0x6, %rcx
bsrq %r15, %r9
xorq $0x3f, %r9
orq %rcx, %r9
xorq $0x3f, %r9
movq %r9, (%rsi)
movl $0x3ed, -0x14(%rsp)     # imm = 0x3ED
xorl %ecx, %ecx
movl %r11d, %r14d
jmp 0x1b1e1
incl %r8d
movb $0x1, %bl
movl %r13d, %edx
movb $0x1, %cl
jmp 0x1b1e1
shlq $0x20, %r14
movl -0x14(%rsp), %eax
orq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq