// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_conditional_format_range
lxw_error
worksheet_conditional_format_range(lxw_worksheet *self, lxw_row_t first_row,
                                   lxw_col_t first_col,
                                   lxw_row_t last_row,
                                   lxw_col_t last_col,
                                   lxw_conditional_format *user_options)
{
    lxw_cond_format_obj *cond_format;
    lxw_row_t tmp_row;
    lxw_col_t tmp_col;
    lxw_error err = LXW_NO_ERROR;
    char *type_strings[] = {
        "none",
        "cellIs",
        "containsText",
        "timePeriod",
        "aboveAverage",
        "duplicateValues",
        "uniqueValues",
        "top10",
        "top10",
        "containsBlanks",
        "notContainsBlanks",
        "containsErrors",
        "notContainsErrors",
        "expression",
        "colorScale",
        "colorScale",
        "dataBar",
        "iconSet",
    };

    /* Swap last row/col with first row/col as necessary */
    if (first_row > last_row) {
        tmp_row = last_row;
        last_row = first_row;
        first_row = tmp_row;
    }
    if (first_col > last_col) {
        tmp_col = last_col;
        last_col = first_col;
        first_col = tmp_col;
    }

    /* Check that dimensions are valid but don't store them. */
    err = _check_dimensions(self, last_row, last_col, LXW_TRUE, LXW_TRUE);
    if (err)
        return err;

    /* Check the validation type is in correct enum range. */
    if (user_options->type <= LXW_CONDITIONAL_TYPE_NONE ||
        user_options->type >= LXW_CONDITIONAL_TYPE_LAST) {

        LXW_WARN_FORMAT1("worksheet_conditional_format_cell()/_range(): "
                         "invalid type value (%d).", user_options->type);

        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Create a copy of the parameters from the user data validation. */
    cond_format = calloc(1, sizeof(lxw_cond_format_obj));
    GOTO_LABEL_ON_MEM_ERROR(cond_format, error);

    /* Create the data validation range. */
    if (first_row == last_row && first_col == last_col)
        lxw_rowcol_to_cell(cond_format->sqref, first_row, first_col);
    else
        lxw_rowcol_to_range(cond_format->sqref, first_row, first_col,
                            last_row, last_col);

    /* Store the first cell string for text and date rules. */
    lxw_rowcol_to_cell(cond_format->first_cell, first_row, first_col);

    /* Overwrite the sqref range with a user supplied set of ranges. */
    if (user_options->multi_range) {

        if (strlen(user_options->multi_range) >= LXW_MAX_ATTRIBUTE_LENGTH) {
            LXW_WARN_FORMAT1("worksheet_conditional_format_cell()/_range(): "
                             "multi_range >= limit = %d.",
                             LXW_MAX_ATTRIBUTE_LENGTH);
            err = LXW_ERROR_PARAMETER_VALIDATION;
            goto error;
        }

        LXW_ATTRIBUTE_COPY(cond_format->sqref, user_options->multi_range);
    }

    /* Get the conditional format dxf format index. */
    if (user_options->format)
        cond_format->dxf_index =
            lxw_format_get_dxf_index(user_options->format);
    else
        cond_format->dxf_index = LXW_PROPERTY_UNSET;

    /* Set some common option for all validation types. */
    cond_format->type = user_options->type;
    cond_format->criteria = user_options->criteria;
    cond_format->stop_if_true = user_options->stop_if_true;
    cond_format->type_string = lxw_strdup(type_strings[cond_format->type]);

    /* Validate the user input for various types of rules. */
    if (user_options->type == LXW_CONDITIONAL_TYPE_CELL
        || cond_format->type == LXW_CONDITIONAL_TYPE_DUPLICATE
        || cond_format->type == LXW_CONDITIONAL_TYPE_UNIQUE) {

        err = _validate_conditional_cell(cond_format, user_options);
        if (err)
            goto error;
    }
    else if (user_options->type == LXW_CONDITIONAL_TYPE_TEXT) {

        err = _validate_conditional_text(cond_format, user_options);
        if (err)
            goto error;
    }
    else if (user_options->type == LXW_CONDITIONAL_TYPE_TIME_PERIOD) {

        err = _validate_conditional_time_period(user_options);
        if (err)
            goto error;
    }
    else if (user_options->type == LXW_CONDITIONAL_TYPE_AVERAGE) {

        err = _validate_conditional_average(user_options);
        if (err)
            goto error;
    }
    else if (cond_format->type == LXW_CONDITIONAL_TYPE_TOP
             || cond_format->type == LXW_CONDITIONAL_TYPE_BOTTOM) {

        err = _validate_conditional_top(cond_format, user_options);
        if (err)
            goto error;
    }
    else if (user_options->type == LXW_CONDITIONAL_TYPE_FORMULA) {

        err = _validate_conditional_formula(cond_format, user_options);
        if (err)
            goto error;
    }
    else if (cond_format->type == LXW_CONDITIONAL_2_COLOR_SCALE
             || cond_format->type == LXW_CONDITIONAL_3_COLOR_SCALE) {

        err = _validate_conditional_scale(cond_format, user_options);
        if (err)
            goto error;
    }
    else if (cond_format->type == LXW_CONDITIONAL_DATA_BAR) {

        err = _validate_conditional_data_bar(self, cond_format, user_options);
        if (err)
            goto error;
    }
    else if (cond_format->type == LXW_CONDITIONAL_TYPE_ICON_SETS) {

        err = _validate_conditional_icons(user_options);
        if (err)
            goto error;

        cond_format->icon_style = user_options->icon_style;
        cond_format->reverse_icons = user_options->reverse_icons;
        cond_format->icons_only = user_options->icons_only;
    }

    /* Set the priority based on the order of adding. */
    cond_format->dxf_priority = ++self->dxf_priority;

    /* Store the conditional format object. */
    err = _store_conditional_format_object(self, cond_format);

    if (err)
        goto error;
    else
        return LXW_NO_ERROR;

error:
    _free_cond_format(cond_format);
    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movw %r8w, %ax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movw %dx, -0x16(%rbp)
movl %ecx, -0x1c(%rbp)
movw %ax, -0x1e(%rbp)
movq %r9, -0x28(%rbp)
movl $0x0, -0x3c(%rbp)
leaq -0xd0(%rbp), %rdi
leaq 0x26566(%rip), %rsi     # 0x7cc10
movl $0x90, %edx
callq 0xc980
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jbe 0x566ce
movl -0x1c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x14(%rbp)
movzwl -0x16(%rbp), %eax
movzwl -0x1e(%rbp), %ecx
cmpl %ecx, %eax
jle 0x566f2
movw -0x1e(%rbp), %ax
movw %ax, -0x36(%rbp)
movw -0x16(%rbp), %ax
movw %ax, -0x1e(%rbp)
movw -0x36(%rbp), %ax
movw %ax, -0x16(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl $0x1, %r8d
movzwl -0x1e(%rbp), %edx
movl %r8d, %ecx
callq 0x4ff90
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x5671f
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x56b45
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jle 0x56737
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x12, %eax
jl 0x56762
movq 0x268ba(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movzbl (%rax), %edx
leaq 0x1772b(%rip), %rsi     # 0x6de7a
movb $0x0, %al
callq 0xc8f0
movl $0xd, -0x4(%rbp)
jmp 0x56b45
movl $0x1, %edi
movl $0x8c8, %esi            # imm = 0x8C8
callq 0xc870
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x567a5
movq 0x26875(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0xf943(%rip), %rsi      # 0x660d0
leaq 0x15c60(%rip), %rdx     # 0x6c3f4
movl $0x2b14, %ecx           # imm = 0x2B14
movb $0x0, %al
callq 0xc8f0
jmp 0x56b36
jmp 0x567a7
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x567d4
movzwl -0x16(%rbp), %eax
movzwl -0x1e(%rbp), %ecx
cmpl %ecx, %eax
jne 0x567d4
movq -0x30(%rbp), %rdi
addq $0x9e, %rdi
movl -0x14(%rbp), %esi
movzwl -0x16(%rbp), %edx
callq 0xca90
jmp 0x567f6
movq -0x30(%rbp), %rdi
addq $0x9e, %rdi
movl -0x14(%rbp), %esi
movw -0x16(%rbp), %ax
movl -0x1c(%rbp), %ecx
movzwl %ax, %edx
movzwl -0x1e(%rbp), %r8d
callq 0xcdc0
movq -0x30(%rbp), %rdi
addq $0x90, %rdi
movl -0x14(%rbp), %esi
movzwl -0x16(%rbp), %edx
callq 0xca90
movq -0x28(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x5688b
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0xc4e0
cmpq $0x820, %rax            # imm = 0x820
jb 0x5685c
movq 0x267be(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x17689(%rip), %rsi     # 0x6decd
movl $0x820, %edx            # imm = 0x820
movb $0x0, %al
callq 0xc8f0
movl $0xd, -0x3c(%rbp)
jmp 0x56b36
jmp 0x5685e
movq -0x30(%rbp), %rdi
addq $0x9e, %rdi
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rsi
movl $0x81f, %edx            # imm = 0x81F
callq 0xc1a0
movq -0x30(%rbp), %rax
movb $0x0, 0x8bd(%rax)
jmp 0x5688b
movq -0x28(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x568b1
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xcbc0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x88(%rax)
jmp 0x568bf
movq -0x30(%rbp), %rax
movl $0xffffffff, 0x88(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
movb (%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x28(%rbp), %rax
movb 0x98(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x73(%rax)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
movq -0xd0(%rbp,%rax,8), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
je 0x5692d
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5, %eax
je 0x5692d
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x6, %eax
jne 0x5694d
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xc700
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x56948
jmp 0x56b36
jmp 0x56af8
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0x56979
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xcf80
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x56974
jmp 0x56b36
jmp 0x56af6
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x569a1
movq -0x28(%rbp), %rdi
callq 0xc660
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x5699c
jmp 0x56b36
jmp 0x56af4
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x4, %eax
jne 0x569c9
movq -0x28(%rbp), %rdi
callq 0xd1b0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x569c4
jmp 0x56b36
jmp 0x56af2
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7, %eax
je 0x569e1
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x8, %eax
jne 0x56a01
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xce90
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x569fc
jmp 0x56b36
jmp 0x56af0
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xd, %eax
jne 0x56a2d
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xc990
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x56a28
jmp 0x56b36
jmp 0x56aee
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe, %eax
je 0x56a45
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf, %eax
jne 0x56a65
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xcde0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x56a60
jmp 0x56b36
jmp 0x56aec
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x10, %eax
jne 0x56a92
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xc840
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x56a90
jmp 0x56b36
jmp 0x56aea
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x11, %eax
jne 0x56ae8
movq -0x28(%rbp), %rdi
callq 0xc370
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x56ab5
jmp 0x56b36
movq -0x28(%rbp), %rax
movb 0x88(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x70(%rax)
movq -0x28(%rbp), %rax
movb 0x89(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x71(%rax)
movq -0x28(%rbp), %rax
movb 0x8a(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x72(%rax)
jmp 0x56aea
jmp 0x56aec
jmp 0x56aee
jmp 0x56af0
jmp 0x56af2
jmp 0x56af4
jmp 0x56af6
jmp 0x56af8
movq -0x10(%rbp), %rax
movl 0x2e8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2e8(%rax)
movq -0x30(%rbp), %rax
movl %ecx, 0x8c(%rax)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xc0c0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x56b2d
jmp 0x56b36
movl $0x0, -0x4(%rbp)
jmp 0x56b45
movq -0x30(%rbp), %rdi
callq 0x47320
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)