// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::openntrip(char const*, int, char*)
static ntrip_t *openntrip(const char *path, int type, char *msg)
	{
		ntrip_t *ntrip;
		int i;
		char addr[256] = "", port[256] = "", tpath[MAXSTRPATH];

		tracet(3, "openntrip: path=%s type=%d\n", path, type);

		if (!(ntrip = (ntrip_t *)malloc(sizeof(ntrip_t)))) return NULL;

		ntrip->state = 0;
		ntrip->type = type; /* 0:server,1:client */
		ntrip->nb = 0;
		ntrip->url[0] = '\0';
		ntrip->mntpnt[0] = ntrip->user[0] = ntrip->passwd[0] = ntrip->str[0] = '\0';
		for (i = 0; i < NTRIP_MAXRSP; i++) ntrip->buff[i] = 0;

		/* decode tcp/ntrip path */
		decodetcppath(path, addr, port, ntrip->user, ntrip->passwd, ntrip->mntpnt,
			ntrip->str);

		/* use default port if no port specified */
		if (!*port) {
			sprintf(port, "%d", type ? NTRIP_CLI_PORT : NTRIP_SVR_PORT);
		}
		sprintf(tpath, "%s:%s", addr, port);

		/* ntrip access via proxy server */
		if (*proxyaddr) {
			sprintf(ntrip->url, "http://%s", tpath);
			strcpy(tpath, proxyaddr);
		}
		/* open tcp client stream */
		if (!(ntrip->tcp = opentcpcli(tpath, msg))) {
			tracet(1, "openntrip: opentcp error\n");
			free(ntrip);
			return NULL;
		}
		return ntrip;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x640, %rsp            # imm = 0x640
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%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
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %ecx
movl $0x3, %edi
leaq 0x2ad48(%rip), %rsi     # 0xc9087
movb $0x0, %al
callq 0x95890
movl $0x8518, %edi           # imm = 0x8518
callq 0x99e0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x9e367
movq $0x0, -0x8(%rbp)
jmp 0x9e507
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0xc(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x40c(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x30c(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x20c(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x10c(%rax)
movl $0x0, -0x2c(%rbp)
cmpl $0x8000, -0x2c(%rbp)    # imm = 0x8000
jge 0x9e3e5
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x0, 0x50c(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9e3c1
movq -0x10(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x230(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x20c, %rcx            # imm = 0x20C
movq -0x28(%rbp), %r8
addq $0x30c, %r8             # imm = 0x30C
movq -0x28(%rbp), %r9
addq $0x10c, %r9             # imm = 0x10C
movq -0x28(%rbp), %rax
addq $0x40c, %rax            # imm = 0x40C
movq %rax, (%rsp)
callq 0x9d090
cmpb $0x0, -0x230(%rbp)
jne 0x9e45c
leaq -0x230(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x50, %edx
movl $0x835, %eax            # imm = 0x835
cmpl $0x0, %ecx
cmovnel %eax, %edx
leaq 0x2aaa5(%rip), %rsi     # 0xc8efa
movb $0x0, %al
callq 0x9150
leaq -0x630(%rbp), %rdi
leaq -0x130(%rbp), %rdx
leaq -0x230(%rbp), %rcx
leaq 0x2ac2b(%rip), %rsi     # 0xc90a3
movb $0x0, %al
callq 0x9150
cmpb $0x0, 0x71bda(%rip)     # 0x110060
je 0x9e4b8
movq -0x28(%rbp), %rdi
addq $0xc, %rdi
leaq -0x630(%rbp), %rdx
leaq 0x2ac0b(%rip), %rsi     # 0xc90a9
movb $0x0, %al
callq 0x9150
leaq -0x630(%rbp), %rdi
leaq 0x71bad(%rip), %rsi     # 0x110060
callq 0x96f0
leaq -0x630(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x9e190
movq -0x28(%rbp), %rcx
movq %rax, 0x8510(%rcx)
cmpq $0x0, %rax
jne 0x9e4ff
movl $0x1, %edi
leaq 0x2abce(%rip), %rsi     # 0xc90b3
movb $0x0, %al
callq 0x95890
movq -0x28(%rbp), %rdi
callq 0x9900
movq $0x0, -0x8(%rbp)
jmp 0x9e507
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x640, %rsp            # imm = 0x640
popq %rbp
retq
nopw %cs:(%rax,%rax)