// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movl %edx, %r14d
movq %rsi, -0x38(%rbp)
movq %rdi, %r12
leaq 0x1cb2a(%rip), %rsi     # 0x75e17
xorl %r13d, %r13d
movl $0x4, %edi
xorl %eax, %eax
callq 0x5342c
testb $0x1, 0x4(%r12)
je 0x59a3c
cmpq $0x0, 0x58(%r12)
je 0x59a3c
leaq 0x30(%r12), %rbx
movq %rbx, %rdi
callq 0x8900
movl (%r12), %eax
decl %eax
cmpl $0xf, %eax
ja 0x59a34
leaq 0x460(%r12), %r15
leaq 0x1c8e1(%rip), %rcx     # 0x75c20
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x58(%r12), %rdi
movq -0x38(%rbp), %rsi
movl %r14d, %edx
movq %r15, %rcx
callq 0x59dc3
jmp 0x599e7
movl %r14d, -0x2c(%rbp)
movq 0x58(%r12), %r14
leaq 0x1d4fa(%rip), %rsi     # 0x7686b
xorl %r13d, %r13d
movl $0x4, %edi
xorl %eax, %eax
callq 0x5342c
movq %r14, %rdi
movq %r15, -0x50(%rbp)
movq %r15, %rsi
callq 0x5d023
testl %eax, %eax
je 0x599ea
movslq 0x8(%r14), %rsi
testq %rsi, %rsi
jle 0x5991d
movl -0x2c(%rbp), %r15d
cmpl %r15d, %esi
cmovll %esi, %r15d
addq %r14, %rsi
movslq %r15d, %rdx
subq %rdx, %rsi
addq $0x50c, %rsi            # imm = 0x50C
movq -0x38(%rbp), %rdi
callq 0x84f0
movl $0x0, 0x8(%r14)
movl %r15d, %r13d
jmp 0x599ea
movl %r14d, -0x2c(%rbp)
movq %rbx, -0x40(%rbp)
movq %r12, -0x48(%rbp)
movq 0x58(%r12), %r14
leaq 0x1d817(%rip), %rsi     # 0x76c07
movl $0x4, %edi
xorl %eax, %eax
callq 0x5342c
movq %r14, %rdi
movq %r15, %rsi
callq 0x5d8a0
leaq 0x8548(%r14), %r12
xorl %ebx, %ebx
xorl %r15d, %r15d
cmpl $0x0, -0x8208(%r12)
je 0x5947f
movq 0x338(%r14), %rax
movl 0x240(%rax,%rbx), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x5cb70
testl %eax, %eax
js 0x59443
je 0x5947f
jmp 0x598e6
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
je 0x59474
movq 0x338(%r14), %rax
movl 0x240(%rax,%rbx), %ecx
movl $0x1, %edi
leaq 0x1d7aa(%rip), %rsi     # 0x76c14
movl %r15d, %edx
xorl %eax, %eax
callq 0x5342c
movq %r14, %rdi
movl %r15d, %esi
callq 0x5e158
incq %r15
addq $0x128, %rbx            # imm = 0x128
addq $0x820c, %r12           # imm = 0x820C
cmpq $0x12800, %rbx          # imm = 0x12800
jne 0x59413
jmp 0x59572
movl %r14d, -0x2c(%rbp)
movq %rbx, -0x40(%rbp)
movq %r12, -0x48(%rbp)
movq 0x58(%r12), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5e925
leaq 0x610(%r14), %rbx
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpl $0x0, (%rbx)
je 0x59554
movq 0x608(%r14), %rax
movl 0x240(%rax,%r12), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x5cb70
testl %eax, %eax
js 0x594fa
je 0x59554
jmp 0x599b0
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
je 0x5952c
movq 0x608(%r14), %rax
movl 0x240(%rax,%r12), %ecx
movl $0x1, %edi
leaq 0x1d6f2(%rip), %rsi     # 0x76c14
movl %r15d, %edx
xorl %eax, %eax
callq 0x5342c
movq 0x608(%r14), %rax
leaq (%rax,%r12), %rdi
addq $0x128, %rdi            # imm = 0x128
movl 0x3695c(%rip), %esi     # 0x8fea0
callq 0x5cc1d
movb $0x0, 0x8(%rbx)
movq $0x0, (%rbx)
incq %r15
addq $0x128, %r12            # imm = 0x128
addq $0x408, %rbx            # imm = 0x408
cmpq $0x100, %r15            # imm = 0x100
jne 0x594cb
xorl %r13d, %r13d
jmp 0x599c7
movq %rbx, %r15
movq 0x58(%r12), %rbx
movl (%rbx), %edx
leaq 0x1d01d(%rip), %rsi     # 0x765a8
xorl %r13d, %r13d
movl $0x4, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x5342c
movl (%rbx), %edi
movslq %r14d, %rdx
movq -0x38(%rbp), %rsi
callq 0x88d0
movq %rax, %r14
testl %r14d, %r14d
js 0x59937
movl (%rbx), %edx
leaq 0x1d001(%rip), %rsi     # 0x765c1
movl $0x5, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x5342c
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
sete %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x595f6
leaq -0xf0(%rbp), %rcx
movq -0x38(%rbp), %rsi
movl %r14d, %edx
callq 0x5a98a
movl %r14d, %r13d
jmp 0x59937
movq 0x58(%r12), %rdi
movq -0x38(%rbp), %rsi
movl %r14d, %edx
movq %r15, %rcx
jmp 0x599e2
movq %rbx, %r15
movq 0x58(%r12), %rbx
xorpd %xmm0, %xmm0
leaq -0x70(%rbp), %r13
movapd %xmm0, (%r13)
movl 0x11c(%rbx), %edx
leaq 0x1d90b(%rip), %rsi     # 0x76f40
movl $0x4, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x5342c
leaq -0xf0(%rbp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsi)
movapd %xmm0, 0x60(%rsi)
movapd %xmm0, 0x50(%rsi)
movapd %xmm0, 0x40(%rsi)
movapd %xmm0, 0x30(%rsi)
movapd %xmm0, 0x20(%rsi)
movapd %xmm0, 0x10(%rsi)
movapd %xmm0, (%rsi)
movl 0x11c(%rbx), %edi
leal 0x3f(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
movl %eax, %edx
andl $-0x40, %edx
movl %edi, %ecx
subl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
sarl $0x6, %eax
cltq
orq %rdx, -0xf0(%rbp,%rax,8)
incl %edi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r13, %r8
callq 0x85e0
testl %eax, %eax
jle 0x59934
movl 0x11c(%rbx), %edi
movslq %r14d, %rdx
movq -0x38(%rbp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x84c0
testl %eax, %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmovgl %eax, %r13d
jmp 0x59937
movq %rbx, -0x40(%rbp)
movq 0x58(%r12), %rbx
movl (%rbx), %edx
leaq 0x1cf23(%rip), %rsi     # 0x76618
xorl %r13d, %r13d
movl $0x4, %edi
xorl %eax, %eax
callq 0x5342c
movq %rbx, -0x58(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5c934
testl %eax, %eax
je 0x599cb
movq %r15, -0x50(%rbp)
movl %r14d, -0x2c(%rbp)
movq -0x58(%rbp), %rax
leaq 0x128(%rax), %r15
movl $0x100, %ebx            # imm = 0x100
cmpl $0x2, (%r15)
jne 0x59760
movl 0x118(%r15), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x5cb70
cmpl $-0x1, %eax
je 0x59a51
movl %eax, %r14d
testl %eax, %eax
jg 0x59a9a
addq $0x128, %r15            # imm = 0x128
decq %rbx
jne 0x59733
jmp 0x599cb
movq %r15, -0x50(%rbp)
movq 0x58(%r12), %r15
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
movq (%r15), %rdx
leaq 0x1ce53(%rip), %rsi     # 0x765e0
xorl %r13d, %r13d
movl $0x4, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x5342c
movq (%r15), %rcx
movq 0x3480f(%rip), %rax     # 0x8dfb8
cmpq (%rax), %rcx
je 0x5993f
cmpq $0x0, 0x8(%r15)
je 0x59c62
movl %r14d, -0x2c(%rbp)
cmpl $0x0, 0x828(%r15)
movq %r12, -0x48(%rbp)
je 0x59aae
movl 0x82c(%r15), %r13d
jmp 0x59ae5
movq %r15, %rsi
movl %r14d, %r15d
movq 0x58(%r12), %r14
movq %r14, %rdi
movq %rsi, %r13
callq 0x5e892
testl %eax, %eax
je 0x599ab
movslq 0x4(%r14), %rax
testq %rax, %rax
jle 0x599d1
movl %r15d, %r13d
cmpl %r15d, %eax
cmovll %eax, %r13d
leaq (%r14,%rax), %rsi
addq $0x208, %rsi            # imm = 0x208
movslq %r13d, %r15
subq %r15, %rsi
movq -0x38(%rbp), %rdi
movq %r15, %rdx
callq 0x84f0
subl %r15d, 0x4(%r14)
jle 0x59857
leaq 0x208(%r14), %rax
addq %r15, %rax
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
movb %dl, 0x208(%r14,%rcx)
incq %rcx
cmpl 0x4(%r14), %ecx
jl 0x59843
jmp 0x599ea
movq 0x58(%r12), %r15
leaq 0x1d6f2(%rip), %rsi     # 0x76f5a
xorl %r13d, %r13d
movl $0x4, %edi
movl %r14d, -0x2c(%rbp)
movl %r14d, %edx
xorl %eax, %eax
callq 0x5342c
testq %r15, %r15
je 0x599ea
leaq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x8900
movl 0x8(%r15), %eax
xorl %r13d, %r13d
cmpl $0x0, -0x2c(%rbp)
jle 0x598d5
cmpl 0x4(%r15), %eax
je 0x598d5
movl -0x2c(%rbp), %ecx
xorl %r13d, %r13d
movq -0x38(%rbp), %rsi
cmpl 0xc(%r15), %eax
jl 0x598b8
xorl %eax, %eax
movq 0x38(%r15), %rdx
cltq
movb (%rdx,%rax), %dl
movb %dl, (%rsi,%r13)
incq %r13
incl %eax
cmpl 0x4(%r15), %eax
je 0x598d5
cmpq %rcx, %r13
jb 0x598b0
movl %eax, 0x8(%r15)
movq %r14, %rdi
callq 0x84b0
jmp 0x599ea
movl %eax, %r13d
callq 0x4fece
movq 0x338(%r14), %rcx
movl %eax, 0x248(%rcx,%rbx)
leaq 0x8(%r14), %rdi
leaq -0x8204(%r12), %rsi
callq 0x85c0
movl (%r12), %eax
movl %eax, 0x820f40(%r14)
jmp 0x599c7
movq 0x8510(%r14), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq -0x50(%rbp), %rcx
jmp 0x599e2
movl %eax, %r13d
movq %r15, %rbx
jmp 0x599ea
leaq -0xf0(%rbp), %rsi
xorpd %xmm0, %xmm0
movupd %xmm0, 0x68(%rsi)
movupd %xmm0, 0x58(%rsi)
movupd %xmm0, 0x48(%rsi)
movupd %xmm0, 0x38(%rsi)
movupd %xmm0, 0x28(%rsi)
movupd %xmm0, 0x18(%rsi)
movupd %xmm0, 0x8(%rsi)
movq $0x0, 0x78(%rsi)
movq $0x1, (%rsi)
leaq -0x70(%rbp), %r8
movl $0x1, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x85e0
testl %eax, %eax
je 0x599ea
movslq %r14d, %rdx
xorl %r13d, %r13d
xorl %edi, %edi
movq -0x38(%rbp), %rsi
callq 0x88d0
testl %eax, %eax
cmovgl %eax, %r13d
jmp 0x599ea
xorl %r13d, %r13d
jmp 0x599ea
movl %eax, %r13d
callq 0x4fece
movq 0x608(%r14), %rcx
movl %eax, 0x248(%rcx,%r12)
movq -0x48(%rbp), %r12
movq -0x40(%rbp), %rbx
jmp 0x599ea
movq 0x608(%r14), %rdi
movq -0x38(%rbp), %rsi
movl %r15d, %edx
movq %r13, %rcx
callq 0x59cb7
movl %eax, %r13d
addl %r13d, 0xc(%r12)
callq 0x4fece
movl %eax, %ecx
testl %r13d, %r13d
jle 0x59a00
movl %ecx, 0x24(%r12)
movl %ecx, %esi
subl 0x1c(%r12), %esi
cmpl 0x3648b(%rip), %esi     # 0x8fe98
jl 0x59a34
movl 0xc(%r12), %edi
movl %edi, %eax
subl 0x28(%r12), %eax
imull $0x1f40, %eax, %eax     # imm = 0x1F40
xorl %edx, %edx
divl %esi
movl %eax, 0x10(%r12)
movl %ecx, 0x1c(%r12)
movl %edi, 0x28(%r12)
movq %rbx, %rdi
callq 0x84b0
movl %r13d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x8070
movl (%rax), %ecx
testl %ecx, %ecx
movq -0x40(%rbp), %rbx
je 0x59a7a
movl 0x118(%r15), %edx
leaq 0x1cbc0(%rip), %rsi     # 0x7662e
movl $0x1, %edi
xorl %eax, %eax
callq 0x5342c
movl 0x36420(%rip), %esi     # 0x8fea0
movq %r15, %rdi
callq 0x5cc1d
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x5cc6f
jmp 0x599ea
callq 0x4fece
movl %eax, 0x120(%r15)
movl %r14d, %r13d
jmp 0x599cb
callq 0x4fece
subl 0x858(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x870(%r15), %xmm1
mulsd 0x119a5(%rip), %xmm1    # 0x6b478
mulsd 0x878(%r15), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r13
movq %rbx, -0x40(%rbp)
cmpl %r13d, 0x868(%r15)
ja 0x59bb4
leaq 0x868(%r15), %r14
leaq -0x5c(%rbp), %rbx
leaq -0xf0(%rbp), %r12
movq 0x8(%r15), %rcx
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x8920
testq %rax, %rax
je 0x59b73
movslq 0x830(%r15), %rsi
cmpq $0x4, %rsi
movq %r12, %rdi
cmoveq %rbx, %rdi
movq 0x8(%r15), %rcx
movl $0x1, %edx
callq 0x8920
testq %rax, %rax
je 0x59b73
cmpl $0x4, 0x830(%r15)
je 0x59b5b
movq -0xf0(%rbp), %rax
jmp 0x59b5e
movl -0x5c(%rbp), %eax
movl 0x868(%r15), %ecx
movq %rax, 0x860(%r15)
cmpl %r13d, %ecx
jbe 0x59b08
jmp 0x59bb4
movl $0xffffffff, 0x868(%r15) # imm = 0xFFFFFFFF
movq (%r15), %rdi
callq 0x8030
movq %rax, %r14
movq (%r15), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x86b0
movq (%r15), %rdi
callq 0x8030
movq %rax, 0x860(%r15)
movq (%r15), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x86b0
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd 0x121b4(%rip), %xmm0    # 0x6bd78
movsd %xmm0, -0x58(%rbp)
leaq 0x1ca29(%rip), %rsi     # 0x765f9
movq -0x50(%rbp), %rdi
movb $0x1, %al
callq 0x8120
movq 0x838(%r15), %rdi
movsd 0x840(%r15), %xmm0
movsd -0x58(%rbp), %xmm1
callq 0x4f4e7
movq %rax, 0x848(%r15)
movsd %xmm0, 0x850(%r15)
movq 0x838(%r15), %rdi
movsd 0x840(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x868(%r15), %xmm1
mulsd 0x1214f(%rip), %xmm1    # 0x6bd78
callq 0x4f4e7
movq %rax, %rdi
callq 0x4f620
movq 0x860(%r15), %rbx
movq (%r15), %rdi
callq 0x8030
subq %rax, %rbx
movl -0x2c(%rbp), %ecx
movslq %ecx, %rax
cmpq %rax, %rbx
cmovgel %ecx, %ebx
movq (%r15), %rcx
movl %ebx, %r14d
movq -0x48(%rbp), %r12
movq -0x40(%rbp), %rbx
testl %r14d, %r14d
jle 0x59c80
movl %r14d, %edx
movl $0x1, %esi
movq -0x38(%rbp), %rdi
callq 0x8920
movq %rax, %r13
movq (%r15), %rcx
jmp 0x59c83
xorl %r13d, %r13d
movq %rcx, %rdi
callq 0x8990
testl %eax, %eax
je 0x59c99
movq -0x50(%rbp), %rax
movl $0x646e65, (%rax)       # imm = 0x646E65
movq (%r15), %rdx
leaq 0x1c95e(%rip), %rsi     # 0x76601
movl $0x5, %edi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x5342c
jmp 0x599ea