// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::stropen(bamboo::stream_t*, int, int, char const*)
extern int stropen(stream_t *stream, int type, int mode, const char *path)
	{
		tracet(3, "stropen: type=%d mode=%d path=%s\n", type, mode, path);

		stream->type = type;
		stream->mode = mode;
		strcpy(stream->path, path);
		stream->inb = stream->inr = stream->outb = stream->outr = 0;
		stream->tick_i = stream->tick_o = tickget();
		stream->inbt = stream->outbt = 0;
		stream->msg[0] = '\0';
		stream->port = NULL;
		switch (type) {
		case STR_SERIAL: stream->port = openserial(path, mode, stream->msg); break;
		case STR_FILE: stream->port = openfile(path, mode, stream->msg); break;
		case STR_TCPSVR: stream->port = opentcpsvr(path, stream->msg); break;
		case STR_TCPCLI: stream->port = opentcpcli(path, stream->msg); break;
		case STR_NTRIPSVR: stream->port = openntrip(path, 0, stream->msg); break;
		case STR_NTRIPCLI: stream->port = openntrip(path, 1, stream->msg); break;
		case STR_NTRIPC_S: stream->port = openntripc(path, 0, stream->msg); break;
		case STR_NTRIPC_C: stream->port = openntripc(path, 1, stream->msg); break;
		case STR_UDPSVR: stream->port = openudpsvr(path, stream->msg); break;
		case STR_UDPCLI: stream->port = openudpcli(path, stream->msg); break;
		case STR_MEMBUF: stream->port = openmembuf(path, stream->msg); break;
		case STR_FTP: stream->port = openftp(path, 0, stream->msg); break;
		case STR_HTTP: stream->port = openftp(path, 1, stream->msg); break;
		case STR_VRSCONCLI: stream->port = openvrsconcli(path, stream->msg); break;
		case STR_VRSCONSVR: stream->port = openvrsconsvr(path, stream->msg); break;
		default: stream->state = 0; return 1;
		}
		stream->state = !stream->port ? -1 : 1;
		return stream->port != NULL;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movq -0x20(%rbp), %r8
leaq 0x2b741(%rip), %rsi     # 0xc8b58
xorl %eax, %eax
movl $0x3, %edi
callq 0x95890
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x20(%rbp), %rsi
callq 0x96f0
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xc(%rax)
callq 0x8f860
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x460(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x58(%rax)
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0xf, %eax
ja 0x9d708
movq -0x28(%rbp), %rax
leaq 0x2b47c(%rip), %rcx     # 0xc8950
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
callq 0x9d760
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
callq 0x9dc50
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq 0x9e020
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq 0x9e190
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
xorl %esi, %esi
callq 0x9e2f0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
movl $0x1, %esi
callq 0x9e2f0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
xorl %esi, %esi
callq 0x9e520
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
movl $0x1, %esi
callq 0x9e520
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq 0x9e7a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq 0x9e890
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq 0x9e9a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
xorl %esi, %esi
callq 0x9eaa0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x460, %rdx            # imm = 0x460
movl $0x1, %esi
callq 0x9eaa0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq 0x9ebd0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x460, %rsi            # imm = 0x460
callq 0x9ed00
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x9d71c
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x9d756
movq -0x10(%rbp), %rax
cmpq $0x0, 0x58(%rax)
setne %dl
xorb $-0x1, %dl
movl $0x1, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x58(%rax)
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop