// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x2, -0x14(%rbp)
jl 0xa583a
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x576d0
cmpl $0x0, %eax
jne 0xa5869
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x2035b(%rip), %rdx     # 0xc5ba5
callq 0x580b0
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0xa59d3
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x56ec0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xa588d
movq -0x30(%rbp), %rax
cmpl $0xfeac14, 0x34(%rax)   # imm = 0xFEAC14
je 0xa58bc
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x20308(%rip), %rdx     # 0xc5ba5
callq 0x580b0
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0xa59d3
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xa58d9
movq -0x28(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0xa5948
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x584d0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xa5902
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xa590f
leaq 0x2030e(%rip), %rax     # 0xc5c17
movq %rax, -0x58(%rbp)
jmp 0xa590f
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %r8
movl $0x2, %esi
leaq 0x202fc(%rip), %rdx     # 0xc5c23
movb $0x0, %al
callq 0x79580
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0xa59d3
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56d50
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x2, -0x14(%rbp)
jle 0xa5988
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x57390
cmpl $0x0, %eax
je 0xa5988
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x56c90
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x38(%rbp), %rsi
movl -0x3c(%rbp), %edx
callq *%rax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0xa59b3
movq -0x30(%rbp), %rdi
callq 0xaabd0
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %ecx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpl $0x0, %ecx
cmovel %eax, %esi
callq 0x56fb0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)