// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_copy
static int jx9Builtin_copy(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const jx9_io_stream *pSin, *pSout;	
	const char *zFile;
	char zBuf[8192];
	void *pIn, *pOut;
	jx9_int64 n;
	int nLen;
	if( nArg < 2 || !jx9_value_is_string(apArg[0]) || !jx9_value_is_string(apArg[1])){
		/* Missing/Invalid arguments, return FALSE */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Expecting a source and a destination path");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the source name */
	zFile = jx9_value_to_string(apArg[0], &nLen);
	/* Point to the target IO stream device */
	pSin = jx9VmGetStreamDevice(pCtx->pVm, &zFile, nLen);
	if( pSin == 0 ){
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "No such stream device, JX9 is returning FALSE");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Try to open the source file in a read-only mode */
	pIn = jx9StreamOpenHandle(pCtx->pVm, pSin, zFile, JX9_IO_OPEN_RDONLY, FALSE, nArg > 2 ? apArg[2] : 0, FALSE, 0);
	if( pIn == 0 ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_ERR, "IO error while opening source: '%s'", zFile);
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the destination name */
	zFile = jx9_value_to_string(apArg[1], &nLen);
	/* Point to the target IO stream device */
	pSout = jx9VmGetStreamDevice(pCtx->pVm, &zFile, nLen);
	if( pSout == 0 ){
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "No such stream device, JX9 is returning FALSE");
		jx9_result_bool(pCtx, 0);
		jx9StreamCloseHandle(pSin, pIn);
		return JX9_OK;
	}
	if( pSout->xWrite == 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), pSin->zName
			);
		jx9_result_bool(pCtx, 0);
		jx9StreamCloseHandle(pSin, pIn);
		return JX9_OK;
	}
	/* Try to open the destination file in a read-write mode */
	pOut = jx9StreamOpenHandle(pCtx->pVm, pSout, zFile, 
		JX9_IO_OPEN_CREATE|JX9_IO_OPEN_TRUNC|JX9_IO_OPEN_RDWR, FALSE, nArg > 2 ? apArg[2] : 0, FALSE, 0);
	if( pOut == 0 ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_ERR, "IO error while opening destination: '%s'", zFile);
		jx9_result_bool(pCtx, 0);
		jx9StreamCloseHandle(pSin, pIn);
		return JX9_OK;
	}
	/* Perform the requested operation */
	for(;;){
		/* Read from source */
		n = pSin->xRead(pIn, zBuf, sizeof(zBuf));
		if( n < 1 ){
			/* EOF or IO error, break immediately */
			break;
		}
		/* Write to dest */
		n = pSout->xWrite(pOut, zBuf, n);
		if( n < 1 ){
			/* IO error, break immediately */
			break;
		}
	}
	/* Close the streams */
	jx9StreamCloseHandle(pSin, pIn);
	jx9StreamCloseHandle(pSout, pOut);
	/* Return TRUE */
	jx9_result_bool(pCtx, 1);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20c0, %rsp           # imm = 0x20C0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x2, -0x14(%rbp)
jl 0xa7cbf
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
je 0xa7cbf
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0xa7ceb
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x1e01e(%rip), %rdx     # 0xc5ced
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa8065
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x205c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
movl -0x205c(%rbp), %edx
leaq -0x38(%rbp), %rsi
callq 0x8e570
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xa7d50
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x1ddc4(%rip), %rdx     # 0xc5af8
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa8065
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x2078(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x2070(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x2068(%rbp)
cmpl $0x2, -0x14(%rbp)
jle 0xa7d8c
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x2080(%rbp)
jmp 0xa7d97
xorl %eax, %eax
movq %rax, -0x2080(%rbp)
jmp 0xa7d97
movq -0x2068(%rbp), %rdx
movq -0x2070(%rbp), %rsi
movq -0x2078(%rbp), %rdi
movq -0x2080(%rbp), %r9
movl $0x1, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
movl $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x8e7e0
movq %rax, -0x2048(%rbp)
cmpq $0x0, -0x2048(%rbp)
jne 0xa7e15
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl $0x1, %esi
leaq 0x1df20(%rip), %rdx     # 0xc5d17
movb $0x0, %al
callq 0x79580
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa8065
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x205c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
movl -0x205c(%rbp), %edx
leaq -0x38(%rbp), %rsi
callq 0x8e570
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xa7e8b
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x1dc99(%rip), %rdx     # 0xc5af8
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movq -0x28(%rbp), %rdi
movq -0x2048(%rbp), %rsi
callq 0x8ea80
movl $0x0, -0x4(%rbp)
jmp 0xa8065
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0xa7ef5
movq -0x10(%rbp), %rax
movq %rax, -0x2088(%rbp)
movq -0x10(%rbp), %rdi
callq 0x584d0
movq -0x2088(%rbp), %rdi
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq (%rax), %r8
movl $0x2, %esi
leaq 0x1dcf5(%rip), %rdx     # 0xc5bbc
movb $0x0, %al
callq 0x79580
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movq -0x28(%rbp), %rdi
movq -0x2048(%rbp), %rsi
callq 0x8ea80
movl $0x0, -0x4(%rbp)
jmp 0xa8065
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x20a0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x2098(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x2090(%rbp)
cmpl $0x2, -0x14(%rbp)
jle 0xa7f31
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20a8(%rbp)
jmp 0xa7f3c
xorl %eax, %eax
movq %rax, -0x20a8(%rbp)
jmp 0xa7f3c
movq -0x2090(%rbp), %rdx
movq -0x2098(%rbp), %rsi
movq -0x20a0(%rbp), %rdi
movq -0x20a8(%rbp), %r9
movl $0x1c, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
movl $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x8e7e0
movq %rax, -0x2050(%rbp)
cmpq $0x0, -0x2050(%rbp)
jne 0xa7fca
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl $0x1, %esi
leaq 0x1dd9f(%rip), %rdx     # 0xc5d3b
movb $0x0, %al
callq 0x79580
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movq -0x28(%rbp), %rdi
movq -0x2048(%rbp), %rsi
callq 0x8ea80
movl $0x0, -0x4(%rbp)
jmp 0xa8065
jmp 0xa7fcc
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x2048(%rbp), %rdi
leaq -0x2040(%rbp), %rsi
movl $0x2000, %edx           # imm = 0x2000
callq *%rax
movq %rax, -0x2058(%rbp)
cmpq $0x1, -0x2058(%rbp)
jge 0xa7ffc
jmp 0xa8030
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x2050(%rbp), %rdi
leaq -0x2040(%rbp), %rsi
movq -0x2058(%rbp), %rdx
callq *%rax
movq %rax, -0x2058(%rbp)
cmpq $0x1, -0x2058(%rbp)
jge 0xa802e
jmp 0xa8030
jmp 0xa7fcc
movq -0x28(%rbp), %rdi
movq -0x2048(%rbp), %rsi
callq 0x8ea80
movq -0x30(%rbp), %rdi
movq -0x2050(%rbp), %rsi
callq 0x8ea80
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20c0, %rsp           # imm = 0x20C0
popq %rbp
retq
nopw %cs:(%rax,%rax)