// File: /workspace/github_c_makefile_star2_O1/mmayer[P]pcal/src/readfile.c
// Function: enter_day_info
int enter_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;
   int is_holiday = text_type == HOLIDAY_TEXT;
   char text[LINSIZ], *tface;

   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) {   /* find/create month record */
      int i;
      pyear->month[m] = pmonth = (month_info *) alloc((int) sizeof(month_info));
      for (i = 0; i < (int)(ARRAYSIZE(pmonth->day)); i++) pmonth->day[i] = NULL;
   }

   if (is_holiday) pmonth->holidays |= (1L << d);

   /* insert text for day at end of list (preserving the order of entry for
      multiple lines on same day); eliminate those differing only in spacing
      and capitalization from existing entries
   */

   copy_text(text, pword);   /* consolidate text from lbuf into text */

   if (DEBUG(DEBUG_DATES)) {
      char *p;
      fprintf(stderr, "Adding 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 that non-null text is unique */
   
   if (*text) {
      for (plast = NULL, pday = pmonth->day[d];
           pday;
           plast = pday, pday = pday->next) {

         if (ci_strcmp(pday->text, text) == 0
#if KEEP_NULL_LINES
             && strcmp(text, BLANK_TEXT) != 0
#endif
             ) {
            pday->is_holiday |= is_holiday;
            return PARSE_OK;
         }
      }
      
      /* unique - add to end of list */
      
      pday = (day_info *) alloc(sizeof(day_info));
      pday->is_holiday = is_holiday;
      
      if (fontstyle[0] == ROMAN || output_type != OUTPUT_PS) {
         /* copy text intact (no font shift) */
         strcpy(pday->text = (char *) alloc(strlen(text)+1), text);
      } 
      else {
         /* prepend font shift sequence to text */
         tface = fontstyle[0] == BOLD   ? BOLD_FONT : fontstyle[0] == ITALIC ? ITALIC_FONT : "";
         pday->text = (char *) alloc(strlen(tface) + strlen(text) + 2);
         strcpy(pday->text, tface);
         if (*tface) strcat(pday->text, " ");
         strcat(pday->text, text);
      }
      
      pday->next = NULL;
      *(plast ? &plast->next : &pmonth->day[d]) = pday;
   }
   
   return PARSE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %r8, %r13
movl %ecx, %r12d
movl %edx, %ebp
movl %esi, %r14d
cmpl $0x1, %ecx
sete %bl
cmpl $0x2, %ecx
movl $0x1, %esi
cmovnel %r14d, %esi
movl %edi, %r15d
cmpl $0x20, %r14d
cmovll %r14d, %esi
callq 0xa4d4
testl %eax, %eax
je 0xd055
movq %r13, 0x8(%rsp)
movb %bl, 0x7(%rsp)
testl %ebp, %ebp
je 0xcf72
movl %ebp, %edi
movl $0x1, %esi
callq 0xc3f7
movq %rax, 0x20efe(%rip)     # 0x2de70
movslq %r15d, %r13
movq 0x20ef4(%rip), %rax     # 0x2de70
movq (%rax,%r13,8), %rbx
testq %rbx, %rbx
jne 0xcfb1
decq %r13
movl $0x170, %edi            # imm = 0x170
callq 0x9ce0
movq %rax, %rbx
movq 0x20ed4(%rip), %rax     # 0x2de70
movq %rbx, 0x8(%rax,%r13,8)
leaq 0x8(%rbx), %rdi
movl $0x168, %edx            # imm = 0x168
xorl %esi, %esi
callq 0x5170
leal -0x1(%r14), %r13d
cmpl $0x1, %r12d
jne 0xcfc9
movl $0x1, %eax
movl %r13d, %ecx
shlq %cl, %rax
orq %rax, (%rbx)
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0xaadb
leaq 0x1f6fd(%rip), %rax     # 0x2c6dc
testb $0x2, (%rax)
jne 0xd170
cmpb $0x0, 0x10(%rsp)
jne 0xd001
movslq %r13d, %rax
cmpq $0x0, 0x8(%rbx,%rax,8)
je 0xd001
movw $0x20, 0x10(%rsp)
cmpb $0x0, 0x10(%rsp)
movl $0x0, %ebp
je 0xd15c
movb 0x7(%rsp), %al
movb %al, %bpl
movslq %r13d, %r15
movq 0x8(%rbx,%r15,8), %rax
testq %rax, %rax
je 0xd06a
leaq 0x10(%rsp), %r14
movq %rax, %r12
movq 0x8(%rax), %rdi
movq %r14, %rsi
callq 0x9d00
testl %eax, %eax
jne 0xd049
cmpw $0x20, 0x10(%rsp)
jne 0xd158
movq 0x10(%r12), %rax
testq %rax, %rax
jne 0xd02a
jmp 0xd06d
xorl $0x2, %r15d
xorl $0x1d, %r14d
xorl %eax, %eax
orl %r15d, %r14d
setne %al
jmp 0xd15e
xorl %r12d, %r12d
leaq (%rbx,%r15,8), %r13
addq $0x8, %r13
movl $0x18, %edi
callq 0x9ce0
movq %rax, %rbx
movl %ebp, (%rax)
leaq 0x1bc0b(%rip), %rax     # 0x28c96
movb (%rax), %al
cmpb $0x52, %al
je 0xd11b
leaq 0x1f62c(%rip), %rcx     # 0x2c6c8
cmpl $0x0, (%rcx)
jne 0xd11b
cmpb $0x49, %al
leaq 0x11463(%rip), %rcx     # 0x1e50d
leaq 0x1268c(%rip), %rdx     # 0x1f73d
cmoveq %rcx, %rdx
cmpb $0x42, %al
leaq 0x1144c(%rip), %r14     # 0x1e50a
cmovneq %rdx, %r14
movq %r14, %rdi
callq 0x5100
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x5100
leal (%rax,%r15), %edi
addl $0x2, %edi
callq 0x9ce0
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x50a0
cmpb $0x0, (%r14)
je 0xd10b
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x5100
movw $0x20, (%r14,%rax)
movq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x52e0
jmp 0xd13f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x5100
leal 0x1(%rax), %edi
callq 0x9ce0
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x50a0
movq $0x0, 0x10(%rbx)
leaq 0x10(%r12), %rax
testq %r12, %r12
cmoveq %r13, %rax
movq %rbx, (%rax)
jmp 0xd15c
orl %ebp, (%r12)
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r12d
movq 0x1ae75(%rip), %r12     # 0x27ff0
movq (%r12), %rdi
movl $0x2a, %eax
movl $0x20, %r9d
cmovel %eax, %r9d
leaq 0x11cc8(%rip), %rsi     # 0x1ee5d
movl %r15d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x5210
movb 0x10(%rsp), %al
testb %al, %al
je 0xd1ba
movzbl %al, %edi
leaq 0x10(%rsp), %rsi
callq 0x556f
movq (%r12), %rcx
leaq 0x129e4(%rip), %rdi     # 0x1fba9
movl $0x2, %esi
movl $0x1, %edx
callq 0x5310
jmp 0xcfe8