// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heather.cpp
// Function: serial_input_check()
int serial_input_check()
{
int i;
static int count = 0;
#define THROTTLE 20

   // returns true if a character is available from the serial port
   // But, we might need to occasionally allow the keyboard to be
   // checked for some polled devices or high nav rate modes.


   if(GetMsecs() > last_kbd_msec) {  // we haven't checked the keyboard in a while
//sprintf(out, "GetMsecs:%.0f  last:%.0f  %.0f    ", GetMsecs(), last_kbd_msec, GetMsecs()-last_kbd_msec);
//DEBUGSTR(out);
//refresh_page();
//    reset_kbd_timer();
      return 0;
   }

   if((nav_rate > 10) && (got_timing_msg % 5) == 4) i = 0;
   else if(rcvr_type == NO_RCVR) i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   else if(rcvr_type == TIDE_RCVR) i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   else if(sim_file) i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   else if(com[RCVR_PORT].process_com == 0) i = 0;
   else if(1 && (rcvr_type == CS_RCVR)) {
      if((++count % THROTTLE) == 0) i = 0;
      else i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   }
   else if(1 && (rcvr_type == LPFRS_RCVR)) {
      if((++count % THROTTLE) < (THROTTLE/2)) i = 0;
      else i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   }
   else if(1 && (rcvr_type == PRS_RCVR)) {
      if((++count % THROTTLE) < (THROTTLE/2)) i = 0;
      else i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   }
   else if(1 && (rcvr_type == SA35_RCVR)) {
      if((++count % THROTTLE) < (THROTTLE/2)) i = 0;
      else i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   }
   else if(1 && (rcvr_type == SRO_RCVR)) {
      if((++count % THROTTLE) < (THROTTLE/2)) i = 0;
      else i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   }
   else if(1 && (rcvr_type == STAR_RCVR) && (star_type == OSA_TYPE)) {
//OSA i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
      if((++count % 50) < (3)) i = 0;
      else i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
   }
   else if(1 && ((++count % THROTTLE) == 0)) {  // mainly for NEC_TYPE GPSDO and ACRON_RCVR
      if(SER_AVAIL_RCVR) {   // polled receivers that need some access to the keyboard
         dup_star_time = 0;
         i = 0;
      }
      else {
         i = SERIAL_DATA_AVAILABLE(RCVR_PORT);
      }
   }
   else i = SERIAL_DATA_AVAILABLE(RCVR_PORT); // check if serial port has data (and stay in loop until it's exhausted)

   return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
callq 0xad3f
ucomisd 0x2d9e50(%rip), %xmm0   # 0x2f7598
jbe 0x1d74e
xorl %eax, %eax
popq %rbp
retq
movsd 0x1e7c02(%rip), %xmm0   # 0x205358
ucomisd 0xd594a(%rip), %xmm0    # 0xf30a8
jbe 0x1d772
movl 0x2d9cd6(%rip), %eax    # 0x2f743c
pushq $0x5
popq %rcx
xorl %edx, %edx
divl %ecx
cmpl $0x4, %edx
je 0x1d74a
movq 0x1e5157(%rip), %rcx    # 0x2028d0
cmpq $0x800000, %rcx         # imm = 0x800000
je 0x1d795
cmpq $0x400, %rcx            # imm = 0x400
je 0x1d795
cmpq $0x0, 0x20ac2d(%rip)    # 0x2283c0
je 0x1d79e
pushq $0xa
popq %rdi
popq %rbp
jmp 0xb771
cmpl $0x0, 0x2f252f(%rip)    # 0x30fcd4
je 0x1d74a
movabsq $0x1000000000, %rax     # imm = 0x1000000000
cmpq %rax, %rcx
je 0x1d7f7
cmpq $0x1000000, %rcx        # imm = 0x1000000
je 0x1d7f7
cmpq $0x8000000, %rcx        # imm = 0x8000000
je 0x1d7f7
cmpq $0x10000000, %rcx       # imm = 0x10000000
je 0x1d7f7
cmpq $0x20000, %rcx          # imm = 0x20000
jne 0x1d819
movl 0x30ce44(%rip), %eax    # 0x32a624
incl %eax
movl %eax, 0x30ce3c(%rip)    # 0x32a624
pushq $0x14
popq %rcx
cltd
idivl %ecx
testl %edx, %edx
jne 0x1d795
jmp 0x1d74a
movl 0x30ce27(%rip), %eax    # 0x32a624
incl %eax
movl %eax, 0x30ce1f(%rip)    # 0x32a624
pushq $0x14
popq %rcx
cltd
idivl %ecx
cmpl $0xa, %edx
jl 0x1d74a
jmp 0x1d795
movl 0x30ce05(%rip), %eax    # 0x32a624
incl %eax
movl 0x1e77c1(%rip), %edx    # 0x204fe8
movl %eax, 0x30cdf7(%rip)    # 0x32a624
cmpq $0x1000, %rcx           # imm = 0x1000
jne 0x1d84f
cmpl $0x4f, %edx
jne 0x1d84f
pushq $0x32
popq %rcx
cltd
idivl %ecx
cmpl $0x3, %edx
jl 0x1d74a
jmp 0x1d795
pushq $0x14
popq %rsi
cltd
idivl %esi
testl %edx, %edx
jne 0x1d795
movabsq $0x101b465000, %rax     # imm = 0x101B465000
testq %rax, %rcx
je 0x1d795
andl $0x0, 0x1e7779(%rip)    # 0x204ff0
jmp 0x1d74a