// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: VmExtractOptArgValue
static void VmExtractOptArgValue(
	jx9_value *pArray,  /* getopt() return value */
	jx9_value *pWorker, /* Worker variable */
	const char *zArg,   /* Argument stream */
	const char *zArgEnd, /* End of the argument stream  */
	int need_val,       /* TRUE to fetch option argument */
	jx9_context *pCtx,  /* Call Context */
	const char *zName   /* Option name */)
{
	jx9_value_bool(pWorker, 0);
	if( !need_val ){
		/* 
		 * Option does not need arguments.
		 * Insert the option name and a boolean FALSE.
		 */
		jx9_array_add_strkey_elem(pArray, (const char *)zName, pWorker); /* Will make it's own copy */
	}else{
		const char *zCur;
		/* Extract option argument */
		zArg++;
		if( zArg < zArgEnd && zArg[0] == '=' ){
			zArg++;
		}
		while( zArg < zArgEnd && (unsigned char)zArg[0] < 0xc0 && SyisSpace(zArg[0]) ){
			zArg++;
		}
		if( zArg >= zArgEnd || zArg[0] == '-' ){
			/*
			 * Argument not found.
			 * Insert the option name and a boolean FALSE.
			 */
			jx9_array_add_strkey_elem(pArray, (const char *)zName, pWorker); /* Will make it's own copy */
			return;
		}
		/* Delimit the value */
		zCur = zArg;
		if( zArg[0] == '\'' || zArg[0] == '"' ){
			int d = zArg[0];
			/* Delimt the argument */
			zArg++;
			zCur = zArg;
			while( zArg < zArgEnd ){
				if( zArg[0] == d && zArg[-1] != '\\' ){
					/* Delimiter found, exit the loop  */
					break;
				}
				zArg++;
			}
			/* Save the value */
			jx9_value_string(pWorker, zCur, (int)(zArg-zCur));
			if( zArg < zArgEnd ){ zArg++; }
		}else{
			while( zArg < zArgEnd && !SyisSpace(zArg[0]) ){
				zArg++;
			}
			/* Save the value */
			jx9_value_string(pWorker, zCur, (int)(zArg-zCur));
		}
		/*
		 * Check if we are dealing with multiple values.
		 * If so, create an array to hold them, rather than a scalar variable.
		 */
		while( zArg < zArgEnd && (unsigned char)zArg[0] < 0xc0 && SyisSpace(zArg[0]) ){
			zArg++;
		}
		if( zArg < zArgEnd && zArg[0] != '-' ){
			jx9_value *pOptArg; /* Array of option arguments */
			pOptArg = jx9_context_new_array(pCtx);
			if( pOptArg == 0 ){
				jx9_context_throw_error(pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
			}else{
				/* Insert the first value */
				jx9_array_add_elem(pOptArg, 0, pWorker); /* Will make it's own copy */
				for(;;){
					if( zArg >= zArgEnd || zArg[0] == '-' ){
						/* No more value */
						break;
					}
					/* Delimit the value */
					zCur = zArg;
					if( zArg < zArgEnd && zArg[0] == '\\' ){
						zArg++;
						zCur = zArg;
					}
					while( zArg < zArgEnd && !SyisSpace(zArg[0]) ){
						zArg++;
					}
					/* Reset the string cursor */
					jx9_value_reset_string_cursor(pWorker);
					/* Save the value */
					jx9_value_string(pWorker, zCur, (int)(zArg-zCur));
					/* Insert */
					jx9_array_add_elem(pOptArg, 0, pWorker); /* Will make it's own copy */
					/* Jump trailing white spaces */
					while( zArg < zArgEnd && (unsigned char)zArg[0] < 0xc0 && SyisSpace(zArg[0]) ){
						zArg++;
					}
				}
				/* Insert the option arg array */
				jx9_array_add_strkey_elem(pArray, (const char *)zName, pOptArg); /* Will make it's own copy */
				/* Safely release */
				jx9_context_release_value(pCtx, pOptArg);
			}
		}else{
			/* Single value */
			jx9_array_add_strkey_elem(pArray, (const char *)zName, pWorker); /* Will make it's own copy */
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, -0x50(%rbp)
movl %r8d, %r15d
movq %rcx, %r13
movq %rdx, -0x48(%rbp)
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10(%rbp), %r12
movq %rsi, %rdi
xorl %esi, %esi
callq 0x294f9
testl %r15d, %r15d
je 0x46f57
movq %rbx, -0x30(%rbp)
movq %r14, -0x40(%rbp)
movq %r12, -0x38(%rbp)
movq -0x48(%rbp), %rcx
leaq 0x1(%rcx), %r14
cmpq %r13, %r14
jae 0x46f04
leaq 0x2(%rcx), %rax
cmpb $0x3d, 0x1(%rcx)
cmoveq %rax, %r14
movq -0x38(%rbp), %r15
movq -0x40(%rbp), %r12
movq -0x30(%rbp), %rdi
cmpq %r13, %r14
jae 0x46f49
movsbq (%r14), %rbx
cmpq $-0x41, %rbx
ja 0x46f37
callq 0xc190
movq -0x30(%rbp), %rdi
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x46f37
incq %r14
jmp 0x46f10
cmpb $0x22, %bl
je 0x46f65
movzbl %bl, %eax
cmpl $0x27, %eax
je 0x46f65
cmpl $0x2d, %eax
jne 0x46f96
movq %rdi, %rdx
movq %r12, %rdi
movq %r15, %rsi
jmp 0x47004
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
jmp 0x47004
incq %r14
xorl %edx, %edx
movq %r14, %r15
cmpq %r13, %r15
jae 0x46f85
cmpb %bl, (%r15)
jne 0x46f7e
cmpb $0x5c, -0x1(%r15)
jne 0x46f85
incq %r15
incl %edx
jmp 0x46f6d
movq %r14, %rsi
callq 0x29588
cmpq %r13, %r15
adcq $0x0, %r15
jmp 0x46fcd
xorl %r12d, %r12d
leaq (%r14,%r12), %r15
cmpq %r13, %r15
jae 0x46fba
callq 0xc190
movq (%rax), %rax
movsbq (%r15), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x46fba
incq %r12
jmp 0x46f99
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x29588
movq -0x40(%rbp), %r12
movq -0x50(%rbp), %r14
cmpq %r13, %r15
jae 0x46ff9
movsbq (%r15), %rbx
cmpq $-0x41, %rbx
ja 0x47017
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x46ff4
incq %r15
jmp 0x46fd1
cmpb $0x2d, %bl
jne 0x47017
movq %r12, %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29c6c
movq %r14, %rdi
callq 0x2a2b0
testq %rax, %rax
je 0x47107
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq -0x30(%rbp), %rbx
movq %rbx, %rdx
callq 0x29c4b
leaq 0x18(%rbx), %rax
movq %rax, -0x48(%rbp)
cmpq %r13, %r15
jae 0x470de
movb (%r15), %al
cmpb $0x2d, %al
je 0x470de
xorl %ecx, %ecx
cmpb $0x5c, %al
sete %cl
addq %rcx, %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %rbx
cmpq %r13, %rbx
jae 0x47086
callq 0xc190
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x47086
incq %r12
jmp 0x47065
movq -0x48(%rbp), %rdi
callq 0x31b1e
movq -0x30(%rbp), %rdi
movq %r15, %rsi
movl %r12d, %edx
movq %rdi, %r15
callq 0x29588
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x29c4b
movq -0x40(%rbp), %r12
cmpq %r13, %rbx
jae 0x470d6
movsbq (%rbx), %r15
cmpq $-0x41, %r15
ja 0x470d6
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r15,2)
je 0x470d6
incq %rbx
jmp 0x470b2
movq %rbx, %r15
jmp 0x47044
movq %r12, %rdi
movq -0x38(%rbp), %rsi
movq %r14, %rdx
callq 0x29c6c
movq -0x50(%rbp), %rdi
movq %r14, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a2f6
movq %r14, %rdi
leaq 0x1f19f(%rip), %rdx     # 0x662b0
pushq $0x1
popq %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a0db