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

   // request the next item from a X72 rubidium.

   if(need_x72_resync) {
      need_x72_resync = 0;
      restart_prs_polling();  // reset the message queues
   }

   if(need_x72_restore && have_x72_pps) {
      need_x72_restore = 0;
if(debug_file) fprintf(debug_file, "! restore x72 state!  fw_dis:%d\n", x72_fw_discipline());  //burp
      restore_x72_state();   // restore last known x72 settings from disk
   }

   test = 0;
   if((test == 0) && (polled_q_in != polled_q_out)) {  // we have a special message request queued
      send_queued_cmd(1);
   }
   else {
      if(polled_req < 0) polled_req = 0;

      if(1 && (have_x72_info == 0)) {        // requesting info can disrupt device timing
         send_polled_cmd("i", X72_INFO_MSG); // ... so we only get it once
      }
      else if(prs_poll_tick) {   // get PPS value every second
         send_polled_cmd("j", X72_GET_PPS_MSG);
         prs_poll_tick = 0;
      }
      else {
         if     (polled_req == 0) send_polled_cmd("w", X72_HEALTH_MSG);
         else if(polled_req == 1) send_polled_cmd("p", X72_GET_CREG_MSG);

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

      ++polled_seq;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl $0x0, 0x2fcbcb(%rip)    # 0x36cbd8
je 0x7001e
movl $0x0, 0x2fcbbf(%rip)    # 0x36cbd8
callq 0x8b1d2
cmpl $0x0, 0x2fcbb7(%rip)    # 0x36cbdc
je 0x70069
leaq 0x1aaca2(%rip), %rax    # 0x21acd0
cmpl $0x0, (%rax)
je 0x70069
movl $0x0, 0x2fcb9f(%rip)    # 0x36cbdc
leaq 0x1ce34c(%rip), %rax    # 0x23e390
movq (%rax), %rbx
testq %rbx, %rbx
je 0x70064
callq 0x6cbe4
leaq 0xb3ca6(%rip), %rsi     # 0x123cfe
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x9560
callq 0x8ea0a
movl 0x2fff61(%rip), %eax    # 0x36ffd0
cmpl 0x2fff5f(%rip), %eax    # 0x36ffd4
jne 0x700c2
movl 0x2fff5f(%rip), %eax    # 0x36ffdc
testl %eax, %eax
jns 0x7008d
movl $0x0, 0x2fff51(%rip)    # 0x36ffdc
xorl %eax, %eax
leaq 0x1aac78(%rip), %rcx    # 0x21ad0c
cmpl $0x0, (%rcx)
je 0x700d2
cmpl $0x0, 0x2fcb58(%rip)    # 0x36cbf8
je 0x700e5
leaq 0xb4b36(%rip), %rdi     # 0x124bdf
movl $0x2c1, %esi            # imm = 0x2C1
callq 0x6e2d1
movl $0x0, 0x2fcb3b(%rip)    # 0x36cbf8
jmp 0x7014c
movl $0x1, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x8aadd
leaq 0xb059d(%rip), %rdi     # 0x120676
movl $0x2c0, %esi            # imm = 0x2C0
callq 0x6e2d1
jmp 0x7014c
cmpl $0x1, %eax
je 0x700fc
testl %eax, %eax
jne 0x70120
leaq 0xb12c6(%rip), %rdi     # 0x1213bb
movl $0x2c9, %esi            # imm = 0x2C9
jmp 0x70108
leaq 0x9d9a7(%rip), %rdi     # 0x10daaa
movl $0x2c5, %esi            # imm = 0x2C5
callq 0x6e2d1
movl 0x2ffec9(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x2ffec0(%rip)    # 0x36ffdc
testl %eax, %eax
jle 0x7014c
movl $0x0, 0x2ffeb2(%rip)    # 0x36ffdc
movl 0x2fbc98(%rip), %eax    # 0x36bdc8
leal 0x1(%rax), %ecx
movl %ecx, 0x2fbc8f(%rip)    # 0x36bdc8
testl %eax, %eax
jne 0x7014c
movl $0x7, %edi
movl $0x11f6, %esi           # imm = 0x11F6
callq 0x1118c
incl 0x2ffe8e(%rip)          # 0x36ffe0
addq $0x8, %rsp
popq %rbx
popq %rbp
retq