// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::strsetsrctbl(bamboo::stream_t*, char const*)
extern int strsetsrctbl(stream_t *stream, const char *file)
	{
		FILE *fp;
		ntripc_t *ntripc;
		char *srctbl = NULL, *srctbl_n;
		int n = 0, nmax;

		tracet(3, "strsetsrctbl: file=%s\n", file);

		strlock(stream);

		if (stream->type != STR_NTRIPC_C && stream->type != STR_NTRIPC_S) {
			strunlock(stream);
			return 1;
		}
		if (!(ntripc = (ntripc_t *)stream->port)) {
			strunlock(stream);
			return 0;
		}
		if (!(fp = fopen(file, "rb"))) {
			tracet(2, "strsetsrctbl: file open error %s\n", file);
			strunlock(stream);
			return 0;
		}
		for (nmax = 4096;; nmax += 4096) {
			if (!(srctbl_n = (char *)realloc(srctbl, nmax))) {
				free(srctbl); fclose(fp);
				strunlock(stream);
				return 0;
			}
			srctbl = srctbl_n;
			n += fread(srctbl + n, 1, nmax - 1 - n, fp);
			if (n < nmax - 1) break;
		}
		srctbl[n++] = '\0';
		fclose(fp);
		tracet(3, "strsetsrctbl: n=%d\n", n);

		lock(&ntripc->lock_srctbl);

		free(ntripc->srctbl);
		ntripc->srctbl = srctbl;

		unlock(&ntripc->lock_srctbl);
		strunlock(stream);
		return 1;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rdx
movl $0x3, %edi
leaq 0x25ae5(%rip), %rsi     # 0xc8bf4
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rdi
callq 0x9ef00
movq -0x10(%rbp), %rax
cmpl $0xb, (%rax)
je 0xa3146
movq -0x10(%rbp), %rax
cmpl $0xa, (%rax)
je 0xa3146
movq -0x10(%rbp), %rdi
callq 0x9f2f0
movl $0x1, -0x4(%rbp)
jmp 0xa32d7
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0xa316d
movq -0x10(%rbp), %rdi
callq 0x9f2f0
movl $0x0, -0x4(%rbp)
jmp 0xa32d7
movq -0x18(%rbp), %rdi
leaq 0x25a93(%rip), %rsi     # 0xc8c0b
callq 0x98d0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0xa31b3
movq -0x18(%rbp), %rdx
movl $0x2, %edi
leaq 0x25a77(%rip), %rsi     # 0xc8c0e
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rdi
callq 0x9f2f0
movl $0x0, -0x4(%rbp)
jmp 0xa32d7
movl $0x1000, -0x40(%rbp)    # imm = 0x1000
movq -0x30(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x9c30
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xa31f8
movq -0x30(%rbp), %rdi
callq 0x9900
movq -0x20(%rbp), %rdi
callq 0x9770
movq -0x10(%rbp), %rdi
callq 0x9f2f0
movl $0x0, -0x4(%rbp)
jmp 0xa32d7
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x3c(%rbp), %rax
addq %rax, %rdi
movl -0x40(%rbp), %eax
subl $0x1, %eax
subl -0x3c(%rbp), %eax
movslq %eax, %rdx
movq -0x20(%rbp), %rcx
movl $0x1, %esi
callq 0x9af0
movq %rax, %rcx
movslq -0x3c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl -0x40(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xa3241
jmp 0xa3253
jmp 0xa3243
movl -0x40(%rbp), %eax
addl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x40(%rbp)
jmp 0xa31ba
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rdi
callq 0x9770
movl -0x3c(%rbp), %edx
movl $0x3, %edi
leaq 0x259af(%rip), %rsi     # 0xc8c30
movb $0x0, %al
callq 0x95890
movq -0x28(%rbp), %rdi
addq $0x310, %rdi            # imm = 0x310
callq 0x9ad0
movq -0x28(%rbp), %rax
movq 0x308(%rax), %rdi
callq 0x9900
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x308(%rax)
movq -0x28(%rbp), %rdi
addq $0x310, %rdi            # imm = 0x310
callq 0x95a0
movq -0x10(%rbp), %rdi
callq 0x9f2f0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq