// File: /workspace/github_cpp_makefile_star2_O1/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 0x1375e9(%rip), %rax    # 0x21b41b
xorl %r12d, %r12d
cmpb $0x0, (%rax)
jne 0xe41b7
leaq 0x1349af(%rip), %rax    # 0x2187f4
cmpl $0x0, (%rax)
je 0xe41b7
leaq 0x25b477(%rip), %r15    # 0x33f2cc
cmpl $0x2, (%r15)
je 0xe41b7
leaq 0x2297e6(%rip), %rax    # 0x30d64c
cmpl $0x0, (%rax)
je 0xe41b7
leaq 0x13497a(%rip), %r13    # 0x2187f0
cmpl $0x0, (%r13)
jle 0xe416a
leaq 0x86fc8(%rip), %r10     # 0x16ae50
leaq 0x229681(%rip), %r11    # 0x30d510
xorl %ebx, %ebx
xorl %r12d, %r12d
leaq (%rbx,%rbx,2), %rax
movl 0x8(%r10,%rax,8), %ecx
testl %ecx, %ecx
je 0xe4158
leaq (%r10,%rax,8), %r14
movl 0x4(%r14), %eax
testl %eax, %eax
sets %sil
movl (%r11), %edx
cmpl %ecx, %edx
sete %cl
orb %sil, %cl
cmpb $0x1, %cl
jne 0xe4158
movl (%r14), %edi
testl %edi, %edi
sete %cl
cmpl $0x64, %edi
setge %sil
orb %cl, %sil
jne 0xe3ef9
leaq 0x229632(%rip), %rcx    # 0x30d514
movl (%rcx), %ecx
movl %eax, %esi
callq 0xdfd9e
leaq 0x22961e(%rip), %r11    # 0x30d510
leaq 0x86f57(%rip), %r10     # 0x16ae50
testl %eax, %eax
js 0xe3f06
movl %r12d, -0x2c(%rbp)
jmp 0xe3fb3
movslq (%r11), %rcx
xorl %edx, %edx
cmpq $0x3, %rcx
setl %dl
leaq 0x2295fb(%rip), %rsi    # 0x30d514
movl (%rsi), %edi
subl %edx, %edi
leal 0x3(%rdi), %esi
testl %edi, %edi
cmovnsl %edi, %esi
sarl $0x2, %esi
movslq %edi, %rdx
imulq $-0x51eb851f, %rdx, %rdi # imm = 0xAE147AE1
movq %rdi, %r8
shrq $0x3f, %r8
shrq $0x20, %rdi
sarl $0x5, %edi
addl %r8d, %edi
imulq $0x51eb851f, %rdx, %r8  # imm = 0x51EB851F
movq %r8, %r9
shrq $0x3f, %r9
shrq $0x20, %r8
sarl $0x7, %r8d
addl %r9d, %r8d
leaq 0x4755d(%rip), %r9      # 0x12b4c0
movzbl -0x1(%rcx,%r9), %ecx
addl %esi, %ecx
leaq 0x22959a(%rip), %rsi    # 0x30d50c
addl (%rsi), %edx
addl %ecx, %edx
addl %edi, %edx
addl %r8d, %edx
movslq %edx, %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(%r14)
jne 0xe4158
movl %r12d, -0x2c(%rbp)
negl %eax
leaq 0x229552(%rip), %rcx    # 0x30d50c
movl (%rcx), %ecx
cmpl %ecx, %eax
jne 0xe40c2
leaq 0x229f75(%rip), %rax    # 0x30df40
movsd (%rax), %xmm0
ucomisd 0x25141(%rip), %xmm0    # 0x109118
jne 0xe40cb
jp 0xe40cb
movq 0x10(%r14), %r12
cmpb $0x40, (%r12)
jne 0xe40cb
movl %ecx, -0x30(%rbp)
movb $0x0, -0x130(%rbp)
movq %r12, %rdi
callq 0x9120
movl $0x1, %r13d
cmpq $0x2, %rax
jb 0xe405a
movl $0x2, %r15d
movsbl (%r12,%r13), %eax
testl %eax, %eax
je 0xe405a
movl %eax, %ecx
addl $-0x30, %ecx
cmpl $0xa, %ecx
setae %cl
cmpb $0x3a, %al
setne %dl
testb %cl, %dl
jne 0xe405a
leal -0x2(%r15), %ecx
movb %al, -0x130(%rbp,%rcx)
movb $0x0, -0x130(%rbp,%r13)
movl %r15d, %r13d
movq %r12, %rdi
callq 0x9120
incl %r15d
cmpq %r13, %rax
ja 0xe4016
cmpb $0x0, -0x130(%rbp)
leaq -0x130(%rbp), %r15
je 0xe40a3
leaq 0x2294a3(%rip), %rax    # 0x30d514
movl (%rax), %edx
leaq 0x229496(%rip), %rax    # 0x30d510
movl (%rax), %ecx
leaq 0x25819d(%rip), %r12    # 0x33c220
movq %r12, %rdi
leaq 0x33454(%rip), %rsi     # 0x1174e1
movl -0x30(%rbp), %r8d
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
movq %r12, %rsi
callq 0x96c0
movq %r15, %rdi
callq 0x30e46
leaq 0x25b21a(%rip), %r15    # 0x33f2cc
leaq 0x86d97(%rip), %r10     # 0x16ae50
leaq 0x229450(%rip), %r11    # 0x30d510
jmp 0xe40ce
movl -0x2c(%rbp), %r12d
jmp 0xe4158
xorl %r13d, %r13d
movl $0x1, (%r15)
xorl %eax, %eax
leaq 0x25a8c2(%rip), %rcx    # 0x33e9a0
movb %al, (%rcx)
leaq 0x25aa09(%rip), %rcx    # 0x33eaf0
movb %al, (%rcx)
leaq 0x25ab50(%rip), %rcx    # 0x33ec40
movb %al, (%rcx)
leaq 0x25ac97(%rip), %rcx    # 0x33ed90
movb %al, (%rcx)
movl -0x2c(%rbp), %r12d
testl %r12d, %r12d
je 0xe411e
cmpl $0x4, %r12d
ja 0xe414e
movslq %r12d, %rax
leaq 0x6bafc(%rip), %rcx     # 0x14fc10
movq -0x8(%rcx,%rax,8), %rdi
incl %r12d
jmp 0xe412b
movl $0x1, %r12d
leaq 0x25a725(%rip), %rdi    # 0x33e850
addq 0x10(%r14), %r13
movq %r13, %rsi
callq 0x9340
leaq 0x1346b2(%rip), %r13    # 0x2187f0
leaq 0x86d0b(%rip), %r10     # 0x16ae50
leaq 0x2293c4(%rip), %r11    # 0x30d510
jmp 0xe4158
incl %r12d
leaq 0x134698(%rip), %r13    # 0x2187f0
incq %rbx
movslq (%r13), %rax
cmpq %rax, %rbx
jl 0xe3e94
jmp 0xe416d
xorl %r12d, %r12d
testl %r12d, %r12d
jne 0xe41b7
xorl %r12d, %r12d
cmpl $0x1, (%r15)
jne 0xe41b7
leaq 0x25a6ce(%rip), %rax    # 0x33e850
xorl %r12d, %r12d
movb %r12b, (%rax)
leaq 0x25a811(%rip), %rax    # 0x33e9a0
movb %r12b, (%rax)
leaq 0x25a957(%rip), %rax    # 0x33eaf0
movb %r12b, (%rax)
leaq 0x25aa9d(%rip), %rax    # 0x33ec40
movb %r12b, (%rax)
leaq 0x25abe3(%rip), %rax    # 0x33ed90
movb %r12b, (%rax)
movl $0x0, (%r15)
movl %r12d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq