// File: /workspace/github_c_makefile_star2_O1/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_filter_column2
lxw_error
worksheet_filter_column2(lxw_worksheet *self, lxw_col_t col,
                         lxw_filter_rule *rule1, lxw_filter_rule *rule2,
                         uint8_t and_or)
{
    lxw_filter_rule_obj *rule_obj;
    uint16_t rule_index;

    if (!rule1 || !rule2) {
        LXW_WARN("worksheet_filter_column2(): rule parameter cannot be NULL");
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    if (self->autofilter.in_use == LXW_FALSE) {
        LXW_WARN("worksheet_filter_column2(): "
                 "Worksheet autofilter range hasn't been defined. "
                 "Use worksheet_autofilter() first.");
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    if (col < self->autofilter.first_col || col > self->autofilter.last_col) {
        LXW_WARN_FORMAT3("worksheet_filter_column2(): "
                         "Column '%d' is outside autofilter range "
                         "'%d <= col <= %d'.", col,
                         self->autofilter.first_col,
                         self->autofilter.last_col);
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Free any previous rule in the column slot. */
    rule_index = col - self->autofilter.first_col;
    _free_filter_rule(self->filter_rules[rule_index]);

    /* Create a new rule and copy user input. */
    rule_obj = calloc(1, sizeof(lxw_filter_rule_obj));
    RETURN_ON_MEM_ERROR(rule_obj, LXW_ERROR_MEMORY_MALLOC_FAILED);

    if (and_or == LXW_FILTER_AND)
        rule_obj->type = LXW_FILTER_TYPE_AND;
    else
        rule_obj->type = LXW_FILTER_TYPE_OR;

    rule_obj->col_num = rule_index;

    rule_obj->criteria1 = rule1->criteria;
    rule_obj->value1 = rule1->value;

    rule_obj->criteria2 = rule2->criteria;
    rule_obj->value2 = rule2->value;

    if (rule_obj->criteria1 != LXW_FILTER_CRITERIA_NON_BLANKS) {
        rule_obj->value1_string = lxw_strdup(rule1->value_string);
    }
    else {
        rule_obj->criteria1 = LXW_FILTER_CRITERIA_NOT_EQUAL_TO;
        rule_obj->value1_string = lxw_strdup(" ");
    }

    if (rule_obj->criteria2 != LXW_FILTER_CRITERIA_NON_BLANKS) {
        rule_obj->value2_string = lxw_strdup(rule2->value_string);
    }
    else {
        rule_obj->criteria2 = LXW_FILTER_CRITERIA_NOT_EQUAL_TO;
        rule_obj->value2_string = lxw_strdup(" ");
    }

    if (rule_obj->criteria1 == LXW_FILTER_CRITERIA_BLANKS)
        rule_obj->has_blanks = LXW_TRUE;

    if (rule_obj->criteria2 == LXW_FILTER_CRITERIA_BLANKS)
        rule_obj->has_blanks = LXW_TRUE;

    _set_custom_filter(rule_obj);

    self->filter_rules[rule_index] = rule_obj;
    self->filter_on = LXW_TRUE;
    self->autofilter.has_rules = LXW_TRUE;

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x3b596
movq %rcx, %r14
testq %rcx, %rcx
je 0x3b596
movq %rdi, %rbx
cmpb $0x0, 0x1e4(%rdi)
je 0x3b59d
movl %esi, %ebp
movzwl 0x1f0(%rbx), %ecx
cmpw %cx, %bp
jb 0x3b571
cmpw %bp, 0x1f2(%rbx)
jb 0x3b571
movl %r8d, %r13d
movq %rdx, %r12
subl %ecx, %ebp
movq 0x3b0(%rbx), %rax
movzwl %bp, %ecx
movq %rcx, (%rsp)
movq (%rax,%rcx,8), %rdi
callq 0x3b3cc
movl $0x1, %edi
movl $0x38, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3b5b6
movq %rax, %r15
testb %r13b, %r13b
sete %al
xorb $0x3, %al
movb %al, (%r15)
movw %bp, 0x4(%r15)
movb (%r12), %al
movb %al, 0x6(%r15)
movsd 0x10(%r12), %xmm0
movsd %xmm0, 0x8(%r15)
movb (%r14), %cl
movb %cl, 0x7(%r15)
movsd 0x10(%r14), %xmm0
movsd %xmm0, 0x10(%r15)
cmpb $0x8, %al
jne 0x3b500
movb $0x2, 0x6(%r15)
leaq 0x9455(%rip), %rdi      # 0x44953
jmp 0x3b505
movq 0x8(%r12), %rdi
callq 0xcce0
movq %rax, 0x18(%r15)
cmpb $0x8, 0x7(%r15)
jne 0x3b523
movb $0x2, 0x7(%r15)
leaq 0x9432(%rip), %rdi      # 0x44953
jmp 0x3b527
movq 0x8(%r14), %rdi
callq 0xcce0
movq (%rsp), %r14
movq %rax, 0x20(%r15)
cmpb $0x7, 0x6(%r15)
jne 0x3b540
movb $0x1, 0x2(%r15)
cmpb $0x7, 0x7(%r15)
jne 0x3b54c
movb $0x1, 0x2(%r15)
movq %r15, %rdi
callq 0xc210
movq 0x3b0(%rbx), %rax
movq %r15, (%rax,%r14,8)
movb $0x1, %al
movb %al, 0x13a(%rbx)
movb %al, 0x1e5(%rbx)
xorl %eax, %eax
jmp 0x3b5a7
movzwl %bp, %edx
movq 0x1aa7d(%rip), %rax     # 0x55ff8
movq (%rax), %rdi
movzwl 0x1f2(%rbx), %r8d
leaq 0xc22f(%rip), %rsi      # 0x477bc
xorl %eax, %eax
callq 0xc870
jmp 0x3b5a2
callq 0xf2e4
jmp 0x3b5a2
callq 0xf324
movl $0xd, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xf300
movl $0x1, %eax
jmp 0x3b5a7