// File: /workspace/github_c_makefile_star2_O2/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, %r14
movl %esi, %ebx
movl %edi, %r15d
movq (%rdx), %rdi
pushq $0x1
popq %rsi
callq 0xbf9b
pushq $0x2
popq %r12
movq %rax, 0x10(%rsp)
cmpl $-0x1, %eax
je 0xd284
cmpq $0x0, 0x8(%r14)
je 0xd284
movq 0x10(%r14), %rdi
pushq $0x1
popq %r13
xorl %esi, %esi
movl %r13d, %edx
callq 0xbe6c
cmpl $-0x1, %eax
je 0xd284
testl %eax, %eax
sete %dl
cmpl $0xd, %eax
sete %cl
orb %dl, %cl
movl %eax, %r12d
cmovnel %r13d, %r12d
pushq $0xc
popq %r8
cmovel %eax, %r8d
leal -0x2(%r15), %edi
cmpl $0x3, %edi
setae %dl
movq 0x10(%rsp), %rcx
addl $-0x7, %ecx
cmpl $0xb, %ecx
setae %sil
orb %dl, %sil
jne 0xd097
movl %eax, 0xc(%rsp)
movl %ecx, %eax
leaq 0x1b25b(%rip), %rcx     # 0x281e0
movq (%rcx,%rax,8), %r14
xorl %ebp, %ebp
movq %r15, 0x10(%rsp)
cmpl $0x3, %r15d
setne %bpl
movslq %r12d, %r15
movslq %r8d, %rax
movq %rax, 0x18(%rsp)
leaq 0x20ec6(%rip), %rbx     # 0x2de70
movl %ebp, 0x24(%rsp)
cmpq 0x18(%rsp), %r15
jg 0xd279
leaq 0x1b1f0(%rip), %rax     # 0x281b0
movsbl -0x1(%r15,%rax), %esi
xorl %r12d, %r12d
cmpq $0x2, %r15
jne 0xcfff
leaq 0x205fa(%rip), %rax     # 0x2d5d0
movl (%rax), %ecx
testb $0x3, %cl
jne 0xcfff
movl %ecx, %eax
cltd
pushq $0x64
popq %rdi
idivl %edi
movl %r13d, %r12d
testl %edx, %edx
jne 0xcfff
movl %ecx, %eax
cltd
movl $0x190, %ecx            # imm = 0x190
idivl %ecx
xorl %r12d, %r12d
testl %edx, %edx
sete %r12b
addl %esi, %r12d
cmpl $0xd, 0xc(%rsp)
cmovnel 0x24(%rsp), %ebp
cmpl %r12d, %r13d
jg 0xd08b
leaq 0x205b8(%rip), %rax     # 0x2d5d0
movl (%rax), %edx
movl %r15d, %edi
movl %r13d, %esi
callq *%r14
testl %eax, %eax
je 0xd05d
testl %ebp, %ebp
je 0xd04e
leaq 0x1f69a(%rip), %rax     # 0x2c6cc
testb $0x2, (%rax)
jne 0xd062
movl %r15d, (%rbx)
movl %r13d, 0x4(%rbx)
leaq 0x2058b(%rip), %rax     # 0x2d5d0
movl (%rax), %eax
movl %eax, 0x8(%rbx)
addq $0xc, %rbx
xorl %eax, %eax
testl %ebp, %ebp
sete %al
cmpl $0x4, 0x10(%rsp)
cmovnel %eax, %ebp
incl %r13d
jmp 0xd00c
movq 0x1af8f(%rip), %rax     # 0x27ff8
movq (%rax), %rdi
leaq 0x2055d(%rip), %rax     # 0x2d5d0
movl (%rax), %edx
leaq 0x10ddf(%rip), %rsi     # 0x1de5b
movl %r15d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x5200
jmp 0xd037
incq %r15
pushq $0x1
popq %r13
jmp 0xcfae
xorl $0xd, %eax
movl %r15d, %ecx
andl $-0x2, %ecx
movl %ecx, %edx
xorl $0x2, %edx
orl %eax, %edx
jne 0xd158
xorl %edi, %edi
cmpl $0x3, %r15d
sete %dil
movq %rsp, %r12
movl $0x1, (%r12)
incl %edi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %rsi
callq 0x9b96
movl %eax, 0x4(%r12)
leaq 0x204f3(%rip), %r15     # 0x2d5d0
movl (%r15), %edx
movl %edx, 0x8(%r12)
leaq 0x20d84(%rip), %rbx     # 0x2de70
leaq 0x1f5d9(%rip), %r13     # 0x2c6cc
movq 0x1aefe(%rip), %rbp     # 0x27ff8
leaq 0x10d5a(%rip), %r14     # 0x1de5b
testb $0x2, (%r13)
movl (%rsp), %ecx
movl 0x4(%rsp), %r8d
jne 0xd13c
movl %ecx, (%rbx)
movl %r8d, 0x4(%rbx)
movl %edx, 0x8(%rbx)
addq $0xc, %rbx
addl $0xe, %r8d
movl %r8d, 0x4(%rsp)
movq %r12, %rdi
callq 0x9aa7
movl 0x8(%rsp), %edx
cmpl (%r15), %edx
je 0xd101
jmp 0xd279
movq (%rbp), %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x5200
movl (%rsp), %ecx
movl 0x4(%rsp), %r8d
movl 0x8(%rsp), %edx
jmp 0xd110
leal 0x1(%r15), %edx
andl $-0x3, %edx
orl %eax, %edx
jne 0xd1ab
movq %rsp, %rdx
movl %ebx, %edi
movq 0x10(%rsp), %rsi
callq 0x9e22
testl %eax, %eax
je 0xd272
leaq 0x1f54b(%rip), %rax     # 0x2c6cc
testb $0x2, (%rax)
jne 0xd296
movq (%rsp), %rax
movq %rax, 0x20cdb(%rip)     # 0x2de70
movl 0x8(%rsp), %eax
movl %eax, 0x20cd9(%rip)     # 0x2de78
leaq 0x20cd6(%rip), %rbx     # 0x2de7c
jmp 0xd279
movl %r13d, %edx
xorl %r13d, %r13d
cmpl $0x2, %ecx
sete %r13b
cmpl $0x3, %r15d
pushq $0x2
popq %rax
cmovnel %ebx, %eax
pushq $0x4
popq %rcx
cmovnel %ebx, %ecx
testl $0xfffffffd, %edi       # imm = 0xFFFFFFFD
cmovel %edx, %eax
movl %eax, 0xc(%rsp)
pushq $0x5
popq %r15
cmovnel %ecx, %r15d
incl %r13d
leaq 0x20c89(%rip), %rbx     # 0x2de70
movl %r8d, 0x18(%rsp)
cmpl %r8d, %r12d
jg 0xd279
movl 0xc(%rsp), %ebp
cmpl %r15d, %ebp
jg 0xd265
movl %ebp, %edi
movq 0x10(%rsp), %rsi
movl %r12d, %edx
callq 0x9b96
testl %eax, %eax
je 0xd237
movl %eax, %r14d
leaq 0x1f4b1(%rip), %rax     # 0x2c6cc
testb $0x2, (%rax)
jne 0xd23c
movl %r12d, (%rbx)
movl %r14d, 0x4(%rbx)
leaq 0x203a2(%rip), %rax     # 0x2d5d0
movl (%rax), %eax
movl %eax, 0x8(%rbx)
addq $0xc, %rbx
addl %r13d, %ebp
jmp 0xd1f9
movq 0x1adb5(%rip), %rax     # 0x27ff8
movq (%rax), %rdi
leaq 0x20383(%rip), %rax     # 0x2d5d0
movl (%rax), %edx
leaq 0x10c05(%rip), %rsi     # 0x1de5b
movl %r12d, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x5200
jmp 0xd220
incl %r12d
movl 0x18(%rsp), %r8d
jmp 0xd1ec
leaq 0x20bf7(%rip), %rbx     # 0x2de70
andl $0x0, 0x8(%rbx)
andq $0x0, (%rbx)
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1ad5b(%rip), %rax     # 0x27ff8
movq (%rax), %rdi
movl 0x8(%rsp), %edx
movl (%rsp), %ecx
movl 0x4(%rsp), %r8d
leaq 0x10ba8(%rip), %rsi     # 0x1de5b
xorl %eax, %eax
callq 0x5200
jmp 0xd18a