// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathmsc.cpp
// Function: init_persian(int)
void init_persian(int year)
{
double jd;
int leap;
int mm;

// gregorian(0, spring-365.24238426);    // time of spring in GMT of last year;
// jd = jdate(g_year, g_month, g_day);   // jdate of start of spring
// if((jd - (3.5/24.0) + (12.0/24.0)) > spring) {  // it's after noon in Tehran
//    jd += 1.0;  //!!! kludge - we should be using solar noon in Tehran
// }

   leap = year-621-1;               // start calculating from last year
   leap %= 33;                      // leap years on 33 year cycles
   if     (leap == 1)  leap = 20;   // leap years start on 20 March
   else if(leap == 5)  leap = 20;
   else if(leap == 9)  leap = 20;
   else if(leap == 13) leap = 20;
   else if(leap == 17) leap = 20;
   else if(leap == 22) leap = 20;
   else if(leap == 26) leap = 20;
   else if(leap == 30) leap = 20;
   else                leap = 21;

   jd = jdate(year-1, 3, leap);  // first day of the previous persian year

   ptimes[0] = jd;
   pyears[0] = year-621-1;

   for(mm=0+1; mm<=36; mm++) { // calculate next 36 months
      if     ((mm%12) <= 6)  ptimes[mm] = ptimes[mm-1] + 31.0;
      else if((mm%12) <= 11) ptimes[mm] = ptimes[mm-1] + 30.0;
      if((mm == 12) || (mm == 24) || (mm == 36)) {  // first month of the next year
         if(leap == 20)  ptimes[mm] = ptimes[mm-1] + 30.0;  // set length of the previous month
         else            ptimes[mm] = ptimes[mm-1] + 29.0;
      }
      pyears[mm] = (year-621-1) + (mm/12);
   }
}

// Assembly:
leal -0x26e(%rdi), %esi
movslq %esi, %rax
imulq $0x3e0f83e1, %rax, %rcx # imm = 0x3E0F83E1
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x23, %rcx
addl %edx, %ecx
movl %ecx, %edx
shll $0x5, %edx
addl %ecx, %edx
subl %edx, %eax
cmpl $0x1e, %eax
ja 0xee9ad
movl $0x44422222, %ecx       # imm = 0x44422222
btl %eax, %ecx
jae 0xee9ad
movsd 0x1d2bf(%rip), %xmm1    # 0x10bb38
movsd 0x1d077(%rip), %xmm0    # 0x10b8f8
pushq %rbp
movq %rsp, %rbp
pushq %rbx
movslq %edi, %rcx
leaq -0x1(%rcx), %rax
movabsq $-0x5c28f5c28f5c28f5, %rdi # imm = 0xA3D70A3D70A3D70B
imulq %rdi
leaq (%rdx,%rcx), %rax
decq %rax
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x6, %rax
addq %rdx, %rax
imulq $-0x64, %rax, %rdx
imulq $0x23ab1, %rax, %rax    # imm = 0x23AB1
leaq 0x3(%rax), %r8
testq %rax, %rax
cmovnsq %rax, %r8
leaq (%rdx,%rcx), %rax
decq %rax
sarq $0x2, %r8
imulq $0x8ead, %rax, %rcx     # imm = 0x8EAD
movq %rcx, %rax
imulq %rdi
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x6, %rdx
addq %rax, %rdx
cvtsi2sd %r8, %xmm2
addsd 0x3ce0d(%rip), %xmm2    # 0x12b708
cvtsi2sd %rdx, %xmm3
addsd %xmm2, %xmm3
addsd %xmm1, %xmm3
movsd %xmm3, 0x28c870(%rip)   # 0x37b180
movl %esi, 0x28c99a(%rip)    # 0x37b2b0
movl $0x1, %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
leaq 0x28c859(%rip), %rdx    # 0x37b180
leaq 0x3df12(%rip), %rdi     # 0x12c840
leaq 0x28c97b(%rip), %r8     # 0x37b2b0
movabsq $0x1001001000, %r9      # imm = 0x1001001000
movl %eax, %r10d
movq %r10, %r11
imulq %rcx, %r11
shrq $0x23, %r11
shll $0x2, %r11d
leal (%r11,%r11,2), %r11d
movl %eax, %ebx
subl %r11d, %ebx
xorl %r11d, %r11d
cmpl $0x7, %ebx
setb %r11b
movsd -0x8(%rdx,%rax,8), %xmm1
addsd (%rdi,%r11,8), %xmm1
movsd %xmm1, (%rdx,%rax,8)
cmpl $0x24, %eax
ja 0xee98f
btq %r10, %r9
jae 0xee98f
movsd -0x8(%rdx,%rax,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rax,8)
movl %eax, %r10d
imulq %rcx, %r10
shrq $0x23, %r10
addl %esi, %r10d
movl %r10d, (%r8,%rax,4)
incq %rax
cmpq $0x25, %rax
jne 0xee93f
popq %rbx
popq %rbp
retq
movsd 0x2fe6b(%rip), %xmm1    # 0x11e820
movsd 0x3db6b(%rip), %xmm0    # 0x12c528
jmp 0xee881