// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::rsp_ntripc_c(bamboo::ntripc_t*, int)
static void rsp_ntripc_c(ntripc_t *ntripc, int i)
	{
		bool bvrs = false;
		const char *rsp1 = NTRIP_RSP_UNAUTH, *rsp2 = NTRIP_RSP_OK_CLI;
		ntripc_con_t *con = ntripc->con + i;
		char url[256] = "", mntpnt[256] = "", proto[256] = "", user[256], user_pwd[256], *p, *q;

		tracet(3, "rspntripc_c i=%d\n", i);
		con->buff[con->nb] = '\0';
		tracet(5, "rspntripc_c: n=%d,buff=\n%s\n", con->nb, con->buff);

		if (con->nb >= NTRIP_MAXRSP - 1) { /* buffer overflow */
			tracet(1, "rsp_ntripc_c: request buffer overflow\n");
			discon_ntripc(ntripc, i);
			return;
		}
		/* test GET and User-Agent */
		if (!(p = strstr((char *)con->buff, "GET")) || !(q = strstr(p, "\r\n")) ||
			!(q = strstr(q, "User-Agent:")) || !strstr(q, "\r\n")) {
			tracet(2, "rsp_ntripc_c: NTRIP request error\n");
			discon_ntripc(ntripc, i);
			return;
		}
		/* test protocol */
		if (sscanf(p, "GET %255s %255s", url, proto) < 2 ) {
			tracet(2, "rsp_ntripc_c: NTRIP request error proto=%s\n", proto);
			discon_ntripc(ntripc, i);
			return;
		}
		if ((p = strchr(url, '/'))) strcpy(mntpnt, p + 1);

		/* test mountpoint */
		//if (!*mntpnt || (!test_mntpnt(ntripc, mntpnt) && !Deploy::s_getInstance()->m_checkIsVrs(mntpnt))) {
		if (!*mntpnt || !test_mntpnt(ntripc, mntpnt)) {
			tracet(2, "rsp_ntripc_c: no mountpoint %s\n", mntpnt);

			/* send source table */
			send_srctbl(ntripc, ntripc->tcp->cli[i].sock);
			discon_ntripc(ntripc, i);
			return;
		}
		/* test authentication */
		if (*ntripc->passwd) {
			sprintf(user, "%s:%s", ntripc->user, ntripc->passwd);
			q = user_pwd;
			q += sprintf(q, "Authorization: Basic ");
			q += encbase64(q, (unsigned char *)user, strlen(user));
			if (!(p = strstr((char *)con->buff, "Authorization:")) ||
				strncmp(p, user_pwd, strlen(user_pwd))) {
				tracet(2, "rsp_ntripc_c: authroziation error\n");
				send_nb(ntripc->tcp->cli[i].sock, (unsigned char *)rsp1,
					strlen(rsp1));
				discon_ntripc(ntripc, i);
				return;
			}
		}
		/* test vrs */
		//bvrs = Deploy::s_getInstance()->m_checkIsVrs(mntpnt);
		/* send OK response */
		send_nb(ntripc->tcp->cli[i].sock, (unsigned char *)rsp2, strlen(rsp2));
		con->state = 1;
		strcpy(con->mntpnt, mntpnt);
		/* self defined code */
		con->msgid = MSG_NOTUSE;
		con->nb = 0;
		if (bvrs)
			con->msgid = ++currentMsgCount%MSG_LOOP;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x580, %rsp            # imm = 0x580
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movb $0x0, -0xd(%rbp)
leaq 0x23155(%rip), %rax     # 0xc9a52
movq %rax, -0x18(%rbp)
leaq 0x22ffa(%rip), %rax     # 0xc9902
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movslq -0xc(%rbp), %rcx
imulq $0x820c, %rcx, %rcx     # imm = 0x820C
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x93d0
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x93d0
leaq -0x330(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x93d0
movl -0xc(%rbp), %edx
movl $0x3, %edi
leaq 0x230fe(%rip), %rsi     # 0xc9a6e
movb $0x0, %al
callq 0x95890
movq -0x28(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq 0x204(%rcx), %rcx
movb $0x0, 0x208(%rax,%rcx)
movq -0x28(%rbp), %rax
movl 0x204(%rax), %edx
movq -0x28(%rbp), %rcx
addq $0x208, %rcx            # imm = 0x208
movl $0x5, %edi
leaq 0x230d1(%rip), %rsi     # 0xc9a80
movb $0x0, %al
callq 0x95890
movq -0x28(%rbp), %rax
cmpl $0x7fff, 0x204(%rax)    # imm = 0x7FFF
jl 0xa69ea
movl $0x1, %edi
leaq 0x230ca(%rip), %rsi     # 0xc9a9c
movb $0x0, %al
callq 0x95890
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa6820
jmp 0xa6de6
movq -0x28(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
leaq 0x230c7(%rip), %rsi     # 0xc9ac3
callq 0x91b0
movq %rax, -0x538(%rbp)
cmpq $0x0, %rax
je 0xa6a67
movq -0x538(%rbp), %rdi
leaq 0x231d6(%rip), %rsi     # 0xc9bf2
callq 0x91b0
movq %rax, -0x540(%rbp)
cmpq $0x0, %rax
je 0xa6a67
movq -0x540(%rbp), %rdi
leaq 0x2308b(%rip), %rsi     # 0xc9ac7
callq 0x91b0
movq %rax, -0x540(%rbp)
cmpq $0x0, %rax
je 0xa6a67
movq -0x540(%rbp), %rdi
leaq 0x23196(%rip), %rsi     # 0xc9bf2
callq 0x91b0
cmpq $0x0, %rax
jne 0xa6a8b
movl $0x2, %edi
leaq 0x23060(%rip), %rsi     # 0xc9ad3
movb $0x0, %al
callq 0x95890
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa6820
jmp 0xa6de6
movq -0x538(%rbp), %rdi
leaq -0x130(%rbp), %rdx
leaq -0x330(%rbp), %rcx
leaq 0x2304f(%rip), %rsi     # 0xc9af6
movb $0x0, %al
callq 0x9750
cmpl $0x2, %eax
jge 0xa6ade
leaq -0x330(%rbp), %rdx
movl $0x2, %edi
leaq 0x23040(%rip), %rsi     # 0xc9b06
movb $0x0, %al
callq 0x95890
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa6820
jmp 0xa6de6
leaq -0x130(%rbp), %rdi
movl $0x2f, %esi
callq 0x9280
movq %rax, -0x538(%rbp)
cmpq $0x0, %rax
je 0xa6b13
leaq -0x230(%rbp), %rdi
movq -0x538(%rbp), %rsi
addq $0x1, %rsi
callq 0x96f0
cmpb $0x0, -0x230(%rbp)
je 0xa6b31
movq -0x8(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0xa7380
cmpl $0x0, %eax
jne 0xa6b8a
leaq -0x230(%rbp), %rdx
movl $0x2, %edi
leaq 0x22fee(%rip), %rsi     # 0xc9b32
movb $0x0, %al
callq 0x95890
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x338(%rax), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0xc(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
movl 0x118(%rax), %esi
callq 0xa7470
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa6820
jmp 0xa6de6
movq -0x8(%rbp), %rax
cmpb $0x0, 0x208(%rax)
je 0xa6d32
leaq -0x430(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x108, %rdx            # imm = 0x108
movq -0x8(%rbp), %rcx
addq $0x208, %rcx            # imm = 0x208
leaq 0x224e4(%rip), %rsi     # 0xc90a3
movb $0x0, %al
callq 0x9150
leaq -0x530(%rbp), %rax
movq %rax, -0x540(%rbp)
movq -0x540(%rbp), %rdi
leaq 0x22ba1(%rip), %rsi     # 0xc9783
movb $0x0, %al
callq 0x9150
movl %eax, %ecx
movq -0x540(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x540(%rbp)
movq -0x540(%rbp), %rax
movq %rax, -0x550(%rbp)
leaq -0x430(%rbp), %rax
movq %rax, -0x548(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x92e0
movq -0x550(%rbp), %rdi
movq -0x548(%rbp), %rsi
movl %eax, %edx
callq 0xa64a0
movl %eax, %ecx
movq -0x540(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x540(%rbp)
movq -0x28(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
leaq 0x22eee(%rip), %rsi     # 0xc9b52
callq 0x91b0
movq %rax, -0x538(%rbp)
cmpq $0x0, %rax
je 0xa6cb9
movq -0x538(%rbp), %rax
movq %rax, -0x560(%rbp)
leaq -0x530(%rbp), %rax
movq %rax, -0x558(%rbp)
leaq -0x530(%rbp), %rdi
callq 0x92e0
movq -0x560(%rbp), %rdi
movq -0x558(%rbp), %rsi
movq %rax, %rdx
callq 0x9360
cmpl $0x0, %eax
je 0xa6d30
movl $0x2, %edi
leaq 0x22e9c(%rip), %rsi     # 0xc9b61
movb $0x0, %al
callq 0x95890
movq -0x8(%rbp), %rax
movq 0x338(%rax), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0xc(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
movl 0x118(%rax), %eax
movl %eax, -0x56c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x568(%rbp)
movq -0x18(%rbp), %rdi
callq 0x92e0
movl -0x56c(%rbp), %edi
movq -0x568(%rbp), %rsi
movl %eax, %edx
callq 0xa76b0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa6820
jmp 0xa6de6
jmp 0xa6d32
movq -0x8(%rbp), %rax
movq 0x338(%rax), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0xc(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
movl 0x118(%rax), %eax
movl %eax, -0x57c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x578(%rbp)
movq -0x20(%rbp), %rdi
callq 0x92e0
movl -0x57c(%rbp), %edi
movq -0x578(%rbp), %rsi
movl %eax, %edx
callq 0xa76b0
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x28(%rbp), %rdi
addq $0x4, %rdi
leaq -0x230(%rbp), %rsi
callq 0x96f0
movq -0x28(%rbp), %rax
movl $0xffffffff, 0x8208(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
movl $0x0, 0x204(%rax)
testb $0x1, -0xd(%rbp)
je 0xa6de6
movl 0x69399(%rip), %eax     # 0x110164
addl $0x1, %eax
movl %eax, 0x69390(%rip)     # 0x110164
movl $0x40000, %ecx          # imm = 0x40000
cltd
idivl %ecx
movq -0x28(%rbp), %rax
movl %edx, 0x8208(%rax)
addq $0x580, %rsp            # imm = 0x580
popq %rbp
retq
nop