// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: csv_write_callback
static int csv_write_callback(jx9_value *pKey, jx9_value *pValue, void *pUserData)
{
	struct csv_data *pData = (struct csv_data *)pUserData;
	const char *zData;
	int nLen, c2;
	sxu32 n;
	/* Point to the raw data */
	zData = jx9_value_to_string(pValue, &nLen);
	if( nLen < 1 ){
		/* Nothing to write */
		return JX9_OK;
	}
	if( pData->iCount > 0 ){
		/* Write the delimiter */
		pData->pDev->pStream->xWrite(pData->pDev->pHandle, (const void *)&pData->delimiter, sizeof(char));
	}
	n = 1;
	c2 = 0;
	if( SyByteFind(zData, (sxu32)nLen, pData->delimiter, 0) == SXRET_OK || 
		SyByteFind(zData, (sxu32)nLen, pData->enclosure, &n) == SXRET_OK ){
			c2 = 1;
			if( n == 0 ){
				c2 = 2;
			}
			/* Write the enclosure */
			pData->pDev->pStream->xWrite(pData->pDev->pHandle, (const void *)&pData->enclosure, sizeof(char));
			if( c2 > 1 ){
				pData->pDev->pStream->xWrite(pData->pDev->pHandle, (const void *)&pData->enclosure, sizeof(char));
			}
	}
	/* Write the data */
	if( pData->pDev->pStream->xWrite(pData->pDev->pHandle, (const void *)zData, (jx9_int64)nLen) < 1 ){
		SXUNUSED(pKey); /* cc warning */
		return JX9_ABORT;
	}
	if( c2 > 0 ){
		/* Write the enclosure */
		pData->pDev->pStream->xWrite(pData->pDev->pHandle, (const void *)&pData->enclosure, sizeof(char));
		if( c2 > 1 ){
			pData->pDev->pStream->xWrite(pData->pDev->pHandle, (const void *)&pData->enclosure, sizeof(char));
		}
	}
	pData->iCount++;
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %rdi
leaq -0x24(%rbp), %r15
movq %r15, %rsi
callq 0x30577
movl (%r15), %esi
testl %esi, %esi
jle 0x64d7f
movq %rax, %r14
cmpl $0x0, 0x10(%rbx)
jle 0x64ca8
movq 0x8(%rbx), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdi
movl $0x1, %edx
movq %rbx, %rsi
callq *0x40(%rcx)
movl -0x24(%rbp), %esi
movl $0x1, -0x28(%rbp)
movl (%rbx), %edx
xorl %r12d, %r12d
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x47327
testl %eax, %eax
je 0x64ce5
movl -0x24(%rbp), %esi
movl 0x4(%rbx), %edx
leaq -0x28(%rbp), %rcx
movq %r14, %rdi
callq 0x47327
testl %eax, %eax
je 0x64cdd
movb $0x1, %r12b
jmp 0x64d1d
cmpl $0x0, -0x28(%rbp)
sete %r12b
movq 0x8(%rbx), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdi
leaq 0x4(%rbx), %r15
movl $0x1, %edx
movq %r15, %rsi
callq *0x40(%rcx)
testb %r12b, %r12b
je 0x64d22
movq 0x8(%rbx), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdi
movl $0x1, %edx
movq %r15, %rsi
callq *0x40(%rcx)
xorl %r12d, %r12d
xorl %r15d, %r15d
jmp 0x64d28
movb $0x1, %r15b
xorl %r12d, %r12d
movq 0x8(%rbx), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdi
movslq -0x24(%rbp), %rdx
movq %r14, %rsi
callq *0x40(%rcx)
testq %rax, %rax
jle 0x64d83
testb %r12b, %r12b
jne 0x64d7c
movq 0x8(%rbx), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdi
leaq 0x4(%rbx), %r14
movl $0x1, %edx
movq %r14, %rsi
callq *0x40(%rcx)
testb %r15b, %r15b
jne 0x64d7c
movq 0x8(%rbx), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdi
movl $0x1, %edx
movq %r14, %rsi
callq *0x40(%rcx)
incl 0x10(%rbx)
xorl %eax, %eax
jmp 0x64d88
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq