// File: /workspace/github_c_makefile_star2_O1/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: validate_conditional_scale
lxw_error
_validate_conditional_scale(lxw_cond_format_obj *cond_format,
                            lxw_conditional_format *user_options)
{
    uint8_t min_rule_type = user_options->min_rule_type;
    uint8_t mid_rule_type = user_options->mid_rule_type;
    uint8_t max_rule_type = user_options->max_rule_type;

    if (min_rule_type > LXW_CONDITIONAL_RULE_TYPE_MINIMUM
        && min_rule_type < LXW_CONDITIONAL_RULE_TYPE_MAXIMUM) {
        cond_format->min_rule_type = min_rule_type;
        cond_format->min_value = user_options->min_value;
        cond_format->min_value_string =
            lxw_strdup_formula(user_options->min_value_string);
    }
    else {
        cond_format->min_rule_type = LXW_CONDITIONAL_RULE_TYPE_MINIMUM;
        cond_format->min_value = 0;
    }

    if (max_rule_type > LXW_CONDITIONAL_RULE_TYPE_MINIMUM
        && max_rule_type < LXW_CONDITIONAL_RULE_TYPE_MAXIMUM) {
        cond_format->max_rule_type = max_rule_type;
        cond_format->max_value = user_options->max_value;
        cond_format->max_value_string =
            lxw_strdup_formula(user_options->max_value_string);
    }
    else {
        cond_format->max_rule_type = LXW_CONDITIONAL_RULE_TYPE_MAXIMUM;
        cond_format->max_value = 0;
    }

    if (cond_format->type == LXW_CONDITIONAL_3_COLOR_SCALE) {
        if (mid_rule_type > LXW_CONDITIONAL_RULE_TYPE_MINIMUM
            && mid_rule_type < LXW_CONDITIONAL_RULE_TYPE_MAXIMUM) {
            cond_format->mid_rule_type = mid_rule_type;
            cond_format->mid_value = user_options->mid_value;
            cond_format->mid_value_string =
                lxw_strdup_formula(user_options->mid_value_string);
        }
        else {
            cond_format->mid_rule_type = LXW_CONDITIONAL_RULE_TYPE_PERCENTILE;
            cond_format->mid_value = 50;
        }
    }

    if (user_options->min_color != LXW_COLOR_UNSET)
        cond_format->min_color = user_options->min_color;
    else
        cond_format->min_color = 0xFF7128;

    if (user_options->max_color != LXW_COLOR_UNSET)
        cond_format->max_color = user_options->max_color;
    else
        cond_format->max_color = 0xFFEF9C;

    if (cond_format->type == LXW_CONDITIONAL_3_COLOR_SCALE) {
        if (user_options->min_color == LXW_COLOR_UNSET)
            cond_format->min_color = 0xF8696B;

        if (user_options->mid_color != LXW_COLOR_UNSET)
            cond_format->mid_color = user_options->mid_color;
        else
            cond_format->mid_color = 0xFFEB84;

        if (user_options->max_color == LXW_COLOR_UNSET)
            cond_format->max_color = 0x63BE7B;
    }

    return LXW_NO_ERROR;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movb 0x30(%rsi), %al
movb 0x48(%rsi), %r15b
movb 0x60(%rsi), %r12b
leal -0x2(%rax), %ecx
cmpb $0x3, %cl
ja 0x33e7c
movb %al, 0x18(%rbx)
movsd 0x20(%r14), %xmm0
movsd %xmm0, 0x8(%rbx)
movq 0x28(%r14), %rdi
callq 0xc0e0
movq %rax, 0x10(%rbx)
jmp 0x33e88
movb $0x1, 0x18(%rbx)
movq $0x0, 0x8(%rbx)
leal -0x2(%r12), %eax
cmpb $0x3, %al
ja 0x33eaf
movb %r12b, 0x49(%rbx)
movsd 0x50(%r14), %xmm0
movsd %xmm0, 0x38(%rbx)
movq 0x58(%r14), %rdi
callq 0xc0e0
movq %rax, 0x40(%rbx)
jmp 0x33ebb
movb $0x6, 0x49(%rbx)
movq $0x0, 0x38(%rbx)
cmpb $0xf, (%rbx)
jne 0x33ef8
leal -0x2(%r15), %eax
cmpb $0x3, %al
ja 0x33ee6
movb %r15b, 0x31(%rbx)
movsd 0x38(%r14), %xmm0
movsd %xmm0, 0x20(%rbx)
movq 0x40(%r14), %rdi
callq 0xc0e0
movq %rax, 0x28(%rbx)
jmp 0x33ef8
movb $0x4, 0x31(%rbx)
movabsq $0x4049000000000000, %rax # imm = 0x4049000000000000
movq %rax, 0x20(%rbx)
movl 0x34(%r14), %ecx
testl %ecx, %ecx
movl $0xff7128, %eax         # imm = 0xFF7128
cmovnel %ecx, %eax
movl %eax, 0x1c(%rbx)
movl 0x64(%r14), %eax
testl %eax, %eax
movl $0xffef9c, %edx         # imm = 0xFFEF9C
cmovnel %eax, %edx
movl %edx, 0x4c(%rbx)
cmpb $0xf, (%rbx)
jne 0x33f46
testl %ecx, %ecx
jne 0x33f2a
movl $0xf8696b, 0x1c(%rbx)   # imm = 0xF8696B
movl 0x4c(%r14), %ecx
testl %ecx, %ecx
movl $0xffeb84, %edx         # imm = 0xFFEB84
cmovnel %ecx, %edx
movl %edx, 0x34(%rbx)
testl %eax, %eax
jne 0x33f46
movl $0x63be7b, 0x4c(%rbx)   # imm = 0x63BE7B
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq