// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9VmGetStreamDevice
JX9_PRIVATE const jx9_io_stream * jx9VmGetStreamDevice(
	jx9_vm *pVm,           /* Target VM */
	const char **pzDevice, /* Full path, URI, ... */
	int nByte              /* *pzDevice length*/
	)
{
	const char *zIn, *zEnd, *zCur, *zNext;
	jx9_io_stream **apStream, *pStream;
	SyString sDev, sCur;
	sxu32 n, nEntry;
	int rc;
	/* Check if a scheme [i.e: file://, http://, zip://...] is available */
	zNext = zCur = zIn = *pzDevice;
	zEnd = &zIn[nByte];
	while( zIn < zEnd ){
		if( zIn < &zEnd[-3]/*://*/ && zIn[0] == ':' && zIn[1] == '/' && zIn[2] == '/' ){
			/* Got one */
			zNext = &zIn[sizeof("://")-1];
			break;
		}
		/* Advance the cursor */
		zIn++;
	}
	if( zIn >= zEnd ){
		/* No such scheme, return the default stream */
		return pVm->pDefStream;
	}
	SyStringInitFromBuf(&sDev, zCur, zIn-zCur);
	/* Remove leading and trailing white spaces */
	SyStringFullTrim(&sDev);
	/* Perform a linear lookup on the installed stream devices */
	apStream = (jx9_io_stream **)SySetBasePtr(&pVm->aIOstream);
	nEntry = SySetUsed(&pVm->aIOstream);
	for( n = 0 ; n < nEntry ; n++ ){
		pStream = apStream[n];
		SyStringInitFromBuf(&sCur, pStream->zName, SyStrlen(pStream->zName));
		/* Perfrom a case-insensitive comparison */
		rc = SyStringCmp(&sDev, &sCur, SyStrnicmp);
		if( rc == 0 ){
			/* Stream device found */
			*pzDevice = zNext;
			return pStream;
		}
	}
	/* No such stream, return NULL */
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq %rax, -0x38(%rbp)
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x8e605
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
addq $-0x3, %rcx
cmpq %rcx, %rax
jae 0x8e5f7
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x8e5f7
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2f, %eax
jne 0x8e5f7
movq -0x28(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x2f, %eax
jne 0x8e5f7
movq -0x28(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x40(%rbp)
jmp 0x8e605
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x8e5a8
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x8e623
movq -0x10(%rbp), %rax
movq 0x488(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x8e7c7
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x58(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x58(%rbp)
movb %al, -0x7d(%rbp)
jbe 0x8e67c
movq -0x60(%rbp), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x7d(%rbp)
jge 0x8e67c
callq 0xd1f0
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %al
testb $0x1, %al
jne 0x8e685
jmp 0x8e69c
movl -0x58(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x8e639
jmp 0x8e69e
xorl %eax, %eax
cmpl $0x0, -0x58(%rbp)
movb %al, -0x7e(%rbp)
jbe 0x8e6f3
movq -0x60(%rbp), %rax
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x7e(%rbp)
jge 0x8e6f3
callq 0xd1f0
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movl -0x58(%rbp), %edx
subl $0x1, %edx
movl %edx, %edx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x7e(%rbp)
movb -0x7e(%rbp), %al
testb $0x1, %al
jne 0x8e6fc
jmp 0x8e707
movl -0x58(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x8e69e
movq -0x10(%rbp), %rax
movq 0x468(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x470(%rax), %eax
movl %eax, -0x78(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x78(%rbp), %eax
jae 0x8e7bf
movq -0x48(%rbp), %rax
movl -0x74(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rdi
callq 0x55d10
movl %eax, -0x68(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x68(%rbp), %eax
jne 0x8e77f
movq -0x60(%rbp), %rdi
movq -0x70(%rbp), %rsi
movl -0x68(%rbp), %edx
callq 0x67830
movl %eax, -0x84(%rbp)
jmp 0x8e78b
movl -0x58(%rbp), %eax
subl -0x68(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jne 0x8e7af
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8e7c7
jmp 0x8e7b1
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x8e72a
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)