// File: /workspace/github_cpp_makefile_star2_O3/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 0x124842(%rip), %rdx    # 0x218800
leaq 0x12f57f(%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 0x124817(%rip), %rbx    # 0x218804
movl $0x258, %ecx            # imm = 0x258
cmpl %ecx, (%rbx)
movl %edi, %r12d
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 0x40fa3(%rip), %rax     # 0x134fbd
leaq 0x40f80(%rip), %rdx     # 0x134fa1
cmovneq %rax, %rdx
movq %rdx, -0x78(%rbp)
leaq 0x1247d8(%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), %r15d
addl $-0x8, %r15d
sarl %r15d
cmpl $0x2, %esi
movl $0x1, %eax
cmovll %eax, %esi
cmpl $0xc, %esi
movl $0xc, %r14d
cmovll %esi, %r14d
callq 0xeceb
xorl %eax, %eax
movl $0x258, %ecx            # imm = 0x258
cmpl %ecx, (%rbx)
movl %r12d, %ebx
setge %al
leal (%rax,%rax,2), %eax
incl %eax
movl %eax, -0x50(%rbp)
subl %eax, %r14d
leal 0xc(%r14), %ecx
xorl %eax, %eax
testl %r14d, %r14d
setle %al
cmovgl %r14d, %ecx
subl %eax, %ebx
leal -0x3(%r13), %eax
movq %rax, -0x70(%rbp)
movq %r13, -0x80(%rbp)
leal (%r15,%r13,2), %edi
movq %rcx, %r14
movl $0x1, %r12d
movq $0x0, -0x38(%rbp)
movq %r15, -0x68(%rbp)
movl %r15d, %r8d
movl %edi, -0x4c(%rbp)
movl %r8d, -0x30(%rbp)
movl %ebx, %edi
callq 0xe0736
leaq 0x2197ca(%rip), %rax    # 0x30d89c
movslq (%rax), %rax
leaq 0x76754(%rip), %rcx     # 0x16a830
movq (%rcx,%rax,8), %rsi
movl %ebx, %edi
callq 0xe1326
xorl %eax, %eax
cmpl $0x3, %r14d
setl %al
movl %ebx, %ecx
movl %eax, -0x48(%rbp)
subl %eax, %ecx
leal 0x3(%rcx), %eax
testl %ecx, %ecx
movq %rcx, -0x88(%rbp)
cmovnsl %ecx, %eax
movl %eax, -0x58(%rbp)
movq %r14, -0x40(%rbp)
movslq %r14d, %r14
leaq 0x37479(%rip), %rax     # 0x12b590
movzbl -0x1(%r14,%rax), %eax
movl %eax, -0x54(%rbp)
leaq 0x76689(%rip), %rax     # 0x16a7b0
movq (%rax,%r14,8), %rdx
testl %ebx, %ebx
js 0xf4144
leaq 0x2480ea(%rip), %r15    # 0x33c220
movq %r15, %rdi
leaq 0x39c24(%rip), %rsi     # 0x12dd64
movl %ebx, %ecx
jmp 0xf4159
movl %ebx, %ecx
negl %ecx
leaq 0x2480d1(%rip), %r15    # 0x33c220
movq %r15, %rdi
leaq 0x40e79(%rip), %rsi     # 0x134fd2
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
callq 0x9120
movq -0x70(%rbp), %rsi
subq %rax, %rsi
shrq %rsi
leaq 0x219397(%rip), %rax    # 0x30d510
movl (%rax), %eax
xorl %r14d, %eax
leaq 0x21938f(%rip), %rcx    # 0x30d514
movl (%rcx), %ecx
xorl %ebx, %ecx
movl %r12d, -0x60(%rbp)
cmpl -0x50(%rbp), %r12d
seta %dl
shlb $0x3, %dl
orb $0x7, %dl
orl %eax, %ecx
movzbl %dl, %eax
movl %eax, -0x5c(%rbp)
movl $0xa, %ecx
cmovel %ecx, %eax
movq %r15, %rcx
movl -0x30(%rbp), %r15d
addl %r15d, %esi
movl %ebx, %r12d
movzbl %al, %ebx
movq -0x38(%rbp), %r13
movl %r13d, %edi
movl %ebx, %edx
callq 0xe787
leal 0x1(%r13), %edi
movl %r15d, %esi
movl %ebx, %edx
movq -0x78(%rbp), %rcx
callq 0xe787
movl %r12d, -0x2c(%rbp)
movl %r12d, %edi
movl %r14d, %esi
movl $0x1, %edx
callq 0xd485e
callq 0xe9da0
leaq 0x76506(%rip), %rax     # 0x16a700
cmpl $0x0, (%rax,%r14,4)
leaq 0x24801a(%rip), %rbx    # 0x33c220
jle 0xf444d
movl -0x48(%rbp), %esi
negl %esi
addl -0x54(%rbp), %esi
movl -0x58(%rbp), %edi
sarl $0x2, %edi
movslq -0x88(%rbp), %rax
imulq $-0x51eb851f, %rax, %rdx # imm = 0xAE147AE1
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rdx
addl %ecx, %edx
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x27, %rax
addl %ecx, %eax
addl %edi, %eax
addl -0x2c(%rbp), %edx
addl %eax, %edx
addl %esi, %edx
movq %rdx, -0x48(%rbp)
movl $0x2, %r15d
movl $0x1, %r12d
leaq 0x12459b(%rip), %rax    # 0x218804
cmpl $0x258, (%rax)          # imm = 0x258
leaq 0x3358b(%rip), %rax     # 0x127801
jl 0xf427f
leaq 0x344c5(%rip), %rax     # 0x128744
leaq 0x12f2be(%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 0x33557(%rip), %rsi     # 0x127801
leaq 0x12454f(%rip), %rdx    # 0x218800
cmpl %ecx, (%rdx)
movq -0x40(%rbp), %r13
jl 0xf42bc
movq %rax, %rsi
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x9120
movq %rax, %rbx
movb $0x9, %cl
cmpl 0x286727(%rip), %r13d   # 0x37aa04
jne 0xf42ee
movl 0x28671b(%rip), %eax    # 0x37aa00
cmpq %rax, %r12
je 0xf438b
cmpl 0x286717(%rip), %r13d   # 0x37aa0c
jne 0xf4306
movl 0x28670b(%rip), %eax    # 0x37aa08
cmpq %rax, %r12
je 0xf438b
leaq 0x7ccb3(%rip), %rax     # 0x170fc0
movq (%rax,%r12,8), %r13
movzbl (%r13), %eax
testl %eax, %eax
je 0xf431f
cmpl $0x51, %eax
jne 0xf435a
movl -0x2c(%rbp), %edi
movq -0x40(%rbp), %rsi
movl %r12d, %edx
callq 0xef797
movb $0xb, %cl
testl %eax, %eax
jne 0xf438b
leaq 0x2191d5(%rip), %rax    # 0x30d510
movl (%rax), %eax
xorl -0x40(%rbp), %eax
leaq 0x2191cd(%rip), %rcx    # 0x30d514
movl (%rcx), %ecx
xorl -0x2c(%rbp), %ecx
orl %eax, %ecx
movl $0xa, %ecx
je 0xf438b
movl -0x5c(%rbp), %ecx
jmp 0xf438b
movq %r13, %rdi
leaq 0x40c77(%rip), %rsi     # 0x134fdb
callq 0x9090
movb $0xe, %cl
testq %rax, %rax
jne 0xf438b
movq %r13, %rdi
leaq 0x40c66(%rip), %rsi     # 0x134fe0
callq 0x9090
testq %rax, %rax
setne %cl
shlb $0x3, %cl
orb $0x6, %cl
movq -0x48(%rbp), %rax
addl %r12d, %eax
cltq
imulq $-0x6db6db6d, %rax, %r13 # imm = 0x92492493
shrq $0x20, %r13
addl %eax, %r13d
movl %r13d, %edx
shrl $0x1f, %edx
sarl $0x2, %r13d
addl %edx, %r13d
leal (,%r13,8), %edx
subl %edx, %r13d
addl %eax, %r13d
movzbl %r13b, %eax
imull %eax, %ebx
addl -0x30(%rbp), %ebx
leaq 0x219146(%rip), %rax    # 0x30d514
movl (%rax), %eax
xorl -0x2c(%rbp), %eax
leaq 0x219136(%rip), %rdx    # 0x30d510
movl (%rdx), %edx
xorl %r14d, %edx
leaq 0x219126(%rip), %rsi    # 0x30d50c
movl (%rsi), %esi
leaq 0x219111(%rip), %rdi    # 0x30d500
testb $0x1, (%rdi)
movzbl %cl, %ecx
movl $0x0, %r8d
cmovel %ecx, %r8d
cmpq %rsi, %r12
cmovnel %ecx, %r8d
orl %eax, %edx
cmovnel %ecx, %r8d
movq -0x38(%rbp), %rax
leal (%r15,%rax), %edi
movzbl %r8b, %edx
movl %ebx, %esi
leaq 0x247dff(%rip), %rbx    # 0x33c220
movq %rbx, %rcx
callq 0xe787
cmpl $0x6, %r13d
sbbl $-0x1, %r15d
leaq 0x1(%r12), %rax
leaq 0x762c3(%rip), %rcx     # 0x16a700
movslq (%rcx,%r14,4), %rcx
cmpq %rcx, %r12
movq %rax, %r12
jl 0xf4262
movl -0x30(%rbp), %r8d
addl -0x80(%rbp), %r8d
movq -0x38(%rbp), %rcx
leal 0x8(%rcx), %eax
movl -0x4c(%rbp), %edi
cmpl %edi, %r8d
cmovlel %ecx, %eax
leaq 0x1243a0(%rip), %rcx    # 0x21880c
movl (%rcx), %ecx
addl $-0x8, %ecx
cmpl %ecx, %eax
movl -0x2c(%rbp), %ebx
movq -0x40(%rbp), %rdx
movl -0x60(%rbp), %r12d
jge 0xf44b1
cmpl %edi, %r8d
cmovgl -0x68(%rbp), %r8d
xorl %ecx, %ecx
cmpl $0xc, %edx
leal 0x1(%rdx), %edx
setge %cl
movl $0x1, %esi
cmovgel %esi, %edx
addl %ecx, %ebx
incl %r12d
movq %rax, -0x38(%rbp)
movl %edx, %r14d
cmpl $0x31, %r12d
jne 0xf40c0
leaq 0x219068(%rip), %rbx    # 0x30d520
movl (%rbx), %edi
callq 0xe0736
movl (%rbx), %edi
leaq 0x2193d4(%rip), %rax    # 0x30d89c
movslq (%rax), %rax
leaq 0x7635e(%rip), %rcx     # 0x16a830
movq (%rcx,%rax,8), %rsi
callq 0xe1326
leaq 0x219066(%rip), %rax    # 0x30d548
movsd (%rax), %xmm0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9da0