// File: /workspace/github_c_makefile_star2_O1/mmayer[P]pcal/src/readfile.c
// Function: parse_ord
int parse_ord (int ord, int val, char **pword)
{
   int wkd, mon, mm, dd, len, doit, (*pfcn) (int, int, int);
   int val_first, val_last, val_incr, mon_first, mon_last;
   date_str *pdate, date;
   
   if ((wkd = get_weekday(*pword, TRUE)) == NOT_WEEKDAY ||   /* weekday */
       *++pword == NULL ||   /* any word */
       (mon = get_month(*++pword, FALSE, TRUE)) == NOT_MONTH) {   /* month */
      return PARSE_INVLINE;
   }
   
   /* set up loop boundaries for month loop */
   mon_first = mon == ALL_MONTHS || mon == ENTIRE_YEAR ? JAN : mon;
   mon_last  = mon == ALL_MONTHS || mon == ENTIRE_YEAR ? DEC : mon;
   
   pdate = candidate_dates;   /* start of 'candidate_dates[]' array */

   /* special case of "all|odd|even <wildcard> in <month>|all|year" */

   if ((ord == ORD_ALL || ord == ORD_EVEN || ord == ORD_ODD) && IS_WILD(wkd)) {
      pfcn = pdatefcn[wkd - WILD_FIRST];
      doit = ord != ORD_EVEN;
      for (mm = mon_first; mm <= mon_last; mm++) {
         len = LENGTH_OF(mm, curr_year);
         if (mon != ENTIRE_YEAR) doit = ord != ORD_EVEN;
         for (dd = 1; dd <= len; dd++) {
            if ((*pfcn)(mm, dd, curr_year)) {
               if (doit) ADD_DATE(mm, dd, curr_year);
               if (ord != ORD_ALL) doit = ! doit;
            }
         }
      }
   }

   /* special case of "odd|even <weekday> in year" */

   else if ((ord == ORD_EVEN || ord == ORD_ODD) && mon == ENTIRE_YEAR) {
      date.mm = JAN;   /* starting date */
      date.dd = calc_day(ord == ORD_EVEN ? 2 : 1, wkd, JAN);
      date.yy = curr_year;
      do {   /* alternates throughout year */
         ADD_DATE(date.mm, date.dd, date.yy);
         date.dd += 14;
         normalize(&date);
      } while (date.yy == curr_year);
   }
   
   /* special case of "<ordinal>|last <weekday>|<wildcard> in year" */
   
   else if ((ord == ORD_NEGNUM || ord == ORD_POSNUM) && mon == ENTIRE_YEAR) {
      if (calc_year_day(val, wkd, &date)) ADD_DATE(date.mm, date.dd, date.yy);
   }
   
   /* all other combinations of ordinal and day */
   
   else {
      /* set up loop boundaries for "wildcard" ordinals */
      
      val_first = ord == ORD_ALL || ord == ORD_ODD ? 1 : ord == ORD_EVEN ? 2 : val;
      val_last  = ord == ORD_ALL || ord == ORD_ODD ? 5 : ord == ORD_EVEN ? 4 : val;
      val_incr  = ord == ORD_ODD || ord == ORD_EVEN ? 2 : 1;
      
      for (mm = mon_first; mm <= mon_last; mm++) {
         for (val = val_first; val <= val_last; val += val_incr) {
            if ((dd = calc_day(val, wkd, mm)) != 0) ADD_DATE(mm, dd, curr_year);
         }
      }
   }
   
   TERM_DATES;   /* terminate array with null entry */
   return PARSE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movl %esi, %r12d
movl %edi, %r14d
movq (%rdx), %rdi
movl $0x1, %esi
callq 0xcb3b
movl $0x2, %r13d
movq %rax, 0x18(%rsp)
cmpl $-0x1, %eax
je 0xdd3a
cmpq $0x0, 0x8(%r15)
je 0xdd3a
movq 0x10(%r15), %rdi
movl $0x1, %r15d
xorl %esi, %esi
movl $0x1, %edx
callq 0xc9f2
cmpl $-0x1, %eax
je 0xdd3a
testl %eax, %eax
sete %dl
cmpl $0xd, %eax
sete %cl
orb %dl, %cl
cmovel %eax, %r15d
movl $0xc, %edi
cmovel %eax, %edi
leal -0x2(%r14), %r8d
cmpl $0x3, %r8d
setae %dl
movq 0x18(%rsp), %rcx
addl $-0x7, %ecx
cmpl $0xb, %ecx
setae %sil
orb %dl, %sil
jne 0xdacd
xorl %r8d, %r8d
cmpl $0x3, %r14d
setne %sil
cmpl %edi, %r15d
jle 0xdb92
leaq 0x203b8(%rip), %r13     # 0x2de80
jmp 0xdd27
xorl $0xd, %eax
movl %r14d, %ecx
andl $-0x2, %ecx
movl %ecx, %edx
xorl $0x2, %edx
orl %eax, %edx
jne 0xdcd5
xorl %edi, %edi
cmpl $0x3, %r14d
sete %dil
leaq 0x4(%rsp), %rbx
movl $0x1, (%rbx)
incl %edi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0xa2da
movl %eax, 0x4(%rbx)
leaq 0x1facd(%rip), %r15     # 0x2d5e0
movl (%r15), %eax
movl %eax, 0x8(%rbx)
leaq 0x20360(%rip), %r13     # 0x2de80
leaq 0x1ebb5(%rip), %r12     # 0x2c6dc
movq 0x1a4c2(%rip), %rbp     # 0x27ff0
leaq 0x11302(%rip), %r14     # 0x1ee37
testb $0x2, (%r12)
jne 0xdb75
movl 0x4(%rsp), %eax
movl %eax, (%r13)
movl 0x8(%rsp), %eax
movl %eax, 0x4(%r13)
movl 0xc(%rsp), %ecx
movl %ecx, 0x8(%r13)
addq $0xc, %r13
addl $0xe, %eax
movl %eax, 0x8(%rsp)
movq %rbx, %rdi
callq 0xa1b1
movl 0xc(%rsp), %eax
cmpl (%r15), %eax
je 0xdb35
jmp 0xdd27
movq (%rbp), %rdi
movl 0xc(%rsp), %edx
movl 0x4(%rsp), %ecx
movl 0x8(%rsp), %r8d
movq %r14, %rsi
xorl %eax, %eax
callq 0x5210
jmp 0xdb3c
movl %eax, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movl %ecx, %ecx
leaq 0x1a64c(%rip), %rdx     # 0x281f0
movq (%rdx,%rcx,8), %rbp
movb %sil, %r8b
movslq %r15d, %r14
incl %edi
movl %edi, 0x14(%rsp)
leaq 0x202c5(%rip), %r13     # 0x2de80
movl %r8d, %ebx
movl %r8d, 0x24(%rsp)
movl $0x0, %eax
cmpq $0x2, %r14
jne 0xdc0d
leaq 0x1fa0b(%rip), %rax     # 0x2d5e0
movl (%rax), %ecx
movl $0x0, %eax
testb $0x3, %cl
jne 0xdc0d
imull $0xc28f5c29, %ecx, %ecx # imm = 0xC28F5C29
addl $0x51eb850, %ecx        # imm = 0x51EB850
movl %ecx, %edx
rorl $0x2, %edx
movl $0x1, %eax
cmpl $0x28f5c28, %edx        # imm = 0x28F5C28
ja 0xdc0d
rorl $0x4, %ecx
xorl %eax, %eax
cmpl $0xa3d70b, %ecx         # imm = 0xA3D70B
setb %al
leaq 0x1a5ac(%rip), %rcx     # 0x281c0
movsbl -0x1(%r14,%rcx), %r15d
cmpl $0xd, 0x10(%rsp)
cmovnel %r8d, %ebx
addl %eax, %r15d
jle 0xdcc0
negl %r15d
movl $0x1, %r12d
leaq 0x1f9a4(%rip), %rax     # 0x2d5e0
movl (%rax), %edx
movl %r14d, %edi
movl %r12d, %esi
callq *%rbp
testl %eax, %eax
je 0xdc82
testl %ebx, %ebx
je 0xdc73
leaq 0x1ea87(%rip), %rax     # 0x2c6dc
testb $0x2, (%rax)
jne 0xdc97
movl %r14d, (%r13)
movl %r12d, 0x4(%r13)
leaq 0x1f977(%rip), %rax     # 0x2d5e0
movl (%rax), %eax
movl %eax, 0x8(%r13)
addq $0xc, %r13
xorl %eax, %eax
testl %ebx, %ebx
sete %al
cmpl $0x4, 0x18(%rsp)
cmovnel %eax, %ebx
leal (%r15,%r12), %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
cmpl $0x1, %eax
jne 0xdc35
jmp 0xdcc0
movq 0x1a352(%rip), %rax     # 0x27ff0
movq (%rax), %rdi
leaq 0x1f938(%rip), %rax     # 0x2d5e0
movl (%rax), %edx
leaq 0x11186(%rip), %rsi     # 0x1ee37
movl %r14d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x5210
jmp 0xdc5a
incq %r14
cmpl %r14d, 0x14(%rsp)
movl 0x24(%rsp), %r8d
jne 0xdbc3
jmp 0xdd27
leal 0x1(%r14), %edx
andl $-0x3, %edx
orl %eax, %edx
jne 0xdd4c
leaq 0x4(%rsp), %rdx
movl %r12d, %edi
movq 0x18(%rsp), %rsi
callq 0xa639
testl %eax, %eax
je 0xdac1
leaq 0x1e9db(%rip), %rax     # 0x2c6dc
testb $0x2, (%rax)
jne 0xde23
movl 0x4(%rsp), %eax
movl %eax, 0x2016c(%rip)     # 0x2de80
movq 0x8(%rsp), %rax
movq %rax, 0x20164(%rip)     # 0x2de84
leaq 0x20165(%rip), %r13     # 0x2de8c
movl $0x0, 0x8(%r13)
movq $0x0, (%r13)
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
cmpl $0x2, %ecx
sete %cl
cmpl $0x3, %r14d
movl $0x2, %edx
cmovnel %r12d, %edx
movl $0x4, %esi
cmovnel %r12d, %esi
testl $0xfffffffd, %r8d       # imm = 0xFFFFFFFD
movl $0x1, %ebp
cmovnel %edx, %ebp
movl $0x5, %r14d
cmovnel %esi, %r14d
cmpl %edi, %r15d
jg 0xdac1
movl %edi, 0x14(%rsp)
movb %cl, %bl
incl %ebx
leaq 0x200e5(%rip), %r13     # 0x2de80
movl %ebp, 0x10(%rsp)
cmpl %r14d, %ebp
jg 0xdde3
movl %ebp, %edi
movq 0x18(%rsp), %rsi
movl %r15d, %edx
callq 0xa2da
testl %eax, %eax
je 0xdddf
movl %eax, %r12d
leaq 0x1e91b(%rip), %rax     # 0x2c6dc
testb $0x2, (%rax)
jne 0xddfa
movl %r15d, (%r13)
movl %r12d, 0x4(%r13)
leaq 0x1f80b(%rip), %rax     # 0x2d5e0
movl (%rax), %eax
movl %eax, 0x8(%r13)
addq $0xc, %r13
addl %ebx, %ebp
jmp 0xdd9f
leal 0x1(%r15), %eax
cmpl 0x14(%rsp), %r15d
movl %eax, %r15d
movl 0x10(%rsp), %ebp
jne 0xdd9f
jmp 0xdd27
movq 0x1a1ef(%rip), %rax     # 0x27ff0
movq (%rax), %rdi
leaq 0x1f7d5(%rip), %rax     # 0x2d5e0
movl (%rax), %edx
leaq 0x11023(%rip), %rsi     # 0x1ee37
movl %r15d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x5210
jmp 0xddc6
leaq 0x4(%rsp), %rdi
callq 0x56f2
jmp 0xdd0a