// File: /workspace/github_cpp_makefile_star2_O2/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 0x19f5a8(%rip), %rax    # 0x204a10
movb (%rax), %al
testb %al, %al
je 0x65487
leaq 0x19f567(%rip), %rcx    # 0x2049dc
cmpl $0x0, (%rcx)
je 0x65487
movsbl %al, %edi
callq 0x93501
callq 0x5be85
movl 0x2f4b43(%rip), %eax    # 0x359fd0
cmpl 0x2f4b41(%rip), %eax    # 0x359fd4
jne 0x6550b
movl 0x2f6b51(%rip), %ecx    # 0x35bfec
movl 0x2f175f(%rip), %eax    # 0x356c00
cmpl %eax, %ecx
setne %dl
cmpl $0x12d, %ecx            # imm = 0x12D
setne %cl
testb %dl, %cl
jne 0x65755
cmpl $0x12c, %eax            # imm = 0x12C
jne 0x65514
movl 0x2f4b18(%rip), %ecx    # 0x359fdc
testl %ecx, %ecx
jns 0x654d1
andl $0x0, 0x2f4b0d(%rip)    # 0x359fdc
xorl %ecx, %ecx
movl 0x2f4b09(%rip), %eax    # 0x359fe0
pushq $0xa
popq %rsi
xorl %edx, %edx
divl %esi
testl %edx, %edx
je 0x65537
cmpl $0x1d, %ecx
ja 0x65725
movl %ecx, %eax
leaq 0xa362c(%rip), %rcx     # 0x108b20
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xa610b(%rip), %rdi     # 0x10b60f
pushq $0x1c
jmp 0x6558e
pushq $0x1
popq %rdi
popq %rbp
jmp 0x7dfa9
leaq 0xa6059(%rip), %rdi     # 0x10b574
movl $0x12d, %esi            # imm = 0x12D
callq 0x64f01
leaq 0xa6053(%rip), %rdi     # 0x10b57f
movl $0x12c, %esi            # imm = 0x12C
popq %rbp
jmp 0x64f01
callq 0x9342f
jmp 0x6574f
leaq 0xaa320(%rip), %rdi     # 0x10f868
movl $0x148, %esi            # imm = 0x148
jmp 0x6570c
leaq 0xaa271(%rip), %rdi     # 0x10f7ca
movl $0x138, %esi            # imm = 0x138
jmp 0x6570c
leaq 0xaa241(%rip), %rdi     # 0x10f7ab
movl $0x137, %esi            # imm = 0x137
jmp 0x6570c
leaq 0xaa210(%rip), %rdi     # 0x10f78b
movl $0x134, %esi            # imm = 0x134
jmp 0x6570c
leaq 0xa5d0e(%rip), %rdi     # 0x10b29a
pushq $0xb
popq %rsi
jmp 0x6570c
leaq 0xaa200(%rip), %rdi     # 0x10f79b
movl $0x135, %esi            # imm = 0x135
jmp 0x6570c
leaq 0xaa1c9(%rip), %rdi     # 0x10f775
movl $0x132, %esi            # imm = 0x132
jmp 0x6570c
leaq 0xaa28e(%rip), %rdi     # 0x10f84b
movl $0x142, %esi            # imm = 0x142
jmp 0x6570c
leaq 0xaa272(%rip), %rdi     # 0x10f840
movl $0x141, %esi            # imm = 0x141
jmp 0x6570c
leaq 0xaa15f(%rip), %rdi     # 0x10f73e
movl $0x145, %esi            # imm = 0x145
jmp 0x6570c
leaq 0xaa1ca(%rip), %rdi     # 0x10f7ba
movl $0x13c, %esi            # imm = 0x13C
jmp 0x6570c
leaq 0xa5da4(%rip), %rdi     # 0x10b3a5
movl $0x143, %esi            # imm = 0x143
jmp 0x6570c
leaq 0xaa143(%rip), %rdi     # 0x10f755
movl $0x130, %esi            # imm = 0x130
jmp 0x6570c
leaq 0xa510e(%rip), %rdi     # 0x10a731
movl $0x146, %esi            # imm = 0x146
jmp 0x6570c
leaq 0xaa1a6(%rip), %rdi     # 0x10f7da
movl $0x139, %esi            # imm = 0x139
jmp 0x6570c
leaq 0xaa1c2(%rip), %rdi     # 0x10f807
movl $0x13d, %esi            # imm = 0x13D
jmp 0x6570c
leaq 0xaa0f4(%rip), %rdi     # 0x10f74a
movl $0x12e, %esi            # imm = 0x12E
jmp 0x6570c
leaq 0xaa1b0(%rip), %rdi     # 0x10f817
movl $0x13e, %esi            # imm = 0x13E
jmp 0x6570c
leaq 0xa5ef1(%rip), %rdi     # 0x10b569
movl $0x136, %esi            # imm = 0x136
jmp 0x6570c
leaq 0xa4fd6(%rip), %rdi     # 0x10a65f
movl $0x14d, %esi            # imm = 0x14D
jmp 0x6570c
leaq 0xaa152(%rip), %rdi     # 0x10f7e9
movl $0x13a, %esi            # imm = 0x13A
jmp 0x6570c
leaq 0xaa0db(%rip), %rdi     # 0x10f780
movl $0x133, %esi            # imm = 0x133
jmp 0x6570c
leaq 0xaa0b2(%rip), %rdi     # 0x10f765
movl $0x131, %esi            # imm = 0x131
jmp 0x6570c
leaq 0xaa165(%rip), %rdi     # 0x10f826
movl $0x13f, %esi            # imm = 0x13F
jmp 0x6570c
leaq 0xaa129(%rip), %rdi     # 0x10f7f8
movl $0x13b, %esi            # imm = 0x13B
jmp 0x6570c
leaq 0xaa156(%rip), %rdi     # 0x10f833
movl $0x140, %esi            # imm = 0x140
jmp 0x6570c
leaq 0xaa18d(%rip), %rdi     # 0x10f878
movl $0x149, %esi            # imm = 0x149
jmp 0x6570c
leaq 0xaa18f(%rip), %rdi     # 0x10f888
movl $0x14a, %esi            # imm = 0x14A
jmp 0x6570c
leaq 0xaa150(%rip), %rdi     # 0x10f857
movl $0x147, %esi            # imm = 0x147
callq 0x64f01
movl 0x2f48c5(%rip), %eax    # 0x359fdc
leal 0x1(%rax), %ecx
movl %ecx, 0x2f48bc(%rip)    # 0x359fdc
cmpl $0x1d, %eax
jl 0x6574f
andl $0x0, 0x2f48b0(%rip)    # 0x359fdc
movl 0x2f0696(%rip), %eax    # 0x355dc8
testl %eax, %eax
jne 0x65747
pushq $0x7
popq %rdi
pushq $0x7b
popq %rsi
callq 0x10a99
movl 0x2f0681(%rip), %eax    # 0x355dc8
incl %eax
movl %eax, 0x2f0679(%rip)    # 0x355dc8
incl 0x2f488b(%rip)          # 0x359fe0
popq %rbp
retq