// File: 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
subq $0x130, %rsp            # imm = 0x130
leaq 0x142159(%rip), %rax    # 0x27a5fb
cmpb $0x0, (%rax)
je 0x1384b3
movl $0x0, -0x4(%rbp)
jmp 0x138973
leaq 0x13f51a(%rip), %rax    # 0x2779d4
cmpl $0x0, (%rax)
jne 0x1384cb
movl $0x0, -0x4(%rbp)
jmp 0x138973
leaq 0x265fda(%rip), %rax    # 0x39e4ac
cmpl $0x2, (%rax)
jne 0x1384e3
movl $0x0, -0x4(%rbp)
jmp 0x138973
leaq 0x234342(%rip), %rax    # 0x36c82c
cmpl $0x0, (%rax)
jne 0x1384fb
movl $0x0, -0x4(%rbp)
jmp 0x138973
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
leaq 0x13f4bd(%rip), %rcx    # 0x2779d0
cmpl (%rcx), %eax
jge 0x138914
movslq -0x8(%rbp), %rcx
leaq 0x9193a(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
jne 0x138538
jmp 0x138906
movslq -0x8(%rbp), %rcx
leaq 0x9191d(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x138558
jmp 0x13857f
leaq 0x234191(%rip), %rax    # 0x36c6f0
movl (%rax), %eax
movslq -0x8(%rbp), %rdx
leaq 0x918f4(%rip), %rcx     # 0x1c9e60
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x13857d
jmp 0x138906
jmp 0x13857f
movslq -0x8(%rbp), %rcx
leaq 0x918d6(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x1385de
movslq -0x8(%rbp), %rcx
leaq 0x918bf(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x64, (%rax)
jge 0x1385de
movslq -0x8(%rbp), %rcx
leaq 0x918a8(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edi
movl -0x14(%rbp), %esi
leaq 0x234125(%rip), %rax    # 0x36c6f0
movl (%rax), %edx
leaq 0x234120(%rip), %rax    # 0x36c6f4
movl (%rax), %ecx
callq 0x132ae0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x138633
xorl %eax, %eax
subl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq 0x2340f9(%rip), %rax    # 0x36c6ec
movl (%rax), %edi
leaq 0x2340f4(%rip), %rax    # 0x36c6f0
movl (%rax), %esi
leaq 0x2340ef(%rip), %rax    # 0x36c6f4
movl (%rax), %edx
callq 0x132a50
movzbl %al, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movslq -0x8(%rbp), %rdx
leaq 0x91840(%rip), %rcx     # 0x1c9e60
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x138631
jmp 0x138906
jmp 0x138633
movl -0x14(%rbp), %eax
leaq 0x2340af(%rip), %rcx    # 0x36c6ec
cmpl (%rcx), %eax
je 0x138646
jmp 0x138906
movl $0x0, -0xc(%rbp)
leaq 0x234acc(%rip), %rax    # 0x36d120
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x138665
jp 0x138665
jmp 0x13866a
jmp 0x13879d
movslq -0x8(%rbp), %rcx
leaq 0x917eb(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movsbl (%rax), %eax
cmpl $0x40, %eax
jne 0x13879b
movb $0x0, -0x120(%rbp)
movl $0x1, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x128(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x917b1(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x9120
movq %rax, %rcx
movq -0x128(%rbp), %rax
cmpq %rcx, %rax
jae 0x138742
movslq -0x8(%rbp), %rcx
leaq 0x91787(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0xc(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0xd(%rbp)
movsbl -0xd(%rbp), %eax
cmpl $0x0, %eax
jne 0x1386f8
jmp 0x138742
movsbl -0xd(%rbp), %edi
callq 0x9330
cmpl $0x0, %eax
je 0x138708
jmp 0x138717
movsbl -0xd(%rbp), %eax
cmpl $0x3a, %eax
jne 0x138713
jmp 0x138715
jmp 0x138742
jmp 0x138717
movb -0xd(%rbp), %cl
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movb %cl, -0x120(%rbp,%rax)
movl -0xc(%rbp), %eax
movb $0x0, -0x120(%rbp,%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13869a
cmpb $0x0, -0x120(%rbp)
je 0x13878f
leaq 0x233fa2(%rip), %rax    # 0x36c6f4
movl (%rax), %edx
leaq 0x233f95(%rip), %rax    # 0x36c6f0
movl (%rax), %ecx
leaq 0x233f88(%rip), %rax    # 0x36c6ec
movl (%rax), %r8d
leaq 0x262c92(%rip), %rdi    # 0x39b400
leaq 0x437fe(%rip), %rsi     # 0x17bf73
movb $0x0, %al
callq 0x9060
leaq -0x120(%rbp), %rdi
leaq 0x262c76(%rip), %rsi    # 0x39b400
callq 0x96a0
leaq -0x120(%rbp), %rdi
callq 0x44c80
jmp 0x13879d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
leaq 0x265cff(%rip), %rax    # 0x39e4ac
movl $0x1, (%rax)
leaq 0x2653c6(%rip), %rax    # 0x39db80
movb $0x0, (%rax)
leaq 0x26550c(%rip), %rax    # 0x39dcd0
movb $0x0, (%rax)
leaq 0x265652(%rip), %rax    # 0x39de20
movb $0x0, (%rax)
leaq 0x265798(%rip), %rax    # 0x39df70
movb $0x0, (%rax)
cmpl $0x1, -0x1c(%rbp)
jne 0x138817
movslq -0x8(%rbp), %rcx
leaq 0x91674(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movl -0xc(%rbp), %eax
addq %rax, %rdx
leaq 0x26522c(%rip), %rdi    # 0x39da30
leaq 0x58322(%rip), %rsi     # 0x190b2d
movb $0x0, %al
callq 0x9060
jmp 0x138904
cmpl $0x2, -0x1c(%rbp)
jne 0x138853
movslq -0x8(%rbp), %rcx
leaq 0x91638(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movl -0xc(%rbp), %eax
addq %rax, %rdx
leaq 0x265340(%rip), %rdi    # 0x39db80
leaq 0x582e6(%rip), %rsi     # 0x190b2d
movb $0x0, %al
callq 0x9060
jmp 0x138902
cmpl $0x3, -0x1c(%rbp)
jne 0x13888c
movslq -0x8(%rbp), %rcx
leaq 0x915fc(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movl -0xc(%rbp), %eax
addq %rax, %rdx
leaq 0x265454(%rip), %rdi    # 0x39dcd0
leaq 0x582aa(%rip), %rsi     # 0x190b2d
movb $0x0, %al
callq 0x9060
jmp 0x138900
cmpl $0x4, -0x1c(%rbp)
jne 0x1388c5
movslq -0x8(%rbp), %rcx
leaq 0x915c3(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movl -0xc(%rbp), %eax
addq %rax, %rdx
leaq 0x26556b(%rip), %rdi    # 0x39de20
leaq 0x58271(%rip), %rsi     # 0x190b2d
movb $0x0, %al
callq 0x9060
jmp 0x1388fe
cmpl $0x5, -0x1c(%rbp)
jne 0x1388fc
movslq -0x8(%rbp), %rcx
leaq 0x9158a(%rip), %rax     # 0x1c9e60
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movl -0xc(%rbp), %eax
addq %rax, %rdx
leaq 0x265682(%rip), %rdi    # 0x39df70
leaq 0x58238(%rip), %rsi     # 0x190b2d
movb $0x0, %al
callq 0x9060
jmp 0x1388fe
jmp 0x138900
jmp 0x138902
jmp 0x138904
jmp 0x138906
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x138509
cmpl $0x0, -0x1c(%rbp)
je 0x138922
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x138973
leaq 0x265b83(%rip), %rax    # 0x39e4ac
cmpl $0x1, (%rax)
jne 0x13896d
leaq 0x2650fb(%rip), %rax    # 0x39da30
movb $0x0, (%rax)
leaq 0x265241(%rip), %rax    # 0x39db80
movb $0x0, (%rax)
leaq 0x265387(%rip), %rax    # 0x39dcd0
movb $0x0, (%rax)
leaq 0x2654cd(%rip), %rax    # 0x39de20
movb $0x0, (%rax)
leaq 0x265613(%rip), %rax    # 0x39df70
movb $0x0, (%rax)
leaq 0x265b45(%rip), %rax    # 0x39e4ac
movl $0x0, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nop