// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: send_user_cmd(char*)
void send_user_cmd(char *s)
{
unsigned i;
int val;
int p;
char *u;
int show_user_cmd;

   // send a user specified (ASCII) command to a receiver
   if(s == 0) return;
   // NEW_RCVR
   ++user_msg_num;

   debug_text2[0] = 0;
   show_user_cmd = 0;
   u = "user";

   strcpy(last_user_cmd, s);
   if(rcvr_type == ACRON_RCVR) {
      send_acron_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == BRANDY_RCVR) {
      if(s[0] == '$') queue_brandy_cmd(&s[0], SCPI_USER_MSG);
      else            queue_brandy_cmd(&s[0], SCPI_USER_MSG); 
      show_user_cmd = 1;
   }
   else if(rcvr_type == CS_RCVR) {
      queue_cs_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == ESIP_RCVR) {
      send_esip_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == FURUNO_RCVR) {
      send_furuno_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == GPSD_RCVR) { // send ascii string
      send_nmea_string(s, 0);
      eom_flag = EOM;
      send_byte(0x0A);
      eom_flag = ADD_CHAR;
      show_user_cmd = 2;
   }
   else if(rcvr_type == LPFRS_RCVR) {
      queue_sro_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == NMEA_RCVR) {
      if(s[0] == '$') send_nmea_cmd(&s[1]);
      else            send_nmea_cmd(&s[0]);
      show_user_cmd = 2;
   }
   else if(rcvr_type == PRS_RCVR) {
      if(strchr(s, '?'))       queue_prs_cmd(s, SCPI_USER_MSG);
      else if(prs_vb == 0)     queue_prs_cmd(s, -SCPI_USER_MSG);  // commands have no response
      else if(strstr(s, "LM")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else if(strstr(s, "lm")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else if(strstr(s, "LO")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else if(strstr(s, "lo")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else                     queue_prs_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == SA35_RCVR) {
      queue_sa35_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == SCPI_RCVR) {
      queue_scpi_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == SRO_RCVR) {
      queue_sro_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == STAR_RCVR) {
      queue_star_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == THERMO_RCVR) { // send ascii string
      send_nmea_string(s, 0);
      eom_flag = EOM;
      send_byte(0x0D);
      eom_flag = ADD_CHAR;
      show_user_cmd = 2;
   }
   else if(rcvr_type == TM4_RCVR) {
      send_tm4_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == TRUE_RCVR) {
      send_true_cmd(s);   // send a user specified message
      show_user_cmd = 2;
   }
   else if(rcvr_type == TSERVE_RCVR) {
      send_nmea_string(s, 0);
      send_byte(0x0D);
      eom_flag = EOM;
      send_byte(0x0A);
      eom_flag = ADD_CHAR;
      show_user_cmd = 2;
   }
   else if(rcvr_type == UCCM_RCVR) {
      queue_uccm_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == X72_RCVR) {
      queue_x72_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 2;
   }
   else if(rcvr_type == Z12_RCVR) {
      if(s[0] == '$') send_z12_cmd(&s[1]);
      else            send_z12_cmd(&s[0]);
      show_user_cmd = 2;
   }
   else if(rcvr_type == ZYFER_RCVR) {
      if(s[0] == '$') send_nmea_cmd(&s[1]);
      else            send_nmea_cmd(&s[0]);
      show_user_cmd = 2;
   }
   else if(ASCII_RCVR) { // send ascii string
      send_ascii_string(s, 1);
      show_user_cmd = 2;
   }
   else if(1) {  // send hex string
      strupr(s);
      p = 0;
      val = 0;
      for(i=0; i<strlen(s); i++) {
         if((s[i] >= '0') && (s[i] <= '9')) {
            val = (val*16) + (s[i] - '0');
            p = 1;
         }
         else if((s[i] >= 'A') && (s[i] <= 'F')) {
            val = (val*16) + (s[i] - 'A' + 10);
            p = 1;
         }
         else if(p) {
            eom_flag = EOM;
            send_byte(val & 0xFF);
            eom_flag = ADD_CHAR;
            val = 0;
            p = 0;
         }
      }
      if(p) {
         eom_flag = EOM;
         send_byte(val & 0xFF);
         eom_flag = ADD_CHAR;
         val = 0;
         p = 0;
      }
      show_user_cmd = 3;
      u = "user hex";
   }

   if(show_user_cmd) {
      sprintf(debug_text3, "sent %s cmd %d:%s", u, user_msg_num, s);
      if(debug_file) fprintf(debug_file, "sent %s cmd %d:%s\n", u, user_msg_num, s);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x5ec75
movq %rdi, %rbx
incl 0x30d4f6(%rip)          # 0x36be14
leaq 0x2e01cb(%rip), %rax    # 0x33eaf0
movb $0x0, (%rax)
leaq 0x2e0bb1(%rip), %rdi    # 0x33f4e0
movq %rbx, %rsi
callq 0x9340
leaq 0x1b9f92(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
jle 0x5e992
cmpq $0x1fffffff, %rax       # imm = 0x1FFFFFFF
jle 0x5e9cb
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jg 0x5ea35
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x5eb69
cmpq $0x40000000, %rax       # imm = 0x40000000
je 0x5ebc6
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x5eb13
movq %rbx, %rdi
callq 0x5ee9b
jmp 0x5ec16
cmpq $0x3fff, %rax           # imm = 0x3FFF
jg 0x5ea00
cmpq $0xf, %rax
jle 0x5eb07
cmpq $0x10, %rax
je 0x5eb4c
cmpq $0x200, %rax            # imm = 0x200
je 0x5eb9f
cmpq $0x1000, %rax           # imm = 0x1000
je 0x5eb4c
jmp 0x5eb13
cmpq $0x1ffffff, %rax        # imm = 0x1FFFFFF
jle 0x5ea73
cmpq $0x2000000, %rax        # imm = 0x2000000
je 0x5eb4c
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x5eb4c
cmpq $0x10000000, %rax       # imm = 0x10000000
je 0x5eb4c
jmp 0x5eb13
cmpq $0x3ffff, %rax          # imm = 0x3FFFF
jle 0x5eb38
cmpq $0x40000, %rax          # imm = 0x40000
je 0x5eb4c
cmpq $0x80000, %rax          # imm = 0x80000
je 0x5ebab
cmpq $0x100000, %rax         # imm = 0x100000
je 0x5eb5e
jmp 0x5eb13
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
je 0x5eb76
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x5ebfa
movabsq $0x1000000000, %rcx     # imm = 0x1000000000
cmpq %rcx, %rax
je 0x5eb4c
jmp 0x5eb13
cmpq $0x200000, %rax         # imm = 0x200000
je 0x5eb88
cmpq $0x1000000, %rax        # imm = 0x1000000
jne 0x5eb13
movq %rbx, %rdi
movl $0x3f, %esi
callq 0x9100
testq %rax, %rax
jne 0x5eb4c
leaq 0x1bc044(%rip), %rax    # 0x21aaec
cmpl $0x0, (%rax)
je 0x5eafd
leaq 0xc474a(%rip), %rsi     # 0x1231fe
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5eafd
leaq 0xc46ed(%rip), %rsi     # 0x1231b5
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5eafd
leaq 0xc53bb(%rip), %rsi     # 0x123e97
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5eafd
leaq 0xc1987(%rip), %rsi     # 0x120477
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
je 0x5eb4c
movq %rbx, %rdi
movl $0xffffffdb, %esi       # imm = 0xFFFFFFDB
jmp 0x5eb54
cmpq $0x2, %rax
je 0x5eb5e
cmpq $0x8, %rax
je 0x5eb4c
movabsq $0x5fb3f521a, %rcx      # imm = 0x5FB3F521A
movq %rbx, %rdi
testq %rcx, %rax
je 0x5ec84
movl $0x1, %esi
callq 0x5e85f
jmp 0x5ec16
cmpq $0x4000, %rax           # imm = 0x4000
je 0x5ec04
cmpq $0x20000, %rax          # imm = 0x20000
jne 0x5eb13
movq %rbx, %rdi
movl $0x25, %esi
callq 0x5edda
jmp 0x5ec16
cmpb $0x24, (%rbx)
jne 0x5eb95
leaq 0x1(%rbx), %rdi
jmp 0x5eb98
movq %rbx, %rdi
callq 0x5eff8
jmp 0x5ec16
cmpb $0x24, (%rbx)
jne 0x5ec0e
leaq 0x1(%rbx), %rdi
jmp 0x5ec11
movq %rbx, %rdi
callq 0x5f228
jmp 0x5ec16
movq %rbx, %rdi
callq 0x5f0e5
jmp 0x5ec16
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e8a6
jmp 0x5ebda
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e8a6
movl $0x1, 0x30d251(%rip)    # 0x36be10
movl $0xd, %edi
jmp 0x5ebe9
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e8a6
movl $0xd, %edi
callq 0x590f7
movl $0x1, 0x30d22c(%rip)    # 0x36be10
movl $0xa, %edi
callq 0x590f7
movl $0x0, 0x30d218(%rip)    # 0x36be10
jmp 0x5ec16
movq %rbx, %rdi
callq 0x5f170
jmp 0x5ec16
movq %rbx, %rdi
callq 0x5ed67
jmp 0x5ec16
movq %rbx, %rdi
callq 0x5f2c8
leaq 0xc1855(%rip), %r14     # 0x120472
movl 0x30d1f1(%rip), %ecx    # 0x36be14
leaq 0x2e0016(%rip), %rdi    # 0x33ec40
leaq 0xc1852(%rip), %rsi     # 0x120483
movq %r14, %rdx
movq %rbx, %r8
xorl %eax, %eax
callq 0x9060
leaq 0x1df74b(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x5ec75
movl 0x30d1c1(%rip), %ecx    # 0x36be14
leaq 0xc183b(%rip), %rsi     # 0x120495
movq %r14, %rdx
movq %rbx, %r8
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9560
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x9899
leaq 0xc17ea(%rip), %r14     # 0x12047a
cmpb $0x0, (%rbx)
je 0x5ec1d
xorl %r12d, %r12d
movl $0x1, %r15d
xorl %ecx, %ecx
movq $0x0, -0x38(%rbp)
movzbl (%rbx,%r12), %eax
leal -0x30(%rax), %edx
cmpb $0x9, %dl
ja 0x5ecc3
movq -0x38(%rbp), %rcx
shll $0x4, %ecx
movzbl %dl, %eax
orl %eax, %ecx
jmp 0x5ecd7
leal -0x41(%rax), %edx
cmpb $0x5, %dl
ja 0x5ed00
movq -0x38(%rbp), %rcx
shll $0x4, %ecx
addl %eax, %ecx
addl $-0x37, %ecx
movq %rcx, -0x38(%rbp)
movl $0x1, %r13d
movl $0x0, -0x2c(%rbp)
movl %r15d, %r12d
movq %rbx, %rdi
callq 0x9120
incl %r15d
movl %r13d, %ecx
cmpq %r12, %rax
ja 0x5eca8
jmp 0x5ed3b
xorl %r13d, %r13d
movb $0x1, %al
testl %ecx, %ecx
jne 0x5ed0e
movl %eax, -0x2c(%rbp)
jmp 0x5ece8
movl %eax, -0x2c(%rbp)
movl $0x1, 0x30d0f5(%rip)    # 0x36be10
movzbl -0x38(%rbp), %edi
callq 0x590f7
movl $0x0, 0x30d0e2(%rip)    # 0x36be10
movq $0x0, -0x38(%rbp)
xorl %r13d, %r13d
jmp 0x5ece8
cmpb $0x0, -0x2c(%rbp)
jne 0x5ec1d
movl $0x1, 0x30d0c1(%rip)    # 0x36be10
movzbl -0x38(%rbp), %edi
callq 0x590f7
movl $0x0, 0x30d0ae(%rip)    # 0x36be10
jmp 0x5ec1d