// File: /workspace/github_c_makefile_star2_O3/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 0xd007
movl $0x2, %r13d
movq %rax, 0x18(%rsp)
cmpl $-0x1, %eax
je 0xe200
cmpq $0x0, 0x8(%r15)
je 0xe200
movq 0x10(%r15), %rdi
movl $0x1, %r15d
xorl %esi, %esi
movl $0x1, %edx
callq 0xcebe
cmpl $-0x1, %eax
je 0xe200
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 0xdf9b
xorl %r8d, %r8d
cmpl $0x3, %r14d
setne %sil
cmpl %edi, %r15d
jle 0xe05b
leaq 0x20eea(%rip), %r13     # 0x2ee80
jmp 0xe1ed
xorl $0xd, %eax
movl %r14d, %ecx
andl $-0x2, %ecx
movl %ecx, %edx
xorl $0x2, %edx
orl %eax, %edx
jne 0xe19e
xorl %edi, %edi
cmpl $0x3, %r14d
sete %dil
movq %rsp, %rbx
movl $0x1, (%rbx)
incl %edi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0xa8a5
movl %eax, 0x4(%rbx)
leaq 0x20601(%rip), %r15     # 0x2e5e0
movl (%r15), %edx
movl %edx, 0x8(%rbx)
leaq 0x20e94(%rip), %r13     # 0x2ee80
leaq 0x1f6e9(%rip), %r12     # 0x2d6dc
movq 0x1aff6(%rip), %rbp     # 0x28ff0
leaq 0x11eaa(%rip), %r14     # 0x1feab
testb $0x2, (%r12)
movl (%rsp), %ecx
movl 0x4(%rsp), %r8d
jne 0xe03f
movl %ecx, (%r13)
movl %r8d, 0x4(%r13)
movl %edx, 0x8(%r13)
addq $0xc, %r13
addl $0xe, %r8d
movl %r8d, 0x4(%rsp)
movq %rbx, %rdi
callq 0xa792
movl 0x8(%rsp), %edx
cmpl (%r15), %edx
je 0xe001
jmp 0xe1ed
movq (%rbp), %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x5210
movl (%rsp), %ecx
movl 0x4(%rsp), %r8d
movl 0x8(%rsp), %edx
jmp 0xe010
movl %eax, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movl %ecx, %ecx
leaq 0x1b183(%rip), %rdx     # 0x291f0
movq (%rdx,%rcx,8), %rbp
movb %sil, %r8b
movslq %r15d, %r14
incl %edi
movl %edi, 0x14(%rsp)
leaq 0x20dfc(%rip), %r13     # 0x2ee80
movl %r8d, %ebx
movl %r8d, 0x24(%rsp)
movl $0x0, %eax
cmpq $0x2, %r14
jne 0xe0d6
leaq 0x20542(%rip), %rax     # 0x2e5e0
movl (%rax), %ecx
movl $0x0, %eax
testb $0x3, %cl
jne 0xe0d6
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 0xe0d6
rorl $0x4, %ecx
xorl %eax, %eax
cmpl $0xa3d70b, %ecx         # imm = 0xA3D70B
setb %al
leaq 0x1b0e3(%rip), %rcx     # 0x291c0
movsbl -0x1(%r14,%rcx), %r15d
cmpl $0xd, 0x10(%rsp)
cmovnel %r8d, %ebx
addl %eax, %r15d
jle 0xe189
negl %r15d
movl $0x1, %r12d
leaq 0x204db(%rip), %rax     # 0x2e5e0
movl (%rax), %edx
movl %r14d, %edi
movl %r12d, %esi
callq *%rbp
testl %eax, %eax
je 0xe14b
testl %ebx, %ebx
je 0xe13c
leaq 0x1f5be(%rip), %rax     # 0x2d6dc
testb $0x2, (%rax)
jne 0xe160
movl %r14d, (%r13)
movl %r12d, 0x4(%r13)
leaq 0x204ae(%rip), %rax     # 0x2e5e0
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 0xe0fe
jmp 0xe189
movq 0x1ae89(%rip), %rax     # 0x28ff0
movq (%rax), %rdi
leaq 0x2046f(%rip), %rax     # 0x2e5e0
movl (%rax), %edx
leaq 0x11d31(%rip), %rsi     # 0x1feab
movl %r14d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x5210
jmp 0xe123
incq %r14
cmpl %r14d, 0x14(%rsp)
movl 0x24(%rsp), %r8d
jne 0xe08c
jmp 0xe1ed
leal 0x1(%r14), %edx
andl $-0x3, %edx
orl %eax, %edx
jne 0xe212
movq %rsp, %rdx
movl %r12d, %edi
movq 0x18(%rsp), %rsi
callq 0xac0f
testl %eax, %eax
je 0xdf8f
leaq 0x1f514(%rip), %rax     # 0x2d6dc
testb $0x2, (%rax)
jne 0xe2e9
movq (%rsp), %rax
movq %rax, 0x20ca4(%rip)     # 0x2ee80
movl 0x8(%rsp), %eax
movl %eax, 0x20ca2(%rip)     # 0x2ee88
leaq 0x20c9f(%rip), %r13     # 0x2ee8c
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 0xdf8f
movl %edi, 0x14(%rsp)
movb %cl, %bl
incl %ebx
leaq 0x20c1f(%rip), %r13     # 0x2ee80
movl %ebp, 0x10(%rsp)
cmpl %r14d, %ebp
jg 0xe2a9
movl %ebp, %edi
movq 0x18(%rsp), %rsi
movl %r15d, %edx
callq 0xa8a5
testl %eax, %eax
je 0xe2a5
movl %eax, %r12d
leaq 0x1f455(%rip), %rax     # 0x2d6dc
testb $0x2, (%rax)
jne 0xe2c0
movl %r15d, (%r13)
movl %r12d, 0x4(%r13)
leaq 0x20345(%rip), %rax     # 0x2e5e0
movl (%rax), %eax
movl %eax, 0x8(%r13)
addq $0xc, %r13
addl %ebx, %ebp
jmp 0xe265
leal 0x1(%r15), %eax
cmpl 0x14(%rsp), %r15d
movl %eax, %r15d
movl 0x10(%rsp), %ebp
jne 0xe265
jmp 0xe1ed
movq 0x1ad29(%rip), %rax     # 0x28ff0
movq (%rax), %rdi
leaq 0x2030f(%rip), %rax     # 0x2e5e0
movl (%rax), %edx
leaq 0x11bd1(%rip), %rsi     # 0x1feab
movl %r15d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x5210
jmp 0xe28c
movq %rsp, %rdi
callq 0x568d
jmp 0xe1d1