// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/razf.c
// Function: razf_seek
int64_t razf_seek(RAZF* rz, int64_t pos, int where){
	int64_t idx;
	int64_t seek_pos, new_out;
	rz->z_eof = 0;
	if (where == SEEK_CUR) pos += rz->out;
	else if (where == SEEK_END) pos += rz->src_end;
	if(rz->file_type == FILE_TYPE_PLAIN){
#ifdef _USE_KNETFILE
		knet_seek(rz->x.fpr, pos, SEEK_SET);
        seek_pos = knet_tell(rz->x.fpr);
#else
		seek_pos = lseek(rz->filedes, pos, SEEK_SET);
#endif
		rz->buf_off = rz->buf_len = 0;
		rz->out = rz->in = seek_pos;
		return seek_pos;
	} else if(rz->file_type == FILE_TYPE_GZ){
		if(pos >= rz->out) goto SKIP;
		return rz->out;
	}
	if(pos == rz->out) return pos;
	if(pos > rz->src_end) return rz->out;
	if(!rz->seekable || !rz->load_index){
		if(pos >= rz->out) goto SKIP;
	}
	idx = pos / RZ_BLOCK_SIZE - 1;
	seek_pos = (idx < 0)? rz->header_size:(rz->index->cell_offsets[idx] + rz->index->bin_offsets[idx / RZ_BIN_SIZE]);
	new_out  = (idx + 1) * RZ_BLOCK_SIZE;
	if(pos > rz->out && new_out <= rz->out) goto SKIP;
	_razf_reset_read(rz, seek_pos, new_out);
	SKIP:
	razf_skip(rz, (int)(pos - rz->out));
	return rz->out;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movq 0x38(%rsp), %rax
movl $0x0, 0x8c(%rax)
cmpl $0x1, 0x2c(%rsp)
jne 0x4fceed
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rax
addq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x4fcf09
cmpl $0x2, 0x2c(%rsp)
jne 0x4fcf07
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rax
addq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x4fcf09
movq 0x38(%rsp), %rax
cmpl $0x2, 0x4(%rax)
jne 0x4fcf71
movq 0x38(%rsp), %rax
movl 0x8(%rax), %edi
movq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0x19660
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movl $0x0, 0x84(%rax)
movq 0x38(%rsp), %rax
movl $0x0, 0x80(%rax)
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x38(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x4fd0f8
movq 0x38(%rsp), %rax
cmpl $0x3, 0x4(%rax)
jne 0x4fcfa4
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jl 0x4fcf91
jmp 0x4fd0d0
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x4fd0f8
jmp 0x4fcfa6
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jne 0x4fcfc5
movq 0x30(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x4fd0f8
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x38(%rcx), %rax
jle 0x4fcfe8
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x4fd0f8
movq 0x38(%rsp), %rax
cmpl $0x0, 0x90(%rax)
je 0x4fd004
movq 0x38(%rsp), %rax
cmpl $0x0, 0x94(%rax)
jne 0x4fd01b
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jl 0x4fd019
jmp 0x4fd0d0
jmp 0x4fd01b
movq 0x30(%rsp), %rax
movl $0x8000, %ecx           # imm = 0x8000
cqto
idivq %rcx
subq $0x1, %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jge 0x4fd04b
movq 0x38(%rsp), %rax
movslq 0x70(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x4fd07e
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x38(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x8(%rcx), %rcx
movq 0x20(%rsp), %rdx
shrq $0x11, %rdx
addq (%rcx,%rdx,8), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
shlq $0xf, %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jle 0x4fd0bc
movq 0x10(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jg 0x4fd0bc
jmp 0x4fd0d0
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x4fcdd0
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq 0x28(%rcx), %rax
movl %eax, %esi
callq 0x4fcad0
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)