// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_write_cf_rule_time_period
STATIC void
_worksheet_write_cf_rule_time_period(lxw_worksheet *self,
                                     lxw_cond_format_obj *cond_format)
{
    struct xml_attribute_list attributes;
    struct xml_attribute *attribute;
    char formula[LXW_MAX_ATTRIBUTE_LENGTH];
    uint8_t pos;
    uint8_t criteria = cond_format->criteria;
    char *first_cell = cond_format->first_cell;
    char *time_periods[] = {
        "yesterday",
        "today",
        "tomorrow",
        "last7Days",
        "lastWeek",
        "thisWeek",
        "nextWeek",
        "lastMonth",
        "thisMonth",
        "nextMonth",
    };

    LXW_INIT_ATTRIBUTES();

    LXW_PUSH_ATTRIBUTES_STR("type", cond_format->type_string);

    if (cond_format->dxf_index != LXW_PROPERTY_UNSET)
        LXW_PUSH_ATTRIBUTES_INT("dxfId", cond_format->dxf_index);

    LXW_PUSH_ATTRIBUTES_INT("priority", cond_format->dxf_priority);

    pos = criteria - LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_YESTERDAY;
    LXW_PUSH_ATTRIBUTES_STR("timePeriod", time_periods[pos]);

    if (cond_format->stop_if_true)
        LXW_PUSH_ATTRIBUTES_INT("stopIfTrue", 1);

    lxw_xml_start_tag(self->file, "cfRule", &attributes);

    if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_YESTERDAY) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "FLOOR(%s,1)=TODAY()-1", first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_TODAY) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "FLOOR(%s,1)=TODAY()", first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_TOMORROW) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "FLOOR(%s,1)=TODAY()+1", first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_LAST_7_DAYS) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "AND(TODAY()-FLOOR(%s,1)<=6,FLOOR(%s,1)<=TODAY())",
                     first_cell, first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_LAST_WEEK) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "AND(TODAY()-ROUNDDOWN(%s,0)>=(WEEKDAY(TODAY())),"
                     "TODAY()-ROUNDDOWN(%s,0)<(WEEKDAY(TODAY())+7))",
                     first_cell, first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_THIS_WEEK) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "AND(TODAY()-ROUNDDOWN(%s,0)<=WEEKDAY(TODAY())-1,"
                     "ROUNDDOWN(%s,0)-TODAY()<=7-WEEKDAY(TODAY()))",
                     first_cell, first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_NEXT_WEEK) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "AND(ROUNDDOWN(%s,0)-TODAY()>(7-WEEKDAY(TODAY())),"
                     "ROUNDDOWN(%s,0)-TODAY()<(15-WEEKDAY(TODAY())))",
                     first_cell, first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_LAST_MONTH) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "AND(MONTH(%s)=MONTH(TODAY())-1,OR(YEAR(%s)=YEAR("
                     "TODAY()),AND(MONTH(%s)=1,YEAR(A1)=YEAR(TODAY())-1)))",
                     first_cell, first_cell, first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_THIS_MONTH) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "AND(MONTH(%s)=MONTH(TODAY()),YEAR(%s)=YEAR(TODAY()))",
                     first_cell, first_cell);
        _worksheet_write_formula_str(self, formula);
    }
    else if (criteria == LXW_CONDITIONAL_CRITERIA_TIME_PERIOD_NEXT_MONTH) {
        lxw_snprintf(formula, LXW_MAX_ATTRIBUTE_LENGTH,
                     "AND(MONTH(%s)=MONTH(TODAY())+1,OR(YEAR(%s)=YEAR("
                     "TODAY()),AND(MONTH(%s)=12,YEAR(%s)=YEAR(TODAY())+1)))",
                     first_cell, first_cell, first_cell, first_cell);
        _worksheet_write_formula_str(self, formula);
    }

    lxw_xml_end_tag(self->file, "cfRule");

    LXW_FREE_ATTRIBUTES();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x8c0, %rsp            # imm = 0x8C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x852(%rbp)
