// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqliteBuiltin_db_fetch_by_id
static int unqliteBuiltin_db_fetch_by_id(jx9_context *pCtx,int argc,jx9_value **argv)
{
	unqlite_col *pCol;
	const char *zName;
	unqlite_vm *pVm;
	SyString sName;
	jx9_int64 nId;
	int nByte;
	int rc;
	/* Extract collection name */
	if( argc < 2 ){
		/* Missing arguments */
		jx9_context_throw_error(pCtx,JX9_CTX_ERR,"Missing collection name and/or record ID");
		/* Return NULL */
		jx9_result_null(pCtx);
		return JX9_OK;
	}
	zName = jx9_value_to_string(argv[0],&nByte);
	if( nByte < 1){
		jx9_context_throw_error(pCtx,JX9_CTX_ERR,"Invalid collection name");
		/* Return NULL */
		jx9_result_null(pCtx);
		return JX9_OK;
	}
	/* Extract the record ID */
	nId = jx9_value_to_int(argv[1]);
	SyStringInitFromBuf(&sName,zName,nByte);
	pVm = (unqlite_vm *)jx9_context_user_data(pCtx);
	/* Fetch the collection */
	pCol = unqliteCollectionFetch(pVm,&sName,UNQLITE_VM_AUTO_LOAD);
	if( pCol ){
		/* Fetch the desired record */
		jx9_value *pValue;
		pValue = jx9_context_new_scalar(pCtx);
		if( pValue == 0 ){
			jx9_context_throw_error(pCtx,JX9_CTX_ERR,"Jx9 is running out of memory");
			jx9_result_null(pCtx);
			return JX9_OK;
		}else{
			rc = unqliteCollectionFetchRecordById(pCol,nId,pValue);
			if( rc == UNQLITE_OK ){
				jx9_result_value(pCtx,pValue);
				/* pValue will be automatically released as soon we return from this function */
			}else{
				/* No such record, return null */
				jx9_result_null(pCtx);
			}
		}
	}else{
		/* No such collection, return null */
		jx9_result_null(pCtx);
	}
	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 $0x2, -0x14(%rbp)
jge 0x6c1c3
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x5641a(%rip), %rdx     # 0xc25c3
callq 0x580b0
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x6c2d3
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x54(%rbp), %rsi
callq 0x56e20
movq %rax, -0x30(%rbp)
cmpl $0x1, -0x54(%rbp)
jge 0x6c207
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x56260(%rip), %rdx     # 0xc244d
callq 0x580b0
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x6c2d3
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56c90
cltq
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x58300
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x4, %edx
callq 0x6d410
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6c2c3
movq -0x10(%rbp), %rdi
callq 0x58510
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x6c28d
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x56316(%rip), %rdx     # 0xc258c
callq 0x580b0
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x6c2d3
movq -0x28(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x722f0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
jne 0x6c2b6
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x572c0
jmp 0x6c2bf
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x6c2c1
jmp 0x6c2cc
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)