// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_filter_list
lxw_error
worksheet_filter_list(lxw_worksheet *self, lxw_col_t col, const char **list)
{
    lxw_filter_rule_obj *rule_obj;
    uint16_t rule_index;
    uint8_t has_blanks = LXW_FALSE;
    uint16_t num_filters = 0;
    uint16_t input_list_index;
    uint16_t rule_obj_list_index;
    const char *str;
    char **tmp_list;

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

    if (self->autofilter.in_use == LXW_FALSE) {
        LXW_WARN("worksheet_filter_list(): "
                 "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_list(): "
                         "Column '%d' is outside autofilter range "
                         "'%d <= col <= %d'.", col,
                         self->autofilter.first_col,
                         self->autofilter.last_col);
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Count the number of non "Blanks" strings in the input list. */
    input_list_index = 0;
    while ((str = list[input_list_index]) != NULL) {
        if (strncmp(str, "Blanks", 6) == 0)
            has_blanks = LXW_TRUE;
        else
            num_filters++;

        input_list_index++;
    }

    /* There should be at least one filter string. */
    if (num_filters == 0) {
        LXW_WARN("worksheet_filter_list(): "
                 "list must have at least 1 non-blanks item.");
        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);

    tmp_list = calloc(num_filters + 1, sizeof(char *));
    GOTO_LABEL_ON_MEM_ERROR(tmp_list, mem_error);

    /* Copy input list (without any "Blanks" command) to an internal list. */
    input_list_index = 0;
    rule_obj_list_index = 0;
    while ((str = list[input_list_index]) != NULL) {
        if (strncmp(str, "Blanks", 6) != 0) {
            tmp_list[rule_obj_list_index] = lxw_strdup(str);
            rule_obj_list_index++;
        }

        input_list_index++;
    }

    rule_obj->list = tmp_list;
    rule_obj->num_list_filters = num_filters;
    rule_obj->is_custom = LXW_FALSE;
    rule_obj->col_num = rule_index;
    rule_obj->type = LXW_FILTER_TYPE_STRING_LIST;
    rule_obj->has_blanks = has_blanks;

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

    return LXW_NO_ERROR;

mem_error:
    free(rule_obj);
    return LXW_ERROR_MEMORY_MALLOC_FAILED;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
testq %rdx, %rdx
je 0x3ba52
movq %rdi, %rdx
cmpb $0x0, 0x1e4(%rdi)
je 0x3ba59
movzwl 0x1f0(%rdx), %ecx
movzwl 0x1f2(%rdx), %eax
cmpw %cx, %si
jb 0x3ba60
cmpw %si, %ax
jb 0x3ba60
movq (%r14), %rdi
testq %rdi, %rdi
je 0x3ba4b
movl %ecx, 0x8(%rsp)
movl %esi, 0x4(%rsp)
movq %rdx, 0x10(%rsp)
movw $0x1, %r13w
xorl %ebx, %ebx
leaq 0xcb1e(%rip), %r12      # 0x48428
movl $0x1, %ebp
xorl %r15d, %r15d
movl $0x6, %edx
movq %r12, %rsi
callq 0xc1a0
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movzbl %r15b, %r15d
cmovel %ebp, %r15d
addl %ecx, %ebx
movzwl %r13w, %eax
movq (%r14,%rax,8), %rdi
incl %r13d
testq %rdi, %rdi
jne 0x3b912
testw %bx, %bx
movq 0x10(%rsp), %rax
movl 0x4(%rsp), %ebp
movl 0x8(%rsp), %ecx
je 0x3ba4b
subl %ecx, %ebp
movq 0x3b0(%rax), %rax
movzwl %bp, %r12d
movq (%rax,%r12,8), %rdi
callq 0x3b688
movl $0x1, %edi
movl $0x38, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3ba86
movq %rax, %r13
movzwl %bx, %edi
incq %rdi
movl $0x8, %esi
callq 0xc7f0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3ba8d
movq %r13, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movl %ebp, 0x4(%rsp)
movq (%r14), %rbp
testq %rbp, %rbp
je 0x3ba03
movw $0x1, %r13w
xorl %r12d, %r12d
movl $0x6, %edx
movq %rbp, %rdi
leaq 0xca56(%rip), %rsi      # 0x48428
callq 0xc1a0
testl %eax, %eax
je 0x3b9f3
movq %rbp, %rdi
callq 0xcce0
movzwl %r12w, %ecx
movq 0x8(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
incl %r12d
movzwl %r13w, %eax
movq (%r14,%rax,8), %rbp
incl %r13d
testq %rbp, %rbp
jne 0x3b9c3
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsi)
movw %bx, 0x28(%rsi)
movl 0x4(%rsp), %eax
movw %ax, 0x4(%rsi)
movb $0x4, (%rsi)
movb %r15b, 0x2(%rsi)
movq 0x10(%rsp), %rcx
movq 0x3b0(%rcx), %rax
movq 0x20(%rsp), %rdx
movq %rsi, (%rax,%rdx,8)
movb $0x1, %al
movb %al, 0x13a(%rcx)
movb %al, 0x1e5(%rcx)
xorl %eax, %eax
jmp 0x3ba9a
callq 0xf778
jmp 0x3ba7f
callq 0xf7b0
jmp 0x3ba7f
callq 0xf794
jmp 0x3ba7f
movzwl %ax, %r8d
movzwl %si, %edx
movq 0x1b58a(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0xbf4a(%rip), %rsi      # 0x479c2
xorl %eax, %eax
callq 0xc870
movl $0xd, %eax
jmp 0x3ba9a
callq 0xf754
jmp 0x3ba95
movq %r13, %rdi
callq 0xf723
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq