// File: /workspace/github_c_makefile_star2_O2/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_filter_column
lxw_error
worksheet_filter_column(lxw_worksheet *self, lxw_col_t col,
                        lxw_filter_rule *rule)
{
    lxw_filter_rule_obj *rule_obj;
    uint16_t rule_index;

    if (!rule) {
        LXW_WARN("worksheet_filter_column(): rule parameter cannot be NULL");
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    if (self->autofilter.in_use == LXW_FALSE) {
        LXW_WARN("worksheet_filter_column(): "
                 "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_column(): "
                         "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);

    rule_obj->col_num = rule_index;
    rule_obj->type = LXW_FILTER_TYPE_SINGLE;
    rule_obj->criteria1 = rule->criteria;
    rule_obj->value1 = rule->value;

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

    if (rule_obj->criteria1 == 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 %r12
pushq %rbx
testq %rdx, %rdx
je 0x3852d
movq %rdi, %rbx
cmpb $0x0, 0x1e4(%rdi)
je 0x38542
movl %esi, %ebp
movzwl 0x1f0(%rbx), %ecx
movzwl 0x1f2(%rbx), %eax
cmpw %cx, %bp
jb 0x38560
cmpw %bp, %ax
jb 0x38560
movq %rdx, %r14
subl %ecx, %ebp
movq 0x3b0(%rbx), %rax
movzwl %bp, %r12d
movq (%rax,%r12,8), %rdi
callq 0x385b3
pushq $0x1
popq %rdi
pushq $0x38
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x38583
movq %rax, %r15
movw %bp, 0x4(%rax)
movb $0x1, (%rax)
movb (%r14), %bpl
movb %bpl, 0x6(%rax)
movsd 0x10(%r14), %xmm0
movsd %xmm0, 0x8(%rax)
cmpb $0x8, %bpl
jne 0x384f0
movb $0x2, 0x6(%r15)
leaq 0x947e(%rip), %rdi      # 0x41963
callq 0xcd50
movq %rax, 0x18(%r15)
jmp 0x38508
movq 0x8(%r14), %rdi
callq 0xcd50
movq %rax, 0x18(%r15)
cmpb $0x7, %bpl
jne 0x38508
movb $0x1, 0x2(%r15)
movq %r15, %rdi
callq 0xc230
movq 0x3b0(%rbx), %rax
movq %r15, (%rax,%r12,8)
movb $0x1, %al
movb %al, 0x13a(%rbx)
movb %al, 0x1e5(%rbx)
xorl %eax, %eax
jmp 0x385aa
movq 0x1aac4(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xc173(%rip), %rdi      # 0x446b1
pushq $0x44
jmp 0x38555
movq 0x1aaaf(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xc1a3(%rip), %rdi      # 0x446f6
pushq $0x78
popq %rsi
pushq $0x1
popq %rdx
callq 0xd000
jmp 0x3857f
movzwl %ax, %r8d
movzwl %bp, %edx
movq 0x1aa8a(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xc1f7(%rip), %rsi      # 0x4476f
xorl %eax, %eax
callq 0xc8d0
pushq $0xd
jmp 0x385a9
movq 0x1aa6e(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x4b4c(%rip), %rsi      # 0x3d0e0
leaq 0xb445(%rip), %rdx      # 0x439e0
movl $0x2350, %ecx           # imm = 0x2350
xorl %eax, %eax
callq 0xc8d0
pushq $0x1
popq %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq