// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Vfs_putenv
static int jx9Vfs_putenv(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zName, *zValue;
	char *zSettings, *zEnd;
	jx9_vfs *pVfs;
	int iLen, rc;
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid argument, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the setting variable */
	zSettings = (char *)jx9_value_to_string(apArg[0], &iLen);
	if( iLen < 1 ){
		/* Empty string, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Parse the setting */
	zEnd = &zSettings[iLen];
	zValue = 0;
	zName = zSettings;
	while( zSettings < zEnd ){
		if( zSettings[0] == '=' ){
			/* Null terminate the name */
			zSettings[0] = 0;
			zValue = &zSettings[1];
			break;
		}
		zSettings++;
	}
	/* Install the environment variable in the $_Env array */
	if( zValue == 0 || zName[0] == 0 || zValue >= zEnd || zName >= zValue ){
		/* Invalid settings, retun FALSE */
		jx9_result_bool(pCtx, 0);
		if( zSettings  < zEnd ){
			zSettings[0] = '=';
		}
		return JX9_OK;
	}
	jx9_vm_config(pCtx->pVm, JX9_VM_CONFIG_ENV_ATTR, zName, zValue, (int)(zEnd-zValue));
	/* Point to the underlying vfs */
	pVfs = (jx9_vfs *)jx9_context_user_data(pCtx);
	if( pVfs == 0 || pVfs->xSetenv == 0 ){
		/* IO routine not implemented, return NULL */
		jx9_context_throw_error_format(pCtx, JX9_CTX_WARNING, 
			"IO routine(%s) not implemented in the underlying VFS, JX9 is returning FALSE", 
			jx9_function_name(pCtx)
			);
		jx9_result_bool(pCtx, 0);
		zSettings[0] = '=';
		return JX9_OK;
	}
	/* Perform the requested operation */
	rc = pVfs->xSetenv(zName, zValue);
	jx9_result_bool(pCtx, rc == JX9_OK );
	zSettings[0] = '=';
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
testl %esi, %esi
jle 0x5fcb1
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
je 0x5fcb1
leaq -0x24(%rbp), %r15
movq %r15, %rsi
callq 0x30577
movq %rax, %r14
movslq (%r15), %rax
testq %rax, %rax
jle 0x5fcb1
movl %eax, %ecx
addq %r14, %rax
leal -0x1(%rcx), %r8d
movq %r14, %r12
cmpb $0x3d, (%r12)
je 0x5fce1
incq %r12
decl %r8d
cmpq %rax, %r12
jb 0x5fc9f
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, (%r12)
cmpb $0x0, (%r14)
leaq 0x1(%r12), %r15
setne %cl
cmpq %rax, %r15
setb %al
cmpq %r15, %r14
setb %dl
andb %al, %dl
testb %cl, %dl
je 0x5fd6e
movq 0x60(%rbx), %rdi
movl $0x9, %esi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x46833
movq (%rbx), %rax
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x5fd54
movq 0xf8(%rcx), %rcx
testq %rcx, %rcx
je 0x5fd54
movq %r14, %rdi
movq %r15, %rsi
callq *%rcx
xorl %r14d, %r14d
testl %eax, %eax
sete %r14b
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq %r14, (%rbx)
jmp 0x5fd81
movq 0x8(%rax), %rcx
leaq 0x177fe(%rip), %rdx     # 0x7755d
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x44ed3
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
movb $0x3d, (%r12)
jmp 0x5fcd2