// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: nth_dow_in(int, int, int, int)
int nth_dow_in(int nth, int dow, int month, int year)
{
int sundays;
int d;

   sundays = 0;
   month = fix_month(month);
   if(nth < 0) {  // nth day of week from end of month
      nth = 0 - nth;
      for(d=dim[month]; d>=1; d--) {
         if(day_of_week(d, month, year) == dow) {
            ++sundays;
            if(sundays == nth) return d;  // last sunday in month, etc
         }
      }
   }
   else { // nth day of week from start of month
      for(d=1; d<=dim[month]; d++) {
         if(day_of_week(d, month, year) == dow) {
            ++sundays;
            if(sundays == nth) return d;  // 2nd sunday in month, etc
         }
      }
   }
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %r15d
movl %esi, %ebx
movl %edi, %r14d
movl %edx, %edi
callq 0x723a5
movl %eax, %ecx
testl %r14d, %r14d
js 0xe0950
movslq %ecx, %rsi
leaq 0x89e76(%rip), %rax     # 0x16a700
movl (%rax,%rsi,4), %ecx
testl %ecx, %ecx
jle 0xe0a0a
xorl %eax, %eax
cmpl $0x3, %esi
setl %al
movl %r15d, %edi
subl %eax, %edi
leal 0x3(%rdi), %edx
testl %edi, %edi
cmovnsl %edi, %edx
sarl $0x2, %edx
movslq %edi, %rdi
imulq $-0x51eb851f, %rdi, %r8 # imm = 0xAE147AE1
movq %r8, %r9
shrq $0x3f, %r9
sarq $0x25, %r8
addl %r9d, %r8d
imulq $0x51eb851f, %rdi, %rdi # imm = 0x51EB851F
movq %rdi, %r9
shrq $0x3f, %r9
sarq $0x27, %rdi
addl %r9d, %edi
addl %r8d, %edi
leaq 0x4acac(%rip), %r8      # 0x12b590
movzbl -0x1(%rsi,%r8), %esi
negl %ecx
addl %r15d, %edx
addl %edi, %edx
subl %eax, %edx
addl %esi, %edx
xorl %esi, %esi
movl $0x1, %eax
leal (%rdx,%rax), %edi
movslq %edi, %rdi
imulq $-0x6db6db6d, %rdi, %r8 # imm = 0x92492493
shrq $0x20, %r8
addl %edi, %r8d
movl %r8d, %r9d
shrl $0x1f, %r9d
sarl $0x2, %r8d
addl %r9d, %r8d
leal (,%r8,8), %r9d
subl %r9d, %r8d
addl %edi, %r8d
movzbl %r8b, %edi
cmpl %ebx, %edi
jne 0xe093f
incl %esi
cmpl %r14d, %esi
je 0xe0a0c
leal (%rcx,%rax), %edi
incl %edi
incl %eax
cmpl $0x1, %edi
jne 0xe08fc
jmp 0xe0a0a
movslq %ecx, %rsi
leaq 0x89da6(%rip), %rax     # 0x16a700
movl (%rax,%rsi,4), %eax
testl %eax, %eax
jle 0xe0a0a
negl %r14d
xorl %edx, %edx
cmpl $0x3, %ecx
setl %dl
movl %r15d, %ecx
subl %edx, %ecx
leal 0x3(%rcx), %edi
testl %ecx, %ecx
cmovnsl %ecx, %edi
sarl $0x2, %edi
movslq %ecx, %rcx
imulq $-0x51eb851f, %rcx, %r8 # imm = 0xAE147AE1
movq %r8, %r9
shrq $0x3f, %r9
sarq $0x25, %r8
addl %r9d, %r8d
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %r9
shrq $0x3f, %r9
sarq $0x27, %rcx
addl %r9d, %ecx
leaq 0x4abdc(%rip), %r9      # 0x12b590
movzbl -0x1(%rsi,%r9), %esi
addl %eax, %edi
addl %r8d, %edi
addl %r15d, %ecx
addl %edi, %ecx
subl %edx, %ecx
addl %esi, %ecx
xorl %edx, %edx
movslq %ecx, %rsi
imulq $-0x6db6db6d, %rsi, %rsi # imm = 0x92492493
shrq $0x20, %rsi
addl %ecx, %esi
movl %esi, %edi
shrl $0x1f, %edi
sarl $0x2, %esi
addl %edi, %esi
leal (,%rsi,8), %edi
subl %edi, %esi
addl %ecx, %esi
movzbl %sil, %esi
cmpl %ebx, %esi
jne 0xe09fe
incl %edx
cmpl %r14d, %edx
je 0xe0a0c
leal -0x1(%rax), %esi
decl %ecx
cmpl $0x1, %eax
movl %esi, %eax
jg 0xe09ca
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq