// File: jkingan[P]ladyheather/heathgps.cpp
// Function: poll_next_lpfrs()
void poll_next_lpfrs()
{
int test;

   // request an item from a LPFRS rubidium.  Requests are alternated between
   // a time message and some device parameter.  The parameter requests are 
   // alternated between one of three important parameters and then the lesser
   // important ones.

   test = 0;
   if(test && (polled_q_in != polled_q_out)) {  // we have a special message request queued
      send_queued_cmd(1);
      if(no_response_msg) {  // last message sends no response
         no_response_msg = 0;
         send_polled_cmd("M", LPFRS_M_MSG); 
      }
   }
   else if(1) { // request next misc message every time
      if((test == 0) && (polled_q_in != polled_q_out)) {  // we have a special message request queued
         send_queued_cmd(2);
         if(no_response_msg) {  // last message sends no response
            no_response_msg = 0;
            send_polled_cmd("M", LPFRS_M_MSG); 
         }
      }
      else {  // poll standard messages 
      if(polled_req < 0) polled_req = 0;
         if     (polled_req == 0) send_polled_cmd("M",   LPFRS_M_MSG); 
         else if(polled_req == 1) send_polled_cmd("L06", LPFRS_C_READ_MSG); 
         else if(polled_req == 2) send_polled_cmd("L0A", LPFRS_F_READ_MSG); 
//       else if(polled_req == 3) send_polled_cmd("V",   LPFRS_ID_MSG);  // takes too long a time to send

         if(++polled_req > 2) {
            polled_req = 0;
            ++all_polled;
            if(all_polled == 1) {  // reset the queues the first time through
               new_queue(RESET_ALL_QUEUES, 4598);
            }
         }

         if(no_response_msg) {  // last message sends no response
            no_response_msg = 0;
            send_polled_cmd("M", LPFRS_M_MSG); 
         }
         ++polled_seq;
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0x970b6
movl 0x338125(%rip), %eax    # 0x3cf1a0
cmpl 0x338123(%rip), %eax    # 0x3cf1a4
je 0x970b6
movl $0x1, %edi
callq 0xbd7c0
cmpl $0x0, 0x333f1c(%rip)    # 0x3cafb0
je 0x970b1
movl $0x0, 0x333f10(%rip)    # 0x3cafb0
leaq 0xeab3e(%rip), %rdi     # 0x181be5
movl $0x384, %esi            # imm = 0x384
callq 0x96370
jmp 0x971e2
cmpl $0x0, -0x4(%rbp)
jne 0x970fd
movl 0x3380de(%rip), %eax    # 0x3cf1a0
cmpl 0x3380dc(%rip), %eax    # 0x3cf1a4
je 0x970fd
movl $0x2, %edi
callq 0xbd7c0
cmpl $0x0, 0x333ed5(%rip)    # 0x3cafb0
je 0x970f8
movl $0x0, 0x333ec9(%rip)    # 0x3cafb0
leaq 0xeaaf7(%rip), %rdi     # 0x181be5
movl $0x384, %esi            # imm = 0x384
callq 0x96370
jmp 0x971e0
cmpl $0x0, 0x3380a8(%rip)    # 0x3cf1ac
jge 0x97110
movl $0x0, 0x33809c(%rip)    # 0x3cf1ac
cmpl $0x0, 0x338095(%rip)    # 0x3cf1ac
jne 0x9712c
leaq 0xeaac5(%rip), %rdi     # 0x181be5
movl $0x384, %esi            # imm = 0x384
callq 0x96370
jmp 0x97166
cmpl $0x1, 0x338079(%rip)    # 0x3cf1ac
jne 0x97148
leaq 0xed8a9(%rip), %rdi     # 0x1849e5
movl $0x387, %esi            # imm = 0x387
callq 0x96370
jmp 0x97164
cmpl $0x2, 0x33805d(%rip)    # 0x3cf1ac
jne 0x97162
leaq 0xefc23(%rip), %rdi     # 0x186d7b
movl $0x388, %esi            # imm = 0x388
callq 0x96370
jmp 0x97164
jmp 0x97166
movl 0x338040(%rip), %eax    # 0x3cf1ac
addl $0x1, %eax
movl %eax, 0x338037(%rip)    # 0x3cf1ac
cmpl $0x2, %eax
jle 0x971ad
movl $0x0, 0x338028(%rip)    # 0x3cf1ac
movl 0x333e1e(%rip), %eax    # 0x3cafa8
addl $0x1, %eax
movl %eax, 0x333e15(%rip)    # 0x3cafa8
cmpl $0x1, 0x333e0e(%rip)    # 0x3cafa8
jne 0x971ab
movl $0x7, %edi
movl $0x11f6, %esi           # imm = 0x11F6
callq 0x14df0
jmp 0x971ad
cmpl $0x0, 0x333dfc(%rip)    # 0x3cafb0
je 0x971d1
movl $0x0, 0x333df0(%rip)    # 0x3cafb0
leaq 0xeaa1e(%rip), %rdi     # 0x181be5
movl $0x384, %esi            # imm = 0x384
callq 0x96370
movl 0x337fd9(%rip), %eax    # 0x3cf1b0
addl $0x1, %eax
movl %eax, 0x337fd0(%rip)    # 0x3cf1b0
jmp 0x971e2
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)