// File: /workspace/github_cpp_makefile_star2_O3/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 0x1be64(%rip), %rsi     # 0x75e26
movq $0x0, -0x30(%rbp)
movl $0x4, %edi
xorl %eax, %eax
callq 0x5342c
testb $0x2, 0x4(%r12)
je 0x5a73f
cmpq $0x0, 0x58(%r12)
je 0x5a73f
leaq 0x30(%r12), %r13
movq %r13, %rdi
callq 0x8900
movl (%r12), %eax
decl %eax
cmpl $0xf, %eax
ja 0x5a618
leaq 0x460(%r12), %rcx
leaq 0x1bc47(%rip), %rdx     # 0x75c60
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
movl %ebx, -0x3c(%rbp)
movq %r12, -0xa0(%rbp)
movq %r13, -0x98(%rbp)
jmpq *%rax
movl %ebx, %edx
movq 0x58(%r12), %rbx
leaq 0x1d292(%rip), %rsi     # 0x772d3
movq $0x0, -0x30(%rbp)
movl $0x3, %edi
xorl %eax, %eax
movq %rcx, %r13
callq 0x5342c
movq %rbx, %rdi
movq %r13, %r12
movq %r13, %rsi
callq 0x5d023
testl %eax, %eax
je 0x5a6da
movq 0x8510(%rbx), %rdi
movq %r14, %rsi
movl -0x3c(%rbp), %edx
movq %r12, %rcx
jmp 0x5a519
movq %r14, -0x60(%rbp)
movq 0x58(%r12), %r14
leaq 0x1d252(%rip), %rsi     # 0x772e5
movl $0x4, %edi
movl %ebx, %edx
xorl %eax, %eax
movq %rcx, %rbx
callq 0x5342c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5d8a0
movq %r14, %rcx
leaq 0x8(%r14), %r12
leaq 0x8548(%r14), %r13
xorl %r14d, %r14d
xorl %ebx, %ebx
movq $0x0, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq %r12, -0x48(%rbp)
movl -0x3c(%rbp), %r15d
cmpl $0x0, -0x8208(%r13)
je 0x5a1a8
cmpb $0x0, (%r12)
je 0x5a106
leaq -0x8204(%r13), %rsi
movq %r12, %rdi
callq 0x8880
movq -0x38(%rbp), %rcx
testl %eax, %eax
jne 0x5a1a8
movl 0x820f40(%rcx), %eax
cmpl $-0x1, %eax
je 0x5a11b
cmpl (%r13), %eax
jne 0x5a1a8
movq 0x338(%rcx), %rax
movq %rcx, %r12
movl 0x240(%rax,%r14), %edi
movq -0x60(%rbp), %rsi
movl %r15d, %edx
callq 0x5e2a4
movq %rax, -0x30(%rbp)
cmpl %r15d, %eax
jge 0x5a18c
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
je 0x5a177
movq -0x38(%rbp), %rax
movq 0x338(%rax), %rax
movl 0x240(%rax,%r14), %ecx
movl $0x1, %edi
leaq 0x1d18a(%rip), %rsi     # 0x772f8
movl %ebx, %edx
xorl %eax, %eax
callq 0x5342c
movq -0x48(%rbp), %r12
movq -0x38(%rbp), %rdi
movl %ebx, %esi
callq 0x5e158
movq -0x38(%rbp), %rcx
jmp 0x5a1a8
callq 0x4fece
movq 0x338(%r12), %rcx
movl %eax, 0x248(%rcx,%r14)
movq %r12, %rcx
movq -0x48(%rbp), %r12
incq %rbx
addq $0x128, %r14            # imm = 0x128
addq $0x820c, %r13           # imm = 0x820C
cmpq $0x12800, %r14          # imm = 0x12800
jne 0x5a0d6
jmp 0x5a6da
movq 0x58(%r12), %rbx
movq %rbx, %rdi
movq %rcx, %rsi
movq %rcx, %r15
callq 0x5e892
testl %eax, %eax
je 0x5a694
movq 0x608(%rbx), %rdi
movq %r14, %rsi
movl -0x3c(%rbp), %edx
movq %r15, %rcx
jmp 0x5a519
movq 0x58(%r12), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x5a98a
jmp 0x5a51e
movq 0x58(%r12), %r15
movq %r15, %rdi
movq %rcx, %rsi
callq 0x5e925
leaq 0x610(%r15), %rax
movq %rax, -0x60(%rbp)
xorl %ecx, %ecx
movq $0x0, -0x30(%rbp)
movl -0x3c(%rbp), %ebx
cmpl $0x0, -0x3c(%rbp)
movq %rcx, -0x38(%rbp)
jle 0x5a2ae
movq %rcx, %rax
shlq $0xa, %rax
leaq (%rax,%rcx,8), %rax
movq -0x60(%rbp), %rcx
cmpl $0x0, (%rcx,%rax)
je 0x5a2ae
movq 0x608(%r15), %rcx
xorl %r12d, %r12d
imulq $0x128, -0x38(%rbp), %r13 # imm = 0x128
movl 0x240(%rcx,%r13), %edi
movslq %r12d, %rax
leaq (%r14,%rax), %rsi
movl %ebx, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
xorl %ecx, %ecx
callq 0x8320
movq %rax, -0x30(%rbp)
testl %eax, %eax
jle 0x5a620
callq 0x4fece
movq 0x608(%r15), %rcx
movl %eax, 0x248(%rcx,%r13)
addl -0x30(%rbp), %r12d
cmpl %ebx, %r12d
jl 0x5a268
movq -0x38(%rbp), %rcx
incq %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x5a237
jmp 0x5a6da
movl %ebx, %r13d
movq 0x58(%r12), %rbx
movl (%rbx), %edx
leaq 0x1ce71(%rip), %rsi     # 0x77149
movq $0x0, -0x30(%rbp)
movl $0x3, %edi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x5342c
movl (%rbx), %edi
movslq %r13d, %rdx
movq %r14, %rsi
callq 0x8230
testq %rax, %rax
jns 0x5a308
movl $0x1, 0x4(%rbx)
movl (%rbx), %edx
leaq 0x1ce52(%rip), %rsi     # 0x77163
movl $0x5, %edi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x5342c
jmp 0x5a6da
movq %rcx, -0x48(%rbp)
movq 0x58(%r12), %r15
callq 0x4fece
movl %eax, -0x7c(%rbp)
movl %eax, -0x54(%rbp)
movq (%r15), %rdx
leaq 0x1ce41(%rip), %rsi     # 0x77183
movq $0x0, -0x30(%rbp)
movl $0x3, %edi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x5342c
callq 0x4f542
movq %rax, %rdi
callq 0x4fa70
movq %r15, %rcx
movapd %xmm0, %xmm1
movsd 0x880(%r15), %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
movq %r15, -0x38(%rbp)
movsd %xmm1, -0x78(%rbp)
jbe 0x5a820
movq 0x848(%rcx), %rdi
testq %rdi, %rdi
je 0x5a820
movq %r14, -0x60(%rbp)
mulsd 0x10518(%rip), %xmm2    # 0x6a8c0
movsd %xmm2, -0x70(%rbp)
movsd 0x850(%rcx), %xmm0
leaq -0x80(%rbp), %rsi
movq %rcx, %r15
movq %rax, %rbx
callq 0x4f2b1
movsd %xmm0, -0x90(%rbp)
leaq -0xac(%rbp), %r14
movq %rbx, %rdi
movsd -0x78(%rbp), %xmm0
movq %r14, %rsi
callq 0x4f2b1
movl (%r14), %eax
leaq -0x80(%rbp), %rcx
subl (%rcx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x119ed(%rip), %xmm1    # 0x6bde8
xorps %xmm2, %xmm2
cvtsi2sdl 0x35aa2(%rip), %xmm2 # 0x8fea8
movsd %xmm2, -0x50(%rbp)
addsd %xmm0, %xmm1
movsd %xmm1, -0x88(%rbp)
movsd -0x90(%rbp), %xmm0
addsd %xmm2, %xmm0
divsd -0x70(%rbp), %xmm0
callq 0x8ac0
movsd %xmm0, -0x68(%rbp)
movsd -0x88(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
divsd -0x70(%rbp), %xmm0
callq 0x8ac0
ucomisd -0x68(%rbp), %xmm0
movsd -0x78(%rbp), %xmm0
movq %rbx, -0x68(%rbp)
jbe 0x5a755
movq %rbx, %rdi
movsd -0x50(%rbp), %xmm1
callq 0x4f4e7
movq %rax, %rbx
movq (%r15), %r14
movq %rax, %rdi
movsd %xmm0, -0x50(%rbp)
xorl %esi, %esi
callq 0x4fdbe
leaq 0x1cd3d(%rip), %rsi     # 0x771c3
movl $0x3, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x5342c
cmpq $0x0, 0x10(%r15)
jne 0x5a776
movq %r15, %r14
cmpq $0x0, 0x18(%r15)
jne 0x5a776
leaq 0x20(%r14), %rdi
leaq 0x10139(%rip), %rcx     # 0x6a5f5
leaq -0x4b0(%rbp), %r15
movq %r15, %rsi
movq %rbx, %rdx
movsd -0x50(%rbp), %xmm0
movq %rcx, %r8
callq 0x5379e
leaq 0x420(%r14), %rsi
movq %r15, %rdi
callq 0x8880
testl %eax, %eax
je 0x5a75c
movups (%r14), %xmm0
movups %xmm0, 0x10(%r14)
movq %r14, %rdi
movq %rbx, %rsi
movsd -0x50(%rbp), %xmm0
movq -0x48(%rbp), %rdx
callq 0x5bf4e
jmp 0x5a776
movq 0x58(%r12), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x5aa8b
jmp 0x5a6d6
movq %rcx, -0x48(%rbp)
movl %ebx, %edx
movq %r14, %rbx
movq 0x58(%r12), %r14
leaq 0x1ce08(%rip), %rsi     # 0x77340
movq $0x0, -0x30(%rbp)
movl $0x3, %edi
xorl %eax, %eax
callq 0x5342c
testq %r14, %r14
je 0x5a6da
leaq 0x10(%r14), %r12
movq %r12, %rdi
callq 0x8900
movl -0x3c(%rbp), %eax
testl %eax, %eax
jle 0x5a69e
movl %eax, %eax
movl 0x4(%r14), %ecx
movq $0x0, -0x30(%rbp)
movq -0x48(%rbp), %r8
movq -0x30(%rbp), %rdx
movb (%rbx,%rdx), %dl
movq 0x38(%r14), %rsi
leal 0x1(%rcx), %edi
movl %edi, 0x4(%r14)
movslq %ecx, %rcx
movb %dl, (%rsi,%rcx)
movl 0x4(%r14), %ecx
cmpl 0xc(%r14), %ecx
jl 0x5a5aa
movl $0x0, 0x4(%r14)
xorl %ecx, %ecx
cmpl 0x8(%r14), %ecx
je 0x5a6ac
movq -0x30(%rbp), %rsi
incq %rsi
movq %rsi, -0x30(%rbp)
cmpq %rsi, %rax
jne 0x5a57e
movl -0x3c(%rbp), %ebx
jmp 0x5a6a0
movl %ebx, %r15d
movq 0x58(%r12), %rbx
movl 0x11c(%rbx), %edx
leaq 0x1cd44(%rip), %rsi     # 0x77325
movl $0x4, %edi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x5342c
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
jmp 0x5a6d6
movq %r13, %rdi
jmp 0x5a73a
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
movq -0x38(%rbp), %rbx
je 0x5a655
movq 0x608(%r15), %rax
movl 0x240(%rax,%r13), %ecx
leaq 0x1ccb1(%rip), %rsi     # 0x772f8
movl $0x1, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x5342c
movl %ebx, %r14d
imulq $0x128, %r14, %rdi      # imm = 0x128
addq 0x608(%r15), %rdi
addq $0x128, %rdi            # imm = 0x128
movl 0x3582d(%rip), %esi     # 0x8fea0
callq 0x5cc1d
movq %r14, %rax
shlq $0xa, %rax
leaq (%rax,%r14,8), %rax
movq -0x60(%rbp), %rcx
movb $0x0, 0x8(%rcx,%rax)
movq $0x0, (%rcx,%rax)
movq $0x0, -0x30(%rbp)
jmp 0x5a6da
xorl %ebx, %ebx
movq %r12, %rdi
callq 0x84b0
movl %ebx, %eax
jmp 0x5a6d6
movupd 0x1cc9f(%rip), %xmm0    # 0x77353
movupd %xmm0, (%r8)
movl $0x776f6c, 0x10(%r8)    # imm = 0x776F6C
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
movq %r12, %rdi
callq 0x84b0
movq -0x30(%rbp), %rax
incl %eax
movq %rax, -0x30(%rbp)
movq -0xa0(%rbp), %rbx
movq -0x30(%rbp), %r14
addl %r14d, 0x14(%rbx)
callq 0x4fece
testl %r14d, %r14d
jle 0x5a6f6
movl %eax, 0x24(%rbx)
movl %eax, %ecx
subl 0x20(%rbx), %ecx
cmpl 0x35797(%rip), %ecx     # 0x8fe98
movq -0x98(%rbp), %rdi
jle 0x5a73a
movl 0x14(%rbx), %edx
movl %edx, %esi
subl 0x2c(%rbx), %esi
xorps %xmm0, %xmm0
cvtsi2sd %rsi, %xmm0
mulsd 0x1b65e(%rip), %xmm0    # 0x75d80
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x18(%rbx)
movl %eax, 0x20(%rbx)
movl %edx, 0x2c(%rbx)
callq 0x84b0
movq -0x30(%rbp), %rax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd -0x50(%rbp), %xmm1
jmp 0x5a781
leaq 0x1ca79(%rip), %rsi     # 0x771dc
leaq -0x4b0(%rbp), %rdx
movl $0x2, %edi
xorl %eax, %eax
callq 0x5342c
xorps %xmm1, %xmm1
cvtsi2sdl 0x35727(%rip), %xmm1 # 0x8fea8
movsd %xmm1, -0x50(%rbp)
movsd -0x90(%rbp), %xmm0
subsd %xmm1, %xmm0
divsd -0x70(%rbp), %xmm0
callq 0x8ac0
movsd %xmm0, -0x48(%rbp)
movsd -0x88(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
divsd -0x70(%rbp), %xmm0
callq 0x8ac0
ucomisd -0x48(%rbp), %xmm0
movq -0x60(%rbp), %r14
movl -0x3c(%rbp), %ebx
movq -0x38(%rbp), %rcx
movq -0x68(%rbp), %rax
jbe 0x5a820
movq 0x10(%rcx), %rdx
leaq 0x1ca21(%rip), %rsi     # 0x771fa
movl $0x3, %edi
xorl %eax, %eax
callq 0x5342c
movq -0x38(%rbp), %rcx
movq 0x10(%rcx), %rdi
testq %rdi, %rdi
je 0x5a7fb
callq 0x8630
movq -0x38(%rbp), %rcx
leaq 0x10(%rcx), %rbx
movq 0x18(%rcx), %rdi
testq %rdi, %rdi
je 0x5a811
callq 0x8630
movq -0x38(%rbp), %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movl -0x3c(%rbp), %ebx
movq -0x68(%rbp), %rax
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x5a6da
movslq %ebx, %r15
movl $0x1, %esi
movq %r14, %rdi
movq %rax, %rbx
movq %r15, %rdx
callq 0x8c30
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x8030
movq %rax, -0x4b0(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x8760
movq -0x38(%rbp), %rax
movq %rbx, 0x848(%rax)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, 0x850(%rax)
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x5a8bb
movl $0x1, %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x8c30
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x8030
movq %rax, -0xa8(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x8760
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x5a960
movl -0x7c(%rbp), %edx
subl 0x858(%rax), %edx
leaq -0x54(%rbp), %rdi
movl %edx, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
callq 0x8c30
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
leaq -0x4b0(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x8c30
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x8760
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0x5a960
leaq -0x54(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x8c30
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x8c30
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x8760
movq -0x38(%rbp), %rax
movq (%rax), %rdx
movl -0x54(%rbp), %r8d
movq -0x4b0(%rbp), %r9
leaq 0x1c825(%rip), %rsi     # 0x7719a
movl $0x5, %edi
movq -0x30(%rbp), %rcx
xorl %eax, %eax
callq 0x5342c
jmp 0x5a6da