// File: /workspace/github_cpp_makefile_star2_O2/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 0x1adef(%rip), %rsi     # 0x6be66
xorl %r15d, %r15d
pushq $0x4
popq %rdi
xorl %eax, %eax
callq 0x4acf2
testb $0x2, 0x4(%r12)
je 0x51976
cmpq $0x0, 0x58(%r12)
je 0x51976
leaq 0x30(%r12), %r13
movq %r13, %rdi
callq 0x8900
movl (%r12), %eax
decl %eax
cmpl $0xf, %eax
ja 0x5169d
leaq 0x460(%r12), %rcx
leaq 0x1abd9(%rip), %rdx     # 0x6bca0
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
movq %rbx, -0x40(%rbp)
movq %r13, -0xa0(%rbp)
jmpq *%rax
movq %r14, -0x50(%rbp)
movq %rbx, %r14
movq 0x58(%r12), %rbx
leaq 0x1c225(%rip), %rsi     # 0x6d313
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %r14d, %edx
xorl %eax, %eax
movq %rcx, %r13
callq 0x4acf2
movq %rbx, %rdi
movq %r13, -0x30(%rbp)
movq %r13, %rsi
callq 0x53e95
testl %eax, %eax
je 0x51913
movq 0x8510(%rbx), %rdi
movq -0x50(%rbp), %rsi
movl %r14d, %edx
movq -0x30(%rbp), %rcx
jmp 0x515bc
movq %r14, -0x50(%rbp)
movq %r12, -0x70(%rbp)
movq 0x58(%r12), %r14
leaq 0x1c1e2(%rip), %rsi     # 0x6d325
pushq $0x4
popq %rdi
movl %ebx, %edx
xorl %eax, %eax
movq %rcx, %rbx
callq 0x4acf2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x54663
movq %r14, %rcx
leaq 0x8(%r14), %r12
leaq 0x8548(%r14), %r13
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %rcx, -0x30(%rbp)
movq %r12, -0x38(%rbp)
cmpq $0x12800, %r14          # imm = 0x12800
je 0x51270
cmpl $0x0, -0x8208(%r13)
je 0x5125a
cmpb $0x0, (%r12)
je 0x511b8
leaq -0x8204(%r13), %rsi
movq %r12, %rdi
callq 0x8890
movq -0x30(%rbp), %rcx
testl %eax, %eax
jne 0x5125a
movl 0x820f40(%rcx), %eax
cmpl $-0x1, %eax
je 0x511cd
cmpl (%r13), %eax
jne 0x5125a
movq 0x338(%rcx), %rax
movq %rcx, %r12
movl 0x240(%rax,%r14), %edi
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %r15
movl %r15d, %edx
callq 0x55008
cmpl %r15d, %eax
movq %rax, %r15
jge 0x5123e
callq 0x533ff
testl %eax, %eax
je 0x51229
movq -0x30(%rbp), %rcx
movq 0x338(%rcx), %rcx
movl 0x240(%rcx,%r14), %ecx
pushq $0x1
popq %rdi
leaq 0x1c11b(%rip), %rsi     # 0x6d338
movl %ebx, %edx
movl %eax, %r8d
xorl %eax, %eax
callq 0x4acf2
movq -0x38(%rbp), %r12
movq -0x30(%rbp), %rdi
movl %ebx, %esi
callq 0x54ee4
movq -0x30(%rbp), %rcx
jmp 0x5125a
callq 0x47c01
movq 0x338(%r12), %rcx
movl %eax, 0x248(%rcx,%r14)
movq %r12, %rcx
movq -0x38(%rbp), %r12
incq %rbx
addq $0x128, %r14            # imm = 0x128
addq $0x820c, %r13           # imm = 0x820C
jmp 0x5117b
movq -0x70(%rbp), %r12
jmp 0x51913
movq 0x58(%r12), %rbx
movq %rbx, %rdi
movq %rcx, %rsi
movq %rcx, %r15
callq 0x555c9
testl %eax, %eax
je 0x516e7
movq 0x608(%rbx), %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
movq %r15, %rcx
jmp 0x515bc
movq 0x58(%r12), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x5198b
jmp 0x515c1
movq 0x58(%r12), %rbx
movq %rbx, %rdi
movq %rcx, %rsi
callq 0x5564d
leaq 0x610(%rbx), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
xorl %r15d, %r15d
movq %r12, -0x70(%rbp)
cmpq $0x100, %rax            # imm = 0x100
je 0x51913
movq %rax, %rcx
imulq $0x408, %rax, %rax      # imm = 0x408
movq -0x50(%rbp), %rdx
cmpl $0x0, (%rdx,%rax)
movq %rcx, -0x30(%rbp)
je 0x5135d
xorl %r12d, %r12d
imulq $0x128, %rcx, %r13      # imm = 0x128
movq -0x40(%rbp), %rax
subl %r12d, %eax
jle 0x5135d
movq 0x608(%rbx), %rcx
movl 0x240(%rcx,%r13), %edi
movslq %r12d, %rsi
addq %r14, %rsi
movslq %eax, %rdx
xorl %ecx, %ecx
callq 0x8330
movq %rax, %r15
testl %r15d, %r15d
jle 0x516a5
callq 0x47c01
movq 0x608(%rbx), %rcx
movl %eax, 0x248(%rcx,%r13)
addl %r15d, %r12d
jmp 0x51310
movq -0x30(%rbp), %rax
incq %rax
movq -0x70(%rbp), %r12
jmp 0x512e2
movq %rbx, %r13
movq 0x58(%r12), %rbx
movl (%rbx), %edx
leaq 0x1be0b(%rip), %rsi     # 0x6d189
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4acf2
movl (%rbx), %edi
movslq %r13d, %rdx
movq %r14, %rsi
callq 0x8230
testq %rax, %rax
jns 0x513a7
movl $0x1, 0x4(%rbx)
movl (%rbx), %edx
leaq 0x1bdf3(%rip), %rsi     # 0x6d1a3
pushq $0x5
popq %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4acf2
jmp 0x51913
movq %rcx, -0x30(%rbp)
movq 0x58(%r12), %r15
movq %r15, -0x38(%rbp)
callq 0x47c01
movl %eax, -0x7c(%rbp)
movl %eax, -0x54(%rbp)
movq (%r15), %rdx
leaq 0x1bde0(%rip), %rsi     # 0x6d1c3
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4acf2
callq 0x47349
movq %rax, %rdi
callq 0x477da
movq -0x38(%rbp), %rdx
movapd %xmm0, %xmm1
movsd 0x880(%rdx), %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
movsd %xmm1, -0x78(%rbp)
jbe 0x517ed
movq 0x848(%rdx), %rdi
testq %rdi, %rdi
je 0x517ed
movq %r14, -0x50(%rbp)
mulsd 0xf472(%rip), %xmm2     # 0x608b0
movsd %xmm2, -0x68(%rbp)
movsd 0x850(%rdx), %xmm0
leaq -0x80(%rbp), %rsi
movq %rax, %rbx
callq 0x470f1
movsd %xmm0, -0x90(%rbp)
leaq -0xac(%rbp), %r14
movq %rbx, %rdi
movsd -0x78(%rbp), %xmm0
movq %r14, %rsi
callq 0x470f1
movl (%r14), %eax
leaq -0x80(%rbp), %rcx
subl (%rcx), %eax
cvtsi2sd %eax, %xmm1
mulsd 0x1094d(%rip), %xmm1    # 0x61dd8
cvtsi2sdl 0x36a25(%rip), %xmm2 # 0x87eb8
movsd %xmm2, -0x48(%rbp)
addsd %xmm0, %xmm1
movsd %xmm1, -0x88(%rbp)
movsd -0x90(%rbp), %xmm0
addsd %xmm2, %xmm0
divsd -0x68(%rbp), %xmm0
callq 0x8ac0
movsd %xmm0, -0x60(%rbp)
movsd -0x88(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
divsd -0x68(%rbp), %xmm0
callq 0x8ac0
movq -0x38(%rbp), %rax
ucomisd -0x60(%rbp), %xmm0
movsd -0x78(%rbp), %xmm0
movq %rbx, -0x60(%rbp)
jbe 0x51728
movq %rbx, %rdi
movsd -0x48(%rbp), %xmm1
movq %rax, %rbx
callq 0x472ee
movq (%rbx), %r14
movq %rax, -0x98(%rbp)
movq %rax, %rdi
movsd %xmm0, -0x48(%rbp)
xorl %esi, %esi
callq 0x47b0e
leaq 0x1bce5(%rip), %rsi     # 0x6d203
pushq $0x3
popq %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x4acf2
cmpq $0x0, 0x10(%rbx)
jne 0x51747
movq -0x38(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x51747
movq -0x38(%rbp), %r14
leaq 0x20(%r14), %rdi
leaq 0xf08e(%rip), %rcx      # 0x605e5
leaq -0x4b0(%rbp), %rsi
movq -0x98(%rbp), %rbx
movq %rbx, %rdx
movsd -0x48(%rbp), %xmm0
movq %rcx, %r8
callq 0x4b018
leaq 0x420(%r14), %rsi
leaq -0x4b0(%rbp), %rdi
callq 0x8890
testl %eax, %eax
je 0x5172f
movups (%r14), %xmm0
movups %xmm0, 0x10(%r14)
movq %r14, %rdi
movq %rbx, %rsi
movsd -0x48(%rbp), %xmm0
movq -0x30(%rbp), %rdx
callq 0x52ebf
jmp 0x51747
movq 0x58(%r12), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x51a87
movl %eax, %r15d
jmp 0x51913
movq %rcx, -0x30(%rbp)
movq %rbx, %r13
movq %r14, %rbx
movq 0x58(%r12), %r14
leaq 0x1bda1(%rip), %rsi     # 0x6d380
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0x4acf2
testq %r14, %r14
je 0x51913
leaq 0x10(%r14), %rdi
movq %rdi, -0x40(%rbp)
callq 0x8900
xorl %r15d, %r15d
testl %r13d, %r13d
cmovlel %r15d, %r13d
movq -0x30(%rbp), %rdi
cmpq %r15, %r13
je 0x516ef
movb (%rbx,%r15), %al
movq 0x38(%r14), %rcx
movslq 0x4(%r14), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x4(%r14)
movb %al, (%rcx,%rdx)
movl 0x4(%r14), %eax
cmpl 0xc(%r14), %eax
jl 0x51643
andl $0x0, 0x4(%r14)
xorl %eax, %eax
cmpl 0x8(%r14), %eax
je 0x51700
incq %r15
jmp 0x51613
movq %rbx, %r15
movq 0x58(%r12), %rbx
movl 0x11c(%rbx), %edx
leaq 0x1bcfe(%rip), %rsi     # 0x6d365
pushq $0x4
popq %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4acf2
movl 0x11c(%rbx), %edi
movslq %r15d, %rdx
addq $0x10c, %rbx            # imm = 0x10C
pushq $0x10
popq %r9
movq %r14, %rsi
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x80a0
movq %rax, %r15
jmp 0x51913
movq %r13, %rdi
jmp 0x51971
callq 0x533ff
testl %eax, %eax
movq -0x70(%rbp), %r12
movq -0x30(%rbp), %r14
je 0x516dc
movq 0x608(%rbx), %rcx
movl 0x240(%rcx,%r13), %ecx
leaq 0x1bc6c(%rip), %rsi     # 0x6d338
pushq $0x1
popq %rdi
movl %r14d, %edx
movl %eax, %r8d
xorl %eax, %eax
callq 0x4acf2
movq %rbx, %rdi
movl %r14d, %esi
callq 0x55748
xorl %r15d, %r15d
jmp 0x51913
movq -0x40(%rbp), %rdi
callq 0x84b0
movl %r13d, %r15d
jmp 0x51913
movupd 0x1bc8b(%rip), %xmm0    # 0x6d393
movupd %xmm0, (%rdi)
movl $0x776f6c, 0x10(%rdi)   # imm = 0x776F6C
orl $-0x1, (%r14)
movq -0x40(%rbp), %rdi
callq 0x84b0
incl %r15d
jmp 0x51913
movsd -0x48(%rbp), %xmm1
jmp 0x5174f
leaq 0x1bae6(%rip), %rsi     # 0x6d21c
pushq $0x2
popq %rdi
leaq -0x4b0(%rbp), %rdx
xorl %eax, %eax
callq 0x4acf2
cvtsi2sdl 0x36769(%rip), %xmm1 # 0x87eb8
movsd %xmm1, -0x48(%rbp)
movsd -0x90(%rbp), %xmm0
subsd %xmm1, %xmm0
divsd -0x68(%rbp), %xmm0
callq 0x8ac0
movsd %xmm0, -0x30(%rbp)
movsd -0x88(%rbp), %xmm0
subsd -0x48(%rbp), %xmm0
divsd -0x68(%rbp), %xmm0
callq 0x8ac0
ucomisd -0x30(%rbp), %xmm0
movq -0x50(%rbp), %r14
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %rdx
movq -0x60(%rbp), %rax
jbe 0x517ed
movq %rdx, %rbx
movq 0x10(%rdx), %rdx
leaq 0x1ba8f(%rip), %rsi     # 0x6d23a
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x4acf2
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x517c3
callq 0x8620
movq -0x38(%rbp), %rax
leaq 0x10(%rax), %rbx
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x517d9
callq 0x8620
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %rdx
movq -0x60(%rbp), %rax
movq (%rdx), %rcx
testq %rcx, %rcx
je 0x51913
movq %rdx, %r13
movslq %ebx, %rdx
pushq $0x1
popq %rsi
movq %r14, %rdi
movq %rdx, -0x40(%rbp)
movq %rax, %rbx
callq 0x8c50
movq %rax, %r15
movq (%r13), %rdi
callq 0x8030
movq %rax, -0x4b0(%rbp)
movq (%r13), %rdi
callq 0x8740
movq %rbx, 0x848(%r13)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, 0x850(%r13)
movq 0x10(%r13), %rcx
testq %rcx, %rcx
je 0x51873
pushq $0x1
popq %rsi
movq %r14, %rdi
movq -0x40(%rbp), %rdx
callq 0x8c50
movq 0x10(%r13), %rdi
callq 0x8030
movq %rax, -0xa8(%rbp)
movq 0x10(%r13), %rdi
callq 0x8740
movq 0x8(%r13), %rcx
testq %rcx, %rcx
je 0x518f0
movl -0x7c(%rbp), %eax
subl 0x858(%r13), %eax
leaq -0x54(%rbp), %rdi
movl %eax, (%rdi)
pushq $0x1
popq %rbx
pushq $0x4
popq %rdx
movq %rbx, %rsi
callq 0x8c50
movq 0x8(%r13), %rcx
leaq -0x4b0(%rbp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x8c50
movq 0x8(%r13), %rdi
callq 0x8740
movq 0x18(%r13), %rcx
testq %rcx, %rcx
je 0x518f0
leaq -0x54(%rbp), %rdi
pushq $0x4
popq %rdx
movq %rbx, %rsi
callq 0x8c50
movq 0x18(%r13), %rcx
leaq -0xa8(%rbp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x8c50
movq 0x18(%r13), %rdi
callq 0x8740
movq (%r13), %rdx
movl -0x54(%rbp), %r8d
movq -0x4b0(%rbp), %r9
leaq 0x1b8d4(%rip), %rsi     # 0x6d1da
pushq $0x5
popq %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4acf2
addl %r15d, 0x14(%r12)
callq 0x47c01
testl %r15d, %r15d
jle 0x51927
movl %eax, 0x24(%r12)
movl %eax, %ecx
subl 0x20(%r12), %ecx
cmpl 0x36574(%rip), %ecx     # 0x87ea8
movq -0xa0(%rbp), %rdi
jle 0x51971
movl 0x14(%r12), %edx
movl %edx, %esi
subl 0x2c(%r12), %esi
cvtsi2sd %rsi, %xmm0
mulsd 0x1a46a(%rip), %xmm0    # 0x6bdc0
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x18(%r12)
movl %eax, 0x20(%r12)
movl %edx, 0x2c(%r12)
callq 0x84b0
movl %r15d, %eax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq