// File: jkingan[P]ladyheather/heathui.cpp
// Function: set_sunrise_type(char*, int)
void set_sunrise_type(char *s, int kbd_cmd)
{
char c;
double jd, jd_nm;
int n;

   need_sunrise = 0;
   realtime_sun = 0;
   play_sun_song = 0;
   do_moonrise = 0;
   if(s == 0) return;
// if(s[0] == 0) return;

   c = 'O';
   while(*s) {
      c = *s;
      if(c == ' ') ;
      else if(c == '\t') ;
      else if(c == '!') realtime_sun = 1;
      else if(c == '*') play_sun_song = 1;
      else break;
      ++s;
   }
   if(c == 0) c = 'O';

   need_sunrise = 1;
   apply_refraction = 0;
   user_set_short = 1;   // abbreviated sat info display
if(kbd_cmd) max_sat_display = max_sat_count;
   c = toupper(c);
   if(c == 'A') {
      sunrise_type = "Astronomical";
      sunrise_horizon = (-18.0);
      sunset_horizon = sunrise_horizon;
   }
   else if(c == 'C') {
      sunrise_type = "Civil";
      sunrise_horizon = (-6.0);
      sunset_horizon = sunrise_horizon;
   }
   else if(c == 'M') {    // Substitute moon info for sun info
      sunrise_type = "Moon";
      do_moonrise = 1;
      sunrise_horizon = (0.0 - ((35.4/60.0) + moon_diam(jd_utc)/2.0));
      sunset_horizon = sunrise_horizon;
//sprintf(plot_title, "moon diam:%f  hor:%f", MoonDisk, sunrise_horizon);
   }
   else if(c == 'N') {
      sunrise_type = "Nautical";
      sunrise_horizon = (-12.0);
      sunset_horizon = sunrise_horizon;
   }
   else if(c == 'O') {
      sunrise_type = "Official";
      sunrise_horizon = (-50.0/60.0);
      sunset_horizon = sunrise_horizon;
   }
   else if(c == 'P') {
      sunrise_type = "Physical";
      sunrise_horizon = 0.0 - (sun_diam(jd_utc)/2.0);
      sunset_horizon = sunrise_horizon;
   }
   else if((c == '+') || (c == '-') || (c == '.') || isdigit(c)) {  // user define angles
      sunrise_type = "User";

      n = sscanf(s, "%lf%c%lf", &sunrise_horizon,&c,&sunset_horizon);

      sunrise_horizon = sunset_horizon = 0.0;
      if(n == 0) sunrise_horizon = sunset_horizon = 999.0;
      else if(n < 3) sunset_horizon = sunrise_horizon;

      if((sunrise_horizon > 90.0) || (sunset_horizon > 90.0) || (sunrise_horizon < (-90.0)) || (sunset_horizon < (-90.0))) {
         sunrise_type = 0;
         need_sunrise = 0;
         play_sun_song = 0;
         realtime_sun = 0;
         return;
      }
   }
else if(c == 'X') {  // debug info
   for(pri_month=1; pri_month<=12; pri_month++) {
      if(debug_file) {
         jd = jdate(pri_year,pri_month,pri_day) + jtime(pri_hours,pri_minutes,pri_seconds,0.0);
         gregorian(0, jd);
         fprintf(debug_file, "\ncheck new moon day: %02d:%02d:%02d %02d/%02d/%04d  jd:%f\n",
            g_hours,g_minutes,g_seconds, g_month,g_day,g_year, jd);
         jd_nm = new_moon(jd);  // get this month's new moon
         gregorian(0, jd_nm-jtime(0,0,0,0.0));
         fprintf(debug_file, "new moon day: %02d:%02d:%02d %02d/%02d/%04d  jd:%f\n",
            g_hours,g_minutes,g_seconds, g_month,g_day,g_year, jd);
      }
   }

   for(pri_month=1; pri_month<=12; pri_month++) {
      for(pri_day=1; pri_day<31; pri_day++) {
         sunrise_type = "Moon";
         do_moonrise = 1;
         sunrise_horizon = (-51.2583333/60.0);
         sunset_horizon = sunrise_horizon;
         calc_moonrise();

         sunrise_type = "Official";
         do_moonrise = 0;
         sunrise_horizon = (-50.0/60.0);
         sunset_horizon = sunrise_horizon;
         calc_sunrise(0.0, 10);
      }
   }
   need_sunrise = 0;
}
   else {
      sunrise_type = "Official";
      sunrise_horizon = (-50.0/60.0);
      sunset_horizon = sunrise_horizon;
   }

   if(strchr(s, '*')) play_sun_song = 1;    // enable sun song
   if(strchr(s, '!')) realtime_sun = 1;     // recalc times every second
   if(strchr(s, 'r')) apply_refraction = 1; // apply refraction correction
   if(strchr(s, 'R')) apply_refraction = 1; // apply refraction correction
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq 0x32209a(%rip), %rax    # 0x36c790
movl $0x0, (%rax)
leaq 0x322091(%rip), %rax    # 0x36c794
movl $0x0, (%rax)
leaq 0x322088(%rip), %rax    # 0x36c798
movl $0x0, (%rax)
leaq 0x322143(%rip), %rax    # 0x36c860
movl $0x0, (%rax)
cmpq $0x0, -0x8(%rbp)
jne 0x4a72f
jmp 0x4af00
movb $0x4f, -0xd(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, (%rax)
je 0x4a7a1
movq -0x8(%rbp), %rax
movb (%rax), %al
movb %al, -0xd(%rbp)
movsbl -0xd(%rbp), %eax
cmpl $0x20, %eax
jne 0x4a750
jmp 0x4a793
movsbl -0xd(%rbp), %eax
cmpl $0x9, %eax
jne 0x4a75b
jmp 0x4a791
movsbl -0xd(%rbp), %eax
cmpl $0x21, %eax
jne 0x4a773
leaq 0x322029(%rip), %rax    # 0x36c794
movl $0x1, (%rax)
jmp 0x4a78f
movsbl -0xd(%rbp), %eax
cmpl $0x2a, %eax
jne 0x4a78b
leaq 0x322015(%rip), %rax    # 0x36c798
movl $0x1, (%rax)
jmp 0x4a78d
jmp 0x4a7a1
jmp 0x4a78f
jmp 0x4a791
jmp 0x4a793
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x4a733
movsbl -0xd(%rbp), %eax
cmpl $0x0, %eax
jne 0x4a7ae
movb $0x4f, -0xd(%rbp)
leaq 0x321fdb(%rip), %rax    # 0x36c790
movl $0x1, (%rax)
leaq 0x321ffe(%rip), %rax    # 0x36c7c0
movl $0x0, (%rax)
leaq 0x2539b9(%rip), %rax    # 0x29e188
movl $0x1, (%rax)
cmpl $0x0, -0xc(%rbp)
je 0x4a7ed
leaq 0x32117e(%rip), %rax    # 0x36b960
movl (%rax), %ecx
leaq 0x253999(%rip), %rax    # 0x29e184
movl %ecx, (%rax)
movsbl -0xd(%rbp), %edi
callq 0x96e0
movb %al, -0xd(%rbp)
movsbl -0xd(%rbp), %eax
cmpl $0x41, %eax
jne 0x4a841
leaq 0x321f9f(%rip), %rax    # 0x36c7a8
leaq 0x12fb9d(%rip), %rcx    # 0x17a3ad
movq %rcx, (%rax)
leaq 0x321f96(%rip), %rax    # 0x36c7b0
movsd 0x126eee(%rip), %xmm0   # 0x171710
movsd %xmm0, (%rax)
leaq 0x321f83(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321f80(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4ae7c
movsbl -0xd(%rbp), %eax
cmpl $0x43, %eax
jne 0x4a889
leaq 0x321f57(%rip), %rax    # 0x36c7a8
leaq 0x12fb62(%rip), %rcx    # 0x17a3ba
movq %rcx, (%rax)
leaq 0x321f4e(%rip), %rax    # 0x36c7b0
movsd 0x126e9e(%rip), %xmm0   # 0x171708
movsd %xmm0, (%rax)
leaq 0x321f3b(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321f38(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4ae7a
movsbl -0xd(%rbp), %eax
cmpl $0x4d, %eax
jne 0x4a905
leaq 0x321f0f(%rip), %rax    # 0x36c7a8
leaq 0x14cf14(%rip), %rcx    # 0x1977b4
movq %rcx, (%rax)
leaq 0x321fb6(%rip), %rax    # 0x36c860
movl $0x1, (%rax)
leaq 0x321e59(%rip), %rax    # 0x36c710
movsd (%rax), %xmm0
callq 0x13f120
movsd 0x124888(%rip), %xmm1   # 0x16f150
divsd %xmm1, %xmm0
movsd 0x126e2c(%rip), %xmm1   # 0x171700
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
subsd %xmm1, %xmm0
leaq 0x321eca(%rip), %rax    # 0x36c7b0
movsd %xmm0, (%rax)
leaq 0x321ebf(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321ebc(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4ae78
movsbl -0xd(%rbp), %eax
cmpl $0x4e, %eax
jne 0x4a94d
leaq 0x321e93(%rip), %rax    # 0x36c7a8
leaq 0x12faa4(%rip), %rcx    # 0x17a3c0
movq %rcx, (%rax)
leaq 0x321e8a(%rip), %rax    # 0x36c7b0
movsd 0x126dca(%rip), %xmm0   # 0x1716f8
movsd %xmm0, (%rax)
leaq 0x321e77(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321e74(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4ae76
movsbl -0xd(%rbp), %eax
cmpl $0x4f, %eax
jne 0x4a995
leaq 0x321e4b(%rip), %rax    # 0x36c7a8
leaq 0x126407(%rip), %rcx    # 0x170d6b
movq %rcx, (%rax)
leaq 0x321e42(%rip), %rax    # 0x36c7b0
movsd 0x12482a(%rip), %xmm0   # 0x16f1a0
movsd %xmm0, (%rax)
leaq 0x321e2f(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321e2c(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4ae74
movsbl -0xd(%rbp), %eax
cmpl $0x50, %eax
jne 0x4a9fb
leaq 0x321e03(%rip), %rax    # 0x36c7a8
leaq 0x12fa1d(%rip), %rcx    # 0x17a3c9
movq %rcx, (%rax)
leaq 0x321d5a(%rip), %rax    # 0x36c710
movsd (%rax), %xmm0
callq 0x13f080
movaps %xmm0, %xmm1
movsd 0x124786(%rip), %xmm0   # 0x16f150
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
subsd %xmm1, %xmm0
leaq 0x321dd4(%rip), %rax    # 0x36c7b0
movsd %xmm0, (%rax)
leaq 0x321dc9(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321dc6(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4ae72
movsbl -0xd(%rbp), %eax
cmpl $0x2b, %eax
je 0x4aa28
movsbl -0xd(%rbp), %eax
cmpl $0x2d, %eax
je 0x4aa28
movsbl -0xd(%rbp), %eax
cmpl $0x2e, %eax
je 0x4aa28
movsbl -0xd(%rbp), %edi
callq 0x9330
cmpl $0x0, %eax
je 0x4ab63
leaq 0x321d79(%rip), %rax    # 0x36c7a8
leaq 0x12f99c(%rip), %rcx    # 0x17a3d2
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
leaq 0x14b529(%rip), %rsi    # 0x195f6d
leaq 0x321d65(%rip), %rdx    # 0x36c7b0
leaq -0xd(%rbp), %rcx
leaq 0x321d62(%rip), %r8     # 0x36c7b8
movb $0x0, %al
callq 0x9370
movl %eax, -0x24(%rbp)
leaq 0x321d51(%rip), %rax    # 0x36c7b8
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 0x321d3b(%rip), %rax    # 0x36c7b0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
cmpl $0x0, -0x24(%rbp)
jne 0x4aaaa
leaq 0x321d2f(%rip), %rax    # 0x36c7b8
movsd 0x126c5f(%rip), %xmm0   # 0x1716f0
movsd %xmm0, (%rax)
leaq 0x321d14(%rip), %rax    # 0x36c7b0
movsd 0x126c4c(%rip), %xmm0   # 0x1716f0
movsd %xmm0, (%rax)
jmp 0x4aac8
cmpl $0x3, -0x24(%rbp)
jge 0x4aac6
leaq 0x321cf9(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321cf6(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4aac8
leaq 0x321ce1(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
movsd 0x1245ad(%rip), %xmm1   # 0x16f088
ucomisd %xmm1, %xmm0
ja 0x4ab24
leaq 0x321cd0(%rip), %rax    # 0x36c7b8
movsd (%rax), %xmm0
movsd 0x124594(%rip), %xmm1   # 0x16f088
ucomisd %xmm1, %xmm0
ja 0x4ab24
movsd 0x12457e(%rip), %xmm0   # 0x16f080
leaq 0x321ca7(%rip), %rax    # 0x36c7b0
ucomisd (%rax), %xmm0
ja 0x4ab24
movsd 0x124569(%rip), %xmm0   # 0x16f080
leaq 0x321c9a(%rip), %rax    # 0x36c7b8
ucomisd (%rax), %xmm0
jbe 0x4ab5e
leaq 0x321c7d(%rip), %rax    # 0x36c7a8
movq $0x0, (%rax)
leaq 0x321c57(%rip), %rax    # 0x36c790
movl $0x0, (%rax)
leaq 0x321c52(%rip), %rax    # 0x36c798
movl $0x0, (%rax)
leaq 0x321c41(%rip), %rax    # 0x36c794
movl $0x0, (%rax)
jmp 0x4af00
jmp 0x4ae70
movsbl -0xd(%rbp), %eax
cmpl $0x58, %eax
jne 0x4ae34
leaq 0x321b79(%rip), %rax    # 0x36c6f0
movl $0x1, (%rax)
leaq 0x321b6c(%rip), %rax    # 0x36c6f0
cmpl $0xc, (%rax)
jg 0x4ad15
leaq 0x2529dc(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0x4acf9
leaq 0x321b4f(%rip), %rax    # 0x36c6f4
movl (%rax), %edi
leaq 0x321b42(%rip), %rax    # 0x36c6f0
movl (%rax), %esi
leaq 0x321b35(%rip), %rax    # 0x36c6ec
movl (%rax), %edx
callq 0x122140
movsd %xmm0, -0x38(%rbp)
leaq 0x321b1e(%rip), %rax    # 0x36c6e8
movl (%rax), %edi
leaq 0x321b11(%rip), %rax    # 0x36c6e4
movl (%rax), %esi
leaq 0x321b04(%rip), %rax    # 0x36c6e0
movl (%rax), %edx
xorps %xmm0, %xmm0
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x252966(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0x321c74(%rip), %rax    # 0x36c888
movl (%rax), %edx
leaq 0x321c6f(%rip), %rax    # 0x36c88c
movl (%rax), %ecx
leaq 0x321c6a(%rip), %rax    # 0x36c890
movl (%rax), %r8d
leaq 0x321c4c(%rip), %rax    # 0x36c87c
movl (%rax), %r9d
leaq 0x321c46(%rip), %rax    # 0x36c880
movl (%rax), %r10d
leaq 0x321c40(%rip), %rax    # 0x36c884
movl (%rax), %eax
movsd -0x18(%rbp), %xmm0
leaq 0x12f785(%rip), %rsi    # 0x17a3d7
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x1, %al
callq 0x9550
movsd -0x18(%rbp), %xmm0
callq 0x13a610
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %edx, %edx
xorps %xmm0, %xmm0
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
subsd %xmm1, %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x2528ce(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0x321bdc(%rip), %rax    # 0x36c888
movl (%rax), %edx
leaq 0x321bd7(%rip), %rax    # 0x36c88c
movl (%rax), %ecx
leaq 0x321bd2(%rip), %rax    # 0x36c890
movl (%rax), %r8d
leaq 0x321bb4(%rip), %rax    # 0x36c87c
movl (%rax), %r9d
leaq 0x321bae(%rip), %rax    # 0x36c880
movl (%rax), %r10d
leaq 0x321ba8(%rip), %rax    # 0x36c884
movl (%rax), %eax
movsd -0x18(%rbp), %xmm0
leaq 0x12f6f4(%rip), %rsi    # 0x17a3de
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x1, %al
callq 0x9550
jmp 0x4acfb
leaq 0x3219ee(%rip), %rax    # 0x36c6f0
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x3219e2(%rip), %rax    # 0x36c6f0
movl %ecx, (%rax)
jmp 0x4ab7d
leaq 0x3219d4(%rip), %rax    # 0x36c6f0
movl $0x1, (%rax)
leaq 0x3219c7(%rip), %rax    # 0x36c6f0
cmpl $0xc, (%rax)
jg 0x4ae25
leaq 0x3219b3(%rip), %rax    # 0x36c6ec
movl $0x1, (%rax)
leaq 0x3219a6(%rip), %rax    # 0x36c6ec
cmpl $0x1f, (%rax)
jge 0x4ae09
leaq 0x321a52(%rip), %rax    # 0x36c7a8
leaq 0x14ca57(%rip), %rcx    # 0x1977b4
movq %rcx, (%rax)
leaq 0x321af9(%rip), %rax    # 0x36c860
movl $0x1, (%rax)
leaq 0x321a3c(%rip), %rax    # 0x36c7b0
movsd 0x12696c(%rip), %xmm0   # 0x1716e8
movsd %xmm0, (%rax)
leaq 0x321a29(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x321a26(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
callq 0x13ddb0
leaq 0x321a06(%rip), %rax    # 0x36c7a8
leaq 0x125fc2(%rip), %rcx    # 0x170d6b
movq %rcx, (%rax)
leaq 0x321aad(%rip), %rax    # 0x36c860
movl $0x0, (%rax)
leaq 0x3219f0(%rip), %rax    # 0x36c7b0
movsd 0x1243d8(%rip), %xmm0   # 0x16f1a0
movsd %xmm0, (%rax)
leaq 0x3219dd(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x3219da(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
movl $0xa, %edi
callq 0x13e3b0
leaq 0x3218f6(%rip), %rax    # 0x36c6ec
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x3218ea(%rip), %rax    # 0x36c6ec
movl %ecx, (%rax)
jmp 0x4ad3f
jmp 0x4ae0b
leaq 0x3218de(%rip), %rax    # 0x36c6f0
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x3218d2(%rip), %rax    # 0x36c6f0
movl %ecx, (%rax)
jmp 0x4ad22
leaq 0x321964(%rip), %rax    # 0x36c790
movl $0x0, (%rax)
jmp 0x4ae6e
leaq 0x32196d(%rip), %rax    # 0x36c7a8
leaq 0x125f29(%rip), %rcx    # 0x170d6b
movq %rcx, (%rax)
leaq 0x321964(%rip), %rax    # 0x36c7b0
movsd 0x12434c(%rip), %xmm0   # 0x16f1a0
movsd %xmm0, (%rax)
leaq 0x321951(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
leaq 0x32194e(%rip), %rax    # 0x36c7b8
movsd %xmm0, (%rax)
jmp 0x4ae70
jmp 0x4ae72
jmp 0x4ae74
jmp 0x4ae76
jmp 0x4ae78
jmp 0x4ae7a
jmp 0x4ae7c
movq -0x8(%rbp), %rdi
movl $0x2a, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x4ae9d
leaq 0x321901(%rip), %rax    # 0x36c798
movl $0x1, (%rax)
movq -0x8(%rbp), %rdi
movl $0x21, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x4aebe
leaq 0x3218dc(%rip), %rax    # 0x36c794
movl $0x1, (%rax)
movq -0x8(%rbp), %rdi
movl $0x72, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x4aedf
leaq 0x3218e7(%rip), %rax    # 0x36c7c0
movl $0x1, (%rax)
movq -0x8(%rbp), %rdi
movl $0x52, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x4af00
leaq 0x3218c6(%rip), %rax    # 0x36c7c0
movl $0x1, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)