// File: /workspace/github_c_makefile_star2_O1/chriso[P]columnix/lib/predicate.c
// Function: cx_index_match_rows
bool cx_index_match_rows(const struct cx_predicate *predicate,
                         const struct cx_row_group *row_group,
                         struct cx_row_group_cursor *cursor, uint64_t *matches,
                         size_t *count)
{
    enum cx_column_type column_type =
        cx_row_group_column_type(row_group, predicate->column);
    uint64_t mask = 0;
    switch (predicate->type) {
        case CX_PREDICATE_TRUE:
            *count = cx_row_group_cursor_batch_count(cursor);
            mask = cx_mask_cap(cx_full_mask, *count);
            break;
        case CX_PREDICATE_NULL: {
            const uint64_t *nulls = cx_row_group_cursor_batch_nulls(
                cursor, predicate->column, count);
            if (!nulls)
                goto error;
            mask = *count ? *nulls : 0;
        } break;
        case CX_PREDICATE_EQ:
            if (!cx_index_match_rows_eq(predicate, cursor, column_type, &mask,
                                        count))
                goto error;
            break;
        case CX_PREDICATE_LT:
            if (!cx_index_match_rows_lt(predicate, cursor, column_type, &mask,
                                        count))
                goto error;
            break;
        case CX_PREDICATE_GT:
            if (!cx_index_match_rows_gt(predicate, cursor, column_type, &mask,
                                        count))
                goto error;
            break;
        case CX_PREDICATE_CONTAINS:
            assert(column_type == CX_COLUMN_STR);
            {
                const struct cx_string *values = cx_row_group_cursor_batch_str(
                    cursor, predicate->column, count);
                if (!values)
                    goto error;
                mask = cx_match_str_contains(
                    *count, values, &predicate->value.str,
                    predicate->case_sensitive, predicate->location);
            }
            break;
        case CX_PREDICATE_CUSTOM:
            if (!cx_index_match_rows_custom(predicate, cursor, column_type,
                                            &mask, count))
                goto error;
            break;
        case CX_PREDICATE_AND:
            mask = cx_full_mask;
            // short-circuit the remaining predicates once the mask is empty
            for (size_t i = 0; mask && i < predicate->operand_count; i++) {
                uint64_t operand_mask;
                if (!cx_index_match_rows(predicate->operands[i], row_group,
                                         cursor, &operand_mask, count))
                    goto error;
                mask &= operand_mask;
            }
            break;
        case CX_PREDICATE_OR:
            mask = 0;
            // short-circuit the remaining predicates once the mask is full
            for (size_t i = 0;
                 mask != cx_full_mask && i < predicate->operand_count; i++) {
                uint64_t operand_mask;
                if (!cx_index_match_rows(predicate->operands[i], row_group,
                                         cursor, &operand_mask, count))
                    goto error;
                mask |= operand_mask;
            }
            break;
    }
    *matches = predicate->negate ? cx_mask_cap(~mask, *count) : mask;
    return true;
error:
    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r14
movq %rcx, 0x10(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r15
movq 0x8(%rdi), %rsi
movq %r13, %rdi
callq 0x58d0
movl %eax, %ebp
movq $0x0, (%rsp)
movl (%r15), %eax
cmpq $0x8, %rax
ja 0x8215
leaq 0x4d5a(%rip), %rcx      # 0xc97c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
callq 0x59f0
movq %rax, (%r14)
cmpq $0x41, %rax
jae 0x8325
movq $-0x1, %rdx
movq $-0x1, %rsi
movl %eax, %ecx
shlq %cl, %rsi
cmpq $0x40, %rax
notq %rsi
cmoveq %rdx, %rsi
movq %rsi, (%rsp)
jmp 0x8215
xorl %eax, %eax
cmpl $0x5, %ebp
ja 0x8211
movl %ebp, %ecx
leaq 0x4d3d(%rip), %rdx      # 0xc9b8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x1, 0x4(%r15)
jne 0x8382
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5800
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movl 0x10(%r15), %edx
movq %r12, %rsi
callq 0x58e0
jmp 0x8208
cmpl $0x5, %ebp
ja 0x81af
movl %ebp, %eax
leaq 0x4d18(%rip), %rcx      # 0xc9e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x4(%r15)
jne 0x83a1
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5500
movq %rax, %rdx
testq %rax, %rax
je 0x82dc
movq (%r14), %rcx
testq %rcx, %rcx
je 0x82dc
cmpb $0x1, 0x10(%r15)
jne 0x82e0
movq (%rdx), %rax
jmp 0x830b
xorl %eax, %eax
cmpl $0x5, %ebp
ja 0x8211
movl %ebp, %ecx
leaq 0x4c9e(%rip), %rdx      # 0xc9d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x1, 0x4(%r15)
jne 0x83c0
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5800
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movl 0x10(%r15), %edx
movq %r12, %rsi
callq 0x5240
jmp 0x8208
movq $0x0, (%rsp)
xorl %ebx, %ebx
leaq 0x8(%rsp), %rbp
cmpq 0x20(%r15), %rbx
jae 0x8215
movq 0x28(%r15), %rax
movq (%rax,%rbx,8), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, %r8
callq 0x5670
testb %al, %al
je 0x8314
movq (%rsp), %rax
orq 0x8(%rsp), %rax
movq %rax, (%rsp)
incq %rbx
cmpq $-0x1, %rax
jne 0x7d84
jmp 0x8215
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x50d0
testq %rax, %rax
je 0x8314
cmpq $0x0, (%r14)
je 0x7eb9
movq (%rax), %rcx
jmp 0x7ebb
cmpl $0x5, %ebp
jne 0x8344
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x55d0
testq %rax, %rax
je 0x8314
movq (%r14), %rdi
leaq 0x10(%r15), %rdx
movzbl 0x3c(%r15), %ecx
movl 0x38(%r15), %r8d
movq %rax, %rsi
callq 0x5510
jmp 0x8211
movq $-0x1, (%rsp)
xorl %ebx, %ebx
leaq 0x8(%rsp), %rbp
cmpq 0x20(%r15), %rbx
jae 0x8215
movq 0x28(%r15), %rax
movq (%rax,%rbx,8), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, %r8
callq 0x5670
testb %al, %al
je 0x8314
movq 0x8(%rsp), %rax
incq %rbx
andq %rax, (%rsp)
jne 0x7e41
jmp 0x8215
cmpl $0x5, %ebp
ja 0x82ac
movq 0x8(%r15), %rsi
movl %ebp, %eax
leaq 0x4b0b(%rip), %rcx      # 0xc9a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x4(%r15)
jne 0x83df
movq %r12, %rdi
movq %r14, %rdx
callq 0x5500
jmp 0x82ae
xorl %ecx, %ecx
movq %rcx, (%rsp)
testq %rax, %rax
jne 0x8215
jmp 0x8314
cmpl $0x4, 0x4(%r15)
jne 0x8363
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5600
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movsd 0x10(%r15), %xmm0
movq %r12, %rsi
callq 0x52e0
jmp 0x8208
cmpl $0x2, 0x4(%r15)
jne 0x83fe
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x58b0
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movq 0x10(%r15), %rdx
movq %r12, %rsi
callq 0x57a0
jmp 0x8208
cmpl $0x4, 0x4(%r15)
jne 0x841d
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5600
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movsd 0x10(%r15), %xmm0
movq %r12, %rsi
callq 0x5060
jmp 0x8208
cmpl $0x3, 0x4(%r15)
jne 0x843c
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5810
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movss 0x10(%r15), %xmm0
movq %r12, %rsi
callq 0x5990
jmp 0x8208
cmpl $0x4, 0x4(%r15)
jne 0x845b
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5600
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movsd 0x10(%r15), %xmm0
movq %r12, %rsi
callq 0x5100
jmp 0x8208
cmpl $0x2, 0x4(%r15)
jne 0x847a
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x58b0
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movq 0x10(%r15), %rdx
movq %r12, %rsi
callq 0x54b0
jmp 0x8208
cmpl $0x3, 0x4(%r15)
jne 0x8499
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5810
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movss 0x10(%r15), %xmm0
movq %r12, %rsi
callq 0x5820
jmp 0x8208
cmpl $0x2, 0x4(%r15)
jne 0x84b8
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x58b0
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movq 0x10(%r15), %rdx
movq %r12, %rsi
callq 0x56c0
jmp 0x8208
cmpl $0x5, 0x4(%r15)
jne 0x84d7
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x55d0
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
leaq 0x10(%r15), %rdx
movzbl 0x3c(%r15), %ecx
movq %r12, %rsi
callq 0x50b0
jmp 0x8208
cmpl $0x1, 0x4(%r15)
jne 0x84f6
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5800
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movl 0x10(%r15), %edx
movq %r12, %rsi
callq 0x5650
jmp 0x8208
cmpl $0x4, 0x4(%r15)
jne 0x8515
movq %r12, %rdi
movq %r14, %rdx
callq 0x5600
jmp 0x82ae
cmpl $0x3, 0x4(%r15)
jne 0x8534
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x5810
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
movss 0x10(%r15), %xmm0
movq %r12, %rsi
callq 0x58a0
jmp 0x8208
cmpl $0x5, 0x4(%r15)
jne 0x8553
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x55d0
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
leaq 0x10(%r15), %rdx
movzbl 0x3c(%r15), %ecx
movq %r12, %rsi
callq 0x5380
jmp 0x8208
xorl %eax, %eax
jmp 0x8211
cmpl $0x2, 0x4(%r15)
jne 0x8572
movq %r12, %rdi
movq %r14, %rdx
callq 0x58b0
jmp 0x82ae
cmpl $0x5, 0x4(%r15)
jne 0x8591
movq 0x8(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x55d0
movq %rax, %r12
testq %rax, %rax
je 0x8206
movq (%r14), %rdi
leaq 0x10(%r15), %rdx
movzbl 0x3c(%r15), %ecx
movq %r12, %rsi
callq 0x5230
jmp 0x8208
xorl %eax, %eax
testq %r12, %r12
je 0x8314
movq %rax, (%rsp)
cmpb $0x1, 0x3d(%r15)
jne 0x8251
movq (%r14), %rcx
cmpq $0x41, %rcx
jae 0x8325
movq $-0x1, %rdx
movq (%rsp), %rsi
xorq %rdx, %rsi
movq $-0x1, %rax
shlq %cl, %rax
cmpq $0x40, %rcx
notq %rax
cmoveq %rdx, %rax
andq %rsi, %rax
jmp 0x8255
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movb $0x1, %al
jmp 0x8316
cmpl $0x3, 0x4(%r15)
jne 0x85b0
movq %r12, %rdi
movq %r14, %rdx
callq 0x5810
jmp 0x82ae
cmpl $0x1, 0x4(%r15)
jne 0x85cf
movq %r12, %rdi
movq %r14, %rdx
callq 0x5800
jmp 0x82ae
cmpl $0x5, 0x4(%r15)
jne 0x85ee
movq %r12, %rdi
movq %r14, %rdx
callq 0x55d0
jmp 0x82ae
xorl %eax, %eax
testq %rax, %rax
je 0x8314
movq 0x40(%r15), %r9
testq %r9, %r9
je 0x8215
movq (%r14), %rsi
movq 0x58(%r15), %r8
movq %rsp, %rcx
movl %ebp, %edi
movq %rax, %rdx
callq *%r9
testb %al, %al
jne 0x8215
jmp 0x8314
xorl %eax, %eax
jmp 0x830b
cmpq $0x41, %rcx
jae 0x8325
movq $-0x1, %rsi
movq (%rdx), %rdi
xorq %rsi, %rdi
movq $-0x1, %rax
shlq %cl, %rax
cmpq $0x40, %rcx
notq %rax
cmoveq %rsi, %rax
andq %rdi, %rax
testq %rdx, %rdx
jne 0x8211
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x47fc(%rip), %rdi      # 0xcb28
leaq 0x4761(%rip), %rsi      # 0xca94
leaq 0x47fa(%rip), %rcx      # 0xcb34
movl $0x1a4, %edx            # imm = 0x1A4
callq 0x5350
leaq 0x4966(%rip), %rdi      # 0xccb1
leaq 0x4742(%rip), %rsi      # 0xca94
leaq 0x4747(%rip), %rcx      # 0xcaa0
movl $0x30b, %edx            # imm = 0x30B
callq 0x5350
leaq 0x4914(%rip), %rdi      # 0xcc7e
leaq 0x4723(%rip), %rsi      # 0xca94
leaq 0x49d9(%rip), %rcx      # 0xcd51
movl $0x289, %edx            # imm = 0x289
callq 0x5350
leaq 0x487d(%rip), %rdi      # 0xcc06
leaq 0x4704(%rip), %rsi      # 0xca94
leaq 0x49ba(%rip), %rcx      # 0xcd51
movl $0x271, %edx            # imm = 0x271
callq 0x5350
leaq 0x47b3(%rip), %rdi      # 0xcb5b
leaq 0x46e5(%rip), %rsi      # 0xca94
leaq 0x47cd(%rip), %rcx      # 0xcb83
movl $0x1b2, %edx            # imm = 0x1B2
callq 0x5350
leaq 0x483f(%rip), %rdi      # 0xcc06
leaq 0x46c6(%rip), %rsi      # 0xca94
leaq 0x48f9(%rip), %rcx      # 0xccce
movl $0x21a, %edx            # imm = 0x21A
callq 0x5350
leaq 0x4775(%rip), %rdi      # 0xcb5b
leaq 0x46a7(%rip), %rsi      # 0xca94
leaq 0x49e0(%rip), %rcx      # 0xcdd4
movl $0x2c7, %edx            # imm = 0x2C7
callq 0x5350
leaq 0x4829(%rip), %rdi      # 0xcc2e
leaq 0x4688(%rip), %rsi      # 0xca94
leaq 0x493e(%rip), %rcx      # 0xcd51
movl $0x279, %edx            # imm = 0x279
callq 0x5350
leaq 0x485a(%rip), %rdi      # 0xcc7e
leaq 0x4669(%rip), %rsi      # 0xca94
leaq 0x4751(%rip), %rcx      # 0xcb83
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x5350
leaq 0x4813(%rip), %rdi      # 0xcc56
leaq 0x464a(%rip), %rsi      # 0xca94
leaq 0x4900(%rip), %rcx      # 0xcd51
movl $0x281, %edx            # imm = 0x281
callq 0x5350
leaq 0x481c(%rip), %rdi      # 0xcc7e
leaq 0x462b(%rip), %rsi      # 0xca94
leaq 0x485e(%rip), %rcx      # 0xccce
movl $0x232, %edx            # imm = 0x232
callq 0x5350
leaq 0x47ad(%rip), %rdi      # 0xcc2e
leaq 0x460c(%rip), %rsi      # 0xca94
leaq 0x46f4(%rip), %rcx      # 0xcb83
movl $0x1c7, %edx            # imm = 0x1C7
callq 0x5350
leaq 0x47b6(%rip), %rdi      # 0xcc56
leaq 0x45ed(%rip), %rsi      # 0xca94
leaq 0x46d5(%rip), %rcx      # 0xcb83
movl $0x1cf, %edx            # imm = 0x1CF
callq 0x5350
leaq 0x476f(%rip), %rdi      # 0xcc2e
leaq 0x45ce(%rip), %rsi      # 0xca94
leaq 0x4801(%rip), %rcx      # 0xccce
movl $0x222, %edx            # imm = 0x222
callq 0x5350
leaq 0x47c8(%rip), %rdi      # 0xcca6
leaq 0x45af(%rip), %rsi      # 0xca94
leaq 0x4865(%rip), %rcx      # 0xcd51
movl $0x291, %edx            # imm = 0x291
callq 0x5350
leaq 0x4709(%rip), %rdi      # 0xcc06
leaq 0x4590(%rip), %rsi      # 0xca94
leaq 0x4678(%rip), %rcx      # 0xcb83
movl $0x1bf, %edx            # imm = 0x1BF
callq 0x5350
leaq 0x4762(%rip), %rdi      # 0xcc7e
leaq 0x4571(%rip), %rsi      # 0xca94
leaq 0x48aa(%rip), %rcx      # 0xcdd4
movl $0x2d7, %edx            # imm = 0x2D7
callq 0x5350
leaq 0x471b(%rip), %rdi      # 0xcc56
leaq 0x4552(%rip), %rsi      # 0xca94
leaq 0x4785(%rip), %rcx      # 0xccce
movl $0x22a, %edx            # imm = 0x22A
callq 0x5350
leaq 0x474c(%rip), %rdi      # 0xcca6
leaq 0x4533(%rip), %rsi      # 0xca94
leaq 0x461b(%rip), %rcx      # 0xcb83
movl $0x1df, %edx            # imm = 0x1DF
callq 0x5350
leaq 0x46b5(%rip), %rdi      # 0xcc2e
leaq 0x4514(%rip), %rsi      # 0xca94
leaq 0x484d(%rip), %rcx      # 0xcdd4
movl $0x2cf, %edx            # imm = 0x2CF
callq 0x5350
leaq 0x470e(%rip), %rdi      # 0xcca6
leaq 0x44f5(%rip), %rsi      # 0xca94
leaq 0x4728(%rip), %rcx      # 0xccce
movl $0x23a, %edx            # imm = 0x23A
callq 0x5350
leaq 0x469f(%rip), %rdi      # 0xcc56
leaq 0x44d6(%rip), %rsi      # 0xca94
leaq 0x480f(%rip), %rcx      # 0xcdd4
movl $0x2d3, %edx            # imm = 0x2D3
callq 0x5350
leaq 0x4630(%rip), %rdi      # 0xcc06
leaq 0x44b7(%rip), %rsi      # 0xca94
leaq 0x47f0(%rip), %rcx      # 0xcdd4
movl $0x2cb, %edx            # imm = 0x2CB
callq 0x5350
leaq 0x46b1(%rip), %rdi      # 0xcca6
leaq 0x4498(%rip), %rsi      # 0xca94
leaq 0x47d1(%rip), %rcx      # 0xcdd4
movl $0x2db, %edx            # imm = 0x2DB
callq 0x5350