movq -0x10(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x860(%rbp)
leaq -0x8b0(%rbp), %rdi
leaq 0x1d701(%rip), %rsi     # 0x7cd10
movl $0x50, %edx
callq 0xc980
movq $0x0, -0x20(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x5f62b
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rsi
leaq 0x8d76(%rip), %rdi      # 0x683b0
callq 0xc030
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x1040(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1040, %rax           # imm = 0x1040
movq %rax, -0x18(%rbp)
jmp 0x5f66d
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x88(%rax)
je 0x5f6c3
jmp 0x5f67c
movq -0x10(%rbp), %rax
movslq 0x88(%rax), %rsi
leaq 0xf0a8(%rip), %rdi      # 0x6e736
callq 0xc1b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x1040(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1040, %rax           # imm = 0x1040
movq %rax, -0x18(%rbp)
jmp 0x5f6c1
jmp 0x5f6c3
jmp 0x5f6c5
movq -0x10(%rbp), %rax
movl 0x8c(%rax), %eax
movl %eax, %esi
leaq 0xf064(%rip), %rdi      # 0x6e73c
callq 0xc1b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x1040(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1040, %rax           # imm = 0x1040
movq %rax, -0x18(%rbp)
jmp 0x5f70b
movzbl -0x852(%rbp), %eax
subl $0xd, %eax
movb %al, -0x851(%rbp)
movzbl -0x851(%rbp), %eax
movq -0x8b0(%rbp,%rax,8), %rsi
leaq 0xe6ae(%rip), %rdi      # 0x6dddf
callq 0xc030
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x1040(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1040, %rax           # imm = 0x1040
movq %rax, -0x18(%rbp)
jmp 0x5f764
movq -0x10(%rbp), %rax
cmpb $0x0, 0x73(%rax)
je 0x5f7b1
jmp 0x5f770
leaq 0xefce(%rip), %rdi      # 0x6e745
movl $0x1, %esi
callq 0xc1b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x1040(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1040, %rax           # imm = 0x1040
movq %rax, -0x18(%rbp)
jmp 0x5f7af
jmp 0x5f7b1
movq -0x8(%rbp), %rax
movq (%rax), %rdi
leaq 0xf772(%rip), %rsi      # 0x6ef31
leaq -0x20(%rbp), %rdx
callq 0xc390
movzbl -0x852(%rbp), %eax
cmpl $0xd, %eax
jne 0x5f80a
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movl $0x820, %esi            # imm = 0x820
leaq 0xf050(%rip), %rdx      # 0x6e83e
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5fab0
movzbl -0x852(%rbp), %eax
cmpl $0xe, %eax
jne 0x5f84c
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movl $0x820, %esi            # imm = 0x820
leaq 0xf024(%rip), %rdx      # 0x6e854
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faae
movzbl -0x852(%rbp), %eax
cmpl $0xf, %eax
jne 0x5f88e
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movl $0x820, %esi            # imm = 0x820
leaq 0xeff6(%rip), %rdx      # 0x6e868
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faac
movzbl -0x852(%rbp), %eax
cmpl $0x10, %eax
jne 0x5f8d7
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movq -0x860(%rbp), %r8
movl $0x820, %esi            # imm = 0x820
leaq 0xefc3(%rip), %rdx      # 0x6e87e
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faaa
movzbl -0x852(%rbp), %eax
cmpl $0x11, %eax
jne 0x5f920
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movq -0x860(%rbp), %r8
movl $0x820, %esi            # imm = 0x820
leaq 0xefab(%rip), %rdx      # 0x6e8af
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faa8
movzbl -0x852(%rbp), %eax
cmpl $0x12, %eax
jne 0x5f969
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movq -0x860(%rbp), %r8
movl $0x820, %esi            # imm = 0x820
leaq 0xefc0(%rip), %rdx      # 0x6e90d
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faa6
movzbl -0x852(%rbp), %eax
cmpl $0x13, %eax
jne 0x5f9b2
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movq -0x860(%rbp), %r8
movl $0x820, %esi            # imm = 0x820
leaq 0xefd4(%rip), %rdx      # 0x6e96a
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faa4
movzbl -0x852(%rbp), %eax
cmpl $0x14, %eax
jne 0x5fa02
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movq -0x860(%rbp), %r8
movq -0x860(%rbp), %r9
movl $0x820, %esi            # imm = 0x820
leaq 0xefe4(%rip), %rdx      # 0x6e9ca
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faa2
movzbl -0x852(%rbp), %eax
cmpl $0x15, %eax
jne 0x5fa48
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movq -0x860(%rbp), %r8
movl $0x820, %esi            # imm = 0x820
leaq 0xf000(%rip), %rdx      # 0x6ea2f
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faa0
movzbl -0x852(%rbp), %eax
cmpl $0x16, %eax
jne 0x5fa9e
leaq -0x850(%rbp), %rdi
movq -0x860(%rbp), %rcx
movq -0x860(%rbp), %r8
movq -0x860(%rbp), %r9
movq -0x860(%rbp), %rax
movl $0x820, %esi            # imm = 0x820
leaq 0xefe1(%rip), %rdx      # 0x6ea64
movq %rax, (%rsp)
movb $0x0, %al
callq 0xc5d0
movq -0x8(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x60da0
jmp 0x5faa0
jmp 0x5faa2
jmp 0x5faa4
jmp 0x5faa6
jmp 0x5faa8
jmp 0x5faaa
jmp 0x5faac
jmp 0x5faae
jmp 0x5fab0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
leaq 0xf473(%rip), %rsi      # 0x6ef31
callq 0xc060
jmp 0x5fac5
cmpq $0x0, -0x20(%rbp)
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5fad5
jmp 0x5fb07
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x1040(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x5fafa
leaq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x5fafc
movq -0x28(%rbp), %rdi
callq 0xc0d0
jmp 0x5fac5
jmp 0x5fb09
addq $0x8c0, %rsp            # imm = 0x8C0
popq %rbp
retq
nopw %cs:(%rax,%rax)