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

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

   if(need_cs_timeset && cs_remote) {  // set the HP5071A date and time from the system clock
      set_cs_time(need_cs_timeset);
      restore_cs_remote();
   }

   test = 1;
   if(test && (polled_q_in != polled_q_out)) {  // we have a special message request queued
      send_queued_cmd(1);
   }
   else if((cs_msg_id != polled_msg_id) && (cs_msg_id != CS_MJD_MSG)) ;  // only process last requested message
   else if(polled_msg_id == CS_TIME_MSG) { // 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);
      }
      else {
         if(polled_req < 0) polled_req = 0;

         if((polled_seq % 10) == 0)   poll_cs_log();
         else {
            if     (polled_req ==  0) send_polled_cmd("*IDN?",              SCPI_ID_MSG);
            else if(polled_req ==  1) send_polled_cmd("SYST:REM?",          CS_REM_MSG);
            else if(polled_req ==  2) send_polled_cmd(":DISP:ENAB?",        CS_DISP_MSG);
            else if(polled_req ==  3) send_polled_cmd(":PTIM:STAN?",        CS_STANDBY_MSG);
            else if(polled_req ==  4) send_polled_cmd(":ROSC:CONT?",        SCPI_EFC_MSG);
            else if(polled_req ==  5) send_polled_cmd("DIAG:CBTS?",         CS_CBTID_MSG);
            else if(polled_req ==  6) send_polled_cmd("DIAG:CONT:STAT?",    CS_LAMP_MSG);
            else if(polled_req ==  7) send_polled_cmd("DIAG:CURR:BEAM?",    CS_BEAM_MSG);
            else if(polled_req ==  8) send_polled_cmd("DIAG:CURR:PUMP?",    CS_PUMP_MSG);
            else if(polled_req ==  9) send_polled_cmd("DIAG:GAIN?",         CS_GAIN_MSG);
            else if(polled_req == 10) send_polled_cmd("DIAG:RFAM?",         CS_RFAM_MSG);
            else if(polled_req == 11) send_polled_cmd("DIAG:STAT:GLOB?",    CS_GLOB_MSG);
            else if(polled_req == 12) send_polled_cmd("DIAG:STAT:SUPP?",    CS_SUPPLY_MSG);
            else if(polled_req == 13) send_polled_cmd("DIAG:TEMP?",         CS_TEMP_MSG);
            else if(polled_req == 14) send_polled_cmd("DIAG:VOLT:COV?",     CS_COVEN_MSG);
            else if(polled_req == 15) send_polled_cmd("DIAG:VOLT:ROSC?",    CS_QOVEN_MSG);
            else if(polled_req == 16) send_polled_cmd("DIAG:VOLT:EMUL?",    CS_EMUL_MSG);
            else if(polled_req == 17) send_polled_cmd("DIAG:VOLT:HWI?",     CS_HWI_MSG);
            else if(polled_req == 18) send_polled_cmd("DIAG:VOLT:MSP?",     CS_MSP_MSG);
            else if(polled_req == 19) send_polled_cmd("DIAG:VOLT:PLL?",     CS_PLL_MSG);
            else if(polled_req == 20) send_polled_cmd("DIAG:VOLT:SUPP?",    CS_VOLT_MSG);
            else if(polled_req == 21) send_polled_cmd("DIAG:CURR:CFI?",     CS_CFIELD_MSG);
            else if(polled_req == 22) send_polled_cmd(":ROSC:FREQ1?",       CS_FREQ1_MSG);
            else if(polled_req == 23) send_polled_cmd(":ROSC:FREQ2?",       CS_FREQ2_MSG);
            else if(polled_req == 24) send_polled_cmd(":ROSC:STE?",         CS_STER_MSG);
            else if(polled_req == 25) send_polled_cmd(":PTIM:SYNC?",        CS_SYNC_MSG);
            else if(polled_req == 26) send_polled_cmd(":PTIM:LEAP:STAT?",   CS_LEAPSTAT_MSG);
            else if(polled_req == 27) send_polled_cmd(":PTIM:LEAP:DUR?",    CS_LEAPDUR_MSG);
            else if(polled_req == 28) send_polled_cmd(":PTIM:LEAP:MJD?",    CS_LEAPMJD_MSG);
            else if(polled_req == 29) send_polled_cmd("DIAG:LOG:COUN?",     CS_LOGCOUNT_MSG);

            if(++polled_req > 29) {  // start the request cycle over
               polled_req = 0;
               if(all_polled == 0) {
                  new_queue(RESET_ALL_QUEUES, 123);
               }
               ++all_polled;
            }
         }
         ++polled_seq;
      }
   }
   else {
      send_polled_cmd(":PTIM:MJD?", CS_MJD_MSG);   // request date message
      send_polled_cmd(":PTIM:TIME?", CS_TIME_MSG); // request time message
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x1ac0d3(%rip), %rax    # 0x21aa10
movb (%rax), %al
testb %al, %al
je 0x6e96a
leaq 0x1ac092(%rip), %rcx    # 0x21a9dc
cmpl $0x0, (%rcx)
je 0x6e96a
movsbl %al, %edi
callq 0xa270d
leaq 0x1ac08e(%rip), %rax    # 0x21a9ec
cmpl $0x0, (%rax)
jne 0x6e96a
xorl %edi, %edi
callq 0x63e3b
movl 0x301660(%rip), %eax    # 0x36ffd0
cmpl 0x30165e(%rip), %eax    # 0x36ffd4
jne 0x6e9f7
movl 0x30366e(%rip), %ecx    # 0x371fec
movl 0x2fe27c(%rip), %eax    # 0x36cc00
cmpl %eax, %ecx
setne %dl
cmpl $0x12d, %ecx            # imm = 0x12D
setne %cl
testb %dl, %cl
jne 0x6ec4c
cmpl $0x12c, %eax            # imm = 0x12C
jne 0x6ea02
movl 0x301635(%rip), %eax    # 0x36ffdc
testl %eax, %eax
jns 0x6e9b7
movl $0x0, 0x301627(%rip)    # 0x36ffdc
xorl %eax, %eax
imull $0xcccccccd, 0x30161f(%rip), %ecx # imm = 0xCCCCCCCD
rorl %ecx
cmpl $0x19999999, %ecx       # imm = 0x19999999
jbe 0x6ea25
cmpl $0x1d, %eax
ja 0x6ec15
movl %eax, %eax
leaq 0xb0203(%rip), %rcx     # 0x11ebe0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xb2cda(%rip), %rdi     # 0x1216c7
movl $0x1c, %esi
jmp 0x6ebfc
movl $0x1, %edi
popq %rbp
jmp 0x8aadd
leaq 0xb2c23(%rip), %rdi     # 0x12162c
movl $0x12d, %esi            # imm = 0x12D
callq 0x6e2d1
leaq 0xb2c1d(%rip), %rdi     # 0x121637
movl $0x12c, %esi            # imm = 0x12C
popq %rbp
jmp 0x6e2d1
callq 0xa261b
jmp 0x6ec46
leaq 0xb6eea(%rip), %rdi     # 0x125920
movl $0x148, %esi            # imm = 0x148
jmp 0x6ebfc
leaq 0xb6e3b(%rip), %rdi     # 0x125882
movl $0x138, %esi            # imm = 0x138
jmp 0x6ebfc
leaq 0xb6e0b(%rip), %rdi     # 0x125863
movl $0x137, %esi            # imm = 0x137
jmp 0x6ebfc
leaq 0xb6dda(%rip), %rdi     # 0x125843
movl $0x134, %esi            # imm = 0x134
jmp 0x6ebfc
leaq 0xb28d8(%rip), %rdi     # 0x121352
movl $0xb, %esi
jmp 0x6ebfc
leaq 0xb6dc8(%rip), %rdi     # 0x125853
movl $0x135, %esi            # imm = 0x135
jmp 0x6ebfc
leaq 0xb6d91(%rip), %rdi     # 0x12582d
movl $0x132, %esi            # imm = 0x132
jmp 0x6ebfc
leaq 0xb6e56(%rip), %rdi     # 0x125903
movl $0x142, %esi            # imm = 0x142
jmp 0x6ebfc
leaq 0xb6e3a(%rip), %rdi     # 0x1258f8
movl $0x141, %esi            # imm = 0x141
jmp 0x6ebfc
leaq 0xb6d27(%rip), %rdi     # 0x1257f6
movl $0x145, %esi            # imm = 0x145
jmp 0x6ebfc
leaq 0xb6d92(%rip), %rdi     # 0x125872
movl $0x13c, %esi            # imm = 0x13C
jmp 0x6ebfc
leaq 0xb296c(%rip), %rdi     # 0x12145d
movl $0x143, %esi            # imm = 0x143
jmp 0x6ebfc
leaq 0xb6d0b(%rip), %rdi     # 0x12580d
movl $0x130, %esi            # imm = 0x130
jmp 0x6ebfc
leaq 0xb1cd6(%rip), %rdi     # 0x1207e9
movl $0x146, %esi            # imm = 0x146
jmp 0x6ebfc
leaq 0xb6d6e(%rip), %rdi     # 0x125892
movl $0x139, %esi            # imm = 0x139
jmp 0x6ebfc
leaq 0xb6d8a(%rip), %rdi     # 0x1258bf
movl $0x13d, %esi            # imm = 0x13D
jmp 0x6ebfc
leaq 0xb6cbc(%rip), %rdi     # 0x125802
movl $0x12e, %esi            # imm = 0x12E
jmp 0x6ebfc
leaq 0xb6d78(%rip), %rdi     # 0x1258cf
movl $0x13e, %esi            # imm = 0x13E
jmp 0x6ebfc
leaq 0xb2ab9(%rip), %rdi     # 0x121621
movl $0x136, %esi            # imm = 0x136
jmp 0x6ebfc
leaq 0xb1b9e(%rip), %rdi     # 0x120717
movl $0x14d, %esi            # imm = 0x14D
jmp 0x6ebfc
leaq 0xb6d1a(%rip), %rdi     # 0x1258a1
movl $0x13a, %esi            # imm = 0x13A
jmp 0x6ebfc
leaq 0xb6ca3(%rip), %rdi     # 0x125838
movl $0x133, %esi            # imm = 0x133
jmp 0x6ebfc
leaq 0xb6c7a(%rip), %rdi     # 0x12581d
movl $0x131, %esi            # imm = 0x131
jmp 0x6ebfc
leaq 0xb6d2d(%rip), %rdi     # 0x1258de
movl $0x13f, %esi            # imm = 0x13F
jmp 0x6ebfc
leaq 0xb6cf1(%rip), %rdi     # 0x1258b0
movl $0x13b, %esi            # imm = 0x13B
jmp 0x6ebfc
leaq 0xb6d1e(%rip), %rdi     # 0x1258eb
movl $0x140, %esi            # imm = 0x140
jmp 0x6ebfc
leaq 0xb6d55(%rip), %rdi     # 0x125930
movl $0x149, %esi            # imm = 0x149
jmp 0x6ebfc
leaq 0xb6d57(%rip), %rdi     # 0x125940
movl $0x14a, %esi            # imm = 0x14A
jmp 0x6ebfc
leaq 0xb6d18(%rip), %rdi     # 0x12590f
movl $0x147, %esi            # imm = 0x147
callq 0x6e2d1
movl 0x3013d5(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x3013cc(%rip)    # 0x36ffdc
cmpl $0x1d, %eax
jl 0x6ec46
movl $0x0, 0x3013bd(%rip)    # 0x36ffdc
movl 0x2fd1a3(%rip), %eax    # 0x36bdc8
testl %eax, %eax
jne 0x6ec3e
movl $0x7, %edi
movl $0x7b, %esi
callq 0x1118c
movl 0x2fd18a(%rip), %eax    # 0x36bdc8
incl %eax
movl %eax, 0x2fd182(%rip)    # 0x36bdc8
incl 0x301394(%rip)          # 0x36ffe0
popq %rbp
retq