// File: /workspace/github_cpp_makefile_star2_O3/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 0x2d883a(%rip), %r9     # 0x30d5b0
xorl %edx, %edx
movl %edx, (%r9)
leaq 0x2d8832(%rip), %rax    # 0x30d5b4
movl %edx, (%rax)
leaq 0x2d882d(%rip), %rcx    # 0x30d5b8
movl %edx, (%rcx)
leaq 0x2d88ec(%rip), %rbx    # 0x30d680
movl %edx, (%rbx)
testq %rdi, %rdi
je 0x3533c
movq %rdi, %r13
movb (%rdi), %dil
testb %dil, %dil
je 0x34de9
movl %edi, %edx
movzbl %dil, %edi
cmpl $0x20, %edi
jg 0x34dc1
cmpl $0x9, %edi
je 0x34dd8
cmpl $0x20, %edi
je 0x34dd8
jmp 0x34de4
movq %rax, %r8
cmpl $0x21, %edi
je 0x34dd1
cmpl $0x2a, %edi
jne 0x34de4
movq %rcx, %r8
movl $0x1, (%r8)
movb 0x1(%r13), %dil
incq %r13
testb %dil, %dil
jne 0x34daa
movsbl %dl, %edi
jmp 0x34dee
movl $0x4f, %edi
movl $0x1, %eax
movl %eax, (%r9)
leaq 0x2d87e3(%rip), %rcx    # 0x30d5e0
movl $0x0, (%rcx)
leaq 0x20a19e(%rip), %rcx    # 0x23efa8
movl %eax, (%rcx)
testl %esi, %esi
je 0x34e22
leaq 0x2d7969(%rip), %rax    # 0x30c780
movl (%rax), %eax
leaq 0x20a184(%rip), %rcx    # 0x23efa4
movl %eax, (%rcx)
callq 0x9700
movb %al, -0x29(%rbp)
shll $0x18, %eax
cmpl $0x42ffffff, %eax       # imm = 0x42FFFFFF
jle 0x34e96
cmpl $0x4dffffff, %eax       # imm = 0x4DFFFFFF
jle 0x34ef5
cmpl $0x4e000000, %eax       # imm = 0x4E000000
je 0x34f65
cmpl $0x4f000000, %eax       # imm = 0x4F000000
je 0x35298
cmpl $0x50000000, %eax       # imm = 0x50000000
jne 0x34fb3
leaq 0xe0bb5(%rip), %rax     # 0x115a1c
leaq 0x2d875a(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d86b8(%rip), %rax    # 0x30d530
movsd (%rax), %xmm0
callq 0xe9b89
mulsd 0xd6aff(%rip), %xmm0    # 0x10b988
xorpd %xmm1, %xmm1
addsd %xmm0, %xmm1
jmp 0x34f4a
cmpl $0x2dffffff, %eax       # imm = 0x2DFFFFFF
jg 0x34eb8
cmpl $0x2b000000, %eax       # imm = 0x2B000000
je 0x34fc4
cmpl $0x2d000000, %eax       # imm = 0x2D000000
je 0x34fc4
jmp 0x34fb3
cmpl $0x2e000000, %eax       # imm = 0x2E000000
je 0x34fc4
cmpl $0x41000000, %eax       # imm = 0x41000000
jne 0x34fb3
leaq 0xe0b2b(%rip), %rax     # 0x115a00
leaq 0x2d86ec(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d86ea(%rip), %rax    # 0x30d5d0
movabsq $-0x3fce000000000000, %rcx # imm = 0xC032000000000000
jmp 0x352ba
cmpl $0x43000000, %eax       # imm = 0x43000000
je 0x34f8c
cmpl $0x4d000000, %eax       # imm = 0x4D000000
jne 0x34fb3
leaq 0xffd10(%rip), %rax     # 0x134c22
leaq 0x2d86af(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
movl $0x1, (%rbx)
leaq 0x2d8607(%rip), %rax    # 0x30d530
movsd (%rax), %xmm0
callq 0xe9bee
mulsd 0xd412e(%rip), %xmm0    # 0x109068
addsd 0xd6a4e(%rip), %xmm0    # 0x10b990
xorpd %xmm1, %xmm1
subsd %xmm0, %xmm1
leaq 0x2d867f(%rip), %rax    # 0x30d5d0
movsd %xmm1, (%rax)
leaq 0x2d867c(%rip), %rax    # 0x30d5d8
movsd %xmm1, (%rax)
jmp 0x352c7
leaq 0xe0aa7(%rip), %rax     # 0x115a13
leaq 0x2d8655(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d8653(%rip), %rax    # 0x30d5d0
movabsq $-0x3fd8000000000000, %rcx # imm = 0xC028000000000000
jmp 0x352ba
leaq 0xe0a7a(%rip), %rax     # 0x115a0d
leaq 0x2d862e(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d862c(%rip), %rax    # 0x30d5d0
movabsq $-0x3fe8000000000000, %rcx # imm = 0xC018000000000000
jmp 0x352ba
movl %eax, %ecx
sarl $0x18, %ecx
addl $-0x30, %ecx
cmpl $0x9, %ecx
ja 0x35049
leaq 0xe0a5a(%rip), %rax     # 0x115a25
leaq 0x2d85f6(%rip), %rbx    # 0x30d5c8
movq %rax, (%rbx)
leaq 0xfe429(%rip), %rsi     # 0x133405
leaq 0x2d85ed(%rip), %r14    # 0x30d5d0
leaq 0x2d85ee(%rip), %r15    # 0x30d5d8
xorl %r12d, %r12d
leaq -0x29(%rbp), %rcx
movq %r13, %rdi
movq %r14, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x9360
movq %r12, (%r15)
movq %r12, (%r14)
testl %eax, %eax
jne 0x352c7
movabsq $0x408f380000000000, %rax # imm = 0x408F380000000000
movq %rax, (%r15)
movq %rax, (%r14)
movq $0x0, (%rbx)
leaq 0x2d8583(%rip), %rax    # 0x30d5b0
movl %r12d, (%rax)
leaq 0x2d8581(%rip), %rax    # 0x30d5b8
movl %r12d, (%rax)
leaq 0x2d8573(%rip), %rax    # 0x30d5b4
movl %r12d, (%rax)
jmp 0x3533c
cmpl $0x58000000, %eax       # imm = 0x58000000
jne 0x35298
movq %r13, -0x40(%rbp)
leaq 0x2d84b1(%rip), %rbx    # 0x30d510
movl $0x1, (%rbx)
leaq 0x209324(%rip), %rax    # 0x23e390
movq (%rax), %rax
movl $0x1, %esi
leaq 0x2d8491(%rip), %r8     # 0x30d50c
testq %rax, %rax
je 0x351c0
leaq 0x2d8489(%rip), %rax    # 0x30d514
movl (%rax), %edi
movl (%r8), %edx
callq 0xd485e
movsd %xmm0, -0x38(%rbp)
leaq 0x2d8467(%rip), %rax    # 0x30d508
movl (%rax), %edi
leaq 0x2d845a(%rip), %rax    # 0x30d504
movl (%rax), %esi
leaq 0x2d844d(%rip), %rax    # 0x30d500
movl (%rax), %edx
xorpd %xmm0, %xmm0
callq 0xd492e
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %edi, %edi
callq 0xd12da
leaq 0x2092ba(%rip), %rax    # 0x23e390
movq (%rax), %rdi
leaq 0x2d85c8(%rip), %r15    # 0x30d6a8
movl (%r15), %edx
leaq 0x2d85c2(%rip), %r13    # 0x30d6ac
movl (%r13), %ecx
leaq 0x2d85bb(%rip), %r12    # 0x30d6b0
movl (%r12), %r8d
leaq 0x2d859c(%rip), %r14    # 0x30d69c
movl (%r14), %r9d
leaq 0x2d8596(%rip), %rax    # 0x30d6a0
movl (%rax), %r10d
leaq 0x2d8590(%rip), %rax    # 0x30d6a4
movl (%rax), %r11d
leaq 0xe090c(%rip), %rsi     # 0x115a2a
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
pushq %r11
pushq %r10
callq 0x9560
addq $0x10, %rsp
movsd -0x38(%rbp), %xmm0
callq 0xe681a
movsd %xmm0, -0x48(%rbp)
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd492e
movsd -0x48(%rbp), %xmm1
subsd %xmm0, %xmm1
xorl %edi, %edi
movapd %xmm1, %xmm0
callq 0xd12da
leaq 0x209225(%rip), %r14    # 0x23e390
movq (%r14), %rdi
movl (%r15), %edx
movl (%r13), %ecx
movl (%r12), %r8d
leaq 0x2d851c(%rip), %rax    # 0x30d69c
movl (%rax), %r9d
leaq 0x2d8516(%rip), %rax    # 0x30d6a0
movl (%rax), %r10d
leaq 0x2d8510(%rip), %rax    # 0x30d6a4
movl (%rax), %r11d
leaq 0xe0893(%rip), %rsi     # 0x115a31
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
pushq %r11
pushq %r10
callq 0x9560
leaq 0x2d8357(%rip), %r8     # 0x30d50c
addq $0x10, %rsp
movq (%r14), %rax
movl (%rbx), %esi
jmp 0x351c2
xorl %eax, %eax
leal 0x1(%rsi), %ecx
movl %ecx, (%rbx)
cmpl $0xc, %esi
movl %ecx, %esi
jl 0x3507b
movl $0x1, (%rbx)
leaq 0xffa43(%rip), %r14     # 0x134c22
leaq 0x2d83e2(%rip), %r12    # 0x30d5c8
leaq 0x2d83e3(%rip), %r13    # 0x30d5d0
movabsq $-0x4014a987658f7bdf, %rbx # imm = 0xBFEB56789A708421
leaq 0x2d83da(%rip), %r15    # 0x30d5d8
movl $0x1, (%r8)
movq %r14, (%r12)
leaq 0x2d8470(%rip), %rax    # 0x30d680
movl $0x1, (%rax)
movq %rbx, (%r13)
movq %rbx, (%r15)
callq 0xe8d21
leaq 0xd5b55(%rip), %rax     # 0x10ad7e
movq %rax, (%r12)
leaq 0x2d844c(%rip), %rax    # 0x30d680
movl $0x0, (%rax)
movabsq $-0x4015555555555555, %rax # imm = 0xBFEAAAAAAAAAAAAB
movq %rax, (%r13)
movq %rax, (%r15)
xorpd %xmm0, %xmm0
movl $0xa, %edi
callq 0xe91e5
leaq 0x2d82ac(%rip), %r8     # 0x30d50c
movl (%r8), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r8)
cmpl $0x1e, %eax
jl 0x35205
leaq 0x2d829b(%rip), %rdx    # 0x30d510
movl (%rdx), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%rdx)
cmpl $0xc, %eax
jl 0x351fe
leaq 0x2d8324(%rip), %rax    # 0x30d5b0
movl $0x0, (%rax)
movq -0x40(%rbp), %r13
jmp 0x352c7
leaq 0xd5adf(%rip), %rax     # 0x10ad7e
leaq 0x2d8322(%rip), %rcx    # 0x30d5c8
movq %rax, (%rcx)
leaq 0x2d8320(%rip), %rax    # 0x30d5d0
movabsq $-0x4015555555555555, %rcx # imm = 0xBFEAAAAAAAAAAAAB
movq %rcx, (%rax)
leaq 0x2d8314(%rip), %rax    # 0x30d5d8
movq %rcx, (%rax)
movq %r13, %rdi
movl $0x2a, %esi
callq 0x9100
testq %rax, %rax
je 0x352e6
leaq 0x2d82d8(%rip), %rax    # 0x30d5b8
movl $0x1, (%rax)
movq %r13, %rdi
movl $0x21, %esi
callq 0x9100
testq %rax, %rax
leaq 0x2d82e3(%rip), %rbx    # 0x30d5e0
je 0x3530c
leaq 0x2d82ae(%rip), %rax    # 0x30d5b4
movl $0x1, (%rax)
movq %r13, %rdi
movl $0x72, %esi
callq 0x9100
testq %rax, %rax
je 0x35324
movl $0x1, (%rbx)
movq %r13, %rdi
movl $0x52, %esi
callq 0x9100
testq %rax, %rax
je 0x3533c
movl $0x1, (%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq