// File: /workspace/github_cpp_makefile_star2_O2/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, %r12
leaq 0x19456(%rip), %rsi     # 0x6bf5b
pushq $0x3
popq %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x4acf2
leaq 0x60(%r12), %rax
movq %rax, -0x50(%rbp)
movabsq $0x100000000, %rbx      # imm = 0x100000000
movl $0x2401, %ecx           # imm = 0x2401
movq %r12, -0x40(%rbp)
movq %r14, %rsi
incq %r14
pushq $0x2
popq %r15
xorl %r13d, %r13d
movzbl -0x1(%r14), %eax
cmpl $0xd, %eax
ja 0x52b4a
btl %eax, %ecx
jb 0x52b55
incq %r14
addq %rbx, %r13
incl %r15d
jmp 0x52b3b
sarq $0x20, %r13
leaq -0x450(%rbp), %rdi
movq %r13, %rdx
callq 0x8360
movb $0x0, -0x450(%rbp,%r13)
movzbl -0x450(%rbp), %eax
testl %eax, %eax
je 0x52e91
cmpl $0x23, %eax
je 0x52e91
cmpl $0x21, %eax
jne 0x52c68
leaq -0x44f(%rbp), %r15
cmpl $0x54494157, (%r15)     # imm = 0x54494157
je 0x52c9c
movq %r15, %rdi
leaq 0x193c4(%rip), %rsi     # 0x6bf74
pushq $0x5
popq %rdx
callq 0x8640
testl %eax, %eax
je 0x52cd9
cmpl $0x5258454c, (%r15)     # imm = 0x5258454C
je 0x52d03
movq %r15, %rdi
leaq 0x193a8(%rip), %rsi     # 0x6bf7f
pushq $0x3
popq %rdx
callq 0x8640
testl %eax, %eax
jne 0x52e91
leaq -0x860(%rbp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
pushq $0x4
popq %rdi
leaq 0x1aa22(%rip), %rsi     # 0x6d620
leaq -0x44c(%rbp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x455bc
movl $0x3ff, %edx            # imm = 0x3FF
leaq -0xc50(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x8360
movq %r13, %rdi
leaq 0x188b5(%rip), %r15     # 0x6b4e5
movq %r15, %rsi
callq 0x89a0
xorl %r13d, %r13d
testq %rax, %rax
je 0x52d3e
cmpq $0x100, %r13            # imm = 0x100
jae 0x52d3e
movq %rax, -0x1450(%rbp,%r13,8)
incq %r13
xorl %edi, %edi
movq %r15, %rsi
callq 0x89a0
jmp 0x52c3b
leaq -0x450(%rbp), %r13
movq %r13, %rdi
callq 0x8290
movw $0xa0d, -0x450(%rbp,%rax) # imm = 0xA0D
movb $0x0, -0x44e(%rbp,%rax)
movq %r12, %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x51054
jmp 0x52e91
leaq -0x44b(%rbp), %rdi
leaq 0x194c1(%rip), %rsi     # 0x6c16b
leaq -0x2c(%rbp), %rdx
xorl %eax, %eax
callq 0x8600
testl %eax, %eax
jle 0x52d2f
movl -0x2c(%rbp), %edi
cmpl $0xbb9, %edi            # imm = 0xBB9
jl 0x52e8c
movl $0xbb8, -0x2c(%rbp)     # imm = 0xBB8
movl $0xbb8, %edi            # imm = 0xBB8
jmp 0x52e8c
leaq -0x44a(%rbp), %rdi
leaq 0x19484(%rip), %rsi     # 0x6c16b
leaq -0x34(%rbp), %rdx
xorl %eax, %eax
callq 0x8600
testl %eax, %eax
jle 0x52da2
movl -0x34(%rbp), %r15d
jmp 0x52daf
leaq -0x44b(%rbp), %rdi
leaq -0x850(%rbp), %rsi
callq 0x4d1e9
testl %eax, %eax
jle 0x52e91
movq %r12, %rdi
leaq -0x850(%rbp), %rsi
movl %eax, %edx
jmp 0x52c92
movl $0x64, -0x2c(%rbp)
pushq $0x64
popq %rdi
jmp 0x52e8c
xorl %r12d, %r12d
leaq -0x850(%rbp), %r15
cmpq %r12, %r13
je 0x52d79
movq -0x1450(%rbp,%r12,8), %rdi
leaq 0x1a8d5(%rip), %rsi     # 0x6d631
leaq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x8600
testl %eax, %eax
je 0x52d74
movb -0x48(%rbp), %al
movb %al, (%r15)
incq %r15
incq %r12
jmp 0x52d48
leaq -0x850(%rbp), %rax
subl %eax, %r15d
testl %r15d, %r15d
movq -0x40(%rbp), %r12
jle 0x52e91
movq %r12, %rdi
leaq -0x850(%rbp), %rsi
movl %r15d, %edx
jmp 0x52c92
movl $0x2580, -0x34(%rbp)    # imm = 0x2580
movl $0x2580, %r15d          # imm = 0x2580
leaq -0xc50(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x8390
cmpl $0x1, (%r12)
jne 0x52e87
movl %r15d, -0x30(%rbp)
movl 0x4(%r12), %eax
movl %eax, -0x44(%rbp)
leaq -0x1450(%rbp), %r15
movq %r15, %rdi
movq -0x50(%rbp), %rsi
callq 0x85c0
movq %r15, %rdi
pushq $0x3a
popq %r12
movl %r12d, %esi
callq 0x8250
testq %rax, %rax
je 0x52e46
movq %rax, %r13
leaq 0x1(%rax), %rdi
movl %r12d, %esi
callq 0x8250
testq %rax, %rax
leaq -0xc50(%rbp), %r15
je 0x52e26
movq %r15, %rdi
movq %rax, %rsi
callq 0x85c0
movq %r13, %rdi
leaq 0x1a7ea(%rip), %rsi     # 0x6d61a
movl -0x30(%rbp), %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x8110
leaq -0x1450(%rbp), %r15
jmp 0x52e6a
movq %r15, %rdi
callq 0x8290
leaq (%rax,%rbp), %rdi
addq $-0x1450, %rdi          # imm = 0xEBB0
leaq 0xee28(%rip), %rsi      # 0x61c88
movl -0x30(%rbp), %edx
xorl %eax, %eax
callq 0x8110
movq -0x40(%rbp), %r12
movq %r12, %rdi
callq 0x5009c
movq %r12, %rdi
pushq $0x1
popq %rsi
movl -0x44(%rbp), %edx
movq %r15, %rcx
callq 0x4efdc
movl $0x1f4, %edi            # imm = 0x1F4
callq 0x47c59
cmpb $0x0, -0x1(%r14)
movl $0x2401, %ecx           # imm = 0x2401
jne 0x52b2e
addq $0x1428, %rsp           # imm = 0x1428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq