// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_fseek
static int jx9Builtin_fseek(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const jx9_io_stream *pStream;
	io_private *pDev;
	jx9_int64 iOfft;
	int whence;  
	int rc;
	if( nArg < 2 || !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_int(pCtx, -1);
		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_int(pCtx, -1);
		return JX9_OK;
	}
	/* Point to the target IO stream device */
	pStream = pDev->pStream;
	if( pStream == 0  || pStream->xSeek == 0){
		jx9_context_throw_error_format(pCtx, JX9_CTX_WARNING, 
			"IO routine(%s) not implemented in the underlying stream(%s) device", 
			jx9_function_name(pCtx), pStream ? pStream->zName : "null_stream"
			);
		jx9_result_int(pCtx, -1);
		return JX9_OK;
	}
	/* Extract the offset */
	iOfft = jx9_value_to_int64(apArg[1]);
	whence = 0;/* SEEK_SET */
	if( nArg > 2 && jx9_value_is_int(apArg[2]) ){
		whence = jx9_value_to_int(apArg[2]);
	}
	/* Perform the requested operation */
	rc = pStream->xSeek(pDev->pHandle, iOfft, whence);
	if( rc == JX9_OK ){
		/* Ignore buffered data */
		ResetIOPrivate(pDev);
	}
	/* IO result */
	jx9_result_int(pCtx, rc == JX9_OK ? 0 : - 1);
	return JX9_OK;	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x2, %esi
jl 0x61729
movq %rdx, %r14
movq (%rdx), %rax
testb $0x1, 0x9(%rax)
je 0x61729
movq (%rax), %r13
testq %r13, %r13
je 0x61729
cmpl $0xfeac14, 0x34(%r13)   # imm = 0xFEAC14
jne 0x61729
movq (%r13), %r12
testq %r12, %r12
je 0x61777
cmpq $0x0, 0x48(%r12)
je 0x61780
movl %esi, %r15d
movq 0x8(%r14), %rdi
movq %rdi, -0x30(%rbp)
callq 0x3f362
movq -0x30(%rbp), %rax
movq (%rax), %rsi
xorl %edx, %edx
cmpl $0x2, %r15d
je 0x616d1
movq 0x10(%r14), %r14
testb $0x2, 0x8(%r14)
je 0x616d1
movq %r14, %rdi
movq %rsi, %r15
callq 0x3f362
movq %r15, %rsi
movl (%r14), %edx
movq 0x8(%r13), %rdi
callq *0x48(%r12)
movl %eax, %r14d
testl %eax, %eax
jne 0x61710
movl $0x0, 0x20(%r13)
movl 0x28(%r13), %eax
testb $0x4, %al
je 0x61708
movq $0x0, 0x18(%r13)
movl $0x0, 0x24(%r13)
andl $-0x5, %eax
movl %eax, 0x28(%r13)
movl $0x0, 0x30(%r13)
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
xorl %eax, %eax
negl %r14d
sbbq %rax, %rax
movq %rax, (%rbx)
jmp 0x61758
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x15f91(%rip), %rcx     # 0x776cc
movl $0x2, %edx
callq 0x40afa
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq $-0x1, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x2, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15fc0(%rip), %r8      # 0x7773e
jmp 0x61784
movq (%r12), %r8
movq (%rbx), %rax
movq 0x8(%rax), %rcx
leaq 0x15fb8(%rip), %rdx     # 0x7774a
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x44ed3
jmp 0x61745