// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: show_greetings()
int show_greetings()
{
int i;
unsigned j;
char c;
int day;
int dow;
int shown;
char alarm[SLEN+1];

   // see if today is a day of greetings
   if(no_greetings) return 0;         // user is a grinch...
   if(greet_on == 0) return 0;        // not all info available for calculating greetings
   if(title_type == USER) return 0;   // don't override the user's title
   if(!have_local_time) return 0;     // time is in an astronomical scale
//printf("greetings %d\n", calendar_entries);
//for(i=0; i<calendar_entries; i++) { // is it a special day?
//printf("i:%-3d  nth:%d  day:%d  mo:%d   text:%s\n", i, holiday[i].nth,holiday[i].day,holiday[i].month,holiday[i].text);
//}

   shown = 0;
   for(i=0; i<calendar_entries; i++) { // is it a special day?
      if(holiday[i].month == 0) continue;

      day = holiday[i].day;
      if(day < 0) ;   // day number for dates like Friday the 13th (would be -13)
      else if(pri_month != holiday[i].month) continue;

      if((holiday[i].nth != 0) && (holiday[i].nth < 100)) {
         day = nth_dow_in(holiday[i].nth, day, pri_month, pri_year);
      }
      if(day < 0) {
         day = 0 - day;
         dow = day_of_week(pri_day,pri_month,pri_year);
         if(dow != holiday[i].month) continue;
      }
      if(day != pri_day) continue;
//if(debug_file) fprintf(debug_file, "toots pri:%02d/%02d/%04d  on:%d  day:%d  i:%d  hlt:%d  tz:%.9f  holiday:%d (%s)\n", 
//pri_day,pri_month,pri_year, greet_on, day,i,have_local_time,time_zone(),holiday[i].month, holiday[i].text);

      j = 0;
      if(alarm_jd) ;  // alarm already set, don't set calendar alarm
      else if(holiday[i].text[0] == '@') {  // calendar entry has an alarm time set
         alarm[0] = 0;
         for(j=1; j<strlen(holiday[i].text); j++) {
            c = holiday[i].text[j];
            if(c == 0) break;
            if(isdigit(c)) ;
            else if(c == ':') ;
            else break;
            alarm[j-1] = c;
            alarm[j] = 0;
         }
         if(alarm[0]) {
            sprintf(out, " %04d/%02d/%02d", pri_year,pri_month,pri_day);
            strcat(alarm, out);
         }
         set_alarm(alarm);
      }

      ++shown;
      title_type = GREETING;
//    plot_title[0] = 0;
      debug_text[0] = 0;
      debug_text2[0] = 0;
      debug_text3[0] = 0;
      debug_text4[0] = 0;
      if     (shown == 1) sprintf(plot_title,  "%s", &holiday[i].text[j]);
      else if(shown == 2) sprintf(debug_text,  "%s", &holiday[i].text[j]);
      else if(shown == 3) sprintf(debug_text2, "%s", &holiday[i].text[j]);
      else if(shown == 4) sprintf(debug_text3, "%s", &holiday[i].text[j]);
      else if(shown == 5) sprintf(debug_text4, "%s", &holiday[i].text[j]);
   }
   if(shown) return shown;

   if(title_type == GREETING) {  // erase old greetings
      plot_title[0] = 0;
      debug_text[0] = 0;
      debug_text2[0] = 0;
      debug_text3[0] = 0;
      debug_text4[0] = 0;
      title_type = NONE;
   }
   return shown;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0x1369e1(%rip), %rax    # 0x21b41b
xorl %r14d, %r14d
cmpb $0x0, (%rax)
jne 0xe4db0
leaq 0x133da7(%rip), %rax    # 0x2187f4
cmpl $0x0, (%rax)
je 0xe4db0
leaq 0x25a86f(%rip), %r13    # 0x33f2cc
cmpl $0x2, (%r13)
je 0xe4db0
leaq 0x228bdd(%rip), %rax    # 0x30d64c
cmpl $0x0, (%rax)
je 0xe4db0
leaq 0x133d71(%rip), %r15    # 0x2187f0
cmpl $0x0, (%r15)
jle 0xe4d66
leaq 0x863c0(%rip), %r10     # 0x16ae50
xorl %ebx, %ebx
xorl %r14d, %r14d
leaq (%rbx,%rbx,2), %rax
movl 0x8(%r10,%rax,8), %ecx
testl %ecx, %ecx
je 0xe4d52
leaq (%r10,%rax,8), %r12
movl 0x4(%r12), %eax
testl %eax, %eax
sets %sil
leaq 0x228a54(%rip), %rdx    # 0x30d510
movl (%rdx), %edx
cmpl %ecx, %edx
sete %cl
orb %sil, %cl
cmpb $0x1, %cl
jne 0xe4d52
movl (%r12), %edi
testl %edi, %edi
sete %cl
cmpl $0x64, %edi
setge %sil
orb %cl, %sil
jne 0xe4afb
leaq 0x228a29(%rip), %rcx    # 0x30d514
movl (%rcx), %ecx
movl %eax, %esi
callq 0xe085c
leaq 0x86355(%rip), %r10     # 0x16ae50
leaq 0x228a0a(%rip), %rcx    # 0x30d50c
movl (%rcx), %r11d
testl %eax, %eax
jns 0xe4bb8
leaq 0x2289fc(%rip), %rcx    # 0x30d510
movslq (%rcx), %rcx
xorl %edx, %edx
cmpq $0x3, %rcx
setl %dl
leaq 0x2289ed(%rip), %rsi    # 0x30d514
movl (%rsi), %esi
subl %edx, %esi
leal 0x3(%rsi), %edx
testl %esi, %esi
cmovnsl %esi, %edx
sarl $0x2, %edx
movslq %esi, %rsi
imulq $-0x51eb851f, %rsi, %rdi # imm = 0xAE147AE1
movq %rdi, %r8
shrq $0x3f, %r8
shrq $0x20, %rdi
sarl $0x5, %edi
addl %r8d, %edi
imulq $0x51eb851f, %rsi, %r8  # imm = 0x51EB851F
movq %r8, %r9
shrq $0x3f, %r9
shrq $0x20, %r8
sarl $0x7, %r8d
addl %r9d, %r8d
leaq 0x46a1f(%rip), %r9      # 0x12b590
movzbl -0x1(%rcx,%r9), %ecx
addl %r11d, %esi
addl %ecx, %esi
addl %edx, %esi
addl %edi, %esi
addl %r8d, %esi
movslq %esi, %rcx
imulq $-0x6db6db6d, %rcx, %rdx # imm = 0x92492493
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %esi
shrl $0x1f, %esi
sarl $0x2, %edx
addl %esi, %edx
leal (,%rdx,8), %esi
subl %esi, %edx
addl %ecx, %edx
movzbl %dl, %ecx
cmpl %ecx, 0x8(%r12)
jne 0xe4d52
negl %eax
cmpl %r11d, %eax
jne 0xe4d52
leaq 0x229378(%rip), %rax    # 0x30df40
movsd (%rax), %xmm0
ucomisd 0x24544(%rip), %xmm0    # 0x109118
jne 0xe4bd8
jnp 0xe4be0
xorl %r15d, %r15d
jmp 0xe4cd1
movl %r14d, -0x2c(%rbp)
movq 0x10(%r12), %r14
cmpb $0x40, (%r14)
jne 0xe4cca
movl %r11d, -0x30(%rbp)
movb $0x0, -0x130(%rbp)
movq %r14, %rdi
callq 0x9120
movl $0x1, %r15d
cmpq $0x2, %rax
jb 0xe4cb1
movl $0x2, %r13d
movl -0x30(%rbp), %r8d
movsbl (%r14,%r15), %eax
testl %eax, %eax
je 0xe4c68
movl %eax, %ecx
addl $-0x30, %ecx
cmpl $0xa, %ecx
setae %cl
cmpb $0x3a, %al
setne %dl
testb %cl, %dl
jne 0xe4c68
leal -0x2(%r13), %ecx
movb %al, -0x130(%rbp,%rcx)
movb $0x0, -0x130(%rbp,%r15)
movl %r13d, %r15d
movq %r14, %rdi
callq 0x9120
movl -0x30(%rbp), %r8d
incl %r13d
cmpq %r15, %rax
ja 0xe4c20
cmpb $0x0, -0x130(%rbp)
je 0xe4caa
leaq 0x22889c(%rip), %rax    # 0x30d514
movl (%rax), %edx
leaq 0x22888f(%rip), %rax    # 0x30d510
movl (%rax), %ecx
leaq 0x257596(%rip), %r14    # 0x33c220
movq %r14, %rdi
leaq 0x328e1(%rip), %rsi     # 0x117575
xorl %eax, %eax
callq 0x9060
leaq -0x130(%rbp), %rdi
movq %r14, %rsi
callq 0x96c0
leaq 0x25a61b(%rip), %r13    # 0x33f2cc
leaq -0x130(%rbp), %rdi
callq 0x30fcc
movl -0x2c(%rbp), %r14d
leaq 0x86188(%rip), %r10     # 0x16ae50
jmp 0xe4cd1
xorl %r15d, %r15d
movl -0x2c(%rbp), %r14d
movl $0x1, (%r13)
xorl %eax, %eax
leaq 0x259cbe(%rip), %rcx    # 0x33e9a0
movb %al, (%rcx)
leaq 0x259e05(%rip), %rcx    # 0x33eaf0
movb %al, (%rcx)
leaq 0x259f4c(%rip), %rcx    # 0x33ec40
movb %al, (%rcx)
leaq 0x25a093(%rip), %rcx    # 0x33ed90
movb %al, (%rcx)
testl %r14d, %r14d
je 0xe4d1e
cmpl $0x4, %r14d
ja 0xe4d48
movslq %r14d, %rax
leaq 0x6aefc(%rip), %rcx     # 0x14fc10
movq -0x8(%rcx,%rax,8), %rdi
incl %r14d
jmp 0xe4d2b
movl $0x1, %r14d
leaq 0x259b25(%rip), %rdi    # 0x33e850
addq 0x10(%r12), %r15
movq %r15, %rsi
callq 0x9340
leaq 0x133ab1(%rip), %r15    # 0x2187f0
leaq 0x8610a(%rip), %r10     # 0x16ae50
jmp 0xe4d52
incl %r14d
leaq 0x133a9e(%rip), %r15    # 0x2187f0
incq %rbx
movslq (%r15), %rax
cmpq %rax, %rbx
jl 0xe4a95
testl %r14d, %r14d
jne 0xe4db0
cmpl $0x1, (%r13)
movl $0x0, %r14d
jne 0xe4db0
leaq 0x259ad6(%rip), %rax    # 0x33e850
xorl %r14d, %r14d
movb %r14b, (%rax)
leaq 0x259c19(%rip), %rax    # 0x33e9a0
movb %r14b, (%rax)
leaq 0x259d5f(%rip), %rax    # 0x33eaf0
movb %r14b, (%rax)
leaq 0x259ea5(%rip), %rax    # 0x33ec40
movb %r14b, (%rax)
leaq 0x259feb(%rip), %rax    # 0x33ed90
movb %r14b, (%rax)
movl $0x0, (%r13)
movl %r14d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq