// File: /workspace/github_c_makefile_star2_O3/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, %ebx
cmpl $0x1, %ecx
sete %r15b
cmpl $0x2, %ecx
movl $0x1, %esi
cmovnel %ebx, %esi
movl %edi, %r14d
cmpl $0x20, %ebx
cmovll %ebx, %esi
callq 0xaaaa
testl %eax, %eax
je 0xd42f
testl %ebp, %ebp
movb %r15b, 0x7(%rsp)
movq %r13, 0x8(%rsp)
je 0xd443
movl %ebp, %edi
movl $0x1, %esi
callq 0xc8d0
movq %rax, 0x21a43(%rip)     # 0x2ee70
jmp 0xd44a
xorl $0x2, %r14d
xorl $0x1d, %ebx
xorl %eax, %eax
orl %r14d, %ebx
setne %al
jmp 0xd614
movq 0x21a26(%rip), %rax     # 0x2ee70
movslq %r14d, %r13
movq (%rax,%r13,8), %r15
testq %r15, %r15
jne 0xd482
decq %r13
movl $0x170, %edi            # imm = 0x170
callq 0xa2c0
movq %rax, %r15
movq 0x21a03(%rip), %rax     # 0x2ee70
movq %r15, 0x8(%rax,%r13,8)
leaq 0x8(%r15), %rdi
movl $0x168, %edx            # imm = 0x168
xorl %esi, %esi
callq 0x5170
leal -0x1(%rbx), %r13d
cmpl $0x1, %r12d
jne 0xd49a
movl $0x1, %eax
movl %r13d, %ecx
shlq %cl, %rax
orq %rax, (%r15)
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0xb09a
leaq 0x2022c(%rip), %rax     # 0x2d6dc
testb $0x2, (%rax)
jne 0xd626
xorl %ebp, %ebp
movb 0x7(%rsp), %al
movb %al, %bpl
cmpb $0x0, 0x10(%rsp)
movslq %r13d, %rcx
movq 0x8(%r15,%rcx,8), %rax
je 0xd4e3
leaq (%r15,%rcx,8), %r12
addq $0x8, %r12
testq %rax, %rax
jne 0xd4fb
xorl %r13d, %r13d
jmp 0xd528
testq %rax, %rax
je 0xd612
movw $0x20, 0x10(%rsp)
leaq (%r15,%rcx,8), %r12
addq $0x8, %r12
leaq 0x10(%rsp), %rbx
movq %rax, %r13
movq 0x8(%rax), %rdi
movq %rbx, %rsi
callq 0xa2e0
testl %eax, %eax
jne 0xd51f
cmpw $0x20, 0x10(%rsp)
jne 0xd5d2
movq 0x10(%r13), %rax
testq %rax, %rax
jne 0xd500
movl $0x18, %edi
callq 0xa2c0
movq %rax, %rbx
movl %ebp, (%rax)
leaq 0x1c758(%rip), %rax     # 0x29c96
movb (%rax), %al
cmpb $0x52, %al
je 0xd5d8
leaq 0x20179(%rip), %rcx     # 0x2d6c8
cmpl $0x0, (%rcx)
jne 0xd5d8
cmpb $0x49, %al
leaq 0x12023(%rip), %rcx     # 0x1f584
leaq 0x13245(%rip), %rdx     # 0x207ad
cmoveq %rcx, %rdx
cmpb $0x42, %al
leaq 0x1200c(%rip), %r14     # 0x1f581
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 0xa2c0
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x50a0
cmpb $0x0, (%r14)
je 0xd5c2
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x5100
movw $0x20, (%r14,%rax)
movq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x52e0
jmp 0xd5fc
orl %ebp, (%r13)
jmp 0xd612
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x5100
leal 0x1(%rax), %edi
callq 0xa2c0
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x50a0
movq $0x0, 0x10(%rbx)
leaq 0x10(%r13), %rax
testq %r13, %r13
cmoveq %r12, %rax
movq %rbx, (%rax)
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 0x1b9bf(%rip), %r12     # 0x28ff0
movq (%r12), %rdi
movl $0x2a, %eax
movl $0x20, %r9d
cmovel %eax, %r9d
leaq 0x12886(%rip), %rsi     # 0x1fed1
movl %r14d, %edx
movl %ebx, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x5210
movb 0x10(%rsp), %al
testb %al, %al
je 0xd66f
movzbl %al, %edi
leaq 0x10(%rsp), %rsi
callq 0x553e
movq (%r12), %rcx
leaq 0x1359f(%rip), %rdi     # 0x20c19
movl $0x2, %esi
movl $0x1, %edx
callq 0x5310
jmp 0xd4b9