// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::waitntrip(bamboo::ntrip_t*, char*)
static int waitntrip(ntrip_t *ntrip, char *msg)
	{
		int n;
		char *p;

		tracet(4, "waitntrip: state=%d nb=%d\n", ntrip->state, ntrip->nb);

		if (ntrip->state < 0) return 0; /* error */

		if (ntrip->tcp->svr.state < 2) ntrip->state = 0; /* tcp disconnected */

		if (ntrip->state == 0) { /* send request */
			if (!(ntrip->type == 0 ? reqntrip_s(ntrip, msg) : reqntrip_c(ntrip, msg))) {
				return 0;
			}
			tracet(2, "waitntrip: state=%d nb=%d\n", ntrip->state, ntrip->nb);
		}
		if (ntrip->state == 1) { /* read response */
			p = (char *)ntrip->buff + ntrip->nb;
			if ((n = readtcpcli(ntrip->tcp, (unsigned char *)p, NTRIP_MAXRSP - ntrip->nb - 1, msg)) == 0) {
				tracet(5, "waitntrip: readtcp n=%d\n", n);
				return 0;
			}
			ntrip->nb += n; ntrip->buff[ntrip->nb] = '\0';

			/* wait response */
			return ntrip->type == 0 ? rspntrip_s(ntrip, msg) : rspntrip_c(ntrip, msg);
		}
		return 1;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %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 $0x4, %edi
leaq 0x23e99(%rip), %rsi     # 0xc9652
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jge 0xa57d5
movl $0x0, -0x4(%rbp)
jmp 0xa5928
movq -0x10(%rbp), %rax
movq 0x8510(%rax), %rax
cmpl $0x2, (%rax)
jge 0xa57ef
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xa5858
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0xa5814
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa5940
movl %eax, -0x2c(%rbp)
jmp 0xa5824
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa5b10
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl $0x0, %eax
jne 0xa5838
movl $0x0, -0x4(%rbp)
jmp 0xa5928
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x2, %edi
leaq 0x23e01(%rip), %rsi     # 0xc9652
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jne 0xa5921
movq -0x10(%rbp), %rax
addq $0x50c, %rax            # imm = 0x50C
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8510(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movl $0x8000, %edx           # imm = 0x8000
subl 0x8(%rax), %edx
subl $0x1, %edx
movq -0x18(%rbp), %rcx
callq 0x9fdc0
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jne 0xa58cc
movl -0x1c(%rbp), %edx
movl $0x5, %edi
leaq 0x23db1(%rip), %rsi     # 0xc966d
movb $0x0, %al
callq 0x95890
movl $0x0, -0x4(%rbp)
jmp 0xa5928
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
movb $0x0, 0x50c(%rax,%rcx)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0xa5909
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa5df0
movl %eax, -0x30(%rbp)
jmp 0xa5919
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa60f0
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xa5928
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)