// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::openntripc(char const*, int, char*)
static ntripc_t *openntripc(const char *path, int type, char *msg)
	{
		ntripc_t *ntripc;
		int i, j;
		char port[256] = "", tpath[MAXSTRPATH];

		tracet(3, "openntripc: path=%s type=%d\n", path, type);

		if (!(ntripc = (ntripc_t *)malloc(sizeof(ntripc_t)))) return NULL;

		ntripc->state = 0;
		ntripc->type = type; /* 0:server,1:client */
		ntripc->srctbl = NULL;
		ntripc->mntpnt[0] = ntripc->user[0] = ntripc->passwd[0] = '\0';
		for (i = 0; i < MAXCLI; i++) {
			ntripc->con[i].state = 0;
			ntripc->con[i].mntpnt[0] = '\0';
			ntripc->con[i].str[0] = '\0';
			ntripc->con[i].nb = 0;
			for (j = 0; j < NTRIP_MAXRSP; j++) ntripc->con[i].buff[j] = 0;
		}
		initlock(&ntripc->lock_srctbl);

		/* decode tcp/ntrip path */
		decodetcppath(path, NULL, port, ntripc->user, ntripc->passwd, NULL, NULL);

		/* use default port if no port specified */
		if (!*port) {
			sprintf(port, "%d", type ? NTRIP_CLI_PORT : NTRIP_SVR_PORT);
		}
		sprintf(tpath, ":%s", port);

		/* open tcp server stream */
		if (!(ntripc->tcp = opentcpsvr(tpath, msg))) {
			tracet(1, "openntripc: opentcpsvr error port=%d\n", port);
			free(ntripc);
			return NULL;
		}
		return ntripc;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x540, %rsp            # imm = 0x540
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
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %ecx
movl $0x3, %edi
leaq 0x2ab71(%rip), %rsi     # 0xc90cd
movb $0x0, %al
callq 0x95890
movl $0x820f48, %edi         # imm = 0x820F48
callq 0x99e0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x9e584
movq $0x0, -0x8(%rbp)
jmp 0x9e790
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x308(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x208(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x108(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x8(%rax)
movl $0x0, -0x2c(%rbp)
cmpl $0x100, -0x2c(%rbp)     # imm = 0x100
jge 0x9e6a3
movq -0x28(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movslq -0x2c(%rbp), %rcx
imulq $0x820c, %rcx, %rcx     # imm = 0x820C
addq %rcx, %rax
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movslq -0x2c(%rbp), %rcx
imulq $0x820c, %rcx, %rcx     # imm = 0x820C
addq %rcx, %rax
movb $0x0, 0x4(%rax)
movq -0x28(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movslq -0x2c(%rbp), %rcx
imulq $0x820c, %rcx, %rcx     # imm = 0x820C
addq %rcx, %rax
movb $0x0, 0x104(%rax)
movq -0x28(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movslq -0x2c(%rbp), %rcx
imulq $0x820c, %rcx, %rcx     # imm = 0x820C
addq %rcx, %rax
movl $0x0, 0x204(%rax)
movl $0x0, -0x30(%rbp)
cmpl $0x8000, -0x30(%rbp)    # imm = 0x8000
jge 0x9e693
movq -0x28(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movslq -0x2c(%rbp), %rcx
imulq $0x820c, %rcx, %rcx     # imm = 0x820C
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movb $0x0, 0x208(%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9e65b
jmp 0x9e695
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9e5cc
movq -0x28(%rbp), %rdi
addq $0x310, %rdi            # imm = 0x310
xorl %eax, %eax
movl %eax, %esi
callq 0x9ae0
movq -0x10(%rbp), %rdi
leaq -0x130(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x108, %rcx            # imm = 0x108
movq -0x28(%rbp), %r8
addq $0x208, %r8             # imm = 0x208
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rsi
movq $0x0, (%rsp)
callq 0x9d090
cmpb $0x0, -0x130(%rbp)
jne 0x9e71e
leaq -0x130(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x50, %edx
movl $0x835, %eax            # imm = 0x835
cmpl $0x0, %ecx
cmovnel %eax, %edx
leaq 0x2a7e3(%rip), %rsi     # 0xc8efa
movb $0x0, %al
callq 0x9150
leaq -0x530(%rbp), %rdi
leaq -0x130(%rbp), %rdx
leaq 0x2a5d9(%rip), %rsi     # 0xc8d0c
movb $0x0, %al
callq 0x9150
leaq -0x530(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x9e020
movq -0x28(%rbp), %rcx
movq %rax, 0x338(%rcx)
cmpq $0x0, %rax
jne 0x9e788
leaq -0x130(%rbp), %rdx
movl $0x1, %edi
leaq 0x2a97c(%rip), %rsi     # 0xc90ea
movb $0x0, %al
callq 0x95890
movq -0x28(%rbp), %rdi
callq 0x9900
movq $0x0, -0x8(%rbp)
jmp 0x9e790
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x540, %rsp            # imm = 0x540
popq %rbp
retq
nopl (%rax)