// File: /workspace/github_c_makefile_star2_O1/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 0x3b79b
movq %rdi, %r8
cmpb $0x0, 0x1e4(%rdi)
je 0x3b7a2
movzwl 0x1f0(%r8), %ecx
cmpw %cx, %si
jb 0x3b776
cmpw %si, 0x1f2(%r8)
jb 0x3b776
movq %rdx, %r14
movl %ecx, 0x8(%rsp)
movl %esi, 0x4(%rsp)
movq %r8, 0x10(%rsp)
movq (%rdx), %rdi
testq %rdi, %rdi
je 0x3b666
movw $0x1, %r13w
xorl %ebx, %ebx
leaq 0xcd11(%rip), %r12      # 0x4833f
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 0x3b636
jmp 0x3b66b
xorl %r15d, %r15d
xorl %ebx, %ebx
testw %bx, %bx
je 0x3b7a9
movl 0x4(%rsp), %ebp
subl 0x8(%rsp), %ebp
movq 0x10(%rsp), %rax
movq 0x3b0(%rax), %rax
movzwl %bp, %r12d
movq (%rax,%r12,8), %rdi
callq 0x3b3cc
movl $0x1, %edi
movl $0x38, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3b7b5
movq %rax, %r13
movzwl %bx, %edi
incq %rdi
movl $0x8, %esi
callq 0xc7f0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3b7bc
movq %r13, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movl %ebp, 0x4(%rsp)
movq (%r14), %rbp
testq %rbp, %rbp
je 0x3b72c
movw $0x1, %r13w
xorl %r12d, %r12d
movl $0x6, %edx
movq %rbp, %rdi
leaq 0xcc44(%rip), %rsi      # 0x4833f
callq 0xc1a0
testl %eax, %eax
je 0x3b71c
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 0x3b6ec
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsi)
movw %bx, 0x28(%rsi)
movl 0x4(%rsp), %eax
movw %ax, 0x4(%rsi)
movw $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 0x3b7c9
movzwl %si, %edx
movq 0x1a878(%rip), %rax     # 0x55ff8
movq (%rax), %rdi
movzwl 0x1f2(%r8), %r8d
leaq 0xc147(%rip), %rsi      # 0x478d9
xorl %eax, %eax
callq 0xc870
jmp 0x3b7ae
callq 0xf3cd
jmp 0x3b7ae
callq 0xf3b1
jmp 0x3b7ae
callq 0xf395
movl $0xd, %eax
jmp 0x3b7c9
callq 0xf371
jmp 0x3b7c4
movq %r13, %rdi
callq 0xf340
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq