// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::strsendcmd(bamboo::stream_t*, char const*)
extern void strsendcmd(stream_t *str, const char *cmd)
	{
		unsigned char buff[1024];
		const char *p = cmd, *q;
		char msg[1024], cmdend[] = "\r\n";
		int n, m, ms, brate;

		tracet(3, "strsendcmd: cmd=%s\n", cmd);

		for (;;) {
			for (q = p;; q++) if (*q == '\r' || *q == '\n' || *q == '\0') break;
			n = (int)(q - p); strncpy(msg, p, n); msg[n] = '\0';

			if (!*msg || *msg == '#') { /* null or comment */
				;
			}
			else if (*msg == '!') { /* binary escape */

				if (!strncmp(msg + 1, "WAIT", 4)) { /* wait */
					if (sscanf(msg + 5, "%d", &ms) < 1) ms = 100;
					if (ms > 3000) ms = 3000; /* max 3 s */
					sleepms(ms);
				}
				else if (!strncmp(msg + 1, "BRATE", 5)) { /* set bitrate */
					if (sscanf(msg + 6, "%d", &brate) < 1) brate = 9600;
					set_brate(str, brate);
					sleepms(500);
				}
				//            else if (!strncmp(msg+1,"UBX",3)) { /* ublox */
				//                if ((m=gen_ubx(msg+4,buff))>0) strwrite(str,buff,m);
				//            }
				//            else if (!strncmp(msg+1,"STQ",3)) { /* skytraq */
				//                if ((m=gen_stq(msg+4,buff))>0) strwrite(str,buff,m);
				//            }
				//            else if (!strncmp(msg+1,"NVS",3)) { /* nvs */
				//                if ((m=gen_nvs(msg+4,buff))>0) strwrite(str,buff,m);
				//            }
				else if (!strncmp(msg + 1, "LEXR", 4)) { /* lex receiver */
					if ((m = gen_lexr(msg + 5, buff)) > 0) strwrite(str, buff, m);
				}
				else if (!strncmp(msg + 1, "HEX", 3)) { /* general hex message */
					if ((m = gen_hex(msg + 4, buff)) > 0) strwrite(str, buff, m);
				}
			}
			else {
				strcat(msg, cmdend);
				strwrite(str, (unsigned char *)msg, n + 2);
			}
			if (*q == '\0') break; else p = q + 1;
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x840, %rsp            # imm = 0x840
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x418(%rbp)
movw 0x265cd(%rip), %ax      # 0xc9bf2
movw %ax, -0x823(%rbp)
movb 0x265c2(%rip), %al      # 0xc9bf4
movb %al, -0x821(%rbp)
movq -0x10(%rbp), %rdx
movl $0x3, %edi
leaq 0x25673(%rip), %rsi     # 0xc8cbb
movb $0x0, %al
callq 0x95890
movq -0x418(%rbp), %rax
movq %rax, -0x420(%rbp)
movq -0x420(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
je 0xa368a
movq -0x420(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0xa368a
movq -0x420(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xa368c
jmp 0xa36a2
jmp 0xa368e
movq -0x420(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x420(%rbp)
jmp 0xa365d
movq -0x420(%rbp), %rax
movq -0x418(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x828(%rbp)
leaq -0x820(%rbp), %rdi
movq -0x418(%rbp), %rsi
movslq -0x828(%rbp), %rdx
callq 0x93b0
movslq -0x828(%rbp), %rax
movb $0x0, -0x820(%rbp,%rax)
cmpb $0x0, -0x820(%rbp)
je 0xa36f7
movsbl -0x820(%rbp), %eax
cmpl $0x23, %eax
jne 0xa36fc
jmp 0xa38dc
movsbl -0x820(%rbp), %eax
cmpl $0x21, %eax
jne 0xa38ae
leaq -0x820(%rbp), %rdi
addq $0x1, %rdi
leaq 0x255b1(%rip), %rsi     # 0xc8ccf
movl $0x4, %edx
callq 0x9360
cmpl $0x0, %eax
jne 0xa3782
leaq -0x820(%rbp), %rdi
addq $0x5, %rdi
leaq 0x257bb(%rip), %rsi     # 0xc8efa
leaq -0x830(%rbp), %rdx
movb $0x0, %al
callq 0x9750
cmpl $0x1, %eax
jge 0xa375c
movl $0x64, -0x830(%rbp)
cmpl $0xbb8, -0x830(%rbp)    # imm = 0xBB8
jle 0xa3772
movl $0xbb8, -0x830(%rbp)    # imm = 0xBB8
movl -0x830(%rbp), %edi
callq 0x8f910
jmp 0xa38ac
leaq -0x820(%rbp), %rdi
addq $0x1, %rdi
leaq 0x25540(%rip), %rsi     # 0xc8cd4
movl $0x5, %edx
callq 0x9360
cmpl $0x0, %eax
jne 0xa37f0
leaq -0x820(%rbp), %rdi
addq $0x6, %rdi
leaq 0x25745(%rip), %rsi     # 0xc8efa
leaq -0x834(%rbp), %rdx
movb $0x0, %al
callq 0x9750
cmpl $0x1, %eax
jge 0xa37d2
movl $0x2580, -0x834(%rbp)   # imm = 0x2580
movq -0x8(%rbp), %rdi
movl -0x834(%rbp), %esi
callq 0xa3910
movl $0x1f4, %edi            # imm = 0x1F4
callq 0x8f910
jmp 0xa38aa
leaq -0x820(%rbp), %rdi
addq $0x1, %rdi
leaq 0x254d8(%rip), %rsi     # 0xc8cda
movl $0x4, %edx
callq 0x9360
cmpl $0x0, %eax
jne 0xa384b
leaq -0x820(%rbp), %rdi
addq $0x5, %rdi
leaq -0x410(%rbp), %rsi
callq 0x997d0
movl %eax, -0x82c(%rbp)
cmpl $0x0, %eax
jle 0xa3849
movq -0x8(%rbp), %rdi
leaq -0x410(%rbp), %rsi
movl -0x82c(%rbp), %edx
callq 0xa09c0
jmp 0xa38a8
leaq -0x820(%rbp), %rdi
addq $0x1, %rdi
leaq 0x25482(%rip), %rsi     # 0xc8cdf
movl $0x3, %edx
callq 0x9360
cmpl $0x0, %eax
jne 0xa38a6
leaq -0x820(%rbp), %rdi
addq $0x4, %rdi
leaq -0x410(%rbp), %rsi
callq 0xa3a60
movl %eax, -0x82c(%rbp)
cmpl $0x0, %eax
jle 0xa38a4
movq -0x8(%rbp), %rdi
leaq -0x410(%rbp), %rsi
movl -0x82c(%rbp), %edx
callq 0xa09c0
jmp 0xa38a6
jmp 0xa38a8
jmp 0xa38aa
jmp 0xa38ac
jmp 0xa38da
leaq -0x820(%rbp), %rdi
leaq -0x823(%rbp), %rsi
callq 0x9d40
movq -0x8(%rbp), %rdi
leaq -0x820(%rbp), %rsi
movl -0x828(%rbp), %edx
addl $0x2, %edx
callq 0xa09c0
jmp 0xa38dc
movq -0x420(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xa38ed
jmp 0xa3904
movq -0x420(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x418(%rbp)
jmp 0xa364f
addq $0x840, %rsp            # imm = 0x840
popq %rbp
retq
nopl (%rax)