// File: /workspace/github_cpp_makefile_star2_O2/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, %r8
movl %edx, %r10d
movq %rsi, -0x18(%rsp)
movq (%rsi), %rax
movabsq $0x40, %rcx
cqto
idivq %rcx
leaq 0x30(%r8), %rcx
movq %rcx, -0x8(%rsp)
movq 0x2c8(%rdi), %rcx
movq 0x250(%rdi), %r14
movq 0x258(%rdi), %rdx
movq %rdx, -0x10(%rsp)
movslq %eax, %r12
movq 0x270(%rdi), %r11
movq %r12, %rax
shlq $0x6, %rax
leaq (%rax,%rcx), %r13
addq $0x20, %r13
leaq (%r12,%r12), %rbp
xorl %r9d, %r9d
vpcmpeqd %xmm0, %xmm0, %xmm0
xorl %eax, %eax
cmpq %r12, %r11
jge 0x1ad6a
movq -0x8(%rsp), %rcx
andw $0x0, 0x4(%rcx)
andl $0x0, (%rcx)
movq %rbp, 0x88(%rdi)
movq %r12, 0x270(%rdi)
vmovdqu -0x20(%r13), %ymm1
vmovdqa %ymm1, 0xa0(%rdi)
vmovdqa 0x140(%rdi), %ymm2
vmovdqa 0x180(%rdi), %ymm3
vpcmpeqb %ymm1, %ymm2, %ymm4
vpmovmskb %ymm4, %r11d
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %ebx
leaq 0x1(%rbp), %rcx
movq %rcx, 0x88(%rdi)
vmovdqu (%r13), %ymm1
vmovdqa %ymm1, 0xc0(%rdi)
vpcmpeqb %ymm1, %ymm2, %ymm2
vpmovmskb %ymm2, %ecx
vpcmpeqb %ymm1, %ymm3, %ymm1
vpmovmskb %ymm1, %edx
shlq $0x20, %rcx
orq %r11, %rcx
shlq $0x20, %rdx
orq %rbx, %rdx
leaq (%rdx,%rdx), %rbx
notq %rbx
andq %rdx, %rbx
movq 0x240(%rdi), %r15
movq %r15, %r11
xorq %r14, %r11
movq %rbx, %rsi
andq %r11, %rsi
notq %r11
andq %rbx, %r11
addq %rdx, %rsi
xorl %ebx, %ebx
addq %rdx, %r11
setb %bl
orq %r15, %r11
movq %rbx, 0x240(%rdi)
andq -0x10(%rsp), %rsi
andq %r14, %r11
orq %rsi, %r11
notq %r11
orq %rdx, %r11
andq %rcx, %r11
movq %r11, 0xe0(%rdi)
vmovq %r11, %xmm1
vpclmulqdq $0x0, %xmm0, %xmm1, %xmm1
vmovq %xmm1, %rcx
xorq 0x248(%rdi), %rcx
movq %rcx, (%rdi)
sarq $0x3f, %rcx
movq %rcx, 0x248(%rdi)
movq %r12, %r11
cmpb $0x0, 0x32(%r8)
jne 0x1adaa
vmovdqa 0x1a0(%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, 0x10(%r8)
movb $0x1, 0x32(%r8)
cmpb $0x0, 0x34(%r8)
je 0x1adb7
movq 0x20(%r8), %r15
jmp 0x1adf0
vmovdqa 0x200(%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), %r15
notq %r15
andq %rdx, %r15
movq %r15, 0x20(%r8)
movb $0x1, 0x34(%r8)
orq 0x10(%r8), %r15
testb $0x1, %al
je 0x1ae0d
movq %r15, %rdx
negq %rdx
setb %cl
andq %r15, %rdx
leaq -0x1(%rdx), %rax
orq %rdx, %rax
jmp 0x1ae65
movq -0x18(%rsp), %rax
movq (%rax), %rax
cqto
movabsq $0x40, %rcx
idivq %rcx
movq %rdx, %rcx
movabsq $0x1, %rbx
shlq %cl, %rbx
movq %rbx, %rax
negq %rax
movq %rax, %rdx
btcq %rcx, %rdx
andq %rdx, %r15
setne %cl
je 0x1ae5d
movq %r15, %rsi
negq %rsi
andq %r15, %rsi
movq %rsi, %rax
subq %rbx, %rax
orq %rsi, %rax
jmp 0x1ae62
btsq $0x3f, %rax
andq %rdx, %rax
vmovdqa 0x220(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %edx
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %ebx
shlq $0x20, %rbx
orq %rdx, %rbx
movq (%rdi), %r15
notq %r15
andq %r15, %rbx
movq %rbx, 0x28(%r8)
cmpb $0x0, 0x31(%r8)
je 0x1aea6
movq 0x8(%r8), %rdx
jmp 0x1aed9
vmovdqa 0x1e0(%rdi), %ymm1
vpcmpeqb 0xa0(%rdi), %ymm1, %ymm2
vpmovmskb %ymm2, %esi
vpcmpeqb 0xc0(%rdi), %ymm1, %ymm1
vpmovmskb %ymm1, %edx
shlq $0x20, %rdx
orq %rsi, %rdx
andq %r15, %rdx
movq %rdx, 0x8(%r8)
movb $0x1, 0x31(%r8)
movq %rbx, %r15
andq %rax, %r15
leaq -0x1(%r15), %rsi
xorq %rbx, %rsi
andq %rax, %rdx
andq %rsi, %rdx
popcntq %rdx, %rsi
addl %esi, %r9d
movl %r10d, %ebx
subl %r9d, %ebx
jle 0x1af24
testq %r15, %r15
jne 0x1af44
testb %cl, %cl
jne 0x1af61
incq %r12
addq $0x40, %r13
addq $0x2, %rbp
movb $0x1, %al
movl %ebx, %r10d
jmp 0x1ac66
leaq -0x1(%rdx), %rax
andq %rax, %rdx
decl %r10d
cmpl $0x2, %r10d
jge 0x1af1a
shlq $0x6, %r11
bsfq %rdx, %rax
orq %r11, %rax
movq -0x18(%rsp), %rcx
movq %rax, (%rcx)
movl $0x3e9, %eax            # imm = 0x3E9
jmp 0x1af5c
shlq $0x6, %r11
bsfq %r15, %rax
orq %r11, %rax
movq -0x18(%rsp), %rcx
movq %rax, (%rcx)
movl $0x3ea, %eax            # imm = 0x3EA
xorl %r9d, %r9d
jmp 0x1af85
shlq $0x6, %r11
bsrq %rax, %rax
xorq $0x3f, %rax
orq %r11, %rax
xorq $0x3f, %rax
movq -0x18(%rsp), %rcx
movq %rax, (%rcx)
shlq $0x20, %r9
movl $0x3ed, %eax            # imm = 0x3ED
orq %rax, %r9
movq %r9, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
nop