// File: /workspace/github_cpp_makefile_star2_O1/AutomataLab[P]JSONSki/src/QueryProcessor.cpp
// Function: QueryProcessor::build_bitmap_basic()
__attribute__((always_inline)) void QueryProcessor::build_bitmap_basic() {
    unsigned long quotebit0, escapebit0;
    unsigned long quotebit, escapebit;
    // step 1: build structural quote and escape bitmaps for the current word
    // first half of bitmap
    top_word = start_id / 2; // word id 
    unsigned long i = start_id * 32;
    v_text0 = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(mRecord + i));
    quotebit0 = (unsigned)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v_text0, v_quote));
    escapebit0 = (unsigned)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v_text0, v_escape));
    // second half of bitmap 
    ++start_id;
    i = (start_id) * 32;
    v_text = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(mRecord + i));
    quotebit = (unsigned)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v_text, v_quote));
    escapebit = (unsigned)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v_text, v_escape));
    quotebit = (quotebit << 32) | quotebit0;
    escapebit = (escapebit << 32) | escapebit0;
    // step 2: update structural quote bitmaps
    uint64_t bs_bits = escapebit;
    uint64_t start_edges = bs_bits & ~(bs_bits << 1);
    int64_t even_start_mask = even_bits ^ prev_iter_ends_odd_backslash;
    uint64_t even_starts = start_edges & even_start_mask;
    uint64_t odd_starts = start_edges & ~even_start_mask;
    uint64_t even_carries = bs_bits + even_starts;
    int64_t odd_carries;
    bool iter_ends_odd_backslash = __builtin_uaddll_overflow(bs_bits, odd_starts,
        (unsigned long long *)(&odd_carries));
    odd_carries |= prev_iter_ends_odd_backslash;
    prev_iter_ends_odd_backslash = iter_ends_odd_backslash ? 0x1ULL : 0x0ULL;
    uint64_t even_carry_ends = even_carries & ~bs_bits;
    uint64_t odd_carry_ends = odd_carries & ~bs_bits;
    uint64_t even_start_odd_end = even_carry_ends & odd_bits;
    uint64_t odd_start_even_end = odd_carry_ends & even_bits;
    uint64_t odd_ends = even_start_odd_end | odd_start_even_end;
    quote_bits = quotebit & ~odd_ends;
     // step 3: build string mask bitmaps
    str_mask = _mm_cvtsi128_si64(_mm_clmulepi64_si128(
        _mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFFu), 0));
    str_mask ^= prev_iter_inside_quote;
    prev_iter_inside_quote = static_cast<uint64_t>(static_cast<int64_t>(str_mask) >> 63);
}

// Assembly:
movq 0x88(%rdi), %rax
movq %rax, %rcx
shrq $0x3f, %rcx
addq %rax, %rcx
sarq %rcx
movq %rcx, 0x270(%rdi)
movq %rax, %rcx
shlq $0x5, %rcx
movq 0x2c8(%rdi), %rdx
vmovdqu (%rdx,%rcx), %ymm0
vmovdqa %ymm0, 0xa0(%rdi)
vmovdqa 0x140(%rdi), %ymm1
vpcmpeqb %ymm0, %ymm1, %ymm2
vpmovmskb %ymm2, %esi
vmovdqa 0x180(%rdi), %ymm2
vpcmpeqb %ymm0, %ymm2, %ymm0
vpmovmskb %ymm0, %r8d
incq %rax
movq %rax, 0x88(%rdi)
shlq $0x5, %rax
vmovdqu (%rdx,%rax), %ymm0
vmovdqa %ymm0, 0xc0(%rdi)
vpcmpeqb %ymm0, %ymm1, %ymm1
vpmovmskb %ymm1, %eax
vpcmpeqb %ymm0, %ymm2, %ymm0
vpmovmskb %ymm0, %ecx
shlq $0x20, %rax
orq %rsi, %rax
shlq $0x20, %rcx
orq %r8, %rcx
leaq (%rcx,%rcx), %rsi
notq %rsi
andq %rcx, %rsi
movq 0x250(%rdi), %r8
movq 0x240(%rdi), %r9
movq %r9, %rdx
xorq %r8, %rdx
movq %rsi, %r10
andq %rdx, %r10
notq %rdx
andq %rsi, %rdx
addq %rcx, %r10
xorl %esi, %esi
addq %rcx, %rdx
setb %sil
orq %r9, %rdx
movq %rsi, 0x240(%rdi)
andq 0x258(%rdi), %r10
andq %r8, %rdx
orq %r10, %rdx
notq %rdx
orq %rcx, %rdx
andq %rax, %rdx
movq %rdx, 0xe0(%rdi)
vmovq %rdx, %xmm0
vpcmpeqd %xmm1, %xmm1, %xmm1
vpclmulqdq $0x0, %xmm1, %xmm0, %xmm0
vmovq %xmm0, %rax
vmovq %xmm0, (%rdi)
xorq 0x248(%rdi), %rax
movq %rax, (%rdi)
sarq $0x3f, %rax
movq %rax, 0x248(%rdi)
vzeroupper
retq
nop