// File: /workspace/github_c_makefile_star2_O2/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
testq %rdx, %rdx
je 0x38986
cmpb $0x0, 0x1e4(%rdi)
je 0x3899b
movzwl 0x1f0(%rdi), %ecx
movzwl 0x1f2(%rdi), %eax
cmpw %cx, %si
jb 0x389b0
cmpw %si, %ax
jb 0x389b0
movq %rdx, %r14
movl %ecx, 0x8(%rsp)
movl %esi, 0x4(%rsp)
movq %rdi, 0x10(%rsp)
xorl %r12d, %r12d
pushq $0x6
popq %rbp
pushq $0x1
popq %r13
xorl %r15d, %r15d
xorl %ebx, %ebx
movzwl %bx, %eax
movq (%r14,%rax,8), %rdi
testq %rdi, %rdi
je 0x38888
leaq 0xcbaa(%rip), %rsi      # 0x45414
movq %rbp, %rdx
callq 0xc1c0
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movzbl %r12b, %r12d
cmovel %r13d, %r12d
addl %ecx, %r15d
incl %ebx
jmp 0x38857
testw %r15w, %r15w
je 0x389d1
movl %r13d, %ebp
movl 0x4(%rsp), %ebx
subl 0x8(%rsp), %ebx
movq 0x10(%rsp), %rax
movq 0x3b0(%rax), %rax
movzwl %bx, %ecx
movq %rcx, 0x20(%rsp)
movq (%rax,%rcx,8), %rdi
callq 0x385b3
pushq $0x1
popq %rdi
pushq $0x38
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x389f2
movq %rax, %r13
movzwl %r15w, %edi
incq %rdi
pushq $0x8
popq %rsi
callq 0xc850
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x38a18
movq %r13, 0x18(%rsp)
movl %ebx, 0x4(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
movzwl %bp, %eax
movq (%r14,%rax,8), %rbx
testq %rbx, %rbx
je 0x3893a
movq %rbx, %rdi
leaq 0xcb02(%rip), %rsi      # 0x45414
pushq $0x6
popq %rdx
callq 0xc1c0
testl %eax, %eax
je 0x38936
movq %rbx, %rdi
callq 0xcd50
movzwl %r13w, %ecx
movq 0x8(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
incl %r13d
incl %ebp
jmp 0x388fc
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rdx)
movw %r15w, 0x28(%rdx)
movl 0x4(%rsp), %eax
movw %ax, 0x4(%rdx)
movb $0x4, (%rdx)
movb %r12b, 0x2(%rdx)
movq 0x10(%rsp), %rcx
movq 0x3b0(%rcx), %rax
movq 0x20(%rsp), %rsi
movq %rdx, (%rax,%rsi,8)
movb $0x1, %al
movb %al, 0x13a(%rcx)
movb %al, 0x1e5(%rcx)
xorl %eax, %eax
jmp 0x38a46
movq 0x1a66b(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xbf5d(%rip), %rdi      # 0x448f4
pushq $0x42
jmp 0x389e4
movq 0x1a656(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xbf8b(%rip), %rdi      # 0x44937
pushq $0x76
jmp 0x389e4
movzwl %ax, %r8d
movzwl %si, %edx
movq 0x1a63a(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xbfe6(%rip), %rsi      # 0x449ae
xorl %eax, %eax
callq 0xc8d0
jmp 0x389ed
movq 0x1a620(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xc02c(%rip), %rdi      # 0x44a0e
pushq $0x4f
popq %rsi
pushq $0x1
popq %rdx
callq 0xd000
pushq $0xd
popq %rax
jmp 0x38a46
movq 0x1a5ff(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x46dd(%rip), %rsi      # 0x3d0e0
leaq 0xafd6(%rip), %rdx      # 0x439e0
movl $0x23fb, %ecx           # imm = 0x23FB
xorl %eax, %eax
callq 0xc8d0
jmp 0x38a44
movq 0x1a5d9(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x46b7(%rip), %rsi      # 0x3d0e0
leaq 0xafb0(%rip), %rdx      # 0x439e0
movl $0x23fe, %ecx           # imm = 0x23FE
xorl %eax, %eax
callq 0xc8d0
movq %r13, %rdi
callq 0xc0d0
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq