// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::rspntrip_s(bamboo::ntrip_t*, char*)
static int rspntrip_s(ntrip_t *ntrip, char *msg)
	{
		int i, nb;
		char *p, *q;

		tracet(3, "rspntrip_s: state=%d nb=%d\n", ntrip->state, ntrip->nb);
		ntrip->buff[ntrip->nb] = '0';
		tracet(5, "rspntrip_s: n=%d buff=\n%s\n", ntrip->nb, ntrip->buff);

		if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_OK_SVR))) { /* ok */
			q = (char *)ntrip->buff;
			p += strlen(NTRIP_RSP_OK_SVR);
			ntrip->nb -= p - q;
			for (i = 0; i < ntrip->nb; i++) *q++ = *p++;
			ntrip->state = 2;
			sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt);
			tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb);
			return 1;
		}
		else if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_ERROR))) { /* error */
			nb = ntrip->nb < MAXSTATMSG ? ntrip->nb : MAXSTATMSG;
			strncpy(msg, (char *)ntrip->buff, nb); msg[nb] = 0;
			if ((p = strchr(msg, '\r'))) *p = '\0';
			tracet(1, "rspntrip_s: %s nb=%d\n", msg, ntrip->nb);
			ntrip->nb = 0;
			ntrip->buff[0] = '\0';
			ntrip->state = 0;
			discontcp(&ntrip->tcp->svr, ntrip->tcp->tirecon);
		}
		else if (ntrip->nb >= NTRIP_MAXRSP) { /* buffer overflow */
			sprintf(msg, "response overflow");
			tracet(1, "rspntrip_s: response overflow nb=%d\n", ntrip->nb);
			ntrip->nb = 0;
			ntrip->buff[0] = '\0';
			ntrip->state = 0;
			discontcp(&ntrip->tcp->svr, ntrip->tcp->tirecon);
		}
		tracet(5, "rspntrip_s: exit state=%d nb=%d\n", ntrip->state, ntrip->nb);
		return 0;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x3, %edi
leaq 0x239e8(%rip), %rsi     # 0xc9801
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
movb $0x30, 0x50c(%rax,%rcx)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x10(%rbp), %rcx
addq $0x50c, %rcx            # imm = 0x50C
movl $0x5, %edi
leaq 0x239cb(%rip), %rsi     # 0xc981d
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rdi
addq $0x50c, %rdi            # imm = 0x50C
leaq 0x23ad3(%rip), %rsi     # 0xc993e
callq 0x91b0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xa5f4d
movq -0x10(%rbp), %rax
addq $0x50c, %rax            # imm = 0x50C
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rax
subq %rax, %rdx
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rcx
subq %rdx, %rcx
movl %ecx, 0x8(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xa5ef1
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb (%rax), %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa5eb8
movq -0x10(%rbp), %rax
movl $0x2, (%rax)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8510(%rax), %rdx
addq $0x4, %rdx
movq -0x10(%rbp), %rcx
addq $0x10c, %rcx            # imm = 0x10C
leaq 0x17ce4(%rip), %rsi     # 0xbdc04
movb $0x0, %al
callq 0x9150
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movl $0x2, %edi
leaq 0x238fe(%rip), %rsi     # 0xc9838
movb $0x0, %al
callq 0x95890
movl $0x1, -0x4(%rbp)
jmp 0xa60e1
movq -0x10(%rbp), %rdi
addq $0x50c, %rdi            # imm = 0x50C
leaq 0x238f8(%rip), %rsi     # 0xc9857
callq 0x91b0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xa603c
movq -0x10(%rbp), %rax
cmpl $0x20, 0x8(%rax)
jge 0xa5f88
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0xa5f92
movl $0x20, %eax
movl %eax, -0x34(%rbp)
jmp 0xa5f92
movl -0x34(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x50c, %rsi            # imm = 0x50C
movslq -0x20(%rbp), %rdx
callq 0x93b0
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rdi
movl $0xd, %esi
callq 0x9280
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xa5fdb
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x1, %edi
leaq 0x2386b(%rip), %rsi     # 0xc985d
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x50c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x8510(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8510(%rax), %rax
movl 0x12c(%rax), %esi
callq 0xa4dd0
jmp 0xa60b8
movq -0x10(%rbp), %rax
cmpl $0x8000, 0x8(%rax)      # imm = 0x8000
jl 0xa60b6
movq -0x18(%rbp), %rdi
leaq 0x2381f(%rip), %rsi     # 0xc9873
movb $0x0, %al
callq 0x9150
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movl $0x1, %edi
leaq 0x23817(%rip), %rsi     # 0xc9885
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x50c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x8510(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8510(%rax), %rax
movl 0x12c(%rax), %esi
callq 0xa4dd0
jmp 0xa60b8
jmp 0xa60ba
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x5, %edi
leaq 0x237d7(%rip), %rsi     # 0xc98aa
movb $0x0, %al
callq 0x95890
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)