// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x5970
movl %eax, -0x34(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x78(%rbp)
subq $0x8, %rax
ja 0xa0c0
movq -0x78(%rbp), %rax
leaq 0x6ba6(%rip), %rcx      # 0x109b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rdi
callq 0x5ab0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq $-0x1, %rdi
callq 0xa120
movq %rax, -0x40(%rbp)
jmp 0xa0c0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rdx
callq 0x5100
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x9e67
jmp 0xa106
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x9e7e
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x9e86
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x9e86
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xa0c0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x30(%rbp), %r8
leaq -0x40(%rbp), %rcx
callq 0xa190
testb $0x1, %al
jne 0x9eb4
jmp 0xa106
jmp 0xa0c0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x30(%rbp), %r8
leaq -0x40(%rbp), %rcx
callq 0xa4d0
testb $0x1, %al
jne 0x9eda
jmp 0xa106
jmp 0xa0c0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x30(%rbp), %r8
leaq -0x40(%rbp), %rcx
callq 0xa780
testb $0x1, %al
jne 0x9f00
jmp 0xa106
jmp 0xa0c0
cmpl $0x5, -0x34(%rbp)
jne 0x9f0d
jmp 0x9f2c
leaq 0x6de5(%rip), %rdi      # 0x10cf9
leaq 0x6bc1(%rip), %rsi      # 0x10adc
movl $0x30b, %edx            # imm = 0x30B
leaq 0x6bc1(%rip), %rcx      # 0x10ae8
callq 0x53a0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rdx
callq 0x5670
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x9f51
jmp 0xa106
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x50(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x10, %rdx
movq -0x10(%rbp), %rax
movb 0x3c(%rax), %al
movq -0x10(%rbp), %rcx
movl 0x38(%rcx), %r8d
andb $0x1, %al
movzbl %al, %ecx
callq 0x55a0
movq %rax, -0x40(%rbp)
jmp 0xa0c0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x30(%rbp), %r8
leaq -0x40(%rbp), %rcx
callq 0xaa30
testb $0x1, %al
jne 0x9fa7
jmp 0xa106
jmp 0xa0c0
movq $-0x1, -0x40(%rbp)
movq $0x0, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x40(%rbp)
movb %al, -0x81(%rbp)
je 0x9fe0
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
setb %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x9fec
jmp 0xa034
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %r8
leaq -0x60(%rbp), %rcx
callq 0x5700
testb $0x1, %al
jne 0xa01a
jmp 0xa106
movq -0x60(%rbp), %rax
andq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x9fbc
jmp 0xa0c0
movq $0x0, -0x40(%rbp)
movq $0x0, -0x68(%rbp)
xorl %eax, %eax
cmpq $-0x1, -0x40(%rbp)
movb %al, -0x82(%rbp)
je 0xa06d
movq -0x68(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
setb %al
movb %al, -0x82(%rbp)
movb -0x82(%rbp), %al
testb $0x1, %al
jne 0xa079
jmp 0xa0be
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %r8
leaq -0x70(%rbp), %rcx
callq 0x5700
testb $0x1, %al
jne 0xa0a4
jmp 0xa106
movq -0x70(%rbp), %rax
orq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0xa049
jmp 0xa0c0
movq -0x10(%rbp), %rax
testb $0x1, 0x3d(%rax)
je 0xa0e7
movq -0x40(%rbp), %rdi
xorq $-0x1, %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
callq 0xa120
movq %rax, -0x90(%rbp)
jmp 0xa0f2
movq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0xa10a
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)