// File: /workspace/github_cpp_makefile_star2_O1/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 0x1bf58(%rip), %rsi     # 0x75e67
xorl %r13d, %r13d
movl $0x4, %edi
xorl %eax, %eax
callq 0x53ec4
testb $0x1, 0x4(%r12)
je 0x5a65d
cmpq $0x0, 0x58(%r12)
je 0x5a65d
leaq 0x30(%r12), %rbx
movq %rbx, %rdi
callq 0x8910
movl (%r12), %eax
xorl %r13d, %r13d
decl %eax
cmpl $0xf, %eax
ja 0x5a655
leaq 0x460(%r12), %r15
leaq 0x1bd0c(%rip), %rcx     # 0x75c70
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 0x5a9e1
jmp 0x5a608
movl %r14d, -0x2c(%rbp)
movq 0x58(%r12), %r14
leaq 0x1c950(%rip), %rsi     # 0x768e6
xorl %r13d, %r13d
movl $0x4, %edi
xorl %eax, %eax
callq 0x53ec4
movq %r14, %rdi
movq %r15, -0x50(%rbp)
movq %r15, %rsi
callq 0x5db7f
testl %eax, %eax
je 0x5a60b
movslq 0x8(%r14), %rsi
testq %rsi, %rsi
jle 0x5a542
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 0x5a60b
movl %r14d, -0x2c(%rbp)
movq %rbx, -0x40(%rbp)
movq %r12, -0x48(%rbp)
movq 0x58(%r12), %r14
leaq 0x1cc6d(%rip), %rsi     # 0x76c82
movl $0x4, %edi
xorl %eax, %eax
callq 0x53ec4
movq %r14, %rdi
movq %r15, %rsi
callq 0x5e3dd
leaq 0x8548(%r14), %r12
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpl $0x0, -0x8208(%r12)
je 0x5a0a4
movq 0x338(%r14), %rax
movl 0x240(%rax,%rbx), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x5d6b4
testl %eax, %eax
js 0x5a068
je 0x5a0a4
jmp 0x5a50b
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
je 0x5a099
movq 0x338(%r14), %rax
movl 0x240(%rax,%rbx), %ecx
movl $0x1, %edi
leaq 0x1cc00(%rip), %rsi     # 0x76c8f
movl %r15d, %edx
xorl %eax, %eax
callq 0x53ec4
movq %r14, %rdi
movl %r15d, %esi
callq 0x5ecaa
addq $0x128, %rbx            # imm = 0x128
incl %r15d
addq $0x820c, %r12           # imm = 0x820C
cmpq $0x12800, %rbx          # imm = 0x12800
jne 0x5a038
jmp 0x5a197
movl %r14d, -0x2c(%rbp)
movq %rbx, -0x40(%rbp)
movq %r12, -0x48(%rbp)
movq 0x58(%r12), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5f457
leaq 0x610(%r14), %rbx
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpl $0x0, (%rbx)
je 0x5a179
movq 0x608(%r14), %rax
movl 0x240(%rax,%r12), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x5d6b4
testl %eax, %eax
js 0x5a11f
je 0x5a179
jmp 0x5a5d1
callq 0x8070
movl (%rax), %r8d
testl %r8d, %r8d
je 0x5a151
movq 0x608(%r14), %rax
movl 0x240(%rax,%r12), %ecx
movl $0x1, %edi
leaq 0x1cb48(%rip), %rsi     # 0x76c8f
movl %r15d, %edx
xorl %eax, %eax
callq 0x53ec4
movq 0x608(%r14), %rax
leaq (%rax,%r12), %rdi
addq $0x128, %rdi            # imm = 0x128
movl 0x35d37(%rip), %esi     # 0x8fea0
callq 0x5d761
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 0x5a0f0
xorl %r13d, %r13d
jmp 0x5a5e8
movq %rbx, %r15
movq 0x58(%r12), %rbx
movl (%rbx), %edx
leaq 0x1c473(%rip), %rsi     # 0x76623
xorl %r13d, %r13d
movl $0x4, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x53ec4
movl (%rbx), %edi
movslq %r14d, %rdx
movq -0x38(%rbp), %rsi
callq 0x88e0
movq %rax, %r14
testl %r14d, %r14d
js 0x5a55c
movl (%rbx), %edx
leaq 0x1c457(%rip), %rsi     # 0x7663c
movl $0x5, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x53ec4
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
sete %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x5a21b
leaq -0xf0(%rbp), %rcx
movq -0x38(%rbp), %rsi
movl %r14d, %edx
callq 0x5b53c
movl %r14d, %r13d
jmp 0x5a55c
movq 0x58(%r12), %rdi
movq -0x38(%rbp), %rsi
movl %r14d, %edx
movq %r15, %rcx
jmp 0x5a603
movq %rbx, %r15
movq 0x58(%r12), %rbx
xorpd %xmm0, %xmm0
leaq -0x70(%rbp), %r13
movapd %xmm0, (%r13)
movl 0x11c(%rbx), %edx
leaq 0x1cd61(%rip), %rsi     # 0x76fbb
movl $0x4, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x53ec4
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 0x5a559
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 0x5a55c
movq %rbx, -0x40(%rbp)
movq 0x58(%r12), %rbx
movl (%rbx), %edx
leaq 0x1c379(%rip), %rsi     # 0x76693
xorl %r13d, %r13d
movl $0x4, %edi
xorl %eax, %eax
callq 0x53ec4
movq %rbx, -0x58(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5d463
testl %eax, %eax
je 0x5a5ec
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 0x5a385
movl 0x118(%r15), %edi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x5d6b4
cmpl $-0x1, %eax
je 0x5a672
movl %eax, %r14d
testl %eax, %eax
jg 0x5a6bb
addq $0x128, %r15            # imm = 0x128
decq %rbx
jne 0x5a358
jmp 0x5a5ec
movq %r15, -0x50(%rbp)
movq 0x58(%r12), %r15
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
movq (%r15), %rdx
leaq 0x1c2a9(%rip), %rsi     # 0x7665b
xorl %r13d, %r13d
movl $0x4, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x53ec4
movq (%r15), %rax
movq 0x33be2(%rip), %rcx     # 0x8dfb0
cmpq (%rcx), %rax
je 0x5a564
cmpq $0x0, 0x8(%r15)
je 0x5a880
movl %r14d, -0x2c(%rbp)
cmpl $0x0, 0x828(%r15)
movq %r12, -0x48(%rbp)
je 0x5a6cf
movl 0x82c(%r15), %r13d
jmp 0x5a706
movq %r15, %rsi
movl %r14d, %r15d
movq 0x58(%r12), %r14
movq %r14, %rdi
movq %rsi, %r13
callq 0x5f3cd
testl %eax, %eax
je 0x5a5cc
movslq 0x4(%r14), %rax
testq %rax, %rax
jle 0x5a5f2
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 0x5a47c
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 0x5a468
jmp 0x5a60b
movq 0x58(%r12), %r15
leaq 0x1cb48(%rip), %rsi     # 0x76fd5
xorl %r13d, %r13d
movl $0x4, %edi
movl %r14d, -0x2c(%rbp)
movl %r14d, %edx
xorl %eax, %eax
callq 0x53ec4
testq %r15, %r15
je 0x5a60b
leaq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x8910
movl 0x8(%r15), %eax
xorl %r13d, %r13d
cmpl $0x0, -0x2c(%rbp)
jle 0x5a4fa
cmpl 0x4(%r15), %eax
je 0x5a4fa
movl -0x2c(%rbp), %ecx
xorl %r13d, %r13d
movq -0x38(%rbp), %rsi
cmpl 0xc(%r15), %eax
jl 0x5a4dd
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 0x5a4fa
cmpq %rcx, %r13
jb 0x5a4d5
movl %eax, 0x8(%r15)
movq %r14, %rdi
callq 0x84b0
jmp 0x5a60b
movl %eax, %r13d
callq 0x5088f
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 0x5a5e8
movq 0x8510(%r14), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq -0x50(%rbp), %rcx
jmp 0x5a603
movl %eax, %r13d
movq %r15, %rbx
jmp 0x5a60b
leaq -0xf0(%rbp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsi)
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)
movq $0x1, (%rsi)
leaq -0x70(%rbp), %r8
movl $0x1, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x85e0
testl %eax, %eax
je 0x5a60b
movslq %r14d, %rdx
xorl %r13d, %r13d
xorl %edi, %edi
movq -0x38(%rbp), %rsi
callq 0x88e0
testl %eax, %eax
cmovgl %eax, %r13d
jmp 0x5a60b
xorl %r13d, %r13d
jmp 0x5a60b
movl %eax, %r13d
callq 0x5088f
movq 0x608(%r14), %rcx
movl %eax, 0x248(%rcx,%r12)
movq -0x48(%rbp), %r12
movq -0x40(%rbp), %rbx
jmp 0x5a60b
movq 0x608(%r14), %rdi
movq -0x38(%rbp), %rsi
movl %r15d, %edx
movq %r13, %rcx
callq 0x5a8d5
movl %eax, %r13d
addl %r13d, 0xc(%r12)
callq 0x5088f
movl %eax, %ecx
testl %r13d, %r13d
jle 0x5a621
movl %ecx, 0x24(%r12)
movl %ecx, %esi
subl 0x1c(%r12), %esi
cmpl 0x3586a(%rip), %esi     # 0x8fe98
jl 0x5a655
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 0x5a69b
movl 0x118(%r15), %edx
leaq 0x1c01a(%rip), %rsi     # 0x766a9
movl $0x1, %edi
xorl %eax, %eax
callq 0x53ec4
movl 0x357ff(%rip), %esi     # 0x8fea0
movq %r15, %rdi
callq 0x5d761
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x5d7b3
jmp 0x5a60b
callq 0x5088f
movl %eax, 0x120(%r15)
movl %r14d, %r13d
jmp 0x5a5ec
callq 0x5088f
subl 0x858(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x870(%r15), %xmm1
mulsd 0x10d84(%rip), %xmm1    # 0x6b478
mulsd 0x878(%r15), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r13
movq %rbx, -0x40(%rbp)
cmpl %r13d, 0x868(%r15)
ja 0x5a7d5
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 0x8930
testq %rax, %rax
je 0x5a794
movslq 0x830(%r15), %rsi
cmpq $0x4, %rsi
movq %r12, %rdi
cmoveq %rbx, %rdi
movq 0x8(%r15), %rcx
movl $0x1, %edx
callq 0x8930
testq %rax, %rax
je 0x5a794
cmpl $0x4, 0x830(%r15)
je 0x5a77c
movq -0xf0(%rbp), %rax
jmp 0x5a77f
movl -0x5c(%rbp), %eax
movl 0x868(%r15), %ecx
movq %rax, 0x860(%r15)
cmpl %r13d, %ecx
jbe 0x5a729
jmp 0x5a7d5
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 0x11593(%rip), %xmm0    # 0x6bd78
movsd %xmm0, -0x58(%rbp)
leaq 0x1be83(%rip), %rsi     # 0x76674
movq -0x50(%rbp), %rdi
movb $0x1, %al
callq 0x8120
movq 0x838(%r15), %rdi
movsd 0x840(%r15), %xmm0
movsd -0x58(%rbp), %xmm1
callq 0x4fe63
movq %rax, 0x848(%r15)
movsd %xmm0, 0x850(%r15)
movq 0x838(%r15), %rdi
movsd 0x840(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x868(%r15), %xmm1
mulsd 0x1152e(%rip), %xmm1    # 0x6bd78
callq 0x4fe63
movq %rax, %rdi
callq 0x4ff9c
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
movl %ebx, %r14d
movq -0x48(%rbp), %r12
movq -0x40(%rbp), %rbx
testl %r14d, %r14d
jle 0x5a89e
movl %r14d, %edx
movq (%r15), %rcx
movl $0x1, %esi
movq -0x38(%rbp), %rdi
callq 0x8930
movq %rax, %r13
jmp 0x5a8a1
xorl %r13d, %r13d
movq (%r15), %rdi
callq 0x89a0
testl %eax, %eax
je 0x5a8b7
movq -0x50(%rbp), %rax
movl $0x646e65, (%rax)       # imm = 0x646E65
movq (%r15), %rdx
leaq 0x1bdbb(%rip), %rsi     # 0x7667c
movl $0x5, %edi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x53ec4
jmp 0x5a60b