// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x2c5635(%rip), %r9     # 0x2f75b0
andl $0x0, (%r9)
leaq 0x2c562e(%rip), %rcx    # 0x2f75b4
andl $0x0, (%rcx)
leaq 0x2c5628(%rip), %rdx    # 0x2f75b8
andl $0x0, (%rdx)
leaq 0x2c56e6(%rip), %rax    # 0x2f7680
andl $0x0, (%rax)
testq %rdi, %rdi
je 0x32428
movq %rdi, %rbx
movb $0x4f, %al
movzbl (%rbx), %edi
cmpl $0x9, %edi
je 0x31fcf
cmpl $0x20, %edi
je 0x31fcf
movq %rcx, %r8
cmpl $0x21, %edi
je 0x31fc8
cmpl $0x2a, %edi
jne 0x31fd6
movq %rdx, %r8
movl $0x1, (%r8)
incq %rbx
movl %edi, %eax
jmp 0x31fab
testl %edi, %edi
je 0x31fdc
movl %edi, %eax
pushq $0x1
popq %r12
leaq 0x2c55f9(%rip), %r13    # 0x2f75e0
andl $0x0, (%r13)
movl %r12d, (%r9)
leaq 0x1f6fb2(%rip), %rcx    # 0x228fa8
movl %r12d, (%rcx)
testl %esi, %esi
je 0x3200f
leaq 0x2c477c(%rip), %rcx    # 0x2f6780
movl (%rcx), %ecx
leaq 0x1f6f97(%rip), %rdx    # 0x228fa4
movl %ecx, (%rdx)
movsbl %al, %edi
callq 0x9700
movb %al, -0x29(%rbp)
shll $0x18, %eax
cmpl $0x2b000000, %eax       # imm = 0x2B000000
je 0x32199
cmpl $0x2d000000, %eax       # imm = 0x2D000000
je 0x32199
cmpl $0x2e000000, %eax       # imm = 0x2E000000
je 0x32199
cmpl $0x50000000, %eax       # imm = 0x50000000
je 0x320a3
cmpl $0x43000000, %eax       # imm = 0x43000000
je 0x320d9
cmpl $0x4d000000, %eax       # imm = 0x4D000000
je 0x32127
cmpl $0x4e000000, %eax       # imm = 0x4E000000
je 0x32100
cmpl $0x4f000000, %eax       # imm = 0x4F000000
je 0x3238f
cmpl $0x41000000, %eax       # imm = 0x41000000
jne 0x32188
leaq 0xcd9fd(%rip), %rax     # 0xffa80
leaq 0x2c553e(%rip), %rcx    # 0x2f75c8
movq %rax, (%rcx)
leaq 0x2c553c(%rip), %rax    # 0x2f75d0
movabsq $-0x3fce000000000000, %rcx # imm = 0xC032000000000000
jmp 0x323b1
leaq 0xcd9f2(%rip), %rax     # 0xffa9c
leaq 0x2c5517(%rip), %rcx    # 0x2f75c8
movq %rax, (%rcx)
leaq 0x2c5475(%rip), %rax    # 0x2f7530
movsd (%rax), %xmm0
callq 0xd55a7
mulsd 0xc3934(%rip), %xmm0    # 0xf5a00
xorpd %xmm1, %xmm1
addsd %xmm0, %xmm1
jmp 0x3216d
leaq 0xcd9ad(%rip), %rax     # 0xffa8d
leaq 0x2c54e1(%rip), %rcx    # 0x2f75c8
movq %rax, (%rcx)
leaq 0x2c54df(%rip), %rax    # 0x2f75d0
movabsq $-0x3fe8000000000000, %rcx # imm = 0xC018000000000000
jmp 0x323b1
leaq 0xcd98c(%rip), %rax     # 0xffa93
leaq 0x2c54ba(%rip), %rcx    # 0x2f75c8
movq %rax, (%rcx)
leaq 0x2c54b8(%rip), %rax    # 0x2f75d0
movabsq $-0x3fd8000000000000, %rcx # imm = 0xC028000000000000
jmp 0x323b1
leaq 0xeca14(%rip), %rax     # 0x11eb42
leaq 0x2c5493(%rip), %rcx    # 0x2f75c8
movq %rax, (%rcx)
leaq 0x2c5541(%rip), %rax    # 0x2f7680
movl $0x1, (%rax)
leaq 0x2c53e4(%rip), %rax    # 0x2f7530
movsd (%rax), %xmm0
callq 0xd560c
mulsd 0xc0f0b(%rip), %xmm0    # 0xf3068
addsd 0xc38a3(%rip), %xmm0    # 0xf5a08
xorpd %xmm1, %xmm1
subsd %xmm0, %xmm1
leaq 0x2c545c(%rip), %rax    # 0x2f75d0
movsd %xmm1, (%rax)
leaq 0x2c5459(%rip), %rax    # 0x2f75d8
movsd %xmm1, (%rax)
jmp 0x323be
movl %eax, %ecx
sarl $0x18, %ecx
addl $-0x30, %ecx
cmpl $0x9, %ecx
ja 0x3221c
leaq 0xcd905(%rip), %rax     # 0xffaa5
leaq 0x2c5421(%rip), %r12    # 0x2f75c8
movq %rax, (%r12)
leaq 0xeb173(%rip), %rsi     # 0x11d325
leaq 0x2c5417(%rip), %r14    # 0x2f75d0
leaq 0x2c5418(%rip), %r15    # 0x2f75d8
leaq -0x29(%rbp), %rcx
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x9350
andq $0x0, (%r15)
andq $0x0, (%r14)
testl %eax, %eax
jne 0x323be
movabsq $0x408f380000000000, %rax # imm = 0x408F380000000000
movq %rax, (%r15)
andq $0x0, (%r12)
movq %rax, (%r14)
leaq 0x2c53b0(%rip), %rax    # 0x2f75b0
andl $0x0, (%rax)
leaq 0x2c53ae(%rip), %rax    # 0x2f75b8
andl $0x0, (%rax)
leaq 0x2c53a0(%rip), %rax    # 0x2f75b4
andl $0x0, (%rax)
jmp 0x32428
cmpl $0x58000000, %eax       # imm = 0x58000000
jne 0x3238f
leaq 0x2c52e2(%rip), %rcx    # 0x2f7510
leaq 0x1f615b(%rip), %r14    # 0x228390
leaq 0x2c52d0(%rip), %r13    # 0x2f750c
movl %r12d, (%rcx)
cmpl $0xd, %r12d
jge 0x32437
cmpq $0x0, (%r14)
je 0x32387
leaq 0x2c52ba(%rip), %rax    # 0x2f7514
movl (%rax), %edi
movl (%r13), %edx
movl %r12d, %esi
callq 0xc2f07
movsd %xmm0, -0x38(%rbp)
leaq 0x2c5294(%rip), %rax    # 0x2f7508
movl (%rax), %edi
leaq 0x2c5287(%rip), %rax    # 0x2f7504
movl (%rax), %esi
leaq 0x2c527a(%rip), %rax    # 0x2f7500
movl (%rax), %edx
xorpd %xmm0, %xmm0
callq 0xc2faf
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %edi, %edi
callq 0xbfac2
movq (%r14), %rdi
leaq 0x2c53fc(%rip), %r12    # 0x2f76a8
movl (%r12), %edx
leaq 0x2c53f5(%rip), %r15    # 0x2f76ac
movl (%r15), %ecx
leaq 0x2c53ef(%rip), %r12    # 0x2f76b0
movl (%r12), %r8d
leaq 0x2c53d0(%rip), %r12    # 0x2f769c
movl (%r12), %r9d
leaq 0x2c53c9(%rip), %r12    # 0x2f76a0
movl (%r12), %r10d
leaq 0x2c53c2(%rip), %r12    # 0x2f76a4
movl (%r12), %r11d
leaq 0xcd7bd(%rip), %rsi     # 0xffaaa
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
pushq %r11
pushq %r10
callq 0x9560
popq %rcx
popq %rdx
movsd -0x38(%rbp), %xmm0
callq 0xd289a
movsd %xmm0, -0x48(%rbp)
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc2faf
movsd -0x48(%rbp), %xmm1
subsd %xmm0, %xmm1
xorl %edi, %edi
movapd %xmm1, %xmm0
callq 0xbfac2
movq (%r14), %rdi
leaq 0x2c536d(%rip), %rax    # 0x2f76a8
movl (%rax), %edx
movl (%r15), %ecx
leaq 0x2c5369(%rip), %rax    # 0x2f76b0
movl (%rax), %r8d
leaq 0x2c534b(%rip), %rax    # 0x2f769c
movl (%rax), %r9d
leaq 0x2c5345(%rip), %rax    # 0x2f76a0
movl (%rax), %r10d
movl (%r12), %r11d
leaq 0xcd748(%rip), %rsi     # 0xffab1
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
pushq %r11
pushq %r10
callq 0x9560
leaq 0x2c5190(%rip), %rcx    # 0x2f7510
addq $0x10, %rsp
movl (%rcx), %r12d
incl %r12d
jmp 0x3223c
leaq 0xc2a63(%rip), %rax     # 0xf4df9
leaq 0x2c522b(%rip), %rcx    # 0x2f75c8
movq %rax, (%rcx)
leaq 0x2c5229(%rip), %rax    # 0x2f75d0
movabsq $-0x4015555555555555, %rcx # imm = 0xBFEAAAAAAAAAAAAB
movq %rcx, (%rax)
leaq 0x2c521d(%rip), %rax    # 0x2f75d8
movq %rcx, (%rax)
pushq $0x2a
popq %rsi
movq %rbx, %rdi
callq 0x9100
testq %rax, %rax
je 0x323db
leaq 0x2c51e3(%rip), %rax    # 0x2f75b8
movl $0x1, (%rax)
pushq $0x21
popq %rsi
movq %rbx, %rdi
callq 0x9100
testq %rax, %rax
je 0x323f8
leaq 0x2c51c2(%rip), %rax    # 0x2f75b4
movl $0x1, (%rax)
pushq $0x72
popq %rsi
movq %rbx, %rdi
callq 0x9100
testq %rax, %rax
je 0x32410
movl $0x1, (%r13)
pushq $0x52
popq %rsi
movq %rbx, %rdi
callq 0x9100
testq %rax, %rax
je 0x32428
movl $0x1, (%r13)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rax
movq %rbx, -0x40(%rbp)
movl %eax, (%rcx)
cmpl $0xc, %eax
jg 0x324de
pushq $0x1
popq %rax
movl %eax, (%r13)
cmpl $0x1e, %eax
jg 0x324ca
leaq 0xec6e6(%rip), %rax     # 0x11eb42
leaq 0x2c5165(%rip), %r14    # 0x2f75c8
movq %rax, (%r14)
leaq 0x2c5213(%rip), %r12    # 0x2f7680
movl $0x1, (%r12)
leaq 0x2c5154(%rip), %r15    # 0x2f75d0
movabsq $-0x4014a987658f7bdf, %rax # imm = 0xBFEB56789A708421
movq %rax, (%r15)
leaq 0x2c5148(%rip), %rbx    # 0x2f75d8
movq %rax, (%rbx)
callq 0xd485d
andl $0x0, (%r12)
leaq 0xc2955(%rip), %rax     # 0xf4df9
movq %rax, (%r14)
movabsq $-0x4015555555555555, %rax # imm = 0xBFEAAAAAAAAAAAAB
movq %rax, (%r15)
movq %rax, (%rbx)
xorps %xmm0, %xmm0
pushq $0xa
popq %rdi
callq 0xd4cfa
movl (%r13), %eax
incl %eax
jmp 0x3244c
leaq 0x2c503f(%rip), %rcx    # 0x2f7510
movl (%rcx), %eax
incl %eax
movq -0x40(%rbp), %rbx
jmp 0x3243e
leaq 0x2c50cb(%rip), %rax    # 0x2f75b0
andl $0x0, (%rax)
leaq 0x2c50f1(%rip), %r13    # 0x2f75e0
jmp 0x323be