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

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

   star_line = 0;
   star_msg = 0;

   test = 1;
   if(star_type == OSA_TYPE) { // OSA-453x
      if(test && (polled_q_in != polled_q_out)) {  // we have a special message request queued
         send_queued_cmd(1);    // send the message
         if(no_response_msg) {  // the message sends no response
            no_response_msg = 0;
            send_polled_cmd("INFO_GPS", STAR_POS_MSG);  // request time and location message
         }
      }
      else if(polled_msg_id == STAR_POS_MSG) { // request next misc message every time message
         if((test == 0) && (polled_q_in != polled_q_out)) {  // we have a special message request queued
            send_queued_cmd(2);
         }
         if(polled_req < 0) polled_req = 0;

         if     (polled_req == 0)  send_polled_cmd("INV;",              STAR_INV_MSG);
         else if(polled_req == 1)  send_polled_cmd("CONF;",             STAR_CONF_MSG);
         else if(polled_req == 2)  send_polled_cmd("HBSQ;",             STAR_HBSQ_MSG);
         else if(polled_req == 3)  send_polled_cmd("STATUS;",           STAR_STATUS_MSG);
         else if(polled_req == 4)  send_polled_cmd("TOD_STATE;",        STAR_TOD_MSG);
         else if(polled_req == 5)  send_polled_cmd("WTR;",              STAR_WTR_MSG);
         else if(polled_req == 6)  send_polled_cmd("AL_MASK;",          STAR_ALMASK_MSG);

         else if(polled_req == 7)  send_polled_cmd("PRIOR_TABLE;",      STAR_PRIOR_MSG);  // !!!! 4531
         else if(polled_req == 8)  send_polled_cmd("OUTPUT_TYPE;",      STAR_OUTPUT_MSG); // !!!! 4531
         else if(polled_req == 9)  send_polled_cmd("AUX_INPUT;",        STAR_AUX_MSG);    // !!!! 4531
         else if(polled_req == 10) send_polled_cmd("ADM_STATE;",        STAR_ADM_MSG);    // !!!! 4531

         ++polled_req;
         if(osa_model && (osa_model == 4530) && (polled_req > 6)) {
            polled_req = 0;
            ++all_polled;
         }
         else if(polled_req > 10) {
            polled_req = 0;
            ++all_polled;
         }

         if(no_response_msg) {
            no_response_msg = 0;
            send_polled_cmd("INFO_GPS", STAR_POS_MSG);  // request time and location message
         }

         ++polled_seq;
      }
      else {
         send_polled_cmd("INFO_GPS", STAR_POS_MSG);  // request time and location message
      }
   }
   else {  // STAR-4
      if(test && (polled_q_in != polled_q_out)) {  // we have a special message request queued
         send_queued_cmd(1);
      }
      else if(polled_msg_id == STAR_POS_MSG) { // request next misc message every time message
         if((test == 0) && (polled_q_in != polled_q_out)) {  // we have a special message request queued
            send_queued_cmd(2);
         }
         if(polled_req < 0) polled_req = 0;

         if(1 && ((polled_seq % 3) == 0)) send_polled_cmd("TEMPERATURE;",  STAR_TEMP_MSG); 
         else {
            if     (polled_req == 0)  send_polled_cmd("GPS_TIME;",         STAR_GPS_TIME_MSG);
            else if(polled_req == 1)  send_polled_cmd("MASK_ANGLE;",       STAR_ANGLE_MSG);
            else if(polled_req == 2)  send_polled_cmd("INV;",              STAR_INV_MSG);
            else if(polled_req == 3)  send_polled_cmd("CONF;",             STAR_CONF_MSG);

            else if(polled_req == 4)  send_polled_cmd("ALARM;",            STAR_ALARM_MSG);
            else if(polled_req == 5)  send_polled_cmd("HBSQ;",             STAR_HBSQ_MSG);
            else if(polled_req == 6)  send_polled_cmd("ATDC_STATUS;",      STAR_ATDC_MSG);
            else if(polled_req == 7)  send_polled_cmd("HOLD_PERF_STATUS;", STAR_PERF_MSG);

            else if(polled_req == 8)  send_polled_cmd("OUTPUT_STATE;",     STAR_STATE_MSG);   // !!! multi-line response 
            else if(polled_req == 9)  send_polled_cmd("STATUS;",           STAR_STATUS_MSG);
            else if(polled_req == 10) send_polled_cmd("TOD_STATE;",        STAR_TOD_MSG);
            else if(polled_req == 11) send_polled_cmd("TYPE;",             STAR_TYPE_MSG);
            else if(polled_req == 12) send_polled_cmd("ALARM_MASK;",       STAR_ALMASK_MSG);
            else if(polled_req == 13) send_polled_cmd("INPUT_TYPE(1);",    STAR_INP_TYPE_MSG);

            ++polled_req;
            if(polled_req > 13) {
               polled_req = 0;
               ++all_polled;
            }
         }

         ++polled_seq;
      }
      else {
         send_polled_cmd("INFO_GPS_POS;", STAR_POS_MSG);  // request time and location message
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x19eb5d(%rip), %rax    # 0x204ff8
andl $0x0, (%rax)
leaq 0x19eb57(%rip), %rax    # 0x204ffc
andl $0x0, (%rax)
leaq 0x19eb39(%rip), %rax    # 0x204fe8
cmpl $0x4f, (%rax)
movl 0x2f3b18(%rip), %eax    # 0x359fd0
movl 0x2f3b16(%rip), %ecx    # 0x359fd4
jne 0x66512
cmpl %ecx, %eax
jne 0x6657e
cmpl $0x12b, 0x2f072e(%rip)  # imm = 0x12B
jne 0x6659a
movl 0x2f3afe(%rip), %eax    # 0x359fdc
testl %eax, %eax
js 0x665be
cmpl $0xa, %eax
ja 0x665dc
movl %eax, %eax
leaq 0xa28a0(%rip), %rcx     # 0x108d98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xa4804(%rip), %rdi     # 0x10ad0c
movl $0xca, %esi
jmp 0x665d1
cmpl %ecx, %eax
jne 0x665a3
cmpl $0x12b, 0x2f06dc(%rip)  # imm = 0x12B
jne 0x665ac
movl 0x2f3aac(%rip), %ecx    # 0x359fdc
testl %ecx, %ecx
jns 0x6653d
andl $0x0, 0x2f3aa1(%rip)    # 0x359fdc
xorl %ecx, %ecx
movl 0x2f3a9d(%rip), %eax    # 0x359fe0
pushq $0x3
popq %rsi
xorl %edx, %edx
divl %esi
testl %edx, %edx
je 0x66638
cmpl $0xd, %ecx
ja 0x667bd
movl %ecx, %eax
leaq 0xa27fc(%rip), %rcx     # 0x108d60
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xa7a57(%rip), %rdi     # 0x10dfcb
movl $0xcf, %esi
jmp 0x667a4
pushq $0x1
popq %rdi
callq 0x7dfa9
cmpl $0x0, 0x2ef843(%rip)    # 0x355dd0
je 0x667d0
andl $0x0, 0x2ef836(%rip)    # 0x355dd0
leaq 0xa79d0(%rip), %rdi     # 0x10df71
jmp 0x665b3
pushq $0x1
popq %rdi
popq %rbp
jmp 0x7dfa9
leaq 0xa5104(%rip), %rdi     # 0x10b6b7
movl $0x12b, %esi            # imm = 0x12B
popq %rbp
jmp 0x64f01
andl $0x0, 0x2f3a17(%rip)    # 0x359fdc
leaq 0xa50e6(%rip), %rdi     # 0x10b6b2
movl $0xd0, %esi
callq 0x64f01
movl 0x2f3a00(%rip), %eax    # 0x359fdc
leal 0x1(%rax), %ecx
movl %ecx, 0x2f39f7(%rip)    # 0x359fdc
leaq 0x19ea00(%rip), %rcx    # 0x204fec
cmpl $0x11b2, (%rcx)         # imm = 0x11B2
sete %cl
cmpl $0x6, %eax
setge %dl
andb %cl, %dl
cmpl $0xa, %eax
setge %al
orb %dl, %al
cmpb $0x1, %al
jne 0x66616
andl $0x0, 0x2f39cc(%rip)    # 0x359fdc
incl 0x2ef7b2(%rip)          # 0x355dc8
cmpl $0x0, 0x2ef7b3(%rip)    # 0x355dd0
je 0x667ca
andl $0x0, 0x2ef7a6(%rip)    # 0x355dd0
leaq 0xa7940(%rip), %rdi     # 0x10df71
movl $0x12b, %esi            # imm = 0x12B
jmp 0x66644
leaq 0xa797f(%rip), %rdi     # 0x10dfbe
movl $0xd4, %esi
callq 0x64f01
jmp 0x667ca
leaq 0xa4b82(%rip), %rdi     # 0x10b1d7
movl $0xd5, %esi
jmp 0x665d1
leaq 0xa7942(%rip), %rdi     # 0x10dfa8
movl $0xde, %esi
jmp 0x665d1
leaq 0xa7903(%rip), %rdi     # 0x10df7a
movl $0xcc, %esi
jmp 0x665d1
leaq 0xa7959(%rip), %rdi     # 0x10dfe1
movl $0xd3, %esi
jmp 0x665d1
leaq 0xa78f5(%rip), %rdi     # 0x10df8e
movl $0xe1, %esi
jmp 0x665d1
leaq 0xa78d6(%rip), %rdi     # 0x10df80
movl $0xda, %esi
jmp 0x665d1
leaq 0xa78ca(%rip), %rdi     # 0x10df85
movl $0xc9, %esi
jmp 0x665d1
leaq 0xa78e7(%rip), %rdi     # 0x10dfb3
movl $0xe2, %esi
jmp 0x665d1
leaq 0xa78be(%rip), %rdi     # 0x10df9b
movl $0xe0, %esi
jmp 0x665d1
leaq 0xa78b4(%rip), %rdi     # 0x10dfa2
movl $0xd6, %esi
jmp 0x667a4
leaq 0xa78d6(%rip), %rdi     # 0x10dfd5
movl $0xc8, %esi
jmp 0x667a4
leaq 0xa78f9(%rip), %rdi     # 0x10e009
movl $0xc9, %esi
jmp 0x667a4
leaq 0xa78c0(%rip), %rdi     # 0x10dfe1
movl $0xd3, %esi
jmp 0x667a4
leaq 0xa4f83(%rip), %rdi     # 0x10b6b2
movl $0xd0, %esi
jmp 0x667a4
leaq 0xa45cf(%rip), %rdi     # 0x10ad0c
movl $0xca, %esi
jmp 0x667a4
leaq 0xa789e(%rip), %rdi     # 0x10dfe9
movl $0xd8, %esi
jmp 0x667a4
leaq 0xa4726(%rip), %rdi     # 0x10ae7f
movl $0xd1, %esi
jmp 0x667a4
leaq 0xa7813(%rip), %rdi     # 0x10df7a
movl $0xcc, %esi
jmp 0x667a4
leaq 0xa417a(%rip), %rdi     # 0x10a8ef
movl $0xcb, %esi
jmp 0x667a4
leaq 0xa7859(%rip), %rdi     # 0x10dfdc
movl $0xd7, %esi
jmp 0x667a4
leaq 0xa4a46(%rip), %rdi     # 0x10b1d7
movl $0xd5, %esi
jmp 0x667a4
leaq 0xa785c(%rip), %rdi     # 0x10dffb
movl $0xd2, %esi
callq 0x64f01
movl 0x2f382d(%rip), %eax    # 0x359fdc
leal 0x1(%rax), %ecx
movl %ecx, 0x2f3824(%rip)    # 0x359fdc
cmpl $0xd, %eax
jl 0x667ca
andl $0x0, 0x2f3818(%rip)    # 0x359fdc
incl 0x2ef5fe(%rip)          # 0x355dc8
incl 0x2f3810(%rip)          # 0x359fe0
popq %rbp
retq