// File: /workspace/github_cpp_makefile_star2_O3/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 0xa80b
mulsd 0xea88c(%rip), %xmm0    # 0x109038
ucomisd 0x2eede4(%rip), %xmm0   # 0x30d598
jbe 0x1e7ba
xorl %eax, %eax
popq %rbp
retq
movsd 0x1fcb96(%rip), %xmm0   # 0x21b358
ucomisd 0xea8de(%rip), %xmm0    # 0x1090a8
jbe 0x1e7e2
imull $0xcccccccd, 0x2eec66(%rip), %eax # imm = 0xCCCCCCCD
addl $0xcccccccc, %eax       # imm = 0xCCCCCCCC
cmpl $0x33333333, %eax       # imm = 0x33333333
jb 0x1e7b6
movq 0x1fa0e7(%rip), %rax    # 0x2188d0
cmpq $0x800000, %rax         # imm = 0x800000
je 0x1e803
cmpq $0x400, %rax            # imm = 0x400
je 0x1e803
cmpq $0x0, 0x21fbbf(%rip)    # 0x23e3c0
je 0x1e80e
movl $0xa, %edi
popq %rbp
jmp 0xb9ad
cmpl $0x0, 0x3074bf(%rip)    # 0x325cd4
je 0x1e7b6
cmpq $0x7ffffff, %rax        # imm = 0x7FFFFFF
jle 0x1e87b
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x1e83e
cmpq $0x10000000, %rax       # imm = 0x10000000
je 0x1e83e
movabsq $0x1000000000, %rcx     # imm = 0x1000000000
cmpq %rcx, %rax
jne 0x1e88b
movl 0x321de0(%rip), %eax    # 0x340624
leal 0x1(%rax), %ecx
movl %ecx, 0x321dd7(%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 0x1e7b6
jmp 0x1e803
cmpq $0x20000, %rax          # imm = 0x20000
je 0x1e8d6
cmpq $0x1000000, %rax        # imm = 0x1000000
je 0x1e83e
movl 0x321d93(%rip), %ecx    # 0x340624
incl %ecx
movl 0x1fc74f(%rip), %edx    # 0x21afe8
movl %ecx, 0x321d85(%rip)    # 0x340624
cmpq $0x1000, %rax           # imm = 0x1000
jne 0x1e903
cmpl $0x4f, %edx
jne 0x1e903
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 0x1e7b6
jmp 0x1e803
movl 0x321d48(%rip), %eax    # 0x340624
leal 0x1(%rax), %ecx
movl %ecx, 0x321d3f(%rip)    # 0x340624
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
addl $0xe6666665, %eax       # imm = 0xE6666665
rorl $0x2, %eax
cmpl $0xccccccd, %eax        # imm = 0xCCCCCCD
jae 0x1e803
jmp 0x1e7b6
imull $0xcccccccd, %ecx, %ecx # imm = 0xCCCCCCCD
addl $0x19999998, %ecx       # imm = 0x19999998
rorl $0x2, %ecx
cmpl $0xccccccc, %ecx        # imm = 0xCCCCCCC
ja 0x1e803
movabsq $0x101b465000, %rcx     # imm = 0x101B465000
testq %rcx, %rax
je 0x1e803
movl $0x0, 0x1fc6b5(%rip)    # 0x21aff0
jmp 0x1e7b6