// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0xa34aa
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0xa34c1
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa3666
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x38(%rbp)
cmpl $0x1, -0x4c(%rbp)
jge 0xa34f2
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa3666
movq -0x38(%rbp), %rax
movslq -0x4c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xa354a
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0xa353c
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xa354a
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xa3511
cmpq $0x0, -0x30(%rbp)
je 0xa3571
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xa3571
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xa3571
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0xa3599
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xa358d
movq -0x38(%rbp), %rax
movb $0x3d, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa3666
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rsi
subq %rsi, %rax
movl %eax, %r8d
movl $0x9, %esi
movb $0x0, %al
callq 0x7ba50
movq -0x10(%rbp), %rdi
callq 0x58300
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xa35e5
movq -0x48(%rbp), %rax
cmpq $0x0, 0xf8(%rax)
jne 0xa362b
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x584d0
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl $0x2, %esi
leaq 0x2242d(%rip), %rdx     # 0xc5a36
movb $0x0, %al
callq 0x79580
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movq -0x38(%rbp), %rax
movb $0x3d, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa3666
movq -0x48(%rbp), %rax
movq 0xf8(%rax), %rax
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq *%rax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
cmpl $0x0, -0x50(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %esi
callq 0x57070
movq -0x38(%rbp), %rax
movb $0x3d, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop