// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1428, %rsp           # imm = 0x1428
movq %rsi, %r14
movq %rdi, %r13
leaq 0x1a399(%rip), %rsi     # 0x75f1b
movl $0x3, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x5342c
leaq 0x60(%r13), %rax
movq %rax, -0x48(%rbp)
movabsq $0x100000000, %rbx      # imm = 0x100000000
movl $0x2401, %ecx           # imm = 0x2401
movq %r14, %rsi
incq %r14
movl $0x2, %r15d
xorl %r12d, %r12d
movzbl -0x1(%r14), %eax
cmpl $0xd, %eax
ja 0x5bbc6
btl %eax, %ecx
jb 0x5bbd1
incq %r14
addq %rbx, %r12
incl %r15d
jmp 0x5bbb7
sarq $0x20, %r12
leaq -0x450(%rbp), %rdi
movq %r12, %rdx
callq 0x8350
movb $0x0, -0x450(%rbp,%r12)
movzbl -0x450(%rbp), %eax
testl %eax, %eax
leaq -0x1450(%rbp), %r12
je 0x5bf20
cmpl $0x23, %eax
je 0x5bf20
cmpl $0x21, %eax
jne 0x5bd67
cmpl $0x54494157, -0x44f(%rbp) # imm = 0x54494157
je 0x5bd9b
movl -0x44f(%rbp), %eax
movl $0x54415242, %ecx       # imm = 0x54415242
xorl %ecx, %eax
movzbl -0x44b(%rbp), %ecx
xorl $0x45, %ecx
orl %eax, %ecx
je 0x5bdd8
cmpl $0x5258454c, -0x44f(%rbp) # imm = 0x5258454C
je 0x5bdfb
movzwl -0x44f(%rbp), %eax
xorl $0x4548, %eax           # imm = 0x4548
movzbl -0x44d(%rbp), %ecx
xorl $0x58, %ecx
orw %ax, %cx
jne 0x5bf20
leaq -0x860(%rbp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movl $0x4, %edi
leaq 0x1b954(%rip), %rsi     # 0x775e0
leaq -0x44c(%rbp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x4d55d
movl $0x3ff, %edx            # imm = 0x3FF
leaq -0xc50(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x8350
movq %r12, %rdi
leaq 0x19811(%rip), %rsi     # 0x754cf
callq 0x89b0
leaq -0x850(%rbp), %r15
testq %rax, %rax
je 0x5bd45
movq %r13, -0x38(%rbp)
xorl %ecx, %ecx
leaq 0x197f3(%rip), %r15     # 0x754cf
movq %rcx, %r12
movq %rax, -0x1450(%rbp,%rcx,8)
xorl %edi, %edi
movq %r15, %rsi
callq 0x89b0
cmpq $0xfe, %r12
ja 0x5bd04
leaq 0x1(%r12), %rcx
testq %rax, %rax
jne 0x5bcdc
movq $-0x1, %r13
leaq -0x850(%rbp), %r15
movq -0x1448(%rbp,%r13,8), %rdi
leaq 0x1b8d0(%rip), %rsi     # 0x775f1
leaq -0x40(%rbp), %rdx
xorl %eax, %eax
callq 0x8610
testl %eax, %eax
je 0x5bd39
movb -0x40(%rbp), %al
movb %al, (%r15)
incq %r15
incq %r13
cmpq %r13, %r12
jne 0x5bd12
movq -0x38(%rbp), %r13
leaq -0x850(%rbp), %rax
subl %eax, %r15d
testl %r15d, %r15d
jle 0x5bf20
movq %r13, %rdi
leaq -0x850(%rbp), %rsi
movl %r15d, %edx
jmp 0x5bd91
leaq -0x450(%rbp), %r12
movq %r12, %rdi
callq 0x8290
movw $0xa0d, -0x450(%rbp,%rax) # imm = 0xA0D
movb $0x0, -0x44e(%rbp,%rax)
movq %r13, %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0x59f9f
jmp 0x5bf20
leaq -0x44b(%rbp), %rdi
leaq 0x1a382(%rip), %rsi     # 0x7612b
leaq -0x2c(%rbp), %rdx
xorl %eax, %eax
callq 0x8610
testl %eax, %eax
jle 0x5be27
movl -0x2c(%rbp), %edi
cmpl $0xbb9, %edi            # imm = 0xBB9
jl 0x5bf1b
movl $0xbb8, -0x2c(%rbp)     # imm = 0xBB8
movl $0xbb8, %edi            # imm = 0xBB8
jmp 0x5bf1b
leaq -0x44a(%rbp), %rdi
leaq 0x1a345(%rip), %rsi     # 0x7612b
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x8610
testl %eax, %eax
jle 0x5be38
movl -0x30(%rbp), %r15d
jmp 0x5be45
leaq -0x44b(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x55d07
testl %eax, %eax
jle 0x5bf20
movq %r13, %rdi
leaq -0x850(%rbp), %rsi
movl %eax, %edx
jmp 0x5bd91
movl $0x64, -0x2c(%rbp)
movl $0x64, %edi
jmp 0x5bf1b
movl $0x2580, -0x30(%rbp)    # imm = 0x2580
movl $0x2580, %r15d          # imm = 0x2580
leaq -0xc50(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x8390
cmpl $0x1, (%r13)
jne 0x5bf16
movl %r15d, -0x38(%rbp)
movl 0x4(%r13), %eax
movl %eax, -0x3c(%rbp)
movq %r12, %rdi
movq -0x48(%rbp), %rsi
callq 0x85c0
movq %r12, %rdi
movl $0x3a, %esi
callq 0x8250
testq %rax, %rax
je 0x5bed4
movq %rax, %r12
leaq 0x1(%rax), %rdi
movl $0x3a, %esi
callq 0x8250
testq %rax, %rax
leaq -0xc50(%rbp), %r15
je 0x5beb4
movq %r15, %rdi
movq %rax, %rsi
callq 0x85c0
movq %r12, %rdi
leaq 0x1b71c(%rip), %rsi     # 0x775da
movl -0x38(%rbp), %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x8120
leaq -0x1450(%rbp), %r15
jmp 0x5befb
movq %r12, %r15
movq %r12, %rdi
callq 0x8290
leaq (%rax,%rbp), %rdi
addq $-0x1450, %rdi          # imm = 0xEBB0
leaq 0xfd97(%rip), %rsi      # 0x6bc88
movl -0x38(%rbp), %edx
xorl %eax, %eax
callq 0x8120
movq %r13, %rdi
callq 0x58f13
movq %r13, %rdi
movl $0x1, %esi
movl -0x3c(%rbp), %edx
movq %r15, %rcx
callq 0x57dbf
movl $0x1f4, %edi            # imm = 0x1F4
callq 0x4ff28
cmpb $0x0, -0x1(%r14)
movl $0x2401, %ecx           # imm = 0x2401
jne 0x5bba8
addq $0x1428, %rsp           # imm = 0x1428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq