// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: gregorian(int, double)
void gregorian(int no_tweak, double jd)
{
long z;
long w;
long x;
long a,b,c,d,e,f;
double t;
double tweak;
int i;


   // convert Julian date to Gregorian
   // The results are returned in the g_xxxx global variables.

   tweak = 0.0;  // used to compensate for subtle round-off errors;
   for(i=0; i<2; i++) {
      if(tweak) jd += jtime(0,0,0, tweak);  // tweak time to prevent round-down errors

      z = (long) (jd + 0.50);
      w = (long) (((double) z - 1867216.25) / 36524.25);
      x = w / 4;
      a = z + 1 + w - x;
      b = a + 1524;
      c = (long) ((((double) b) - 122.1) / 365.25);
      d = (long) (((double) c) * 365.25);
      e = (long) (((double) (b-d)) / 30.6001);
      f = (long) (((double) e) * 30.6001);

      g_day   = (int) (b - d - f);
      g_month = (int) (e - 1);
      if(g_month > 12) g_month = (int) (e - 13);

      if(g_month < 3) g_year = (int) (c - 4715);
      else            g_year = (int) (c - 4716);

      t = jd - jdate(g_year,g_month,g_day); 

      t *= 24.0;          // convert fractional day to hours
      g_hours = (int) t;  // convert decimal hours to hh:mm:ss

      t = (t - g_hours);
      g_minutes = (int) (t * 60.0);

      t = (t * 60.0) - g_minutes;
      g_seconds = (int) (t * 60.0);

      g_frac = (t * 60.0) - g_seconds;

      if(no_tweak) return;
      else if(g_frac >= 0.999) tweak += 0.001;
      else break;
   }

   if(g_month < 1) g_month = 0;        // invalid month, protect against possible array indexing errors
   else if(g_month > 12) g_month = 0;
   if(g_day < 1) g_day = 0;            // invalid day, protect against possible array indexing errors
   else if(g_day > 31) g_day = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
pushq $0x2
popq %r13
xorpd %xmm4, %xmm4
subl $0x1, %r13d
jb 0xbfc6b
movapd %xmm4, %xmm1
divsd 0x3351d(%rip), %xmm1    # 0xf3010
xorpd %xmm2, %xmm2
addsd %xmm2, %xmm1
movsd 0x3353d(%rip), %xmm3    # 0xf3040
divsd %xmm3, %xmm1
addsd %xmm0, %xmm1
movsd %xmm4, -0x30(%rbp)
cmpneqsd %xmm2, %xmm4
andpd %xmm4, %xmm1
andnpd %xmm0, %xmm4
orpd %xmm1, %xmm4
movapd %xmm4, -0x40(%rbp)
movapd %xmm4, %xmm0
addsd 0x33536(%rip), %xmm0    # 0xf3068
cvttsd2si %xmm0, %rsi
cvtsi2sd %rsi, %xmm0
addsd 0x55b8c(%rip), %xmm0    # 0x1156d0
divsd 0x55b8c(%rip), %xmm0    # 0x1156d8
cvttsd2si %xmm0, %rcx
movq %rcx, %rax
cqto
pushq $-0x4
popq %rdi
idivq %rdi
addq %rcx, %rsi
leaq (%rax,%rsi), %r15
addq $0x5f5, %r15            # imm = 0x5F5
cvtsi2sd %r15, %xmm0
addsd 0x55b69(%rip), %xmm0    # 0x1156e0
movsd 0x55b69(%rip), %xmm1    # 0x1156e8
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
cvtsi2sd %rax, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
subq %rcx, %r15
cvtsi2sd %r15, %xmm0
movsd 0x55b4a(%rip), %xmm1    # 0x1156f0
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %r14
cvtsi2sd %r14, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
subl %ecx, %r15d
leal -0x1(%r14), %ecx
addl $-0xd, %r14d
cmpl $0xd, %ecx
cmovll %ecx, %r14d
xorl %ecx, %ecx
cmpl $0x3, %r14d
setl %cl
leal -0x126c(%rax,%rcx), %r12d
movl %r12d, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0xc2f07
movapd -0x40(%rbp), %xmm3
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
mulsd 0x3343d(%rip), %xmm1    # 0xf3040
cvttsd2si %xmm1, %eax
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm1
movsd 0x333ed(%rip), %xmm2    # 0xf3008
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %ecx
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edx
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm1
testl %ebx, %ebx
jne 0xbfccd
ucomisd 0x3351d(%rip), %xmm1    # 0xf3170
jb 0xbfc6b
movsd -0x30(%rbp), %xmm4
addsd 0x35d46(%rip), %xmm4    # 0xf59a8
movapd %xmm3, %xmm0
jmp 0xbfadd
leaq 0x237a2e(%rip), %rsi    # 0x2f76a0
movl %r15d, (%rsi)
leaq 0x237a20(%rip), %rdi    # 0x2f769c
movl %r14d, (%rdi)
leaq 0x237a1e(%rip), %r8     # 0x2f76a4
movl %r12d, (%r8)
leaq 0x237a18(%rip), %r8     # 0x2f76a8
movl %eax, (%r8)
leaq 0x237a12(%rip), %rax    # 0x2f76ac
movl %ecx, (%rax)
leaq 0x237a0d(%rip), %rax    # 0x2f76b0
movl %edx, (%rax)
leaq 0x237a0c(%rip), %rax    # 0x2f76b8
movsd %xmm1, (%rax)
addl $-0xd, %r14d
cmpl $-0xd, %r14d
ja 0xbfcbd
andl $0x0, (%rdi)
movl (%rsi), %eax
testl %eax, %eax
jle 0xbfcc8
cmpl $0x20, %eax
jb 0xbfd11
andl $0x0, (%rsi)
jmp 0xbfd11
leaq 0x2379cc(%rip), %rsi    # 0x2f76a0
movl %r15d, (%rsi)
leaq 0x2379be(%rip), %rsi    # 0x2f769c
movl %r14d, (%rsi)
leaq 0x2379bc(%rip), %rsi    # 0x2f76a4
movl %r12d, (%rsi)
leaq 0x2379b6(%rip), %rsi    # 0x2f76a8
movl %eax, (%rsi)
leaq 0x2379b1(%rip), %rax    # 0x2f76ac
movl %ecx, (%rax)
leaq 0x2379ac(%rip), %rax    # 0x2f76b0
movl %edx, (%rax)
leaq 0x2379ab(%rip), %rax    # 0x2f76b8
movsd %xmm1, (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq