// File: /workspace/github_cpp_makefile_star2_O2/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 0x1340c2(%rip), %rax    # 0x20541b
xorl %r15d, %r15d
cmpb $0x0, (%rax)
jne 0xd1627
leaq 0x131488(%rip), %rax    # 0x2027f4
cmpl $0x0, (%rax)
je 0xd1627
leaq 0x257f50(%rip), %rax    # 0x3292cc
cmpl $0x2, (%rax)
je 0xd1627
leaq 0x2262c0(%rip), %rax    # 0x2f764c
cmpl $0x0, (%rax)
je 0xd1627
leaq 0x131454(%rip), %rsi    # 0x2027f0
leaq 0x83aad(%rip), %r8      # 0x154e50
xorl %ebx, %ebx
xorl %r15d, %r15d
movslq (%rsi), %rax
cmpq %rax, %rbx
jge 0xd15d4
imulq $0x18, %rbx, %r14
movl 0x8(%r14,%r8), %eax
testl %eax, %eax
je 0xd1576
addq %r8, %r14
movl 0x4(%r14), %r13d
testl %r13d, %r13d
sets %cl
leaq 0x226137(%rip), %rdx    # 0x2f7510
movl (%rdx), %edx
cmpl %eax, %edx
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0xd1576
movl (%r14), %edi
testl %edi, %edi
sete %al
cmpl $0x64, %edi
setge %cl
orb %al, %cl
jne 0xd141e
leaq 0x226111(%rip), %rax    # 0x2f7514
movl (%rax), %ecx
movl %r13d, %esi
callq 0xcd819
leaq 0x83a3c(%rip), %r8      # 0x154e50
leaq 0x1313d5(%rip), %rsi    # 0x2027f0
movl %eax, %r13d
leaq 0x2260e7(%rip), %rax    # 0x2f750c
movl (%rax), %edi
testl %r13d, %r13d
jns 0xd1467
leaq 0x2260dd(%rip), %rax    # 0x2f7510
movl (%rax), %esi
leaq 0x2260d8(%rip), %rax    # 0x2f7514
movl (%rax), %edx
movl %edi, %r12d
callq 0xcd7b8
movzbl %al, %eax
cmpl %eax, 0x8(%r14)
jne 0xd1568
negl %r13d
leaq 0x131393(%rip), %rsi    # 0x2027f0
leaq 0x839ec(%rip), %r8      # 0x154e50
movl %r12d, %edi
cmpl %edi, %r13d
jne 0xd1576
movl %r15d, -0x30(%rbp)
leaq 0x226ac5(%rip), %rax    # 0x2f7f40
movsd (%rax), %xmm0
ucomisd 0x21c91(%rip), %xmm0    # 0xf3118
jne 0xd14f5
jp 0xd14f5
movq 0x10(%r14), %r15
cmpb $0x40, (%r15)
jne 0xd14f5
movl %edi, -0x2c(%rbp)
movb $0x0, -0x130(%rbp)
xorl %r12d, %r12d
leal 0x1(%r12), %r13d
movq %r15, %rdi
callq 0x9120
cmpq %r13, %rax
jbe 0xd157e
movsbl (%r15,%r13), %eax
testl %eax, %eax
je 0xd157e
movl %eax, %ecx
addl $-0x30, %ecx
cmpl $0xa, %ecx
setae %cl
cmpb $0x3a, %al
setne %dl
testb %cl, %dl
jne 0xd157e
movl %r12d, %ecx
movb %al, -0x130(%rbp,%rcx)
movb $0x0, -0x130(%rbp,%r13)
movl %r13d, %r12d
jmp 0xd14a2
xorl %r13d, %r13d
leaq 0x257dcd(%rip), %rax    # 0x3292cc
movl $0x1, (%rax)
leaq 0x257494(%rip), %rax    # 0x3289a0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x2575d9(%rip), %rax    # 0x328af0
movb %cl, (%rax)
leaq 0x257720(%rip), %rax    # 0x328c40
movb %cl, (%rax)
leaq 0x257867(%rip), %rax    # 0x328d90
movb %cl, (%rax)
leaq 0x25731e(%rip), %rdi    # 0x328850
pushq $0x1
popq %r15
movl -0x30(%rbp), %eax
testl %eax, %eax
je 0xd1557
cmpl $0x4, %eax
movl %eax, %r15d
ja 0xd1565
movslq %r15d, %rax
leaq 0x686c9(%rip), %rcx     # 0x139c18
movq -0x8(%rcx,%rax,8), %rdi
incl %r15d
addq 0x10(%r14), %r13
movq %r13, %rsi
callq 0x9330
jmp 0xd1568
incl %r15d
leaq 0x131281(%rip), %rsi    # 0x2027f0
leaq 0x838da(%rip), %r8      # 0x154e50
incq %rbx
jmp 0xd13a8
cmpb $0x0, -0x130(%rbp)
leaq -0x130(%rbp), %r15
je 0xd15c7
leaq 0x225f7f(%rip), %rax    # 0x2f7514
movl (%rax), %edx
leaq 0x225f72(%rip), %rax    # 0x2f7510
movl (%rax), %ecx
leaq 0x254c79(%rip), %r12    # 0x326220
movq %r12, %rdi
leaq 0x30044(%rip), %rsi     # 0x1015f5
movl -0x2c(%rbp), %r8d
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
movq %r12, %rsi
callq 0x96c0
movq %r15, %rdi
callq 0x2e447
jmp 0xd14f8
testl %r15d, %r15d
jne 0xd1627
xorl %r15d, %r15d
leaq 0x257ce9(%rip), %rax    # 0x3292cc
cmpl $0x1, (%rax)
jne 0xd1627
leaq 0x257261(%rip), %rax    # 0x328850
xorl %r15d, %r15d
movb %r15b, (%rax)
leaq 0x2573a4(%rip), %rax    # 0x3289a0
movb %r15b, (%rax)
leaq 0x2574ea(%rip), %rax    # 0x328af0
movb %r15b, (%rax)
leaq 0x257630(%rip), %rax    # 0x328c40
movb %r15b, (%rax)
leaq 0x257776(%rip), %rax    # 0x328d90
movb %r15b, (%rax)
leaq 0x257ca8(%rip), %rax    # 0x3292cc
andl $0x0, (%rax)
movl %r15d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq