// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathmsc.cpp
// Function: zoom_cal(int, int)
void zoom_cal(int year, int month)
{
int day;
int dow;
int row, col;
int top;
int color;
int i, j;
int CAL_WIDTH;
int CAL_LEFT;
int pre_month;
double jd;
char *days;

   // Show a zoomed full screen calendar
   
   CAL_WIDTH = 30;
   CAL_LEFT = 2;
   i = 4;
   days = "SUN MON TUE WED THU FRI SAT";
   if(SMALL_SCREEN) {
      CAL_WIDTH = 24;
      CAL_LEFT = 2;
      i = 3;
      days = "SU MO TU WE TH FR SA";
   }

   CAL_LEFT = (TEXT_COLS - ((CAL_WIDTH*3) + (i*2))) / 2;

   if(month < 1) month = 1;
   if(month > 12) month = 12;

   erase_screen();

   col = CAL_LEFT;
   top = 0;
   if(SCREEN_HEIGHT < SHORT_SCREEN) pre_month = 1; // start with 1 previous months
   else pre_month = 4;  // 4 previous months
   month = month - pre_month;
   if(month <= 0) { 
      --year;
      month += 12;
   }

   for(j=1; j<=48; j++) {  // display up to 48 months
      init_dsm(year);
      calc_dst_times(year, dst_list[dst_area]);  // find daylight savings change times

      row = 0;

      dow = day_of_week(1, month, year);
      if(year < 0) sprintf(out, "%s %d BC", full_months[month], 0-year);
      else         sprintf(out, "%s %04d",  full_months[month], year);
      i = ((CAL_WIDTH-3) - strlen(out)) / 2;
      color = WHITE;
      if((month == pri_month) && (year == pri_year)) color = GREEN;
      else if(j <= pre_month) color = DIM_WHITE;
      vidstr(top+row, col+i, color, out);  // center year/month string
      ++row;

      vidstr(top+row, col, color, days);
      ++row;

      jd = jdate(year,month,1);
      calc_moons(jd, 3); 

      for(day=1; day<=dim[month]; day++) {  // show the day values
         dow = day_of_week(day, month, year);

         if(SMALL_SCREEN) sprintf(out, "%-3d", day);
         else             sprintf(out, "%-4d", day);
         i = col + (dow * strlen(out));

         if((month == dst_start_month) && (day == dst_start_day)) color = BLUE;
         else if((month == dst_end_month) && (day == dst_end_day)) color = BLUE;
         else if(moons[day][0] && (moons[day][0] != 'Q')) {
            if(strstr(moons[day], "Full")) color = YELLOW;     // full moon
            else if(strstr(moons[day], "Blue")) color = YELLOW; // blue moon
            else color = BROWN;  // new moon / black moon
         }
         else if(is_holiday(year,month,day)) color = CYAN;
         else if((month == pri_month) && (year == pri_year)) color = GREEN;
         else if(j <= pre_month) color = DIM_WHITE;
         else color = WHITE;
         if((pri_year == year) && (pri_month == month) && (pri_day == day) && (pri_seconds & 1)) {
            color = BLACK;  // blink today's date
         }
         vidstr(top+row, i, color, out);

         if(dow >= 6) {  // end of week, go to next row
            ++row;
         }
      }


      col += CAL_WIDTH;  // setup for next month
      if(col > ((CAL_WIDTH*2)+CAL_LEFT)) {
         col = CAL_LEFT;
         top += 8;
      }
      if(top >= (TEXT_ROWS-8)) break;

      ++month;
      if(month > 12) {
         month = 1;
         year += 1;
      }
   }

   init_dsm(this_year);
   calc_dst_times(this_year, dst_list[dst_area]);  // find daylight savings change times
   calc_moons(jd_local, 5); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x124f06(%rip), %rdx    # 0x218800
leaq 0x12fc43(%rip), %rax    # 0x223544
imull $0x31a, (%rax), %eax    # imm = 0x31A
cltq
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
cmpl %eax, (%rdx)
setl %al
leaq 0x124edb(%rip), %r15    # 0x218804
movl $0x258, %ecx            # imm = 0x258
cmpl %ecx, (%r15)
movl %edi, %ebx
setl %cl
orb %al, %cl
movzbl %cl, %eax
leal (%rax,%rax), %ecx
testb %al, %al
movl $0x18, %eax
movl $0x1e, %r13d
cmovnel %eax, %r13d
leaq 0x41577(%rip), %rax     # 0x134ecd
leaq 0x41554(%rip), %rdx     # 0x134eb1
cmovneq %rax, %rdx
movq %rdx, -0x78(%rbp)
leaq 0x124e9c(%rip), %rax    # 0x218808
leal (%r13,%r13,2), %edx
addl (%rax), %ecx
subl %edx, %ecx
movl %ecx, %eax
addl $-0x8, %eax
shrl $0x1f, %eax
leal (%rcx,%rax), %r12d
addl $-0x8, %r12d
sarl %r12d
cmpl $0x2, %esi
movl $0x1, %eax
cmovll %eax, %esi
cmpl $0xc, %esi
movl $0xc, %r14d
cmovll %esi, %r14d
callq 0xed5e
xorl %eax, %eax
movl $0x258, %ecx            # imm = 0x258
cmpl %ecx, (%r15)
setge %al
leal (%rax,%rax,2), %eax
incl %eax
movl %eax, -0x3c(%rbp)
subl %eax, %r14d
leal 0xc(%r14), %r15d
xorl %eax, %eax
testl %r14d, %r14d
setle %al
cmovgl %r14d, %r15d
subl %eax, %ebx
leal -0x3(%r13), %eax
movq %rax, -0x70(%rbp)
movq %r13, -0x80(%rbp)
leal (%r12,%r13,2), %edi
movl $0x1, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq %r12, -0x68(%rbp)
movl %r12d, %r8d
movl %edi, -0x5c(%rbp)
movl %r8d, -0x38(%rbp)
movl %ebx, %edi
callq 0xdfc78
leaq 0x219e92(%rip), %rax    # 0x30d89c
movslq (%rax), %rax
leaq 0x76e1c(%rip), %rcx     # 0x16a830
movq (%rcx,%rax,8), %rsi
movl %ebx, %edi
callq 0xe0868
xorl %eax, %eax
cmpl $0x3, %r15d
setl %al
movl %ebx, %ecx
movq %rax, -0x50(%rbp)
subl %eax, %ecx
leal 0x3(%rcx), %eax
testl %ecx, %ecx
movq %rcx, -0x88(%rbp)
cmovnsl %ecx, %eax
movl %eax, -0x34(%rbp)
movslq %r15d, %rcx
leaq 0x37a74(%rip), %rax     # 0x12b4c0
movzbl -0x1(%rcx,%rax), %eax
movl %eax, -0x60(%rbp)
leaq 0x76d55(%rip), %rax     # 0x16a7b0
movq %rcx, -0x58(%rbp)
movq (%rax,%rcx,8), %rdx
testl %ebx, %ebx
js 0xf3a7c
leaq 0x2487b2(%rip), %r12    # 0x33c220
movq %r12, %rdi
leaq 0x3a1fc(%rip), %rsi     # 0x12dc74
movl %ebx, %ecx
jmp 0xf3a91
movl %ebx, %ecx
negl %ecx
leaq 0x248799(%rip), %r12    # 0x33c220
movq %r12, %rdi
leaq 0x41451(%rip), %rsi     # 0x134ee2
xorl %eax, %eax
callq 0x9060
movq %r12, %rdi
callq 0x9120
movq -0x70(%rbp), %rsi
subq %rax, %rsi
shrq %rsi
leaq 0x219a5f(%rip), %rax    # 0x30d510
movl (%rax), %eax
xorl -0x58(%rbp), %eax
leaq 0x219a57(%rip), %rcx    # 0x30d514
movl (%rcx), %ecx
xorl %ebx, %ecx
movl -0x30(%rbp), %edx
cmpl -0x3c(%rbp), %edx
seta %dl
shlb $0x3, %dl
orb $0x7, %dl
orl %eax, %ecx
movzbl %dl, %eax
movl $0xa, %ecx
cmovel %ecx, %eax
movl -0x38(%rbp), %r14d
addl %r14d, %esi
movq %r12, %rcx
movl %ebx, %r12d
movzbl %al, %ebx
movq -0x48(%rbp), %r13
movl %r13d, %edi
movl %ebx, %edx
callq 0xe7d0
leal 0x1(%r13), %edi
movl %r14d, %esi
movl %ebx, %edx
movq -0x78(%rbp), %rcx
callq 0xe7d0
movl %r12d, -0x2c(%rbp)
movl %r12d, %edi
movq -0x58(%rbp), %rbx
movl %ebx, %esi
movl $0x1, %edx
callq 0xd4110
callq 0xe932d
leaq 0x76bd0(%rip), %rax     # 0x16a700
cmpl $0x0, (%rax,%rbx,4)
jle 0xf3d90
movq -0x50(%rbp), %rdi
negl %edi
movl -0x34(%rbp), %r8d
sarl $0x2, %r8d
movslq -0x88(%rbp), %rcx
imulq $-0x51eb851f, %rcx, %rax # imm = 0xAE147AE1
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rax
addl %edx, %eax
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x27, %rcx
addl %edx, %ecx
xorl %edx, %edx
movl -0x30(%rbp), %esi
cmpl -0x3c(%rbp), %esi
seta %dl
leal 0x7(,%rdx,8), %edx
movl %edx, -0x34(%rbp)
addl -0x2c(%rbp), %eax
addl %r8d, %ecx
addl %eax, %ecx
addl -0x60(%rbp), %edi
addl %ecx, %edi
movq %rdi, -0x50(%rbp)
movl $0x2, %r13d
movl $0x1, %r12d
leaq 0x124c54(%rip), %rax    # 0x218804
cmpl $0x258, (%rax)          # imm = 0x258
leaq 0x33b79(%rip), %rax     # 0x127736
jl 0xf3bc6
leaq 0x34ab3(%rip), %rax     # 0x128679
leaq 0x12f977(%rip), %rcx    # 0x223544
imull $0x31a, (%rcx), %ecx    # imm = 0x31A
movslq %ecx, %rcx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
leaq 0x33b45(%rip), %rsi     # 0x127736
leaq 0x124c08(%rip), %rdx    # 0x218800
cmpl %ecx, (%rdx)
jl 0xf3bff
movq %rax, %rsi
leaq 0x24861a(%rip), %rbx    # 0x33c220
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x9120
movq %rax, %r14
movl $0x9, %ecx
cmpl 0x286dda(%rip), %r15d   # 0x37aa04
jne 0xf3c3b
movl 0x286dce(%rip), %eax    # 0x37aa00
cmpq %rax, %r12
je 0xf3cde
cmpl 0x286dca(%rip), %r15d   # 0x37aa0c
jne 0xf3c53
movl 0x286dbe(%rip), %eax    # 0x37aa08
cmpq %rax, %r12
je 0xf3cde
leaq 0x7d366(%rip), %rax     # 0x170fc0
movq (%rax,%r12,8), %rbx
movzbl (%rbx), %eax
testl %eax, %eax
je 0xf3c6a
cmpl $0x51, %eax
jne 0xf3ca7
movl -0x2c(%rbp), %edi
movl %r15d, %esi
movl %r12d, %edx
callq 0xef061
movl $0xb, %ecx
testl %eax, %eax
jne 0xf3cde
leaq 0x219888(%rip), %rax    # 0x30d510
movl (%rax), %eax
xorl %r15d, %eax
leaq 0x219880(%rip), %rcx    # 0x30d514
movl (%rcx), %ecx
xorl -0x2c(%rbp), %ecx
orl %eax, %ecx
movl $0xa, %ecx
je 0xf3cde
movl -0x34(%rbp), %ecx
jmp 0xf3cde
movq %rbx, %rdi
leaq 0x4123a(%rip), %rsi     # 0x134eeb
callq 0x9090
movl $0xe, %ecx
testq %rax, %rax
jne 0xf3cde
movq %rbx, %rdi
leaq 0x41226(%rip), %rsi     # 0x134ef0
callq 0x9090
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
leal 0x6(,%rcx,8), %ecx
movq -0x50(%rbp), %rax
addl %r12d, %eax
cltq
imulq $-0x6db6db6d, %rax, %rbx # imm = 0x92492493
shrq $0x20, %rbx
addl %eax, %ebx
movl %ebx, %edx
shrl $0x1f, %edx
sarl $0x2, %ebx
addl %edx, %ebx
leal (,%rbx,8), %edx
subl %edx, %ebx
addl %eax, %ebx
movzbl %bl, %eax
imull %eax, %r14d
addl -0x38(%rbp), %r14d
leaq 0x2197f9(%rip), %rax    # 0x30d514
movl (%rax), %eax
xorl -0x2c(%rbp), %eax
leaq 0x2197e9(%rip), %rdx    # 0x30d510
movl (%rdx), %esi
xorl %r15d, %esi
leaq 0x2197cd(%rip), %rdx    # 0x30d500
testb $0x1, (%rdx)
movl $0x0, %edx
cmovel %ecx, %edx
leaq 0x2197c7(%rip), %rdi    # 0x30d50c
movl (%rdi), %edi
cmpq %rdi, %r12
cmovnel %ecx, %edx
orl %eax, %esi
cmovnel %ecx, %edx
movq -0x48(%rbp), %rax
leal (%rax,%r13), %edi
movl %r14d, %esi
leaq 0x2484bc(%rip), %rcx    # 0x33c220
callq 0xe7d0
cmpl $0x6, %ebx
sbbl $-0x1, %r13d
leaq 0x1(%r12), %rax
leaq 0x76984(%rip), %rcx     # 0x16a700
movq -0x58(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpq %rcx, %r12
movq %rax, %r12
jl 0xf3ba9
movl -0x38(%rbp), %r8d
addl -0x80(%rbp), %r8d
movq -0x48(%rbp), %rcx
leal 0x8(%rcx), %eax
movl -0x5c(%rbp), %edi
cmpl %edi, %r8d
cmovlel %ecx, %eax
leaq 0x124a5d(%rip), %rcx    # 0x21880c
movl (%rcx), %ecx
addl $-0x8, %ecx
cmpl %ecx, %eax
movl -0x2c(%rbp), %ebx
jge 0xf3df2
cmpl %edi, %r8d
cmovgl -0x68(%rbp), %r8d
xorl %ecx, %ecx
cmpl $0xc, %r15d
leal 0x1(%r15), %edx
setge %cl
movl $0x1, %esi
cmovgel %esi, %edx
addl %ecx, %ebx
movl -0x30(%rbp), %ecx
incl %ecx
movq %rax, -0x48(%rbp)
movl %edx, %r15d
movl %ecx, -0x30(%rbp)
cmpl $0x31, %ecx
jne 0xf39f8
leaq 0x219727(%rip), %rbx    # 0x30d520
movl (%rbx), %edi
callq 0xdfc78
movl (%rbx), %edi
leaq 0x219a93(%rip), %rax    # 0x30d89c
movslq (%rax), %rax
leaq 0x76a1d(%rip), %rcx     # 0x16a830
movq (%rcx,%rax,8), %rsi
callq 0xe0868
leaq 0x219725(%rip), %rax    # 0x30d548
movsd (%rax), %xmm0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe932d