// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::strread(bamboo::stream_t*, unsigned char*, int)
extern int strread(stream_t *stream, unsigned char *buff, int n)
	{
		unsigned int tick;
		char *msg = stream->msg;
		int nr;

		tracet(4, "strread: n=%d\n", n);

		if (!(stream->mode&STR_MODE_R) || !stream->port) return 0;

		strlock(stream);

		switch (stream->type) {
		case STR_SERIAL: nr = readserial((serial_t *)stream->port, buff, n, msg); break;
		case STR_FILE: nr = readfile((file_t   *)stream->port, buff, n, msg); break;
		case STR_TCPSVR: nr = readtcpsvr((tcpsvr_t *)stream->port, buff, n, msg); break;
		case STR_TCPCLI: nr = readtcpcli((tcpcli_t *)stream->port, buff, n, msg); break;
		case STR_NTRIPSVR:
		case STR_NTRIPCLI: nr = readntrip((ntrip_t  *)stream->port, buff, n, msg); break;
		case STR_NTRIPC_S:
		case STR_NTRIPC_C: nr = readntripc((ntripc_t *)stream->port, buff, n, msg); break;
		case STR_UDPSVR: nr = readudpsvr((udp_t    *)stream->port, buff, n, msg); break;
		case STR_MEMBUF: nr = readmembuf((membuf_t *)stream->port, buff, n, msg); break;
		case STR_FTP: nr = readftp((ftp_t    *)stream->port, buff, n, msg); break;
		case STR_HTTP: nr = readftp((ftp_t    *)stream->port, buff, n, msg); break;
		case STR_VRSCONCLI: nr = readvrsconcli((vrscon_cli_t*)stream->port, buff, n, msg); break;
		case STR_VRSCONSVR: nr = readvrsconsvr((vrscon_svr_t*)stream->port, buff, n, msg); break;
		default:
			strunlock(stream);
			return 0;
		}
		stream->inb += nr;
		tick = tickget(); if (nr > 0) stream->tact = tick;

		if ((int)(tick - stream->tick_i) >= tirate) {
			stream->inr = (stream->inb - stream->inbt) * 8000 / (tick - stream->tick_i);
			stream->tick_i = tick; stream->inbt = stream->inb;
		}
		strunlock(stream);
		return nr;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, %r14d
movq %rsi, %r12
movq %rdi, %r13
leaq 0x1b9f3(%rip), %rsi     # 0x6be57
xorl %r15d, %r15d
pushq $0x4
popq %rdi
xorl %eax, %eax
callq 0x4acf2
testb $0x1, 0x4(%r13)
je 0x50b70
cmpq $0x0, 0x58(%r13)
je 0x50b70
leaq 0x30(%r13), %rbx
movq %rbx, %rdi
callq 0x8900
movl (%r13), %eax
decl %eax
cmpl $0xf, %eax
ja 0x509e7
leaq 0x460(%r13), %rsi
leaq 0x1b7b0(%rip), %rcx     # 0x6bc60
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %rbx, -0x78(%rbp)
jmpq *%rax
movq 0x58(%r13), %rdi
movq %rsi, %rcx
movq %r12, %rsi
movl %r14d, %edx
callq 0x50e93
jmp 0x50adf
movl %r14d, -0x2c(%rbp)
movq 0x58(%r13), %r14
movq %rsi, %rbx
leaq 0x1c3c5(%rip), %rsi     # 0x6c8ab
xorl %r15d, %r15d
pushq $0x4
popq %rdi
xorl %eax, %eax
callq 0x4acf2
movq %r14, %rdi
movq %rbx, -0x40(%rbp)
movq %rbx, %rsi
callq 0x53e95
testl %eax, %eax
je 0x50b24
movslq 0x8(%r14), %rsi
testq %rsi, %rsi
jle 0x50a3b
movl -0x2c(%rbp), %ebx
cmpl %ebx, %esi
cmovll %esi, %ebx
addq %r14, %rsi
movslq %ebx, %rdx
subq %rdx, %rsi
addq $0x50c, %rsi            # imm = 0x50C
movq %r12, %rdi
callq 0x84f0
andl $0x0, 0x8(%r14)
movl %ebx, %r15d
jmp 0x50b24
movl %r14d, -0x2c(%rbp)
movq %r12, -0x38(%rbp)
movq %r13, -0x48(%rbp)
movq 0x58(%r13), %r14
movq %rsi, %rbx
leaq 0x1c6e9(%rip), %rsi     # 0x6cc47
pushq $0x4
popq %rdi
xorl %eax, %eax
callq 0x4acf2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x54663
leaq 0x8548(%r14), %rbx
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq $0x12800, %r13          # imm = 0x12800
je 0x50608
cmpl $0x0, -0x8208(%rbx)
je 0x505f2
movq 0x338(%r14), %rax
movl 0x240(%rax,%r13), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x53a26
testl %eax, %eax
js 0x505b8
je 0x505f2
jmp 0x509ff
callq 0x533ff
testl %eax, %eax
je 0x505e7
movq 0x338(%r14), %rcx
movl 0x240(%rcx,%r13), %ecx
pushq $0x1
popq %rdi
leaq 0x1c67a(%rip), %rsi     # 0x6cc54
movl %r15d, %edx
movl %eax, %r8d
xorl %eax, %eax
callq 0x4acf2
movq %r14, %rdi
movl %r15d, %esi
callq 0x54ee4
incq %r15
addq $0x128, %r13            # imm = 0x128
addq $0x820c, %rbx           # imm = 0x820C
jmp 0x50580
movq -0x48(%rbp), %r13
jmp 0x50b21
movl %r14d, -0x2c(%rbp)
movq %r12, -0x38(%rbp)
movq 0x58(%r13), %rbx
movq %rbx, %rdi
callq 0x5564d
movq %rbx, %rax
leaq 0x610(%rbx), %r14
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %r13, -0x48(%rbp)
cmpq $0x100, %r15            # imm = 0x100
je 0x50b21
cmpl $0x0, (%r14)
je 0x506bd
movq %rax, %r13
movq 0x608(%rax), %rax
movl 0x240(%rax,%rbx), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x53a26
testl %eax, %eax
js 0x5067d
movl %eax, %r12d
movq %r13, %rax
movq -0x48(%rbp), %r13
je 0x506bd
jmp 0x50ab0
callq 0x533ff
testl %eax, %eax
je 0x506ab
movq 0x608(%r13), %rcx
movl 0x240(%rcx,%rbx), %ecx
pushq $0x1
popq %rdi
leaq 0x1c5b6(%rip), %rsi     # 0x6cc54
movl %r15d, %edx
movl %eax, %r8d
xorl %eax, %eax
callq 0x4acf2
movq %r13, %rdi
movl %r15d, %esi
callq 0x55748
movq %r13, %rax
movq -0x48(%rbp), %r13
incq %r15
addq $0x128, %rbx            # imm = 0x128
addq $0x408, %r14            # imm = 0x408
jmp 0x50638
movq 0x58(%r13), %rbx
movl (%rbx), %edx
leaq 0x1bf08(%rip), %rsi     # 0x6c5e8
xorl %r15d, %r15d
pushq $0x4
popq %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4acf2
movl (%rbx), %edi
movslq %r14d, %rdx
movq %r12, %rsi
callq 0x88d0
movq %rax, %r14
testl %r14d, %r14d
js 0x50b24
movl (%rbx), %edx
leaq 0x1beef(%rip), %rsi     # 0x6c601
pushq $0x5
popq %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4acf2
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
sete %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x50745
leaq -0x100(%rbp), %rcx
movq %r12, %rsi
movl %r14d, %edx
callq 0x5198b
movl %r14d, %r15d
jmp 0x50b24
movq 0x58(%r13), %rdi
movq %rsi, %rcx
movq %r12, %rsi
movl %r14d, %edx
jmp 0x50ada
movq 0x58(%r13), %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
movl 0x11c(%rbx), %edx
leaq 0x1c807(%rip), %rsi     # 0x6cf80
movl %r14d, %ecx
xorl %r14d, %r14d
pushq $0x4
popq %rdi
movl %ecx, -0x2c(%rbp)
xorl %eax, %eax
callq 0x4acf2
cmpq $0x10, %r14
je 0x507a0
andq $0x0, -0x100(%rbp,%r14,8)
incq %r14
jmp 0x5078c
movl 0x11c(%rbx), %edi
pushq $0x40
popq %rcx
movl %edi, %eax
cltd
idivl %ecx
movslq %eax, %rdx
shll $0x6, %eax
movl %edi, %ecx
subl %eax, %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
orq %rax, -0x100(%rbp,%rdx,8)
incl %edi
leaq -0x100(%rbp), %rsi
leaq -0x70(%rbp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x85e0
testl %eax, %eax
jle 0x50adf
movl 0x11c(%rbx), %edi
movslq -0x2c(%rbp), %rdx
movq %r12, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x84c0
testl %eax, %eax
pushq $-0x1
popq %r15
jmp 0x50aaa
movq 0x58(%r13), %r15
movl (%r15), %edx
movq %rsi, -0x40(%rbp)
leaq 0x1be3d(%rip), %rsi     # 0x6c658
pushq $0x4
popq %rdi
xorl %eax, %eax
callq 0x4acf2
movq %r15, -0x50(%rbp)
movq %r15, %rdi
movq -0x40(%rbp), %rsi
callq 0x53819
testl %eax, %eax
je 0x50b21
movl %r14d, -0x2c(%rbp)
movq %r12, -0x38(%rbp)
movq -0x50(%rbp), %r14
leaq 0x128(%r14), %r15
movl $0x100, %ebx            # imm = 0x100
subq $0x1, %rbx
jb 0x50b21
cmpl $0x2, (%r15)
jne 0x5088c
movl 0x118(%r15), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x53a26
cmpl $-0x1, %eax
je 0x50ae4
movl %eax, %r12d
testl %eax, %eax
jg 0x50b85
addq $0x128, %r15            # imm = 0x128
jmp 0x50855
movq %rsi, -0x40(%rbp)
movq %r12, -0x38(%rbp)
movq 0x58(%r13), %r12
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
movq (%r12), %rdx
leaq 0x1bd6b(%rip), %rsi     # 0x6c620
pushq $0x4
popq %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4acf2
movq (%r12), %rcx
movq 0x356eb(%rip), %rax     # 0x85fb8
cmpq (%rax), %rcx
je 0x50a59
cmpq $0x0, 0x8(%r12)
je 0x50d3b
cmpl $0x0, 0x828(%r12)
movq %r13, -0x48(%rbp)
movl %r14d, -0x2c(%rbp)
je 0x50b96
movl 0x82c(%r12), %r15d
jmp 0x50bcd
movl %r14d, %ebx
movq 0x58(%r13), %r14
movq %r14, %rdi
movq %rsi, %r15
callq 0x555c9
testl %eax, %eax
je 0x50b21
movslq 0x4(%r14), %rax
testq %rax, %rax
jle 0x50acb
cmpl %ebx, %eax
cmovll %eax, %ebx
leaq (%r14,%rax), %rsi
addq $0x208, %rsi            # imm = 0x208
movl %ebx, -0x2c(%rbp)
movslq %ebx, %r15
subq %r15, %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x84f0
movl 0x4(%r14), %ecx
subl %r15d, %ecx
movl %ecx, 0x4(%r14)
leaq (%r14,%r15), %rax
addq $0x208, %rax            # imm = 0x208
xorl %edx, %edx
cmpl %ecx, %edx
jge 0x50a51
movb (%rax,%rdx), %cl
movb %cl, 0x208(%r14,%rdx)
movl 0x4(%r14), %ecx
incq %rdx
jmp 0x50968
movq 0x58(%r13), %rbx
leaq 0x1c60b(%rip), %rsi     # 0x6cf9a
xorl %r15d, %r15d
pushq $0x4
popq %rdi
movl %r14d, -0x2c(%rbp)
movl %r14d, %edx
xorl %eax, %eax
callq 0x4acf2
testq %rbx, %rbx
je 0x50b24
leaq 0x10(%rbx), %r14
movq %r14, %rdi
callq 0x8900
movl 0x8(%rbx), %eax
movslq -0x2c(%rbp), %rcx
xorl %r15d, %r15d
cmpl 0x4(%rbx), %eax
je 0x509ef
cmpq %rcx, %r15
jge 0x509ef
cmpl 0xc(%rbx), %eax
jl 0x509d3
xorl %eax, %eax
movq 0x38(%rbx), %rdx
cltq
movb (%rdx,%rax), %dl
movb %dl, (%r12,%r15)
incq %r15
incl %eax
jmp 0x509c2
movq %rbx, %rdi
jmp 0x50b6b
movl %eax, 0x8(%rbx)
movq %r14, %rdi
callq 0x84b0
jmp 0x50b24
movl %eax, %r12d
callq 0x47c01
movq 0x338(%r14), %rcx
movl %eax, 0x248(%rcx,%r13)
leaq 0x8(%r14), %rdi
leaq -0x8204(%rbx), %rsi
callq 0x85c0
movl (%rbx), %eax
movl %eax, 0x820f40(%r14)
movl %r12d, %r15d
movq -0x48(%rbp), %r13
jmp 0x50b24
movq 0x8510(%r14), %rdi
movq %r12, %rsi
movl -0x2c(%rbp), %edx
movq -0x40(%rbp), %rcx
jmp 0x50ada
movl -0x2c(%rbp), %eax
jmp 0x50adf
xorl %eax, %eax
movq -0x38(%rbp), %rbx
cmpq $0x10, %rax
je 0x50a73
andq $0x0, -0x100(%rbp,%rax,8)
incq %rax
jmp 0x50a5f
leaq -0x100(%rbp), %rsi
orb $0x1, (%rsi)
xorl %r15d, %r15d
pushq $0x1
popq %rdi
leaq -0x70(%rbp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x85e0
testl %eax, %eax
je 0x50b24
movslq %r14d, %rdx
xorl %r15d, %r15d
xorl %edi, %edi
movq %rbx, %rsi
callq 0x88d0
testl %eax, %eax
cmovgl %eax, %r15d
jmp 0x50b24
movq %rax, %r14
callq 0x47c01
movq 0x608(%r14), %rcx
movl %eax, 0x248(%rcx,%rbx)
jmp 0x50b91
movq 0x608(%r14), %rdi
movq %r12, %rsi
movl %ebx, %edx
movq %r15, %rcx
callq 0x50d8f
movl %eax, %r15d
jmp 0x50b24
callq 0x533ff
testl %eax, %eax
je 0x50b07
movl 0x118(%r15), %edx
leaq 0x1bb73(%rip), %rsi     # 0x6c66e
pushq $0x1
popq %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x4acf2
movl 0x373a3(%rip), %esi     # 0x87eb0
movq %r15, %rdi
callq 0x53ac3
movq %r14, %rdi
movq -0x40(%rbp), %rsi
callq 0x53b10
xorl %r15d, %r15d
addl %r15d, 0xc(%r13)
callq 0x47c01
movl %eax, %ecx
testl %r15d, %r15d
jle 0x50b38
movl %ecx, 0x24(%r13)
movl %ecx, %esi
subl 0x1c(%r13), %esi
cmpl 0x37364(%rip), %esi     # 0x87ea8
movq -0x78(%rbp), %rdi
jl 0x50b6b
movl 0xc(%r13), %r8d
movl %r8d, %eax
subl 0x28(%r13), %eax
imull $0x1f40, %eax, %eax     # imm = 0x1F40
xorl %edx, %edx
divl %esi
movl %eax, 0x10(%r13)
movl %ecx, 0x1c(%r13)
movl %r8d, 0x28(%r13)
callq 0x84b0
movl %r15d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x47c01
movl %eax, 0x120(%r15)
movl %r12d, %r15d
jmp 0x50b24
callq 0x47c01
subl 0x858(%r12), %eax
cvtsi2sd %rax, %xmm0
movsd 0x870(%r12), %xmm1
mulsd 0x108ae(%rip), %xmm1    # 0x61468
mulsd 0x878(%r12), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r15
leaq 0x868(%r12), %r14
pushq $0x1
popq %r13
leaq -0x100(%rbp), %rbx
cmpl %r15d, (%r14)
ja 0x50c8d
movq 0x8(%r12), %rcx
movq %r14, %rdi
pushq $0x4
popq %rsi
movq %r13, %rdx
callq 0x8920
testq %rax, %rax
je 0x50c4b
movslq 0x830(%r12), %rsi
cmpq $0x4, %rsi
movq %rbx, %rdi
leaq -0x54(%rbp), %rax
cmoveq %rax, %rdi
movq 0x8(%r12), %rcx
movq %r13, %rdx
callq 0x8920
testq %rax, %rax
je 0x50c4b
cmpl $0x4, 0x830(%r12)
je 0x50c3e
movq -0x100(%rbp), %rax
jmp 0x50c41
movl -0x54(%rbp), %eax
movq %rax, 0x860(%r12)
jmp 0x50be0
orl $-0x1, 0x868(%r12)
movq (%r12), %rdi
callq 0x8030
movq %rax, %r14
movq (%r12), %rdi
pushq $0x2
popq %rdx
xorl %esi, %esi
callq 0x86a0
movq (%r12), %rdi
callq 0x8030
movq %rax, 0x860(%r12)
movq (%r12), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x86a0
cvtsi2sd %r15d, %xmm0
mulsd 0x110de(%rip), %xmm0    # 0x61d78
movsd %xmm0, -0x50(%rbp)
leaq 0x1b993(%rip), %rsi     # 0x6c639
movq -0x40(%rbp), %rdi
movb $0x1, %al
callq 0x8110
movq 0x838(%r12), %rdi
movsd 0x840(%r12), %xmm0
movsd -0x50(%rbp), %xmm1
callq 0x472ee
movq %rax, 0x848(%r12)
movsd %xmm0, 0x850(%r12)
movq 0x838(%r12), %rdi
movsd 0x840(%r12), %xmm0
cvtsi2sdl 0x868(%r12), %xmm1
mulsd 0x11075(%rip), %xmm1    # 0x61d78
callq 0x472ee
movq %rax, %rdi
callq 0x47415
movq 0x860(%r12), %rbx
movq (%r12), %rdi
callq 0x8030
subq %rax, %rbx
movl -0x2c(%rbp), %ecx
movslq %ecx, %rax
cmpq %rax, %rbx
cmovgel %ecx, %ebx
movq (%r12), %rcx
movl %ebx, %r14d
movq -0x48(%rbp), %r13
testl %r14d, %r14d
jle 0x50d58
movl %r14d, %edx
pushq $0x1
popq %rsi
movq -0x38(%rbp), %rdi
callq 0x8920
movq %rax, %rbx
movq (%r12), %rcx
jmp 0x50d5a
xorl %ebx, %ebx
movq %rcx, %rdi
callq 0x8980
testl %eax, %eax
je 0x50d70
movq -0x40(%rbp), %rax
movl $0x646e65, (%rax)       # imm = 0x646E65
movq (%r12), %rdx
leaq 0x1b8c6(%rip), %rsi     # 0x6c641
pushq $0x5
popq %rdi
movq %rbx, %r15
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4acf2
jmp 0x50b24