// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_fgetcsv
static int jx9Builtin_fgetcsv(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const jx9_io_stream *pStream;
	const char *zLine;
	io_private *pDev;
	jx9_int64 n, nLen;
	if( nArg < 1 || !jx9_value_is_resource(apArg[0]) ){
		/* Missing/Invalid arguments, return FALSE */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Expecting an IO handle");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract our private data */
	pDev = (io_private *)jx9_value_to_resource(apArg[0]);
	/* Make sure we are dealing with a valid io_private instance */
	if( IO_PRIVATE_INVALID(pDev) ){
		/*Expecting an IO handle */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Expecting an IO handle");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Point to the target IO stream device */
	pStream = pDev->pStream;
	if( pStream == 0  ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_WARNING, 
			"IO routine(%s) not implemented in the underlying stream(%s) device, JX9 is returning FALSE", 
			jx9_function_name(pCtx), pStream ? pStream->zName : "null_stream"
			);
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	nLen = -1;
	if( nArg > 1 ){
		/* Maximum data to read */
		nLen = jx9_value_to_int64(apArg[1]);
	}
	/* Perform the requested operation */
	n = StreamReadLine(pDev, &zLine, nLen);
	if( n < 1 ){
		/* EOF or IO error, return FALSE */
		jx9_result_bool(pCtx, 0);
	}else{
		jx9_value *pArray;
		int delim  = ',';   /* Delimiter */
		int encl   = '"' ;  /* Enclosure */
		int escape = '\\';  /* Escape character */
		if( nArg > 2 ){
			const char *zPtr;
			int i;
			if( jx9_value_is_string(apArg[2]) ){
				/* Extract the delimiter */
				zPtr = jx9_value_to_string(apArg[2], &i);
				if( i > 0 ){
					delim = zPtr[0];
				}
			}
			if( nArg > 3 ){
				if( jx9_value_is_string(apArg[3]) ){
					/* Extract the enclosure */
					zPtr = jx9_value_to_string(apArg[3], &i);
					if( i > 0 ){
						encl = zPtr[0];
					}
				}
				if( nArg > 4 ){
					if( jx9_value_is_string(apArg[4]) ){
						/* Extract the escape character */
						zPtr = jx9_value_to_string(apArg[4], &i);
						if( i > 0 ){
							escape = zPtr[0];
						}
					}
				}
			}
		}
		/* Create our array */
		pArray = jx9_context_new_array(pCtx);
		if( pArray == 0 ){
			jx9_context_throw_error(pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
			jx9_result_null(pCtx);
			return JX9_OK;
		}
		/* Parse the raw input */
		jx9ProcessCsv(zLine, (int)n, delim, encl, escape, jx9CsvConsumer, pArray);
		/* Return the freshly created array  */
		jx9_result_value(pCtx, pArray);
	}
	return JX9_OK;	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0xa653d
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x576d0
cmpl $0x0, %eax
jne 0xa6569
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x1f658(%rip), %rdx     # 0xc5ba5
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa67de
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x56ec0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xa658d
movq -0x38(%rbp), %rax
cmpl $0xfeac14, 0x34(%rax)   # imm = 0xFEAC14
je 0xa65b9
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x1f608(%rip), %rdx     # 0xc5ba5
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa67de
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xa6640
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
callq 0x584d0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xa65f7
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0xa6607
leaq 0x1f619(%rip), %rax     # 0xc5c17
movq %rax, -0x88(%rbp)
jmp 0xa6607
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %r8
movl $0x2, %esi
leaq 0x1f59a(%rip), %rdx     # 0xc5bbc
movb $0x0, %al
callq 0x79580
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa67de
movq $-0x1, -0x48(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0xa665f
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56d50
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq -0x30(%rbp), %rsi
callq 0xaad40
movq %rax, -0x40(%rbp)
cmpq $0x1, -0x40(%rbp)
jge 0xa668b
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
jmp 0xa67d7
movl $0x2c, -0x54(%rbp)
movl $0x22, -0x58(%rbp)
movl $0x5c, -0x5c(%rbp)
cmpl $0x2, -0x14(%rbp)
jle 0xa6767
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
je 0xa66e3
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x6c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x6c(%rbp)
jle 0xa66e1
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0xa66e3
cmpl $0x3, -0x14(%rbp)
jle 0xa6765
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
je 0xa6722
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x6c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x6c(%rbp)
jle 0xa6720
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x58(%rbp)
jmp 0xa6722
cmpl $0x4, -0x14(%rbp)
jle 0xa6763
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
je 0xa6761
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x6c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x6c(%rbp)
jle 0xa675f
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x5c(%rbp)
jmp 0xa6761
jmp 0xa6763
jmp 0xa6765
jmp 0xa6767
movq -0x10(%rbp), %rdi
callq 0x58570
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xa67a2
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x1e026(%rip), %rdx     # 0xc47b1
callq 0x580b0
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0xa67de
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %esi
movl -0x54(%rbp), %edx
movl -0x58(%rbp), %ecx
movl -0x5c(%rbp), %r8d
movq -0x50(%rbp), %rax
leaq -0xb021(%rip), %r9      # 0x9b7a0
movq %rax, (%rsp)
callq 0x9b630
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x572c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)