// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/razf.c
// Function: razf_close
void razf_close(RAZF *rz){
	if(rz->mode == 'w'){
#ifndef _RZ_READONLY
		razf_end_flush(rz);
		deflateEnd(rz->stream);
#ifdef _USE_KNETFILE
		save_zindex(rz, rz->x.fpw);
		if(is_big_endian()){
			write(rz->x.fpw, &rz->in, sizeof(int64_t));
			write(rz->x.fpw, &rz->out, sizeof(int64_t));
		} else {
			uint64_t v64 = byte_swap_8((uint64_t)rz->in);
			write(rz->x.fpw, &v64, sizeof(int64_t));
			v64 = byte_swap_8((uint64_t)rz->out);
			write(rz->x.fpw, &v64, sizeof(int64_t));
		}
#else
		save_zindex(rz, rz->filedes);
		if(is_big_endian()){
			write(rz->filedes, &rz->in, sizeof(int64_t));
			write(rz->filedes, &rz->out, sizeof(int64_t));
		} else {
			uint64_t v64 = byte_swap_8((uint64_t)rz->in);
			write(rz->filedes, &v64, sizeof(int64_t));
			v64 = byte_swap_8((uint64_t)rz->out);
			write(rz->filedes, &v64, sizeof(int64_t));
		}
#endif
#endif
	} else if(rz->mode == 'r'){
		if(rz->stream) inflateEnd(rz->stream);
	}
	if(rz->inbuf) free(rz->inbuf);
	if(rz->outbuf) free(rz->outbuf);
	if(rz->header){
		free(rz->header->extra);
		free(rz->header->name);
		free(rz->header->comment);
		free(rz->header);
	}
	if(rz->index){
		free(rz->index->bin_offsets);
		free(rz->index->cell_offsets);
		free(rz->index);
	}
	free(rz->stream);
#ifdef _USE_KNETFILE
    if (rz->mode == 'r')
        knet_close(rz->x.fpr);
    if (rz->mode == 'w')
        close(rz->x.fpw);
#else
	close(rz->filedes);
#endif
	free(rz);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
jne 0x4fd27c
movq 0x10(%rsp), %rdi
callq 0x4fd3a0
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x3b0110
movq 0x10(%rsp), %rdi
movq 0x10(%rsp), %rax
movl 0x8(%rax), %esi
callq 0x4fd4b0
callq 0x4fdc90
cmpl $0x0, %eax
je 0x4fd226
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edi
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movl $0x8, %edx
callq 0x19230
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edi
movq 0x10(%rsp), %rsi
addq $0x28, %rsi
movl $0x8, %edx
callq 0x19230
jmp 0x4fd27a
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x4fd630
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edi
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
callq 0x19230
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x4fd630
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edi
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
callq 0x19230
jmp 0x4fd2a7
movq 0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
jne 0x4fd2a5
movq 0x10(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4fd2a3
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x3bd8c0
jmp 0x4fd2a5
jmp 0x4fd2a7
movq 0x10(%rsp), %rax
cmpq $0x0, 0x60(%rax)
je 0x4fd2c1
movq 0x10(%rsp), %rax
movq 0x60(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
cmpq $0x0, 0x68(%rax)
je 0x4fd2db
movq 0x10(%rsp), %rax
movq 0x68(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
cmpq $0x0, 0x78(%rax)
je 0x4fd32b
movq 0x10(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x38(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
movq 0x78(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x4fd368
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x19ef0
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edi
callq 0x19ec0
movq 0x10(%rsp), %rdi
callq 0x19ef0
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)