// File: /workspace/github_c_makefile_star2_O2/mmayer[P]pcal/src/readfile.c
// Function: delete_day_info
int delete_day_info (int m, int d, int y, int text_type, char **pword)
{
   static year_info *pyear;
   static int prev_year = 0;
   month_info *pmonth;
   day_info *pday, *plast, *pdel = NULL, *pldel = NULL;
   int is_holiday = FALSE;
   int found = FALSE;
   char text[LINSIZ];
   
   if (! is_valid(m, d >= FIRST_NOTE_DAY && text_type == NOTE_TEXT ? 1 : d, y)) {
      return (m == FEB && d == 29 && FEB_29_OK) ? PARSE_OK : PARSE_INVDATE;
   }
   
   if (y != prev_year) {   /* avoid unnecessary year lookup */
      pyear = find_year(y, 1);
   }
   
   --m, --d;   /* adjust for use as subscripts */
   
   if ((pmonth = pyear->month[m]) == NULL) {   /* ignore delete if no entries exist */
      return PARSE_OK;
   }
   if (pmonth->day[d] == NULL) return PARSE_OK;
   
   /* delete text for day from list ignoring differences in only spacing and
      capitalization in the existing entry.
   */
   
   copy_text(text, pword); /* consolidate text from lbuf into text */
   
   if (DEBUG(DEBUG_DATES)) {
      char *p;
      fprintf(stderr, "Deleting event: %02d/%02d/%d%c '", m+1, d+1, y, is_holiday ? '*' : ' ');
      for (p = text; *p; p++) {
         fprintf(stderr, isprint((int)*p) ? "%c" : "\\%03o", *p & CHAR_MSK);
      }
      fprintf(stderr, "'\n");
   }
   
#if KEEP_NULL_LINES   /* preserve blank text lines in output */
   if (*text == '\0' && pmonth->day[d]) strcpy(text, BLANK_TEXT);
#endif

   /* check if non-null and find entry to delete */
   
   if (*text) {
      for (plast = NULL, pday = pmonth->day[d];
           pday;
           plast = pday, pday = pday->next) {
         if (ci_strcmp(pday->text, text) == 0) {
            found = TRUE;
            pdel = pday;
            pldel = plast;
         } 
         else is_holiday |= pday->is_holiday;
      }
      
      if (found) {
         if (pldel) pldel->next = pdel->next;
         else pmonth->day[d] = pdel->next;
         free(pdel);
         
         if (is_holiday) pmonth->holidays |= (1L << d);
         else pmonth->holidays &= ~(1L << d);
      }
   }
   
   return PARSE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %r8, %rbx
movl %edx, %r15d
movl %esi, %r14d
cmpl $0x2, %ecx
pushq $0x1
popq %rax
cmovel %eax, %esi
movl %edi, %r12d
cmpl $0x20, %r14d
cmovll %r14d, %esi
callq 0x9d12
testl %eax, %eax
je 0xc657
testl %r15d, %r15d
je 0xc66d
pushq $0x1
popq %rsi
movl %r15d, %edi
callq 0xb9d3
movq %rax, 0x21813(%rip)     # 0x2de68
jmp 0xc674
xorl $0x2, %r12d
xorl $0x1d, %r14d
xorl %ebp, %ebp
orl %r12d, %r14d
setne %bpl
jmp 0xc787
movq 0x217f4(%rip), %rax     # 0x2de68
movslq %r12d, %rcx
movq (%rax,%rcx,8), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0xc787
leal -0x1(%r14), %ecx
movslq %ecx, %rdx
cmpq $0x0, 0x8(%rax,%rdx,8)
je 0xc787
movq %rdx, (%rsp)
movl %ecx, 0x14(%rsp)
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0xa253
leaq 0x2000f(%rip), %rax     # 0x2c6cc
testb $0x2, (%rax)
jne 0xc79b
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
leaq (%rax,%rcx,8), %rax
addq $0x8, %rax
cmpb $0x0, 0x20(%rsp)
jne 0xc6ef
cmpq $0x0, (%rax)
je 0xc787
movw $0x20, 0x20(%rsp)
xorl %r15d, %r15d
leaq 0x20(%rsp), %rbx
movq %rax, 0x18(%rsp)
movq $0x0, (%rsp)
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq (%rax), %rbp
testq %rbp, %rbp
je 0xc73f
movq 0x8(%rbp), %rdi
movq %rbx, %rsi
callq 0x9624
testl %eax, %eax
je 0xc72b
orl (%rbp), %r13d
jmp 0xc736
movq %rbp, (%rsp)
movq %r15, %r14
pushq $0x1
popq %r12
leaq 0x10(%rbp), %rax
movq %rbp, %r15
jmp 0xc70d
xorl %ebp, %ebp
testl %r12d, %r12d
je 0xc787
leaq 0x10(%r14), %rax
testq %r14, %r14
movq (%rsp), %rdi
movq 0x10(%rdi), %rcx
cmoveq 0x18(%rsp), %rax
movq %rcx, (%rax)
callq 0x5050
movl 0x14(%rsp), %ecx
pushq $0x1
popq %rdx
shlq %cl, %rdx
testl %r13d, %r13d
je 0xc77c
movq 0x8(%rsp), %rax
orq %rdx, (%rax)
jmp 0xc787
notq %rdx
movq 0x8(%rsp), %rax
andq %rdx, (%rax)
movl %ebp, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1b856(%rip), %rax     # 0x27ff8
movq (%rax), %rdi
leaq 0x116fa(%rip), %rsi     # 0x1dea6
pushq $0x20
popq %r9
movl %r12d, %edx
movl %r14d, %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x5200
leaq 0x116d9(%rip), %r15     # 0x1dea0
leaq 0x14bf9(%rip), %r12     # 0x213c7
movzbl (%r13), %r14d
movq 0x1b81e(%rip), %rax     # 0x27ff8
movq (%rax), %rbx
testl %r14d, %r14d
je 0xc810
callq 0x5330
movq (%rax), %rax
movsbq %r14b, %rcx
movzwl (%rax,%rcx,2), %eax
btl $0xe, %eax
movq %r15, %rsi
jae 0xc7fe
movq %r12, %rsi
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x5200
incq %r13
jmp 0xc7ce
leaq 0x123b2(%rip), %rdi     # 0x1ebc9
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x5300
jmp 0xc6c6