// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::strwrite(bamboo::stream_t*, unsigned char*, int)
extern int strwrite(stream_t *stream, unsigned char *buff, int n)
	{
		unsigned int tick;
		char *msg = stream->msg;
		int ns;

		tracet(4, "strwrite: n=%d\n", n);

		if (!(stream->mode&STR_MODE_W) || !stream->port) return 0;

		strlock(stream);

		switch (stream->type) {
		case STR_SERIAL: ns = writeserial((serial_t *)stream->port, buff, n, msg); break;
		case STR_FILE: ns = writefile((file_t   *)stream->port, buff, n, msg); break;
		case STR_TCPSVR: ns = writetcpsvr((tcpsvr_t *)stream->port, buff, n, msg); break;
		case STR_TCPCLI: ns = writetcpcli((tcpcli_t *)stream->port, buff, n, msg); break;
		case STR_NTRIPSVR:
		case STR_NTRIPCLI: ns = writentrip((ntrip_t  *)stream->port, buff, n, msg); break;
		case STR_NTRIPC_S:
		case STR_NTRIPC_C: ns = writentripc((ntripc_t *)stream->port, buff, n, msg); break;
		case STR_UDPCLI: ns = writeudpcli((udp_t    *)stream->port, buff, n, msg); break;
		case STR_MEMBUF: ns = writemembuf((membuf_t *)stream->port, buff, n, msg); break;
		case STR_VRSCONCLI: ns = writevrsconcli((vrscon_cli_t*)stream->port, buff, n, msg); break;
		case STR_VRSCONSVR: ns = writevrsconsvr((vrscon_svr_t*)stream->port, buff, n, msg); break;
		case STR_FTP:
		case STR_HTTP:

		default:
			strunlock(stream);
			return 0;
		}
		stream->outb += ns;
		tick = tickget(); if (ns > 0) stream->tact = tick;

		if ((int)(tick - stream->tick_o) > tirate) {
			stream->outr = (int)((double)(stream->outb - stream->outbt) * 8000 / (tick - stream->tick_o));
			stream->tick_o = tick; stream->outbt = stream->outb;
		}
		strunlock(stream);
		return ns;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r12
leaq 0x1b29c(%rip), %rsi     # 0x75e76
xorl %r15d, %r15d
movl $0x4, %edi
xorl %eax, %eax
callq 0x53ec4
testb $0x2, 0x4(%r12)
je 0x5b527
cmpq $0x0, 0x58(%r12)
je 0x5b527
leaq 0x30(%r12), %r13
movq %r13, %rdi
callq 0x8910
movl (%r12), %eax
xorl %r15d, %r15d
decl %eax
cmpl $0xf, %eax
ja 0x5b51f
leaq 0x460(%r12), %rcx
leaq 0x1b081(%rip), %rdx     # 0x75cb0
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
movl %ebx, -0x34(%rbp)
movq %r12, -0xa0(%rbp)
movq %r13, -0x98(%rbp)
jmpq *%rax
movl %ebx, %edx
movq 0x58(%r12), %rbx
leaq 0x1c6f7(%rip), %rsi     # 0x7734e
xorl %r15d, %r15d
movl $0x3, %edi
xorl %eax, %eax
movq %rcx, %r13
callq 0x53ec4
movq %rbx, %rdi
movq %r13, %r12
movq %r13, %rsi
callq 0x5db7f
testl %eax, %eax
je 0x5b4c3
movq 0x8510(%rbx), %rdi
movq %r14, %rsi
movl -0x34(%rbp), %edx
movq %r12, %rcx
jmp 0x5b100
movq %r14, -0x58(%rbp)
movq 0x58(%r12), %r12
leaq 0x1c6bc(%rip), %rsi     # 0x77360
movl $0x4, %edi
movl %ebx, %edx
xorl %eax, %eax
movq %rcx, %rbx
callq 0x53ec4
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5e3dd
leaq 0x8(%r12), %rcx
leaq 0x8548(%r12), %r13
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %rcx, -0x30(%rbp)
cmpl $0x0, -0x8208(%r13)
je 0x5ad9a
cmpb $0x0, (%rcx)
je 0x5ad08
leaq -0x8204(%r13), %rsi
movq -0x30(%rbp), %rdi
callq 0x8890
movq -0x30(%rbp), %rcx
testl %eax, %eax
jne 0x5ad9a
movl 0x820f40(%r12), %eax
cmpl $-0x1, %eax
je 0x5ad1b
cmpl (%r13), %eax
jne 0x5ad9a
movq 0x338(%r12), %rax
movl 0x240(%rax,%r14), %edi
movq -0x58(%rbp), %rsi
movl -0x34(%rbp), %r15d
movl %r15d, %edx
callq 0x5edf0
cmpl %r15d, %eax
movq %rax, %r15
jge 0x5ad81
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
je 0x5ad75
movq 0x338(%r12), %rax
movl 0x240(%rax,%r14), %ecx
movl $0x1, %edi
leaq 0x1c607(%rip), %rsi     # 0x77373
movl %ebx, %edx
xorl %eax, %eax
callq 0x53ec4
movq %r12, %rdi
movl %ebx, %esi
callq 0x5ecaa
jmp 0x5ad96
callq 0x5088f
movq 0x338(%r12), %rcx
movl %eax, 0x248(%rcx,%r14)
movq -0x30(%rbp), %rcx
incl %ebx
addq $0x128, %r14            # imm = 0x128
addq $0x820c, %r13           # imm = 0x820C
cmpq $0x12800, %r14          # imm = 0x12800
jne 0x5acd9
jmp 0x5b4c3
movq 0x58(%r12), %rbx
movq %rbx, %rdi
movq %rcx, %rsi
movq %rcx, %r15
callq 0x5f3cd
testl %eax, %eax
je 0x5b25f
movq 0x608(%rbx), %rdi
movq %r14, %rsi
movl -0x34(%rbp), %edx
movq %r15, %rcx
jmp 0x5b100
movq 0x58(%r12), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x5b53c
jmp 0x5b105
movq %r14, -0x58(%rbp)
movq 0x58(%r12), %r14
movq %r14, %rdi
movq %rcx, %rsi
callq 0x5f457
leaq 0x610(%r14), %rax
movq %rax, -0x40(%rbp)
xorl %ecx, %ecx
xorl %r15d, %r15d
movl -0x34(%rbp), %ebx
cmpl $0x0, -0x34(%rbp)
movq %rcx, -0x30(%rbp)
jle 0x5aea1
movq %rcx, %rax
shlq $0xa, %rax
leaq (%rax,%rcx,8), %rax
movq -0x40(%rbp), %rcx
cmpl $0x0, (%rcx,%rax)
je 0x5aea1
xorl %r12d, %r12d
imulq $0x128, -0x30(%rbp), %r13 # imm = 0x128
movq 0x608(%r14), %rax
movl 0x240(%rax,%r13), %edi
movslq %r12d, %rax
movq -0x58(%rbp), %rcx
leaq (%rcx,%rax), %rsi
movl %ebx, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
xorl %ecx, %ecx
callq 0x8320
movq %rax, %r15
testl %r15d, %r15d
jle 0x5b1ec
callq 0x5088f
movq 0x608(%r14), %rcx
movl %eax, 0x248(%rcx,%r13)
addl %r15d, %r12d
cmpl %ebx, %r12d
jl 0x5ae51
movq -0x30(%rbp), %rcx
incq %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x5ae27
jmp 0x5b4c3
movl %ebx, %r13d
movq 0x58(%r12), %rbx
movl (%rbx), %edx
leaq 0x1c2f9(%rip), %rsi     # 0x771c4
xorl %r15d, %r15d
movl $0x3, %edi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x53ec4
movl (%rbx), %edi
movslq %r13d, %rdx
movq %r14, %rsi
callq 0x8230
testq %rax, %rax
jns 0x5aef6
movl $0x1, 0x4(%rbx)
movl (%rbx), %edx
leaq 0x1c2df(%rip), %rsi     # 0x771de
movl $0x5, %edi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x53ec4
jmp 0x5b4c3
movq %rcx, -0x40(%rbp)
movq 0x58(%r12), %r15
movq %r15, -0x30(%rbp)
callq 0x5088f
movl %eax, -0x7c(%rbp)
movl %eax, -0x4c(%rbp)
movq (%r15), %rdx
leaq 0x1c2ca(%rip), %rsi     # 0x771fe
xorl %r15d, %r15d
movl $0x3, %edi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x53ec4
callq 0x4febe
movq %rax, %rdi
callq 0x5040e
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rax
movsd %xmm0, -0x70(%rbp)
movsd 0x880(%rax), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x5b35f
movq 0x848(%rax), %rdi
testq %rdi, %rdi
je 0x5b35f
movq %r14, -0x58(%rbp)
mulsd 0xf92f(%rip), %xmm1     # 0x6a8c0
movsd %xmm1, -0x60(%rbp)
movsd 0x850(%rax), %xmm0
leaq -0xb0(%rbp), %rbx
movq %rbx, %rsi
callq 0x4fc2d
movsd %xmm0, -0x90(%rbp)
leaq -0xac(%rbp), %r14
movq -0x78(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
movq %r14, %rsi
callq 0x4fc2d
movl (%r14), %eax
subl (%rbx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x10e07(%rip), %xmm1    # 0x6bde8
cvtsi2sdl 0x34ebf(%rip), %xmm2 # 0x8fea8
movsd %xmm2, -0x48(%rbp)
addsd %xmm0, %xmm1
movsd %xmm1, -0x88(%rbp)
movsd -0x90(%rbp), %xmm0
addsd %xmm2, %xmm0
divsd -0x60(%rbp), %xmm0
callq 0x8ad0
movsd %xmm0, -0x68(%rbp)
movsd -0x88(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
divsd -0x60(%rbp), %xmm0
callq 0x8ad0
ucomisd -0x68(%rbp), %xmm0
jbe 0x5b2bd
movq -0x78(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
callq 0x4fe63
movq -0x30(%rbp), %r14
movq (%r14), %rbx
movq %rax, -0x68(%rbp)
movq %rax, %rdi
movsd %xmm0, -0x48(%rbp)
xorl %esi, %esi
callq 0x5077f
leaq 0x1c1d3(%rip), %rsi     # 0x7723e
movl $0x3, %edi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x53ec4
cmpq $0x0, 0x10(%r14)
jne 0x5b2bd
cmpq $0x0, 0x18(%r14)
jne 0x5b2bd
leaq 0x20(%r14), %rdi
leaq 0xf557(%rip), %rcx      # 0x6a5f5
leaq -0x4b0(%rbp), %rsi
movq -0x68(%rbp), %rbx
movq %rbx, %rdx
movsd -0x48(%rbp), %xmm0
movq %rcx, %r8
callq 0x5422a
leaq 0x420(%r14), %rsi
leaq -0x4b0(%rbp), %rdi
callq 0x8890
testl %eax, %eax
je 0x5b2a3
movups (%r14), %xmm0
movups %xmm0, 0x10(%r14)
movq %r14, %rdi
movq %rbx, %rsi
movsd -0x48(%rbp), %xmm0
movq -0x40(%rbp), %rdx
callq 0x5ca8c
jmp 0x5b2bd
movq 0x58(%r12), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x5b63d
movl %eax, %r15d
jmp 0x5b4c3
movq %rcx, -0x40(%rbp)
movl %ebx, %edx
movq %r14, %rbx
movq 0x58(%r12), %r14
leaq 0x1c299(%rip), %rsi     # 0x773bb
xorl %r15d, %r15d
movl $0x3, %edi
xorl %eax, %eax
callq 0x53ec4
testq %r14, %r14
je 0x5b4c3
leaq 0x10(%r14), %r12
movq %r12, %rdi
callq 0x8910
movl -0x34(%rbp), %eax
testl %eax, %eax
jle 0x5b267
movl %eax, %eax
xorl %r15d, %r15d
movq -0x40(%rbp), %r8
movb (%rbx,%r15), %cl
movq 0x38(%r14), %rdx
movslq 0x4(%r14), %rsi
leal 0x1(%rsi), %edi
movl %edi, 0x4(%r14)
movb %cl, (%rdx,%rsi)
movl 0x4(%r14), %ecx
cmpl 0xc(%r14), %ecx
jl 0x5b182
movl $0x0, 0x4(%r14)
movl 0x4(%r14), %ecx
cmpl 0x8(%r14), %ecx
je 0x5b277
incq %r15
cmpq %r15, %rax
jne 0x5b15a
jmp 0x5b26a
movl %ebx, %r15d
movq 0x58(%r12), %rbx
movl 0x11c(%rbx), %edx
leaq 0x1c1ee(%rip), %rsi     # 0x773a0
movl $0x4, %edi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x53ec4
movl 0x11c(%rbx), %edi
movslq %r15d, %rdx
addq $0x10c, %rbx            # imm = 0x10C
movq %r14, %rsi
xorl %ecx, %ecx
movq %rbx, %r8
movl $0x10, %r9d
callq 0x80b0
movq %rax, %r15
jmp 0x5b4c3
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
movq -0x30(%rbp), %rbx
je 0x5b221
movq 0x608(%r14), %rax
movl 0x240(%rax,%r13), %ecx
leaq 0x1c160(%rip), %rsi     # 0x77373
movl $0x1, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x53ec4
movl %ebx, %ebx
imulq $0x128, %rbx, %rdi      # imm = 0x128
addq 0x608(%r14), %rdi
addq $0x128, %rdi            # imm = 0x128
movl 0x34c62(%rip), %esi     # 0x8fea0
callq 0x5d761
movq %rbx, %rax
shlq $0xa, %rax
leaq (%rax,%rbx,8), %rax
movq -0x40(%rbp), %rcx
movb $0x0, 0x8(%rcx,%rax)
movq $0x0, (%rcx,%rax)
xorl %r15d, %r15d
jmp 0x5b4c3
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x84b0
jmp 0x5b4c3
movupd 0x1c14f(%rip), %xmm0    # 0x773ce
movupd %xmm0, (%r8)
movl $0x776f6c, 0x10(%r8)    # imm = 0x776F6C
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
movq %r12, %rdi
callq 0x84b0
incl %r15d
jmp 0x5b4c3
leaq 0x1bfad(%rip), %rsi     # 0x77257
leaq -0x4b0(%rbp), %rdx
movl $0x2, %edi
xorl %eax, %eax
callq 0x53ec4
xorps %xmm1, %xmm1
cvtsi2sdl 0x34be0(%rip), %xmm1 # 0x8fea8
movsd %xmm1, -0x48(%rbp)
movsd -0x90(%rbp), %xmm0
subsd %xmm1, %xmm0
divsd -0x60(%rbp), %xmm0
callq 0x8ad0
movsd %xmm0, -0x40(%rbp)
movsd -0x88(%rbp), %xmm0
subsd -0x48(%rbp), %xmm0
divsd -0x60(%rbp), %xmm0
callq 0x8ad0
ucomisd -0x40(%rbp), %xmm0
movq -0x58(%rbp), %r14
movl -0x34(%rbp), %ebx
movq -0x30(%rbp), %rax
jbe 0x5b35f
movq 0x10(%rax), %rdx
leaq 0x1bf59(%rip), %rsi     # 0x77275
movl $0x3, %edi
xorl %eax, %eax
callq 0x53ec4
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x5b33e
callq 0x8630
movq -0x30(%rbp), %rax
leaq 0x10(%rax), %rbx
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x5b354
callq 0x8630
movq -0x30(%rbp), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movl -0x34(%rbp), %ebx
movq (%rax), %rcx
testq %rcx, %rcx
je 0x5b4c3
movslq %ebx, %rbx
movl $0x1, %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x8c40
movq %rax, %r15
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x8030
movq %rax, -0x4b0(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x8770
movq -0x30(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x848(%rax)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x850(%rax)
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x5b3fa
movl $0x1, %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x8c40
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x8030
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x8770
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x5b49f
movl -0x7c(%rbp), %edx
subl 0x858(%rax), %edx
leaq -0x4c(%rbp), %rdi
movl %edx, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
callq 0x8c40
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
leaq -0x4b0(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x8c40
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x8770
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0x5b49f
leaq -0x4c(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x8c40
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x8c40
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x8770
movq -0x30(%rbp), %rax
movq (%rax), %rdx
movl -0x4c(%rbp), %r8d
movq -0x4b0(%rbp), %r9
leaq 0x1bd61(%rip), %rsi     # 0x77215
movl $0x5, %edi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x53ec4
movq -0xa0(%rbp), %rbx
addl %r15d, 0x14(%rbx)
callq 0x5088f
testl %r15d, %r15d
jle 0x5b4db
movl %eax, 0x24(%rbx)
movl %eax, %ecx
subl 0x20(%rbx), %ecx
cmpl 0x349b2(%rip), %ecx     # 0x8fe98
movq -0x98(%rbp), %r13
jle 0x5b51f
movl 0x14(%rbx), %edx
movl %edx, %esi
subl 0x2c(%rbx), %esi
xorps %xmm0, %xmm0
cvtsi2sd %rsi, %xmm0
mulsd 0x1a8c9(%rip), %xmm0    # 0x75dd0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x18(%rbx)
movl %eax, 0x20(%rbx)
movl %edx, 0x2c(%rbx)
movq %r13, %rdi
callq 0x84b0
movl %r15d, %eax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq