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

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


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

      if(0 && ((polled_seq % 3) == 0)) ;
      else if(1 && (polled_seq % 20)) {  // rate limit messages due to low baud rate
        if(use_a_time)  send_polled_cmd("a", BRANDY_TIME_MSG);  // request "a" time
        else            send_polled_cmd("t", BRANDY_TIME_MSG);  // request "t" time
      }
      else {
         if     (polled_req == 0)  send_polled_cmd("a", BRANDY_VERSION_MSG);
         else if(polled_req == 1)  send_polled_cmd("c", BRANDY_PULSE_MSG);
         else if(polled_req == 2)  send_polled_cmd("e", BRANDY_CODE_MSG);
         else if(polled_req == 3)  send_polled_cmd("h", BRANDY_HEALTH_MSG);   //long
         else if(polled_req == 4)  send_polled_cmd("j", BRANDY_LEAP_MSG);
         else if(polled_req == 5)  send_polled_cmd("p", BRANDY_POSN_MSG);     //long
         else if(polled_req == 6)  send_polled_cmd("n", BRANDY_FW_MSG);
         else if(polled_req == 7)  send_polled_cmd("d", BRANDY_DOP_MSG);      //long
         else if(polled_req == 8)  send_polled_cmd("s", BRANDY_INFO_MSG);
//       else if(polled_req == 9)  send_polled_cmd("f", BRANDY_FREQ_MSG);     //long
//       else if(polled_req == 10) send_polled_cmd("o", BRANDY_ZONE_MSG);

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

      ++polled_seq;
   }
   else {
      if(use_a_time)  send_polled_cmd("a", BRANDY_TIME_MSG);  // request "a" time
      else            send_polled_cmd("t", BRANDY_TIME_MSG);  // request "t" time
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x1, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0xbd5a2
movl 0x311c15(%rip), %eax    # 0x3cf1a0
cmpl 0x311c13(%rip), %eax    # 0x3cf1a4
je 0xbd5a2
movl $0x1, %edi
callq 0xbd7c0
jmp 0xbd7b4
cmpl $0x19b, 0x30e824(%rip)  # imm = 0x19B
jne 0xbd783
cmpl $0x0, -0x4(%rbp)
jne 0xbd5d0
movl 0x311be2(%rip), %eax    # 0x3cf1a0
cmpl 0x311be0(%rip), %eax    # 0x3cf1a4
je 0xbd5d0
movl $0x2, %edi
callq 0xbd7c0
cmpl $0x0, 0x311bd5(%rip)    # 0x3cf1ac
jge 0xbd5e3
movl $0x0, 0x311bc9(%rip)    # 0x3cf1ac
movl 0x311bc7(%rip), %eax    # 0x3cf1b0
movl $0x14, %ecx
xorl %edx, %edx
divl %ecx
cmpl $0x0, %edx
je 0xbd629
cmpl $0x0, 0x30e7ce(%rip)    # 0x3cbdcc
je 0xbd613
leaq 0xdb181(%rip), %rdi     # 0x198788
movl $0x19b, %esi            # imm = 0x19B
callq 0x96370
jmp 0xbd624
leaq 0xbab57(%rip), %rdi     # 0x178171
movl $0x19b, %esi            # imm = 0x19B
callq 0x96370
jmp 0xbd772
cmpl $0x0, 0x311b7c(%rip)    # 0x3cf1ac
jne 0xbd648
leaq 0xdb14f(%rip), %rdi     # 0x198788
movl $0x190, %esi            # imm = 0x190
callq 0x96370
jmp 0xbd73f
cmpl $0x1, 0x311b5d(%rip)    # 0x3cf1ac
jne 0xbd667
leaq 0xd2fab(%rip), %rdi     # 0x190603
movl $0x191, %esi            # imm = 0x191
callq 0x96370
jmp 0xbd73d
cmpl $0x2, 0x311b3e(%rip)    # 0x3cf1ac
jne 0xbd686
leaq 0xb7f3b(%rip), %rdi     # 0x1755b2
movl $0x192, %esi            # imm = 0x192
callq 0x96370
jmp 0xbd73b
cmpl $0x3, 0x311b1f(%rip)    # 0x3cf1ac
jne 0xbd6a5
leaq 0xbe8f7(%rip), %rdi     # 0x17bf8d
movl $0x194, %esi            # imm = 0x194
callq 0x96370
jmp 0xbd739
cmpl $0x4, 0x311b00(%rip)    # 0x3cf1ac
jne 0xbd6c1
leaq 0xca816(%rip), %rdi     # 0x187ecb
movl $0x195, %esi            # imm = 0x195
callq 0x96370
jmp 0xbd737
cmpl $0x5, 0x311ae4(%rip)    # 0x3cf1ac
jne 0xbd6dd
leaq 0xb4d36(%rip), %rdi     # 0x172407
movl $0x199, %esi            # imm = 0x199
callq 0x96370
jmp 0xbd735
cmpl $0x6, 0x311ac8(%rip)    # 0x3cf1ac
jne 0xbd6f9
leaq 0xb4d4a(%rip), %rdi     # 0x172437
movl $0x197, %esi            # imm = 0x197
callq 0x96370
jmp 0xbd733
cmpl $0x7, 0x311aac(%rip)    # 0x3cf1ac
jne 0xbd715
leaq 0xbe87e(%rip), %rdi     # 0x17bf87
movl $0x19c, %esi            # imm = 0x19C
callq 0x96370
jmp 0xbd731
cmpl $0x8, 0x311a90(%rip)    # 0x3cf1ac
jne 0xbd72f
leaq 0xbe874(%rip), %rdi     # 0x17bf99
movl $0x19a, %esi            # imm = 0x19A
callq 0x96370
jmp 0xbd731
jmp 0xbd733
jmp 0xbd735
jmp 0xbd737
jmp 0xbd739
jmp 0xbd73b
jmp 0xbd73d
jmp 0xbd73f
movl 0x311a67(%rip), %eax    # 0x3cf1ac
addl $0x1, %eax
movl %eax, 0x311a5e(%rip)    # 0x3cf1ac
cmpl $0x8, 0x311a57(%rip)    # 0x3cf1ac
jle 0xbd770
movl $0x0, 0x311a4b(%rip)    # 0x3cf1ac
movl 0x30d841(%rip), %eax    # 0x3cafa8
addl $0x1, %eax
movl %eax, 0x30d838(%rip)    # 0x3cafa8
jmp 0xbd772
movl 0x311a38(%rip), %eax    # 0x3cf1b0
addl $0x1, %eax
movl %eax, 0x311a2f(%rip)    # 0x3cf1b0
jmp 0xbd7b2
cmpl $0x0, 0x30e642(%rip)    # 0x3cbdcc
je 0xbd79f
leaq 0xdaff5(%rip), %rdi     # 0x198788
movl $0x19b, %esi            # imm = 0x19B
callq 0x96370
jmp 0xbd7b0
leaq 0xba9cb(%rip), %rdi     # 0x178171
movl $0x19b, %esi            # imm = 0x19B
callq 0x96370
jmp 0xbd7b2
jmp 0xbd7b4
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)