// File: 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
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
leaq 0x1e19d6(%rip), %rax    # 0x27a1d8
movl $0x0, (%rax)
leaq 0x1e19cd(%rip), %rax    # 0x27a1dc
movl $0x0, (%rax)
movl $0x1, -0x8(%rbp)
leaq 0x1e19a5(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0x98acb
cmpl $0x0, -0x8(%rbp)
je 0x98873
movl 0x336968(%rip), %eax    # 0x3cf1a0
cmpl 0x336966(%rip), %eax    # 0x3cf1a4
je 0x98873
movl $0x1, %edi
callq 0xbd7c0
cmpl $0x0, 0x33275f(%rip)    # 0x3cafb0
je 0x9886e
movl $0x0, 0x332753(%rip)    # 0x3cafb0
leaq 0xeeab2(%rip), %rdi     # 0x187316
movl $0x12b, %esi            # imm = 0x12B
callq 0x96370
jmp 0x98ac6
cmpl $0x12b, 0x333553(%rip)  # imm = 0x12B
jne 0x98ab3
cmpl $0x0, -0x8(%rbp)
jne 0x988a1
movl 0x336911(%rip), %eax    # 0x3cf1a0
cmpl 0x33690f(%rip), %eax    # 0x3cf1a4
je 0x988a1
movl $0x2, %edi
callq 0xbd7c0
cmpl $0x0, 0x336904(%rip)    # 0x3cf1ac
jge 0x988b4
movl $0x0, 0x3368f8(%rip)    # 0x3cf1ac
cmpl $0x0, 0x3368f1(%rip)    # 0x3cf1ac
jne 0x988d3
leaq 0xec136(%rip), %rdi     # 0x1849fa
movl $0xd0, %esi
callq 0x96370
jmp 0x98a0c
cmpl $0x1, 0x3368d2(%rip)    # 0x3cf1ac
jne 0x988f2
leaq 0xeb761(%rip), %rdi     # 0x184044
movl $0xca, %esi
callq 0x96370
jmp 0x98a0a
cmpl $0x2, 0x3368b3(%rip)    # 0x3cf1ac
jne 0x98911
leaq 0xeea1d(%rip), %rdi     # 0x18731f
movl $0xcc, %esi
callq 0x96370
jmp 0x98a08
cmpl $0x3, 0x336894(%rip)    # 0x3cf1ac
jne 0x98930
leaq 0xeea65(%rip), %rdi     # 0x187386
movl $0xd3, %esi
callq 0x96370
jmp 0x98a06
cmpl $0x4, 0x336875(%rip)    # 0x3cf1ac
jne 0x9894f
leaq 0xebbdf(%rip), %rdi     # 0x18451f
movl $0xd5, %esi
callq 0x96370
jmp 0x98a04
cmpl $0x5, 0x336856(%rip)    # 0x3cf1ac
jne 0x9896e
leaq 0xee9c6(%rip), %rdi     # 0x187325
movl $0xda, %esi
callq 0x96370
jmp 0x98a02
cmpl $0x6, 0x336837(%rip)    # 0x3cf1ac
jne 0x9898a
leaq 0xee9ac(%rip), %rdi     # 0x18732a
movl $0xc9, %esi
callq 0x96370
jmp 0x98a00
cmpl $0x7, 0x33681b(%rip)    # 0x3cf1ac
jne 0x989a6
leaq 0xee999(%rip), %rdi     # 0x187333
movl $0xe1, %esi
callq 0x96370
jmp 0x989fe
cmpl $0x8, 0x3367ff(%rip)    # 0x3cf1ac
jne 0x989c2
leaq 0xee98a(%rip), %rdi     # 0x187340
movl $0xe0, %esi
callq 0x96370
jmp 0x989fc
cmpl $0x9, 0x3367e3(%rip)    # 0x3cf1ac
jne 0x989de
leaq 0xee97b(%rip), %rdi     # 0x18734d
movl $0xde, %esi
callq 0x96370
jmp 0x989fa
cmpl $0xa, 0x3367c7(%rip)    # 0x3cf1ac
jne 0x989f8
leaq 0xee96a(%rip), %rdi     # 0x187358
movl $0xe2, %esi
callq 0x96370
jmp 0x989fa
jmp 0x989fc
jmp 0x989fe
jmp 0x98a00
jmp 0x98a02
jmp 0x98a04
jmp 0x98a06
jmp 0x98a08
jmp 0x98a0a
jmp 0x98a0c
movl 0x33679a(%rip), %eax    # 0x3cf1ac
addl $0x1, %eax
movl %eax, 0x336791(%rip)    # 0x3cf1ac
leaq 0x1e17aa(%rip), %rax    # 0x27a1cc
cmpl $0x0, (%rax)
je 0x98a5a
leaq 0x1e179e(%rip), %rax    # 0x27a1cc
cmpl $0x11b2, (%rax)         # imm = 0x11B2
jne 0x98a5a
cmpl $0x6, 0x33676f(%rip)    # 0x3cf1ac
jle 0x98a5a
movl $0x0, 0x336763(%rip)    # 0x3cf1ac
movl 0x332559(%rip), %eax    # 0x3cafa8
addl $0x1, %eax
movl %eax, 0x332550(%rip)    # 0x3cafa8
jmp 0x98a7e
cmpl $0xa, 0x33674b(%rip)    # 0x3cf1ac
jle 0x98a7c
movl $0x0, 0x33673f(%rip)    # 0x3cf1ac
movl 0x332535(%rip), %eax    # 0x3cafa8
addl $0x1, %eax
movl %eax, 0x33252c(%rip)    # 0x3cafa8
jmp 0x98a7e
cmpl $0x0, 0x33252b(%rip)    # 0x3cafb0
je 0x98aa2
movl $0x0, 0x33251f(%rip)    # 0x3cafb0
leaq 0xee87e(%rip), %rdi     # 0x187316
movl $0x12b, %esi            # imm = 0x12B
callq 0x96370
movl 0x336708(%rip), %eax    # 0x3cf1b0
addl $0x1, %eax
movl %eax, 0x3366ff(%rip)    # 0x3cf1b0
jmp 0x98ac4
leaq 0xee85c(%rip), %rdi     # 0x187316
movl $0x12b, %esi            # imm = 0x12B
callq 0x96370
jmp 0x98ac6
jmp 0x98d6d
cmpl $0x0, -0x8(%rbp)
je 0x98aee
movl 0x3366c9(%rip), %eax    # 0x3cf1a0
cmpl 0x3366c7(%rip), %eax    # 0x3cf1a4
je 0x98aee
movl $0x1, %edi
callq 0xbd7c0
jmp 0x98d6b
cmpl $0x12b, 0x3332d8(%rip)  # imm = 0x12B
jne 0x98d58
cmpl $0x0, -0x8(%rbp)
jne 0x98b1c
movl 0x336696(%rip), %eax    # 0x3cf1a0
cmpl 0x336694(%rip), %eax    # 0x3cf1a4
je 0x98b1c
movl $0x2, %edi
callq 0xbd7c0
cmpl $0x0, 0x336689(%rip)    # 0x3cf1ac
jge 0x98b2f
movl $0x0, 0x33667d(%rip)    # 0x3cf1ac
movl 0x33667b(%rip), %eax    # 0x3cf1b0
movl $0x3, %ecx
xorl %edx, %edx
divl %ecx
cmpl $0x0, %edx
jne 0x98b59
leaq 0xee819(%rip), %rdi     # 0x187363
movl $0xd4, %esi
callq 0x96370
jmp 0x98d47
cmpl $0x0, 0x33664c(%rip)    # 0x3cf1ac
jne 0x98b78
leaq 0xee807(%rip), %rdi     # 0x187370
movl $0xcf, %esi
callq 0x96370
jmp 0x98d14
cmpl $0x1, 0x33662d(%rip)    # 0x3cf1ac
jne 0x98b97
leaq 0xeb62f(%rip), %rdi     # 0x1841b7
movl $0xd1, %esi
callq 0x96370
jmp 0x98d12
cmpl $0x2, 0x33660e(%rip)    # 0x3cf1ac
jne 0x98bb6
leaq 0xebe53(%rip), %rdi     # 0x1849fa
movl $0xd0, %esi
callq 0x96370
jmp 0x98d10
cmpl $0x3, 0x3365ef(%rip)    # 0x3cf1ac
jne 0x98bd5
leaq 0xeb47e(%rip), %rdi     # 0x184044
movl $0xca, %esi
callq 0x96370
jmp 0x98d0e
cmpl $0x4, 0x3365d0(%rip)    # 0x3cf1ac
jne 0x98bf4
leaq 0xee795(%rip), %rdi     # 0x18737a
movl $0xc8, %esi
callq 0x96370
jmp 0x98d0c
cmpl $0x5, 0x3365b1(%rip)    # 0x3cf1ac
jne 0x98c13
leaq 0xee71b(%rip), %rdi     # 0x18731f
movl $0xcc, %esi
callq 0x96370
jmp 0x98d0a
cmpl $0x6, 0x336592(%rip)    # 0x3cf1ac
jne 0x98c32
leaq 0xee75e(%rip), %rdi     # 0x187381
movl $0xd7, %esi
callq 0x96370
jmp 0x98d08
cmpl $0x7, 0x336573(%rip)    # 0x3cf1ac
jne 0x98c51
leaq 0xee74c(%rip), %rdi     # 0x18738e
movl $0xd8, %esi
callq 0x96370
jmp 0x98d06
cmpl $0x8, 0x336554(%rip)    # 0x3cf1ac
jne 0x98c70
leaq 0xee73f(%rip), %rdi     # 0x1873a0
movl $0xd2, %esi
callq 0x96370
jmp 0x98d04
cmpl $0x9, 0x336535(%rip)    # 0x3cf1ac
jne 0x98c8c
leaq 0xee706(%rip), %rdi     # 0x187386
movl $0xd3, %esi
callq 0x96370
jmp 0x98d02
cmpl $0xa, 0x336519(%rip)    # 0x3cf1ac
jne 0x98ca8
leaq 0xeb883(%rip), %rdi     # 0x18451f
movl $0xd5, %esi
callq 0x96370
jmp 0x98d00
cmpl $0xb, 0x3364fd(%rip)    # 0x3cf1ac
jne 0x98cc4
leaq 0xee68f(%rip), %rdi     # 0x187347
movl $0xd6, %esi
callq 0x96370
jmp 0x98cfe
cmpl $0xc, 0x3364e1(%rip)    # 0x3cf1ac
jne 0x98ce0
leaq 0xee6da(%rip), %rdi     # 0x1873ae
movl $0xc9, %esi
callq 0x96370
jmp 0x98cfc
cmpl $0xd, 0x3364c5(%rip)    # 0x3cf1ac
jne 0x98cfa
leaq 0xeaf37(%rip), %rdi     # 0x183c27
movl $0xcb, %esi
callq 0x96370
jmp 0x98cfc
jmp 0x98cfe
jmp 0x98d00
jmp 0x98d02
jmp 0x98d04
jmp 0x98d06
jmp 0x98d08
jmp 0x98d0a
jmp 0x98d0c
jmp 0x98d0e
jmp 0x98d10
jmp 0x98d12
jmp 0x98d14
movl 0x336492(%rip), %eax    # 0x3cf1ac
addl $0x1, %eax
movl %eax, 0x336489(%rip)    # 0x3cf1ac
cmpl $0xd, 0x336482(%rip)    # 0x3cf1ac
jle 0x98d45
movl $0x0, 0x336476(%rip)    # 0x3cf1ac
movl 0x33226c(%rip), %eax    # 0x3cafa8
addl $0x1, %eax
movl %eax, 0x332263(%rip)    # 0x3cafa8
jmp 0x98d47
movl 0x336463(%rip), %eax    # 0x3cf1b0
addl $0x1, %eax
movl %eax, 0x33645a(%rip)    # 0x3cf1b0
jmp 0x98d69
leaq 0xebca0(%rip), %rdi     # 0x1849ff
movl $0x12b, %esi            # imm = 0x12B
callq 0x96370
jmp 0x98d6b
jmp 0x98d6d
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)