// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: vm_builtin_getopt
static int vm_builtin_getopt(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zIn, *zEnd, *zArg, *zArgIn, *zArgEnd;
	struct getopt_long_opt sLong;
	jx9_value *pArray, *pWorker;
	SyBlob *pArg;
	int nByte;
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid arguments, return FALSE */
		jx9_context_throw_error(pCtx, JX9_CTX_ERR, "Missing/Invalid option arguments");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract option arguments */
	zIn  = jx9_value_to_string(apArg[0], &nByte);
	zEnd = &zIn[nByte];
	/* Point to the string representation of the $argv[] array */
	pArg = &pCtx->pVm->sArgv;
	/* Create a new empty array and a worker variable */
	pArray = jx9_context_new_array(pCtx);
	pWorker = jx9_context_new_scalar(pCtx);
	if( pArray == 0 || pWorker == 0 ){
		jx9_context_throw_error(pCtx,JX9_CTX_ERR, "JX9 is running out of memory");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	if( SyBlobLength(pArg) < 1 ){
		/* Empty command line, return the empty array*/
		jx9_result_value(pCtx, pArray);
		/* Everything will be released automatically when we return 
		 * from this function.
		 */
		return JX9_OK;
	}
	zArgIn = (const char *)SyBlobData(pArg);
	zArgEnd = &zArgIn[SyBlobLength(pArg)];
	/* Fill the long option structure */
	sLong.pArray = pArray;
	sLong.pWorker = pWorker;
	sLong.zArgIn =  zArgIn;
	sLong.zArgEnd = zArgEnd;
	sLong.pCtx = pCtx;
	/* Start processing */
	while( zIn < zEnd ){
		int c = zIn[0];
		int need_val = 0;
		/* Advance the stream cursor */
		zIn++;
		/* Ignore non-alphanum characters */
		if( !SyisAlphaNum(c) ){
			continue;
		}
		if( zIn < zEnd && zIn[0] == ':' ){
			zIn++;
			need_val = 1;
			if( zIn < zEnd && zIn[0] == ':' ){
				zIn++;
			}
		}
		/* Find option */
		zArg = VmFindShortOpt(c, zArgIn, zArgEnd);
		if( zArg == 0 ){
			/* No such option */
			continue;
		}
		/* Extract option argument value */
		VmExtractOptArgValue(pArray, pWorker, zArg, zArgEnd, need_val, pCtx, (const char *)&c);	
	}
	if( nArg > 1 && jx9_value_is_json_array(apArg[1]) && jx9_array_count(apArg[1]) > 0 ){
		/* Process long options */
		jx9_array_walk(apArg[1], VmProcessLongOpt, &sLong);
	}
	/* Return the option array */
	jx9_result_value(pCtx, pArray);
	/* 
	 * Don't worry about freeing memory, everything will be released
	 * automatically as soon we return from this foreign function.
	 */
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0x8bc4d
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0x8bc79
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x38c66(%rip), %rdx     # 0xc48c3
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x8bec4
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movslq -0x8c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
addq $0x3c8, %rax            # imm = 0x3C8
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
callq 0x58570
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x58510
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x8bcdf
cmpq $0x0, -0x80(%rbp)
jne 0x8bd0b
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x38ac2(%rip), %rdx     # 0xc47b1
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x8bec4
movq -0x88(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jae 0x8bd31
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x572c0
movl $0x0, -0x4(%rbp)
jmp 0x8bec4
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x88(%rbp), %rcx
movl 0x10(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x8be6e
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x90(%rbp)
movl $0x0, -0x94(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
callq 0xd1f0
movq (%rax), %rax
movslq -0x90(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x8bdcb
jmp 0x8bd7d
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x8be1b
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x8be1b
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movl $0x1, -0x94(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x8be19
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x8be19
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x8be1b
movl -0x90(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x8dcd0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x8be3e
jmp 0x8bd7d
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl -0x94(%rbp), %r8d
movq -0x10(%rbp), %r9
leaq -0x90(%rbp), %rax
movq %rax, (%rsp)
callq 0x8dd40
jmp 0x8bd7d
cmpl $0x1, -0x14(%rbp)
jle 0x8beb0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x57610
cmpl $0x0, %eax
je 0x8beb0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x57a90
cmpl $0x0, %eax
jbe 0x8beb0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x22d9(%rip), %rsi      # 0x8e180
leaq -0x70(%rbp), %rdx
callq 0x57880
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x572c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq