// File: /workspace/github_cpp_makefile_star2_O1/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 0x724e5
movl %eax, %ecx
testl %r14d, %r14d
js 0xdfe92
movslq %ecx, %rsi
leaq 0x8a934(%rip), %rax     # 0x16a700
movl (%rax,%rsi,4), %ecx
testl %ecx, %ecx
jle 0xdff4c
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 0x4b69a(%rip), %r8      # 0x12b4c0
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 0xdfe81
incl %esi
cmpl %r14d, %esi
je 0xdff4e
leal (%rcx,%rax), %edi
incl %edi
incl %eax
cmpl $0x1, %edi
jne 0xdfe3e
jmp 0xdff4c
movslq %ecx, %rsi
leaq 0x8a864(%rip), %rax     # 0x16a700
movl (%rax,%rsi,4), %eax
testl %eax, %eax
jle 0xdff4c
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 0x4b5ca(%rip), %r9      # 0x12b4c0
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 0xdff40
incl %edx
cmpl %r14d, %edx
je 0xdff4e
leal -0x1(%rax), %esi
decl %ecx
cmpl $0x1, %eax
movl %esi, %eax
jg 0xdff0c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq