// File: /workspace/github_cpp_makefile_star2_O1/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 0xa826
mulsd 0xea869(%rip), %xmm0    # 0x109038
ucomisd 0x2eedc1(%rip), %xmm0   # 0x30d598
jbe 0x1e7dd
xorl %eax, %eax
popq %rbp
retq
movsd 0x1fcb73(%rip), %xmm0   # 0x21b358
ucomisd 0xea8bb(%rip), %xmm0    # 0x1090a8
jbe 0x1e805
imull $0xcccccccd, 0x2eec43(%rip), %eax # imm = 0xCCCCCCCD
addl $0xcccccccc, %eax       # imm = 0xCCCCCCCC
cmpl $0x33333333, %eax       # imm = 0x33333333
jb 0x1e7d9
movq 0x1fa0c4(%rip), %rax    # 0x2188d0
cmpq $0x800000, %rax         # imm = 0x800000
je 0x1e826
cmpq $0x400, %rax            # imm = 0x400
je 0x1e826
cmpq $0x0, 0x21fb9c(%rip)    # 0x23e3c0
je 0x1e831
movl $0xa, %edi
popq %rbp
jmp 0xb9c3
cmpl $0x0, 0x30749c(%rip)    # 0x325cd4
je 0x1e7d9
cmpq $0x7ffffff, %rax        # imm = 0x7FFFFFF
jle 0x1e89e
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x1e861
cmpq $0x10000000, %rax       # imm = 0x10000000
je 0x1e861
movabsq $0x1000000000, %rcx     # imm = 0x1000000000
cmpq %rcx, %rax
jne 0x1e8ae
movl 0x321dbd(%rip), %eax    # 0x340624
leal 0x1(%rax), %ecx
movl %ecx, 0x321db4(%rip)    # 0x340624
movslq %ecx, %rcx
imulq $0x66666667, %rcx, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x23, %rcx
addl %edx, %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,4), %ecx
negl %ecx
addl %ecx, %eax
incl %eax
cmpl $0xa, %eax
jl 0x1e7d9
jmp 0x1e826
cmpq $0x20000, %rax          # imm = 0x20000
je 0x1e8f9
cmpq $0x1000000, %rax        # imm = 0x1000000
je 0x1e861
movl 0x321d70(%rip), %ecx    # 0x340624
incl %ecx
movl 0x1fc72c(%rip), %edx    # 0x21afe8
movl %ecx, 0x321d62(%rip)    # 0x340624
cmpq $0x1000, %rax           # imm = 0x1000
jne 0x1e926
cmpl $0x4f, %edx
jne 0x1e926
movslq %ecx, %rax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x24, %rax
addl %edx, %eax
imull $0x32, %eax, %eax
subl %eax, %ecx
cmpl $0x3, %ecx
jl 0x1e7d9
jmp 0x1e826
movl 0x321d25(%rip), %eax    # 0x340624
leal 0x1(%rax), %ecx
movl %ecx, 0x321d1c(%rip)    # 0x340624
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
addl $0xe6666665, %eax       # imm = 0xE6666665
rorl $0x2, %eax
cmpl $0xccccccd, %eax        # imm = 0xCCCCCCD
jae 0x1e826
jmp 0x1e7d9
imull $0xcccccccd, %ecx, %ecx # imm = 0xCCCCCCCD
addl $0x19999998, %ecx       # imm = 0x19999998
rorl $0x2, %ecx
cmpl $0xccccccc, %ecx        # imm = 0xCCCCCCC
ja 0x1e826
movabsq $0x101b465000, %rcx     # imm = 0x101B465000
testq %rcx, %rax
je 0x1e826
movl $0x0, 0x1fc692(%rip)    # 0x21aff0
jmp 0x1e7d9