// File: /workspace/github_c_makefile_star2_O3/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 0xaaaa
testl %eax, %eax
je 0xd6e3
testl %r15d, %r15d
je 0xd6f9
movl %r15d, %edi
movl $0x1, %esi
callq 0xc8d0
movq %rax, 0x21797(%rip)     # 0x2ee78
jmp 0xd700
xorl $0x2, %r12d
xorl $0x1d, %r14d
xorl %ebp, %ebp
orl %r12d, %r14d
setne %bpl
jmp 0xd82a
movq 0x21778(%rip), %rax     # 0x2ee78
movslq %r12d, %rcx
movq (%rax,%rcx,8), %rcx
xorl %ebp, %ebp
testq %rcx, %rcx
je 0xd82a
leal -0x1(%r14), %edx
movslq %edx, %rax
cmpq $0x0, 0x8(%rcx,%rax,8)
je 0xd82a
movl %edx, (%rsp)
movq %rcx, 0x8(%rsp)
leaq (%rcx,%rax,8), %rbx
addq $0x8, %rbx
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0xb09a
leaq 0x1ff93(%rip), %rax     # 0x2d6dc
testb $0x2, (%rax)
jne 0xd83e
cmpb $0x0, 0x20(%rsp)
movq %rbx, 0x10(%rsp)
movq (%rbx), %r14
je 0xd76b
testq %r14, %r14
jne 0xd77b
jmp 0xd82a
testq %r14, %r14
je 0xd82a
movw $0x20, 0x20(%rsp)
xorl %r12d, %r12d
movb $0x1, %al
leaq 0x20(%rsp), %r15
xorl %ecx, %ecx
xorl %ebx, %ebx
movq %rcx, 0x18(%rsp)
movl %eax, 0x4(%rsp)
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0xa2e0
testl %eax, %eax
je 0xd7c3
movq %r14, %r13
orl (%r14), %r12d
movq 0x10(%r14), %r14
testq %r14, %r14
je 0xd7d9
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0xa2e0
testl %eax, %eax
jne 0xd7a2
jmp 0xd7c6
movq %rbx, %r13
movq %r14, %rbx
movq 0x10(%r14), %r14
xorl %eax, %eax
movq %r13, %rcx
testq %r14, %r14
jne 0xd789
jmp 0xd7e7
xorl %ebp, %ebp
movq 0x18(%rsp), %r13
testb $0x1, 0x4(%rsp)
jne 0xd82a
leaq 0x10(%r13), %rax
testq %r13, %r13
movq 0x10(%rbx), %rcx
cmoveq 0x10(%rsp), %rax
movq %rcx, (%rax)
movq %rbx, %rdi
callq 0x5050
movl $0x1, %eax
movl (%rsp), %ecx
shlq %cl, %rax
testl %r12d, %r12d
je 0xd81d
movq 0x8(%rsp), %rcx
orq %rax, (%rcx)
jmp 0xd828
notq %rax
movq 0x8(%rsp), %rcx
andq %rax, (%rcx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20(%rsp), %rcx
movl %r12d, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x55ad
jmp 0xd752