// File: /workspace/github_cpp_makefile_star2_O1/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 0x2d8957(%rip), %r9     # 0x30d5b0
xorl %edx, %edx
movl %edx, (%r9)
leaq 0x2d894f(%rip), %rax    # 0x30d5b4
movl %edx, (%rax)
leaq 0x2d894a(%rip), %rcx    # 0x30d5b8
movl %edx, (%rcx)
leaq 0x2d8a09(%rip), %r14    # 0x30d680
movl %edx, (%r14)
testq %rdi, %rdi
je 0x3525b
movq %rdi, %r13
movb $0x4f, -0x29(%rbp)
movb (%rdi), %dil
testb %dil, %dil
je 0x34cce
movl %edi, %edx
movzbl %dil, %edi
cmpl $0x20, %edi
jg 0x34ca9
cmpl $0x9, %edi
je 0x34cc0
cmpl $0x20, %edi
je 0x34cc0
jmp 0x34cd0
movq %rax, %r8
cmpl $0x21, %edi
je 0x34cb9
cmpl $0x2a, %edi
jne 0x34cd0
movq %rcx, %r8
movl $0x1, (%r8)
movb 0x1(%r13), %dil
incq %r13
testb %dil, %dil
jne 0x34c92
jmp 0x34cd0
movb $0x4f, %dl
movb %dl, -0x29(%rbp)
movl $0x1, %eax
movl %eax, (%r9)
leaq 0x2d88fe(%rip), %rbx    # 0x30d5e0
movl $0x0, (%rbx)
leaq 0x20a2b9(%rip), %rcx    # 0x23efa8
movl %eax, (%rcx)
testl %esi, %esi
je 0x34d07
leaq 0x2d7a84(%rip), %rax    # 0x30c780
movl (%rax), %eax
leaq 0x20a29f(%rip), %rcx    # 0x23efa4
movl %eax, (%rcx)
movsbl -0x29(%rbp), %edi
callq 0x9700
movb %al, -0x29(%rbp)
shll $0x18, %eax
cmpl $0x42ffffff, %eax       # imm = 0x42FFFFFF
jle 0x34d7f
cmpl $0x4dffffff, %eax       # imm = 0x4DFFFFFF
jle 0x34dde
cmpl $0x4e000000, %eax       # imm = 0x4E000000
je 0x34e4f
cmpl $0x4f000000, %eax       # imm = 0x4F000000
je 0x351be
cmpl $0x50000000, %eax       # imm = 0x50000000
jne 0x34e9d
leaq 0xe0c38(%rip), %rax     # 0x115988
leaq 0x2d8871(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d87cf(%rip), %rax    # 0x30d530
movsd (%rax), %xmm0
callq 0xe9113
mulsd 0xd6c0e(%rip), %xmm0    # 0x10b980
xorpd %xmm1, %xmm1
addsd %xmm0, %xmm1
jmp 0x34e34
cmpl $0x2dffffff, %eax       # imm = 0x2DFFFFFF
jg 0x34da1
cmpl $0x2b000000, %eax       # imm = 0x2B000000
je 0x34eae
cmpl $0x2d000000, %eax       # imm = 0x2D000000
je 0x34eae
jmp 0x34e9d
cmpl $0x2e000000, %eax       # imm = 0x2E000000
je 0x34eae
cmpl $0x41000000, %eax       # imm = 0x41000000
jne 0x34e9d
leaq 0xe0bae(%rip), %rax     # 0x11596c
leaq 0x2d8803(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d8801(%rip), %rax    # 0x30d5d0
movabsq $-0x3fce000000000000, %rcx # imm = 0xC032000000000000
jmp 0x351e0
cmpl $0x43000000, %eax       # imm = 0x43000000
je 0x34e76
cmpl $0x4d000000, %eax       # imm = 0x4D000000
jne 0x34e9d
leaq 0xffd37(%rip), %rax     # 0x134b32
leaq 0x2d87c6(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
movl $0x1, (%r14)
leaq 0x2d871d(%rip), %rax    # 0x30d530
movsd (%rax), %xmm0
callq 0xe9178
mulsd 0xd4244(%rip), %xmm0    # 0x109068
addsd 0xd6b5c(%rip), %xmm0    # 0x10b988
xorpd %xmm1, %xmm1
subsd %xmm0, %xmm1
leaq 0x2d8795(%rip), %rax    # 0x30d5d0
movsd %xmm1, (%rax)
leaq 0x2d8792(%rip), %rax    # 0x30d5d8
movsd %xmm1, (%rax)
jmp 0x351ed
leaq 0xe0b29(%rip), %rax     # 0x11597f
leaq 0x2d876b(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d8769(%rip), %rax    # 0x30d5d0
movabsq $-0x3fd8000000000000, %rcx # imm = 0xC028000000000000
jmp 0x351e0
leaq 0xe0afc(%rip), %rax     # 0x115979
leaq 0x2d8744(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d8742(%rip), %rax    # 0x30d5d0
movabsq $-0x3fe8000000000000, %rcx # imm = 0xC018000000000000
jmp 0x351e0
movl %eax, %ecx
sarl $0x18, %ecx
addl $-0x30, %ecx
cmpl $0x9, %ecx
ja 0x34f7a
leaq 0xe0adc(%rip), %rax     # 0x115991
leaq 0x2d870c(%rip), %r12    # 0x30d5c8
movq %rax, (%r12)
leaq 0xfe44e(%rip), %rsi     # 0x133315
leaq 0x2d8702(%rip), %r15    # 0x30d5d0
leaq 0x2d8703(%rip), %r14    # 0x30d5d8
xorl %ebx, %ebx
leaq -0x29(%rbp), %rcx
movq %r13, %rdi
movq %r15, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x9360
movq %rbx, (%r14)
movq %rbx, (%r15)
testl %eax, %eax
je 0x34f03
cmpl $0x2, %eax
jg 0x34f13
movq $0x0, (%r14)
jmp 0x34f13
movabsq $0x408f380000000000, %rax # imm = 0x408F380000000000
movq %rax, (%r14)
movq %rax, (%r15)
movsd (%r15), %xmm1
movsd 0xd6a70(%rip), %xmm0    # 0x10b990
ucomisd %xmm1, %xmm0
leaq 0x2d86b5(%rip), %rbx    # 0x30d5e0
ja 0x34f50
ucomisd 0xd69db(%rip), %xmm1    # 0x10b910
ja 0x34f50
movsd (%r14), %xmm1
ucomisd 0xd69cc(%rip), %xmm1    # 0x10b910
ja 0x34f50
ucomisd %xmm1, %xmm0
jbe 0x351ed
movq $0x0, (%r12)
xorl %eax, %eax
leaq 0x2d864f(%rip), %rcx    # 0x30d5b0
movl %eax, (%rcx)
leaq 0x2d864e(%rip), %rcx    # 0x30d5b8
movl %eax, (%rcx)
leaq 0x2d8641(%rip), %rcx    # 0x30d5b4
movl %eax, (%rcx)
jmp 0x3525b
cmpl $0x58000000, %eax       # imm = 0x58000000
jne 0x351be
movq %r13, -0x40(%rbp)
leaq 0x2d8580(%rip), %rbx    # 0x30d510
movl $0x1, (%rbx)
movl $0x1, %esi
leaq 0x2093ee(%rip), %r14    # 0x23e390
leaq 0x2d8563(%rip), %r8     # 0x30d50c
cmpq $0x0, (%r14)
je 0x350e1
leaq 0x2d855a(%rip), %rax    # 0x30d514
movl (%rax), %edi
movl (%r8), %edx
callq 0xd4110
movsd %xmm0, -0x38(%rbp)
leaq 0x2d8538(%rip), %rax    # 0x30d508
movl (%rax), %edi
leaq 0x2d852b(%rip), %rax    # 0x30d504
movl (%rax), %esi
leaq 0x2d851e(%rip), %rax    # 0x30d500
movl (%rax), %edx
xorpd %xmm0, %xmm0
callq 0xd41e0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %edi, %edi
callq 0xd0c46
movq (%r14), %rdi
leaq 0x2d86a0(%rip), %r14    # 0x30d6a8
movl (%r14), %edx
leaq 0x2d869a(%rip), %r12    # 0x30d6ac
movl (%r12), %ecx
leaq 0x2d8693(%rip), %r15    # 0x30d6b0
movl (%r15), %r8d
leaq 0x2d8675(%rip), %r13    # 0x30d69c
movl (%r13), %r9d
leaq 0x2d866e(%rip), %r15    # 0x30d6a0
movl (%r15), %r10d
leaq 0x2d8668(%rip), %r12    # 0x30d6a4
movl (%r12), %r11d
leaq 0xe094f(%rip), %rsi     # 0x115996
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
pushq %r11
pushq %r10
callq 0x9560
addq $0x10, %rsp
movsd -0x38(%rbp), %xmm0
callq 0xe5ccc
movsd %xmm0, -0x48(%rbp)
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd41e0
movsd -0x48(%rbp), %xmm1
subsd %xmm0, %xmm1
xorl %edi, %edi
movapd %xmm1, %xmm0
callq 0xd0c46
leaq 0x2092fc(%rip), %rax    # 0x23e390
movq (%rax), %rdi
movl (%r14), %edx
leaq 0x2092ef(%rip), %r14    # 0x23e390
leaq 0x2d8604(%rip), %rax    # 0x30d6ac
movl (%rax), %ecx
leaq 0x2d85ff(%rip), %rax    # 0x30d6b0
movl (%rax), %r8d
movl (%r13), %r9d
movl (%r15), %r10d
movl (%r12), %r11d
leaq 0xe08d7(%rip), %rsi     # 0x11599d
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
pushq %r11
pushq %r10
callq 0x9560
leaq 0x2d842f(%rip), %r8     # 0x30d50c
addq $0x10, %rsp
movl (%rbx), %eax
leal 0x1(%rax), %esi
movl %esi, (%rbx)
cmpl $0xc, %eax
jl 0x34fa9
movl $0x1, (%rbx)
leaq 0xffa34(%rip), %r14     # 0x134b32
leaq 0x2d84c3(%rip), %r12    # 0x30d5c8
leaq 0x2d84c4(%rip), %r13    # 0x30d5d0
movabsq $-0x4014a987658f7bdf, %rbx # imm = 0xBFEB56789A708421
leaq 0x2d84bb(%rip), %r15    # 0x30d5d8
movl $0x1, (%r8)
movq %r14, (%r12)
leaq 0x2d8551(%rip), %rax    # 0x30d680
movl $0x1, (%rax)
movq %rbx, (%r13)
movq %rbx, (%r15)
callq 0xe82a0
leaq 0xd5c26(%rip), %rax     # 0x10ad6e
movq %rax, (%r12)
leaq 0x2d852d(%rip), %rax    # 0x30d680
movl $0x0, (%rax)
movabsq $-0x4015555555555555, %rax # imm = 0xBFEAAAAAAAAAAAAB
movq %rax, (%r13)
movq %rax, (%r15)
xorpd %xmm0, %xmm0
movl $0xa, %edi
callq 0xe8764
leaq 0x2d838d(%rip), %r8     # 0x30d50c
movl (%r8), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r8)
cmpl $0x1e, %eax
jl 0x35124
leaq 0x2d837c(%rip), %rdx    # 0x30d510
movl (%rdx), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%rdx)
cmpl $0xc, %eax
jl 0x3511d
leaq 0x2d8405(%rip), %rax    # 0x30d5b0
movl $0x0, (%rax)
movq -0x40(%rbp), %r13
leaq 0x2d8424(%rip), %rbx    # 0x30d5e0
jmp 0x351ed
leaq 0xd5ba9(%rip), %rax     # 0x10ad6e
leaq 0x2d83fc(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d83fa(%rip), %rax    # 0x30d5d0
movabsq $-0x4015555555555555, %rcx # imm = 0xBFEAAAAAAAAAAAAB
movq %rcx, (%rax)
leaq 0x2d83ee(%rip), %rax    # 0x30d5d8
movq %rcx, (%rax)
movq %r13, %rdi
movl $0x2a, %esi
callq 0x9100
testq %rax, %rax
je 0x3520c
leaq 0x2d83b2(%rip), %rax    # 0x30d5b8
movl $0x1, (%rax)
movq %r13, %rdi
movl $0x21, %esi
callq 0x9100
testq %rax, %rax
je 0x3522b
leaq 0x2d838f(%rip), %rax    # 0x30d5b4
movl $0x1, (%rax)
movq %r13, %rdi
movl $0x72, %esi
callq 0x9100
testq %rax, %rax
je 0x35243
movl $0x1, (%rbx)
movq %r13, %rdi
movl $0x52, %esi
callq 0x9100
testq %rax, %rax
je 0x3525b
movl $0x1, (%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq