// File: /workspace/github_c_makefile_star2_O3/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, -0x30(%rbp)
movq %rsi, %r12
movq %rdi, %r14
movq 0x10(%rbp), %rbx
movq %rsi, %rdi
callq 0x30465
movq $0x0, (%r12)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%r12), %eax
orl $0x8, %eax
movl %eax, 0x8(%r12)
testl %r15d, %r15d
je 0x516bd
movq %r14, -0x38(%rbp)
movq %r12, -0x40(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x1(%rcx), %r12
cmpq %r13, %r12
movq %rbx, -0x48(%rbp)
jae 0x5167d
leaq 0x2(%rcx), %rax
cmpb $0x3d, 0x1(%rcx)
cmoveq %rax, %r12
movq %r13, -0x30(%rbp)
cmpq %r13, %r12
jae 0x516e8
movq -0x30(%rbp), %r13
subq %r12, %r13
xorl %r14d, %r14d
xorl %r15d, %r15d
movsbq (%r12,%r14), %rbx
cmpq $-0x41, %rbx
ja 0x516c8
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x516c8
decq %r15
incq %r14
movq %r13, %rax
addq %r15, %rax
jne 0x51693
jmp 0x516e8
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x517fb
leaq (%r15,%r13), %r14
movq %r12, %rdx
subq %r15, %rdx
cmpb $0x22, %bl
je 0x516f9
movzbl %bl, %eax
cmpl $0x27, %eax
je 0x516f9
cmpl $0x2d, %eax
jne 0x51768
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
jmp 0x517fe
movq %r12, %rsi
subq %r15, %rsi
incq %rsi
cmpq -0x30(%rbp), %rsi
jae 0x51742
addq %r15, %r13
addq %r13, %rdx
movb $0x1, %al
movl $0x1, %ecx
movq %rsi, %r13
cmpb %bl, (%r13)
jne 0x51725
cmpb $0x5c, -0x1(%r13)
jne 0x5173a
incq %r13
cmpq -0x30(%rbp), %r13
setb %al
incq %rcx
cmpq %rcx, %r14
jne 0x51718
movq %rdx, %r13
movzbl %al, %ebx
andl $0x1, %ebx
jmp 0x51747
xorl %ebx, %ebx
movq %rsi, %r13
movq -0x30(%rbp), %r14
notl %r12d
addl %r13d, %r15d
addl %r12d, %r15d
movq -0x40(%rbp), %r12
movq %r12, %rdi
movl %r15d, %edx
callq 0x302f6
addq %r13, %rbx
jmp 0x517b9
movq %rdx, %rbx
cmpq -0x30(%rbp), %rdx
jae 0x5179b
movq %rdx, %rbx
callq 0xc170
movq %rbx, %rdx
movq (%rax), %rax
addq %r15, %r13
addq %rbx, %r13
movsbq (%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x5179b
incq %rbx
decq %r14
jne 0x51785
movq %r13, %rbx
movl %ebx, %eax
subl %r12d, %eax
addl %eax, %r15d
movq -0x40(%rbp), %r12
movq %r12, %rdi
movq %rdx, %rsi
movl %r15d, %edx
callq 0x302f6
movq -0x30(%rbp), %r14
cmpq %r14, %rbx
movq -0x50(%rbp), %r13
jae 0x517f3
movq -0x30(%rbp), %r14
subq %rbx, %r14
movsbq (%rbx), %r15
cmpq $-0x41, %r15
ja 0x51811
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r15,2)
je 0x517ed
incq %rbx
decq %r14
jne 0x517c9
jmp 0x517f3
cmpb $0x2d, %r15b
jne 0x51811
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r12, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x30ad3
movq %r13, %rdi
callq 0x31231
testq %rax, %rax
je 0x5193c
movq %rax, %r15
testb $0x40, 0x8(%rax)
je 0x51838
movq (%r15), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x3ef1d
cmpq -0x30(%rbp), %rbx
movq -0x38(%rbp), %r14
jae 0x51914
movb (%rbx), %al
cmpb $0x2d, %al
je 0x51914
xorl %ecx, %ecx
cmpb $0x5c, %al
sete %cl
addq %rcx, %rbx
movq %rbx, %r12
cmpq -0x30(%rbp), %rbx
jae 0x51887
callq 0xc170
movq (%rax), %rax
movq %rbx, %r12
movsbq (%r12), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x51887
incq %r12
cmpq -0x30(%rbp), %r12
jb 0x5186e
movq -0x30(%rbp), %r12
movq -0x40(%rbp), %rdi
movl $0x0, 0x28(%rdi)
movl 0x30(%rdi), %eax
testb $0x4, %al
je 0x518ae
movq $0x0, 0x20(%rdi)
movl $0x0, 0x2c(%rdi)
andl $-0x5, %eax
movl %eax, 0x30(%rdi)
movl %r12d, %edx
subl %ebx, %edx
movq %rbx, %rsi
callq 0x302f6
testb $0x40, 0x8(%r15)
je 0x518d0
movq (%r15), %rdi
xorl %esi, %esi
movq -0x40(%rbp), %rdx
callq 0x3ef1d
movq -0x30(%rbp), %rbx
cmpq %rbx, %r12
jae 0x51907
subq %r12, %rbx
movsbq (%r12), %r14
cmpq $-0x41, %r14
ja 0x51903
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
je 0x51903
incq %r12
decq %rbx
jne 0x518dc
movq -0x30(%rbp), %r12
movq -0x38(%rbp), %r14
movq %r12, %rbx
cmpq -0x30(%rbp), %r12
jb 0x51846
movq %r14, %rdi
movq -0x48(%rbp), %rsi
movq %r15, %rdx
callq 0x30ad3
movq %r13, %rdi
movq %r15, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31277
movq (%r13), %rsi
movq 0x60(%r13), %rdi
addq $0x8, %rsi
leaq 0x24981(%rip), %rcx     # 0x762d0
movl $0x1, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40afa