// File: /workspace/github_cpp_makefile_star2_O3/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movzbl (%rdi), %eax
cmpl $0x72, %eax
je 0x22b18
cmpl $0x77, %eax
jne 0x22b26
movl 0x84(%rbx), %edx
testl %edx, %edx
je 0x229d9
movq 0x60(%rbx), %rsi
movq %rbx, %rdi
callq 0x22bd4
movq $0x0, 0x80(%rbx)
movq 0x10(%rbx), %rdi
movl 0x20(%rdi), %r14d
movl $0x4, %esi
callq 0x3180
movq 0x10(%rbx), %rdi
movl 0x20(%rdi), %eax
subl %eax, %r14d
addq %r14, 0x28(%rbx)
cmpl $0xfff, %eax            # imm = 0xFFF
ja 0x22a46
movl $0x1000, %ebp           # imm = 0x1000
movl 0x8(%rbx), %edi
movq 0x68(%rbx), %rsi
movl $0x1000, %edx           # imm = 0x1000
subl %eax, %edx
callq 0x3640
movq 0x10(%rbx), %rdi
movl %ebp, 0x20(%rdi)
movq 0x68(%rbx), %rax
movq %rax, 0x18(%rdi)
movl $0x4, %esi
callq 0x3180
movq 0x10(%rbx), %rdi
movl 0x20(%rdi), %eax
movl %eax, %ecx
subl %ebp, %ecx
negl %ecx
addq %rcx, 0x28(%rbx)
cmpl %ebp, %eax
jb 0x22a05
callq 0x32f0
movl 0x8(%rbx), %ebp
movq 0x18(%rbx), %rax
movl 0x10(%rax), %eax
bswapl %eax
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
movl $0x4, %edx
movl %ebp, %edi
callq 0x3640
movq 0x18(%rbx), %rax
movl 0x10(%rax), %edx
movl %edx, %edi
sarl $0x11, %edi
leal 0x1(%rdi), %ecx
movq 0x8(%rax), %rsi
testl %edi, %edi
js 0x22ab9
movl %ecx, %edi
xorl %r8d, %r8d
movq (%rsi,%r8,8), %r9
bswapq %r9
movq %r9, (%rsi,%r8,8)
incq %r8
cmpq %r8, %rdi
jne 0x22a86
testl %edx, %edx
jle 0x22ab9
movq (%rax), %rdx
xorl %edi, %edi
movl (%rdx,%rdi,4), %r8d
bswapl %r8d
movl %r8d, (%rdx,%rdi,4)
incq %rdi
movslq 0x10(%rax), %r8
cmpq %r8, %rdi
jl 0x22aa2
movslq %ecx, %rdx
shlq $0x3, %rdx
movl %ebp, %edi
callq 0x3640
movq 0x18(%rbx), %rax
movq (%rax), %rsi
movslq 0x10(%rax), %rdx
shlq $0x2, %rdx
movl %ebp, %edi
callq 0x3640
movq 0x20(%rbx), %rax
bswapq %rax
leaq 0x8(%rsp), %r14
movq %rax, (%r14)
movl 0x8(%rbx), %edi
movl $0x8, %edx
movq %r14, %rsi
callq 0x3640
movq 0x28(%rbx), %rax
bswapq %rax
movq %rax, (%r14)
movl 0x8(%rbx), %edi
movl $0x8, %edx
movq %r14, %rsi
callq 0x3640
jmp 0x22b26
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x22b26
callq 0x30a0
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x22b34
callq 0x32c0
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x22b42
callq 0x32c0
movq 0x78(%rbx), %rax
testq %rax, %rax
je 0x22b77
movq 0x18(%rax), %rdi
callq 0x32c0
movq 0x78(%rbx), %rax
movq 0x28(%rax), %rdi
callq 0x32c0
movq 0x78(%rbx), %rax
movq 0x38(%rax), %rdi
callq 0x32c0
movq 0x78(%rbx), %rdi
callq 0x32c0
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x22b9e
movq 0x8(%rax), %rdi
callq 0x32c0
movq 0x18(%rbx), %rax
movq (%rax), %rdi
callq 0x32c0
movq 0x18(%rbx), %rdi
callq 0x32c0
movq 0x10(%rbx), %rdi
callq 0x32c0
movb (%rbx), %al
cmpb $0x72, %al
jne 0x22bb8
movq 0x8(%rbx), %rdi
callq 0x1ca39
movb (%rbx), %al
cmpb $0x77, %al
jne 0x22bc4
movl 0x8(%rbx), %edi
callq 0x3090
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x32c0