// File: /workspace/github_c_makefile_star2_O1/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 0x631aa
movq %rdx, %r14
movq (%rdx), %rax
testb $0x1, 0x9(%rax)
je 0x631aa
movq (%rax), %r13
testq %r13, %r13
je 0x631aa
cmpl $0xfeac14, 0x34(%r13)   # imm = 0xFEAC14
jne 0x631aa
movq (%r13), %r12
testq %r12, %r12
je 0x631f8
cmpq $0x0, 0x48(%r12)
je 0x631f8
movl %esi, %r15d
movq 0x8(%r14), %rdi
movq %rdi, -0x30(%rbp)
callq 0x3fd5f
movq -0x30(%rbp), %rax
movq (%rax), %rsi
xorl %edx, %edx
cmpl $0x2, %r15d
je 0x63152
movq 0x10(%r14), %r14
testb $0x2, 0x8(%r14)
je 0x63152
movq %r14, %rdi
movq %rsi, %r15
callq 0x3fd5f
movq %r15, %rsi
movl (%r14), %edx
movq 0x8(%r13), %rdi
callq *0x48(%r12)
movl %eax, %r14d
testl %eax, %eax
jne 0x63191
movl $0x0, 0x20(%r13)
movl 0x28(%r13), %eax
testb $0x4, %al
je 0x63189
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 0x309f2
xorl %eax, %eax
negl %r14d
sbbq %rax, %rax
movq %rax, (%rbx)
jmp 0x631d9
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x16505(%rip), %rcx     # 0x796c1
movl $0x2, %edx
callq 0x4153c
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x309f2
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
movq (%rbx), %rax
movq 0x8(%rax), %rcx
testq %r12, %r12
je 0x6320a
movq (%r12), %r8
jmp 0x63211
leaq 0x16522(%rip), %r8      # 0x79733
leaq 0x16527(%rip), %rdx     # 0x7973f
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x45d26
jmp 0x631c6