// File: /workspace/github_c_makefile_star2_O1/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, -0x48(%rbp)
movl %r8d, %r13d
movq %rcx, %rbx
movq %rdx, -0x30(%rbp)
movq %rsi, %r15
movq %rdi, %r14
movq 0x10(%rbp), %r12
movq %rsi, %rdi
callq 0x309f2
movq $0x0, (%r15)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%r15), %eax
orl $0x8, %eax
movl %eax, 0x8(%r15)
testl %r13d, %r13d
je 0x52eb1
movq %r12, -0x38(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x1(%rcx), %r13
cmpq %rbx, %r13
movq %rbx, %rsi
jae 0x52deb
leaq 0x2(%rcx), %rax
cmpb $0x3d, 0x1(%rcx)
cmoveq %rax, %r13
movq %r14, %r12
cmpq %rsi, %r13
setb %bl
movq %r15, %r14
jae 0x52f38
movb (%r13), %r15b
cmpb $-0x41, %r15b
movq %rsi, -0x30(%rbp)
ja 0x52e50
callq 0xc170
movq -0x30(%rbp), %rsi
movq (%rax), %rcx
leaq 0x1(%r13), %rax
notq %r13
addq %rsi, %r13
movsbq %r15b, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
je 0x52e4a
testq %r13, %r13
je 0x52f38
cmpq %rsi, %rax
setb %bl
movb (%rax), %r15b
incq %rax
decq %r13
cmpb $-0x41, %r15b
jbe 0x52e21
decq %rax
movq %rax, %r13
testb $0x1, %bl
je 0x52f38
movzbl (%r13), %eax
cmpl $0x22, %eax
je 0x52ebf
cmpl $0x27, %eax
je 0x52ebf
cmpl $0x2d, %eax
je 0x52f38
movq %r13, %r15
cmpq %rsi, %r13
jae 0x52e9e
callq 0xc170
movq (%rax), %rax
movq %r13, %r15
movq -0x30(%rbp), %rdx
movsbq (%r15), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x52e9e
incq %r15
cmpq %rdx, %r15
jb 0x52e88
movq %rdx, %r15
movl %r15d, %edx
subl %r13d, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x3087c
jmp 0x52f02
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
jmp 0x52f42
incq %r13
cmpq %rsi, %r13
setb %r15b
movq %r13, %rbx
jae 0x52ee7
cmpb %al, (%rbx)
jne 0x52ed8
cmpb $0x5c, -0x1(%rbx)
jne 0x52ee7
incq %rbx
cmpq %rsi, %rbx
setb %r15b
jb 0x52ece
movq %rsi, %rbx
movl %ebx, %edx
subl %r13d, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x3087c
movzbl %r15b, %r15d
andl $0x1, %r15d
addq %rbx, %r15
movq -0x30(%rbp), %rbx
cmpq %rbx, %r15
jae 0x52f38
subq %r15, %rbx
movsbq (%r15), %r13
cmpq $-0x41, %r13
ja 0x52f32
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r13,2)
je 0x52f32
incq %r15
decq %rbx
jne 0x52f0e
jmp 0x52f38
cmpb $0x2d, %r13b
jne 0x52f55
movq %r12, %rdi
movq -0x38(%rbp), %rsi
movq %r14, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3106a
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x317eb
testq %rax, %rax
je 0x530a4
movq %rax, -0x40(%rbp)
testb $0x40, 0x8(%rax)
je 0x52f85
movq -0x40(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x3f924
movq -0x30(%rbp), %rdx
cmpq %rdx, %r15
movq -0x38(%rbp), %r13
jae 0x53078
movb (%r15), %al
cmpb $0x2d, %al
je 0x53078
xorl %ecx, %ecx
cmpb $0x5c, %al
sete %cl
addq %rcx, %r15
movq %r15, %rbx
cmpq %rdx, %r15
jae 0x52fd8
callq 0xc170
movq -0x30(%rbp), %rdx
movq (%rax), %rax
movq %r15, %rbx
movsbq (%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x52fd8
incq %rbx
cmpq %rdx, %rbx
jb 0x52fc2
movq %rdx, %rbx
movl $0x0, 0x28(%r14)
movl 0x30(%r14), %eax
testb $0x4, %al
je 0x52fff
movq $0x0, 0x20(%r14)
movl $0x0, 0x2c(%r14)
andl $-0x5, %eax
movl %eax, 0x30(%r14)
movl %ebx, %edx
subl %r15d, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3087c
movq -0x40(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x53026
movq (%rax), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x3f924
movq -0x30(%rbp), %rdx
cmpq %rdx, %rbx
jae 0x5306c
movq %rdx, %r15
subq %rbx, %r15
movsbq (%rbx), %r13
cmpq $-0x41, %r13
ja 0x5305e
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r13,2)
je 0x53064
incq %rbx
decq %r15
movq -0x30(%rbp), %rdx
jne 0x53035
movq %rdx, %rbx
movq -0x38(%rbp), %r13
jmp 0x5306c
movq -0x38(%rbp), %r13
movq -0x30(%rbp), %rdx
movq %rbx, %r15
cmpq %rdx, %rbx
jb 0x52f96
movq %r12, %rdi
movq %r13, %rsi
movq -0x40(%rbp), %rbx
movq %rbx, %rdx
callq 0x3106a
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31831
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x2520f(%rip), %rcx     # 0x782c5
movl $0x1, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4153c