// File: 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
subq $0x10, %rsp
cmpl $0x0, 0x332cd9(%rip)    # 0x3cbda8
je 0x990e0
movl $0x0, 0x332ccd(%rip)    # 0x3cbda8
callq 0xbe120
cmpl $0x0, 0x332cc5(%rip)    # 0x3cbdac
je 0x99138
leaq 0x1e0dc0(%rip), %rax    # 0x279eb0
cmpl $0x0, (%rax)
je 0x99138
movl $0x0, 0x332cad(%rip)    # 0x3cbdac
leaq 0x20446a(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0x99133
leaq 0x20445d(%rip), %rax    # 0x29d570
movq (%rax), %rax
movq %rax, -0x10(%rbp)
callq 0x94230
movq -0x10(%rbp), %rdi
movl %eax, %edx
leaq 0xedeb9(%rip), %rsi     # 0x186fe5
movb $0x0, %al
callq 0x9550
callq 0xc31e0
movl $0x0, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x99162
movl 0x336055(%rip), %eax    # 0x3cf1a0
cmpl 0x336053(%rip), %eax    # 0x3cf1a4
je 0x99162
movl $0x1, %edi
callq 0xbd7c0
jmp 0x99252
cmpl $0x0, 0x336043(%rip)    # 0x3cf1ac
jge 0x99175
movl $0x0, 0x336037(%rip)    # 0x3cf1ac
leaq 0x1e0d70(%rip), %rax    # 0x279eec
cmpl $0x0, (%rax)
jne 0x99197
leaq 0xea76e(%rip), %rdi     # 0x1838f6
movl $0x2c0, %esi            # imm = 0x2C0
callq 0x96370
jmp 0x99243
cmpl $0x0, 0x332c2a(%rip)    # 0x3cbdc8
je 0x991c0
leaq 0xeed24(%rip), %rdi     # 0x187ecb
movl $0x2c1, %esi            # imm = 0x2C1
callq 0x96370
movl $0x0, 0x332c0d(%rip)    # 0x3cbdc8
jmp 0x99241
cmpl $0x0, 0x335fe5(%rip)    # 0x3cf1ac
jne 0x991dc
leaq 0xeb47b(%rip), %rdi     # 0x18464b
movl $0x2c9, %esi            # imm = 0x2C9
callq 0x96370
jmp 0x991f8
cmpl $0x1, 0x335fc9(%rip)    # 0x3cf1ac
jne 0x991f6
leaq 0xd921b(%rip), %rdi     # 0x172407
movl $0x2c5, %esi            # imm = 0x2C5
callq 0x96370
jmp 0x991f8
movl 0x335fae(%rip), %eax    # 0x3cf1ac
addl $0x1, %eax
movl %eax, 0x335fa5(%rip)    # 0x3cf1ac
cmpl $0x1, %eax
jle 0x9923f
movl $0x0, 0x335f96(%rip)    # 0x3cf1ac
movl 0x331d8c(%rip), %eax    # 0x3cafa8
addl $0x1, %eax
movl %eax, 0x331d83(%rip)    # 0x3cafa8
cmpl $0x1, 0x331d7c(%rip)    # 0x3cafa8
jne 0x9923d
movl $0x7, %edi
movl $0x11f6, %esi           # imm = 0x11F6
callq 0x14df0
jmp 0x9923f
jmp 0x99241
jmp 0x99243
movl 0x335f67(%rip), %eax    # 0x3cf1b0
addl $0x1, %eax
movl %eax, 0x335f5e(%rip)    # 0x3cf1b0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)