// File: /workspace/github_cpp_makefile_star2_O3/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 0x1ab594(%rip), %rax    # 0x21aff8
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0x1ab58d(%rip), %rax    # 0x21affc
movl %ecx, (%rax)
leaq 0x1ab570(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
movl 0x30054f(%rip), %eax    # 0x36ffd0
movl 0x30054d(%rip), %ecx    # 0x36ffd4
jne 0x6fadb
cmpl %ecx, %eax
jne 0x6fb4b
cmpl $0x12b, 0x2fd165(%rip)  # imm = 0x12B
jne 0x6fb6c
movl 0x300535(%rip), %eax    # 0x36ffdc
testl %eax, %eax
js 0x6fb92
cmpl $0xa, %eax
ja 0x6fbb3
movl %eax, %eax
leaq 0xaf397(%rip), %rcx     # 0x11ee58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xb12f3(%rip), %rdi     # 0x120dc4
movl $0xca, %esi
jmp 0x6fba8
cmpl %ecx, %eax
jne 0x6fb75
cmpl $0x12b, 0x2fd113(%rip)  # imm = 0x12B
jne 0x6fb80
movl 0x3004e3(%rip), %eax    # 0x36ffdc
testl %eax, %eax
jns 0x6fb09
movl $0x0, 0x3004d5(%rip)    # 0x36ffdc
xorl %eax, %eax
imull $0xaaaaaaab, 0x3004cd(%rip), %ecx # imm = 0xAAAAAAAB
cmpl $0x55555555, %ecx       # imm = 0x55555555
jbe 0x6fc15
cmpl $0xd, %eax
ja 0x6fd9a
movl %eax, %eax
leaq 0xaf2ef(%rip), %rcx     # 0x11ee20
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xb4542(%rip), %rdi     # 0x124083
movl $0xcf, %esi
jmp 0x6fd81
movl $0x1, %edi
callq 0x8aadd
cmpl $0x0, 0x2fc274(%rip)    # 0x36bdd0
je 0x6fdb0
movl $0x0, 0x2fc264(%rip)    # 0x36bdd0
leaq 0xb44b6(%rip), %rdi     # 0x124029
jmp 0x6fb87
movl $0x1, %edi
popq %rbp
jmp 0x8aadd
leaq 0xb1be8(%rip), %rdi     # 0x12176f
movl $0x12b, %esi            # imm = 0x12B
popq %rbp
jmp 0x6e2d1
movl $0x0, 0x300440(%rip)    # 0x36ffdc
leaq 0xb1bc7(%rip), %rdi     # 0x12176a
movl $0xd0, %esi
callq 0x6e2d1
movl 0x300429(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x300420(%rip)    # 0x36ffdc
leaq 0x1ab429(%rip), %rcx    # 0x21afec
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 0x6fbf0
movl $0x0, 0x3003f2(%rip)    # 0x36ffdc
incl 0x2fc1d8(%rip)          # 0x36bdc8
cmpl $0x0, 0x2fc1d9(%rip)    # 0x36bdd0
je 0x6fdaa
movl $0x0, 0x2fc1c9(%rip)    # 0x36bdd0
leaq 0xb441b(%rip), %rdi     # 0x124029
movl $0x12b, %esi            # imm = 0x12B
jmp 0x6fc21
leaq 0xb445a(%rip), %rdi     # 0x124076
movl $0xd4, %esi
callq 0x6e2d1
jmp 0x6fdaa
leaq 0xb165d(%rip), %rdi     # 0x12128f
movl $0xd5, %esi
jmp 0x6fba8
leaq 0xb441d(%rip), %rdi     # 0x124060
movl $0xde, %esi
jmp 0x6fba8
leaq 0xb43de(%rip), %rdi     # 0x124032
movl $0xcc, %esi
jmp 0x6fba8
leaq 0xb4434(%rip), %rdi     # 0x124099
movl $0xd3, %esi
jmp 0x6fba8
leaq 0xb43d0(%rip), %rdi     # 0x124046
movl $0xe1, %esi
jmp 0x6fba8
leaq 0xb43b1(%rip), %rdi     # 0x124038
movl $0xda, %esi
jmp 0x6fba8
leaq 0xb43a5(%rip), %rdi     # 0x12403d
movl $0xc9, %esi
jmp 0x6fba8
leaq 0xb43c2(%rip), %rdi     # 0x12406b
movl $0xe2, %esi
jmp 0x6fba8
leaq 0xb4399(%rip), %rdi     # 0x124053
movl $0xe0, %esi
jmp 0x6fba8
leaq 0xb438f(%rip), %rdi     # 0x12405a
movl $0xd6, %esi
jmp 0x6fd81
leaq 0xb43b1(%rip), %rdi     # 0x12408d
movl $0xc8, %esi
jmp 0x6fd81
leaq 0xb43d4(%rip), %rdi     # 0x1240c1
movl $0xc9, %esi
jmp 0x6fd81
leaq 0xb439b(%rip), %rdi     # 0x124099
movl $0xd3, %esi
jmp 0x6fd81
leaq 0xb1a5e(%rip), %rdi     # 0x12176a
movl $0xd0, %esi
jmp 0x6fd81
leaq 0xb10aa(%rip), %rdi     # 0x120dc4
movl $0xca, %esi
jmp 0x6fd81
leaq 0xb4379(%rip), %rdi     # 0x1240a1
movl $0xd8, %esi
jmp 0x6fd81
leaq 0xb1201(%rip), %rdi     # 0x120f37
movl $0xd1, %esi
jmp 0x6fd81
leaq 0xb42ee(%rip), %rdi     # 0x124032
movl $0xcc, %esi
jmp 0x6fd81
leaq 0xb0c55(%rip), %rdi     # 0x1209a7
movl $0xcb, %esi
jmp 0x6fd81
leaq 0xb4334(%rip), %rdi     # 0x124094
movl $0xd7, %esi
jmp 0x6fd81
leaq 0xb1521(%rip), %rdi     # 0x12128f
movl $0xd5, %esi
jmp 0x6fd81
leaq 0xb4337(%rip), %rdi     # 0x1240b3
movl $0xd2, %esi
callq 0x6e2d1
movl 0x300250(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x300247(%rip)    # 0x36ffdc
cmpl $0xd, %eax
jl 0x6fdaa
movl $0x0, 0x300238(%rip)    # 0x36ffdc
incl 0x2fc01e(%rip)          # 0x36bdc8
incl 0x300230(%rip)          # 0x36ffe0
popq %rbp
retq