// File: jkingan[P]ladyheather/heathgps.cpp
// Function: send_queued_cmd(int)
int send_queued_cmd(int why)
{
int id;

   // send the next message in the request queue to the receiver

   if(polled_q_in == polled_q_out) return 0;
   id = polled_q[polled_q_out].id;

if(debug_file) fprintf(debug_file, "SEND Q %d: sqe:%d  old_id=%d: %s  why:%d\n", polled_q_out, polled_q_entries, polled_msg_id, polled_q[polled_q_out].msg, why);

   send_polled_cmd(polled_q[polled_q_out].msg, polled_q[polled_q_out].id);


   if(++polled_q_out >= POLLED_Q_SIZE) polled_q_out = 0;
   --polled_q_entries;

   if(rcvr_type == STAR_RCVR) ;
   else if(rcvr_type == BRANDY_RCVR) ;
   else if((id == SCPI_TEST_MSG) && (scpi_type != UCCMP_TYPE)) {
      if(sim_file == 0) Sleep(20000);    // wait for reset to complete

      erase_screen();
      vidstr(0,0, YELLOW, "Re-establishing communications in 30 seconds...");
      refresh_page();

      drain_com_data();      // flush com data
      reset_com_timer(RCVR_PORT);
      polled_q_in = 0;           // reset SCPI message send queue pointers
      polled_q_out = 0;
      polled_q_entries = 0;
      polled_req = 0;
      polled_seq = 0;
      need_redraw = 3487;
   }
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl 0x3119cf(%rip), %eax    # 0x3cf1a0
cmpl 0x3119cd(%rip), %eax    # 0x3cf1a4
jne 0xbd7e5
movl $0x0, -0x4(%rbp)
jmp 0xbd997
movslq 0x3119b8(%rip), %rcx    # 0x3cf1a4
leaq 0x30e61d(%rip), %rax    # 0x3cbe10
imulq $0x84, %rcx, %rcx
addq %rcx, %rax
movl 0x80(%rax), %eax
movl %eax, -0xc(%rbp)
leaq 0x1dfd63(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xbd85c
leaq 0x1dfd56(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movl 0x311981(%rip), %edx    # 0x3cf1a4
movl 0x31197f(%rip), %ecx    # 0x3cf1a8
movl 0x30e5a0(%rip), %r8d    # 0x3cbdd0
movslq 0x31196d(%rip), %rax    # 0x3cf1a4
leaq 0x30e5d2(%rip), %r9     # 0x3cbe10
imulq $0x84, %rax, %rax
addq %rax, %r9
movl -0x8(%rbp), %eax
leaq 0xcad19(%rip), %rsi     # 0x18856b
movl %eax, (%rsp)
movb $0x0, %al
callq 0x9550
movslq 0x311941(%rip), %rax    # 0x3cf1a4
leaq 0x30e5a6(%rip), %rdi    # 0x3cbe10
imulq $0x84, %rax, %rax
addq %rax, %rdi
movslq 0x311929(%rip), %rcx    # 0x3cf1a4
leaq 0x30e58e(%rip), %rax    # 0x3cbe10
imulq $0x84, %rcx, %rcx
addq %rcx, %rax
movl 0x80(%rax), %esi
callq 0x96370
movl 0x311907(%rip), %eax    # 0x3cf1a4
addl $0x1, %eax
movl %eax, 0x3118fe(%rip)    # 0x3cf1a4
cmpl $0x64, %eax
jl 0xbd8b5
movl $0x0, 0x3118ef(%rip)    # 0x3cf1a4
movl 0x3118ed(%rip), %eax    # 0x3cf1a8
addl $-0x1, %eax
movl %eax, 0x3118e4(%rip)    # 0x3cf1a8
leaq 0x1ba1e5(%rip), %rax    # 0x277ab0
cmpq $0x1000, (%rax)         # imm = 0x1000
jne 0xbd8d9
jmp 0xbd990
leaq 0x1ba1d0(%rip), %rax    # 0x277ab0
cmpq $0x40000, (%rax)        # imm = 0x40000
jne 0xbd8ee
jmp 0xbd98e
cmpl $0x19, -0xc(%rbp)
jne 0xbd98c
leaq 0x1bc8c1(%rip), %rax    # 0x27a1c0
cmpl $0x50, (%rax)
je 0xbd98c
leaq 0x1dfc91(%rip), %rax    # 0x29d5a0
cmpq $0x0, (%rax)
jne 0xbd91f
movl $0x4e20, %edi           # imm = 0x4E20
callq 0xb8b0
callq 0x117e0
xorl %esi, %esi
movl $0xe, %edx
leaq 0xcac63(%rip), %rcx     # 0x188595
movl %esi, %edi
callq 0x10ee0
callq 0xb0d0
callq 0x7a150
movl $0xa, %edi
callq 0x2bd30
movl $0x0, 0x311849(%rip)    # 0x3cf1a0
movl $0x0, 0x311843(%rip)    # 0x3cf1a4
movl $0x0, 0x31183d(%rip)    # 0x3cf1a8
movl $0x0, 0x311837(%rip)    # 0x3cf1ac
movl $0x0, 0x311831(%rip)    # 0x3cf1b0
leaq 0x1ba09e(%rip), %rax    # 0x277a24
movl $0xd9f, (%rax)          # imm = 0xD9F
jmp 0xbd98e
jmp 0xbd990
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq