// File: /workspace/github_c_makefile_star2_O1/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, %r13
movl %edx, %r15d
movl %esi, %r14d
cmpl $0x2, %ecx
movl $0x1, %esi
cmovnel %r14d, %esi
movl %edi, %r12d
cmpl $0x20, %r14d
cmovll %r14d, %esi
callq 0xa4d4
testl %eax, %eax
je 0xd322
testl %r15d, %r15d
je 0xd230
movl %r15d, %edi
movl $0x1, %esi
callq 0xc3f7
movq %rax, 0x20c48(%rip)     # 0x2de78
movq 0x20c41(%rip), %rax     # 0x2de78
movslq %r12d, %rcx
movq (%rax,%rcx,8), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0xd333
leal -0x1(%r14), %ecx
movslq %ecx, %rbx
cmpq $0x0, 0x8(%rax,%rbx,8)
je 0xd333
movl %ecx, 0xc(%rsp)
movq %rax, (%rsp)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0xaadb
leaq 0x1f464(%rip), %rax     # 0x2c6dc
testb $0x2, (%rax)
jne 0xd396
movq (%rsp), %rax
leaq (%rax,%rbx,8), %rdx
addq $0x8, %rdx
cmpb $0x0, 0x20(%rsp)
jne 0xd2a1
cmpq $0x0, (%rdx)
je 0xd2a1
movw $0x20, 0x20(%rsp)
cmpb $0x0, 0x20(%rsp)
je 0xd333
movq (%rdx), %rax
testq %rax, %rax
je 0xd347
movq $0x0, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
leaq 0x20(%rsp), %r15
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r13d, %r13d
movq %rax, %r14
movq 0x8(%rax), %rdi
movq %r15, %rsi
callq 0x9d00
testl %eax, %eax
je 0xd2ed
orl (%r14), %r12d
jmp 0xd2fd
movl $0x1, %eax
movq %rax, 0x10(%rsp)
movq %r14, %rbx
movq %r13, %rbp
movq 0x10(%r14), %rax
movq %r14, %r13
testq %rax, %rax
jne 0xd2d5
cmpl $0x0, 0x10(%rsp)
sete %al
testl %r12d, %r12d
sete %r14b
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
jmp 0xd350
xorl $0x2, %r12d
xorl $0x1d, %r14d
xorl %ebp, %ebp
orl %r12d, %r14d
setne %bpl
movl %ebp, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %r14b
xorl %ebx, %ebx
xorl %ecx, %ecx
movb $0x1, %al
xorl %ebp, %ebp
testb %al, %al
jne 0xd333
leaq 0x10(%rcx), %rax
testq %rcx, %rcx
movq 0x10(%rbx), %rcx
cmoveq %rdx, %rax
movq %rcx, (%rax)
movq %rbx, %rdi
callq 0x5050
movl $0x1, %eax
movl 0xc(%rsp), %ecx
shlq %cl, %rax
testb %r14b, %r14b
je 0xd38d
notq %rax
movq (%rsp), %rcx
andq %rax, (%rcx)
jmp 0xd333
movq (%rsp), %rcx
orq %rax, (%rcx)
jmp 0xd333
leaq 0x20(%rsp), %rcx
movl %r12d, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x55de
jmp 0xd281