// File: /workspace/github_c_makefile_star2_O2/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 $0x228, %rsp            # imm = 0x228
movq %r8, %r13
movl %ecx, %r12d
movl %edx, %ebp
movl %esi, %r14d
cmpl $0x1, %ecx
sete %bl
cmpl $0x2, %ecx
pushq $0x1
popq %rsi
cmovnel %r14d, %esi
movl %edi, %r15d
cmpl $0x20, %r14d
cmovll %r14d, %esi
callq 0x9d12
testl %eax, %eax
je 0xc374
testl %ebp, %ebp
movb %bl, 0xf(%rsp)
movl %ebp, 0x10(%rsp)
movq %r13, 0x18(%rsp)
je 0xc389
pushq $0x1
popq %rsi
movl %ebp, %edi
callq 0xb9d3
movq %rax, 0x21aee(%rip)     # 0x2de60
jmp 0xc390
xorl $0x2, %r15d
xorl $0x1d, %r14d
xorl %eax, %eax
orl %r15d, %r14d
setne %al
jmp 0xc55f
movq 0x21ad0(%rip), %rax     # 0x2de60
movslq %r15d, %rbp
movq (%rax,%rbp,8), %rbx
pushq $0x1
popq %r13
testq %rbx, %rbx
je 0xc4f3
leal -0x1(%r14), %ecx
cmpl $0x1, %r12d
jne 0xc3b4
shlq %cl, %r13
orq %r13, (%rbx)
movl %ecx, 0x14(%rsp)
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq 0xa253
leaq 0x202fb(%rip), %rax     # 0x2c6cc
testb $0x2, (%rax)
movl $0x0, %ebp
jne 0xc571
cmpb $0x0, 0x20(%rsp)
movl 0x14(%rsp), %eax
cltq
jne 0xc3ff
cmpq $0x0, 0x8(%rbx,%rax,8)
je 0xc55d
movw $0x20, 0x20(%rsp)
movb 0xf(%rsp), %cl
movb %cl, %bpl
leaq (%rbx,%rax,8), %r12
addq $0x8, %r12
xorl %r13d, %r13d
leaq 0x20(%rsp), %rbx
movq %r12, %rax
movq (%rax), %r14
testq %r14, %r14
je 0xc446
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x9624
testl %eax, %eax
jne 0xc43d
cmpw $0x20, 0x20(%rsp)
jne 0xc4ee
leaq 0x10(%r14), %rax
movq %r14, %r13
jmp 0xc419
pushq $0x18
popq %rdi
callq 0x95e4
movq %rax, %rbx
movl %ebp, (%rax)
leaq 0x1c82c(%rip), %rax     # 0x28c86
movb (%rax), %al
cmpb $0x52, %al
je 0xc526
leaq 0x2024d(%rip), %rcx     # 0x2c6b8
cmpl $0x0, (%rcx)
jne 0xc526
cmpb $0x49, %al
leaq 0x110b7(%rip), %rcx     # 0x1d534
leaq 0x122d9(%rip), %rdx     # 0x1e75d
cmoveq %rcx, %rdx
cmpb $0x42, %al
leaq 0x110a0(%rip), %r14     # 0x1d531
cmovneq %rdx, %r14
movq %r14, %rdi
callq 0x5100
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x5100
leal (%rax,%r15), %edi
addl $0x2, %edi
callq 0x95e4
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x50a0
cmpb $0x0, (%r14)
je 0xc4de
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x5100
movw $0x20, (%r14,%rax)
movq 0x8(%rbx), %rdi
leaq 0x20(%rsp), %rsi
callq 0x52d0
jmp 0xc54a
orl %ebp, (%r14)
jmp 0xc55d
decq %rbp
movl $0x170, %edi            # imm = 0x170
callq 0x95e4
movq %rax, %rbx
movq 0x21956(%rip), %rax     # 0x2de60
movq %rbx, 0x8(%rax,%rbp,8)
movq %r13, %rax
cmpq $0x2e, %rax
je 0xc3a4
andq $0x0, (%rbx,%rax,8)
incq %rax
jmp 0xc512
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x5100
leal 0x1(%rax), %edi
callq 0x95e4
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x50a0
andq $0x0, 0x10(%rbx)
leaq 0x10(%r13), %rax
testq %r13, %r13
cmoveq %r12, %rax
movq %rbx, (%rax)
xorl %eax, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r12d
movq 0x1ba7c(%rip), %r12     # 0x27ff8
movq (%r12), %rdi
pushq $0x2a
popq %rax
pushq $0x20
popq %r9
cmovel %eax, %r9d
leaq 0x118ef(%rip), %rsi     # 0x1de81
movl %r15d, %edx
movl %r14d, %ecx
movl 0x10(%rsp), %r8d
xorl %eax, %eax
callq 0x5200
leaq 0x118f5(%rip), %rbp     # 0x1dea0
movzbl (%r13), %r15d
movq (%r12), %r14
testl %r15d, %r15d
je 0xc5eb
callq 0x5330
movq (%rax), %rax
movsbq %r15b, %rcx
movzwl (%rax,%rcx,2), %eax
btl $0xe, %eax
movq %rbp, %rsi
jae 0xc5d9
leaq 0x14dee(%rip), %rsi     # 0x213c7
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x5200
incq %r13
jmp 0xc5ab
leaq 0x125d7(%rip), %rdi     # 0x1ebc9
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x5300
xorl %ebp, %ebp
jmp 0xc3df