// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bgzf.c
// Function: bgzf_read_block
int bgzf_read_block(BGZF *fp)
{
	uint8_t header[BLOCK_HEADER_LENGTH], *compressed_block;
	int count, size = 0, block_length, remaining;
	int64_t block_address;
	block_address = _bgzf_tell((_bgzf_file_t)fp->fp);
	if (fp->cache_size && load_block_from_cache(fp, block_address)) return 0;
	count = _bgzf_read(fp->fp, header, sizeof(header));
	if (count == 0) { // no data read
		fp->block_length = 0;
		return 0;
	}
	if (count != sizeof(header) || !check_header(header)) {
		fp->errcode |= BGZF_ERR_HEADER;
		return -1;
	}
	size = count;
	block_length = unpackInt16((uint8_t*)&header[16]) + 1; // +1 because when writing this number, we used "-1"
	compressed_block = (uint8_t*)fp->compressed_block;
	memcpy(compressed_block, header, BLOCK_HEADER_LENGTH);
	remaining = block_length - BLOCK_HEADER_LENGTH;
	count = _bgzf_read(fp->fp, &compressed_block[BLOCK_HEADER_LENGTH], remaining);
	if (count != remaining) {
		fp->errcode |= BGZF_ERR_IO;
		return -1;
	}
	size += count;
	if ((count = inflate_block(fp, block_length)) < 0) return -1;
	if (fp->block_length != 0) fp->block_offset = 0; // Do not reset offset if this read follows a seek.
	fp->block_address = block_address;
	fp->block_length = count;
	cache_block(fp, size);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
movq 0x8(%rdi), %r12
cmpl $0x0, 0x4(%rbx)
je 0x17a72
movq 0x28(%rbx), %r8
movl (%r8), %r9d
testl %r9d, %r9d
je 0x17a15
movq %r12, %rcx
shrq $0x21, %rcx
movl %r12d, %eax
shll $0xb, %eax
xorl %eax, %ecx
xorl %r12d, %ecx
xorl %r10d, %r10d
movl %ecx, %eax
xorl %edx, %edx
divl %r9d
movl %edx, %esi
leal -0x1(%r9), %r11d
movl %ecx, %eax
xorl %edx, %edx
divl %r11d
incl %edx
movq 0x10(%r8), %r11
movl %esi, %eax
movl %eax, %ecx
shrl $0x4, %ecx
movl (%r11,%rcx,4), %ebp
leal (%rax,%rax), %ecx
andl $0x1e, %ecx
movl %ebp, %r14d
shrl %cl, %r14d
testb $0x2, %r14b
jne 0x17a09
testb $0x1, %r14b
jne 0x179f5
movq 0x18(%r8), %r14
movl %eax, %r15d
cmpq %r12, (%r14,%r15,8)
je 0x17a09
addl %edx, %eax
cmpl %r9d, %eax
movl %r9d, %ecx
cmovbl %r10d, %ecx
subl %ecx, %eax
cmpl %esi, %eax
jne 0x179c7
jmp 0x17a72
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r9d, %eax
jmp 0x17a17
xorl %eax, %eax
cmpl %r9d, %eax
je 0x17a72
movl %eax, %eax
leaq (%rax,%rax,2), %r14
shlq $0x3, %r14
addq 0x20(%r8), %r14
cmpl $0x0, 0x8(%rbx)
je 0x17a37
movl $0x0, 0xc(%rbx)
movq %r12, 0x10(%rbx)
movl (%r14), %eax
movl %eax, 0x8(%rbx)
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rsi
movl $0x10000, %edx          # imm = 0x10000
callq 0x3370
movq 0x30(%rbx), %rdi
movq 0x10(%r14), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x15ed4
cmpl $0x0, (%r14)
jne 0x17c3f
movq 0x30(%rbx), %rdi
movq %rsp, %rsi
movl $0x12, %edx
callq 0x15e14
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rax, %rcx
je 0x17c36
cmpl $0x12, %ecx
jne 0x17c2c
cmpb $0x1f, (%rsp)
jne 0x17c2c
cmpb $-0x75, 0x1(%rsp)
jne 0x17c2c
cmpb $0x8, 0x2(%rsp)
jne 0x17c2c
testb $0x4, 0x3(%rsp)
je 0x17c2c
cmpw $0x6, 0xa(%rsp)
jne 0x17c2c
cmpb $0x42, 0xc(%rsp)
jne 0x17c2c
cmpb $0x43, 0xd(%rsp)
jne 0x17c2c
cmpw $0x2, 0xe(%rsp)
jne 0x17c2c
movzwl 0x10(%rsp), %r13d
movq 0x20(%rbx), %rsi
movzwl 0x10(%rsp), %eax
movw %ax, 0x10(%rsi)
movapd (%rsp), %xmm0
movupd %xmm0, (%rsi)
leaq -0x11(%r13), %r15
movq 0x30(%rbx), %rdi
addq $0x12, %rsi
movq %r15, %rdx
callq 0x15e14
movq %rax, %r14
cmpl %r14d, %r15d
jne 0x17c53
xorpd %xmm0, %xmm0
leaq 0x50(%rsp), %rdi
movupd %xmm0, 0x40(%rdi)
movq 0x20(%rbx), %rax
addq $0x12, %rax
movq %rax, (%rdi)
addl $-0xf, %r13d
movl %r13d, 0x8(%rdi)
movq 0x18(%rbx), %rax
movq %rax, 0x18(%rdi)
movl $0x10000, 0x20(%rdi)    # imm = 0x10000
leaq 0x4d3d(%rip), %rdx      # 0x1c89f
movl $0xfffffff1, %esi       # imm = 0xFFFFFFF1
movl $0x70, %ecx
callq 0x34c0
testl %eax, %eax
jne 0x17c58
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movl $0x4, %esi
callq 0x30e0
movl %eax, %ebp
xorl $0x1, %ebp
movq %r15, %rdi
callq 0x3380
orl %ebp, %eax
jne 0x17c58
movl 0x78(%rsp), %eax
testl %eax, %eax
js 0x17c2f
cmpl $0x0, 0x8(%rbx)
je 0x17bb9
movl $0x0, 0xc(%rbx)
movq %r12, 0x10(%rbx)
movl %eax, 0x8(%rbx)
movl 0x4(%rbx), %ecx
cmpl $0x10001, %ecx          # imm = 0x10001
jl 0x17c3d
movq 0x28(%rbx), %r13
movl (%r13), %eax
movl 0x4(%r13), %edx
shll $0x10, %edx
addl $0x10000, %edx          # imm = 0x10000
cmpl %ecx, %edx
movq %r14, 0x28(%rsp)
jbe 0x17c27
testl %eax, %eax
je 0x17c5d
movq 0x10(%r13), %rsi
movl $0x4, %edx
xorl %edi, %edi
xorl %r12d, %r12d
movl %edi, %ebp
andl $0x1e, %ebp
movl $0x3, %r14d
movl %ebp, %ecx
shll %cl, %r14d
movl %r12d, %r15d
shrl $0x4, %r15d
testl %r14d, (%rsi,%r15,4)
je 0x17c62
incl %r12d
addq $0xc, %rdx
addl $0x2, %edi
cmpl %r12d, %eax
jne 0x17bfb
movl %eax, %r12d
jmp 0x17c97
orb $0x2, (%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x17c3f
movl $0x0, 0x8(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
orb $0x4, (%rbx)
jmp 0x17c2f
orb $0x1, (%rbx)
jmp 0x17c2f
xorl %r12d, %r12d
jmp 0x17c97
movq 0x20(%r13), %rax
movq (%rax,%rdx,2), %rdi
callq 0x3060
movl (%r13), %edx
cmpl %r12d, %edx
je 0x17c97
movq 0x10(%r13), %rax
movl (%rax,%r15,4), %ecx
movl %edx, %r12d
testl %r14d, %ecx
jne 0x17c97
btsl %ebp, %ecx
movl %ecx, (%rax,%r15,4)
decl 0x4(%r13)
movl (%r13), %r12d
movq 0x10(%rbx), %r15
movl 0x8(%r13), %eax
cmpl 0xc(%r13), %eax
jb 0x17f3d
movl 0x4(%r13), %eax
leal (%rax,%rax), %edx
xorl %ecx, %ecx
cmpl %r12d, %edx
sbbl %ecx, %ecx
orl $0x1, %ecx
addl %r12d, %ecx
movl $0x21, %esi
leaq 0x55d7(%rip), %rdx      # 0x1d2a0
leal -0x2(%rsi), %edi
decl %esi
cmpl %ecx, (%rdx,%rdi,4)
ja 0x17cc9
movl %esi, %ecx
movl (%rdx,%rcx,4), %ebp
cvtsi2sd %rbp, %xmm0
mulsd 0x255b(%rip), %xmm0     # 0x1a240
addsd 0x2533(%rip), %xmm0     # 0x1a220
cvttsd2si %xmm0, %rcx
cmpl %ecx, %eax
jae 0x17f3d
movq %rcx, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
leaq 0x4(,%rax,4), %r14
movq %r14, %rdi
callq 0x33e0
movq %rax, %r15
movq %rax, %rdi
movl $0xaa, %esi
movq %r14, %rdx
callq 0x3260
cmpl %ebp, %r12d
jae 0x17d5e
movq 0x18(%r13), %rdi
leaq (,%rbp,8), %r12
movq %r12, %rsi
callq 0x3430
movq %rax, 0x18(%r13)
movq 0x20(%r13), %rdi
leaq (%r12,%r12,2), %rsi
callq 0x3430
movq %rax, 0x20(%r13)
movl (%r13), %r12d
testl %r12d, %r12d
je 0x17f14
leal -0x1(%rbp), %edi
xorl %r8d, %r8d
movq 0x10(%r13), %r9
movl %r8d, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %edx
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %edx, %esi
shrl %cl, %esi
testb $0x3, %sil
jne 0x17eda
movq 0x18(%r13), %rsi
movl %r8d, %r11d
movq (%rsi,%r11,8), %r10
movq 0x20(%r13), %rsi
leaq (%r11,%r11,2), %r11
movq 0x10(%rsi,%r11,8), %r14
movq %r14, 0x60(%rsp)
movupd (%rsi,%r11,8), %xmm0
movapd %xmm0, 0x50(%rsp)
btsl %ecx, %edx
movl %edx, (%r9,%rax,4)
movq %r10, %rcx
shrq $0x21, %rcx
movl %r10d, %eax
shll $0xb, %eax
xorl %eax, %ecx
xorl %r10d, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %esi, %eax
movl %esi, %ecx
addl %esi, %ecx
andl $0x1e, %ecx
movl $0x2, %r12d
shll %cl, %r12d
shrl $0x4, %eax
movl (%r15,%rax,4), %r11d
testl %r11d, %r12d
jne 0x17e29
incl %edx
addl %edx, %esi
xorl %eax, %eax
cmpl %ebp, %esi
jb 0x17e0a
movl %ebp, %eax
subl %eax, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r15,%rax,4), %r11d
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl $0x2, %r12d
shll %cl, %r12d
testl %r11d, %r12d
je 0x17e00
notl %r12d
andl %r11d, %r12d
movl %r12d, (%r15,%rax,4)
cmpl (%r13), %esi
jae 0x17eaf
movl (%r9,%rax,4), %r9d
shrl %cl, %r9d
movq 0x18(%r13), %rdx
testb $0x3, %r9b
jne 0x17eb3
movl %esi, %esi
movq (%rdx,%rsi,8), %r11
movq %r10, (%rdx,%rsi,8)
movq 0x20(%r13), %rdx
leaq (%rsi,%rsi,2), %rsi
movq 0x10(%rdx,%rsi,8), %r9
movq %r9, 0x40(%rsp)
movups (%rdx,%rsi,8), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x60(%rsp), %r9
movq %r9, 0x10(%rdx,%rsi,8)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rdx,%rsi,8)
movq 0x40(%rsp), %rdx
movq %rdx, 0x60(%rsp)
movapd 0x30(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
movl $0x1, %edx
shll %cl, %edx
movq 0x10(%r13), %r9
orl %edx, (%r9,%rax,4)
movq %r11, %r10
jmp 0x17dc0
movq 0x18(%r13), %rdx
movl %esi, %eax
movq %r10, (%rdx,%rax,8)
movq 0x20(%r13), %rcx
leaq (%rax,%rax,2), %rax
movq 0x60(%rsp), %rdx
movq %rdx, 0x10(%rcx,%rax,8)
movapd 0x50(%rsp), %xmm0
movupd %xmm0, (%rcx,%rax,8)
movl (%r13), %r12d
incl %r8d
cmpl %r12d, %r8d
jne 0x17d6d
cmpl %ebp, %r12d
jbe 0x17f14
movq 0x18(%r13), %rdi
leaq (,%rbp,8), %r12
movq %r12, %rsi
callq 0x3430
movq %rax, 0x18(%r13)
movq 0x20(%r13), %rdi
leaq (%r12,%r12,2), %rsi
callq 0x3430
movq %rax, 0x20(%r13)
movq 0x10(%r13), %rdi
callq 0x3060
movq %r15, 0x10(%r13)
movl %ebp, (%r13)
movl 0x4(%r13), %eax
movl %eax, 0x8(%r13)
movq 0x18(%rsp), %rax
movl %eax, 0xc(%r13)
movq 0x20(%rsp), %r15
jmp 0x17f40
movl %r12d, %ebp
movq %r15, %rdi
shrq $0x21, %rdi
movl %r15d, %eax
shll $0xb, %eax
xorl %eax, %edi
xorl %r15d, %edi
xorl %r9d, %r9d
movl %edi, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %esi
movq 0x10(%r13), %r8
movl %edx, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %eax
leal (%rsi,%rsi), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x17f77
movl %esi, %eax
jmp 0x17fef
leal -0x1(%rbp), %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %esi, %edi
movl %ebp, %eax
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %r10d
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %r10d, %r11d
shrl %cl, %r11d
testb $0x2, %r11b
jne 0x17fd5
testb $0x1, %r11b
jne 0x17fb4
movq 0x18(%r13), %r11
movl %edi, %r14d
cmpq %r15, (%r11,%r14,8)
je 0x17fd5
btl %ecx, %r10d
cmovbl %edi, %eax
addl %edx, %edi
cmpl %ebp, %edi
movl %ebp, %ecx
cmovbl %r9d, %ecx
subl %ecx, %edi
cmpl %esi, %edi
jne 0x17f86
movb $0x1, %cl
movl %ebp, %edx
cmpl %ebp, %eax
je 0x17fe3
jmp 0x17fef
shrl %cl, %r10d
testb $0x2, %r10b
sete %cl
movl %eax, %edx
movl %edi, %esi
cmpl %ebp, %edx
cmovel %esi, %edx
testb %cl, %cl
cmovnel %esi, %edx
movl %edx, %eax
movl %eax, %edx
shrl $0x4, %edx
movl (%r8,%rdx,4), %esi
leal (%rax,%rax), %ecx
andl $0x1e, %ecx
movl %esi, %edi
shrl %cl, %edi
testb $0x2, %dil
jne 0x18035
testb $0x1, %dil
je 0x17c3d
movq 0x18(%r13), %rdi
movl $0x3, %r9d
shll %cl, %r9d
movl %eax, %eax
movq %r15, (%rdi,%rax,8)
notl %r9d
andl %r9d, %esi
movl %esi, (%r8,%rdx,4)
incl 0x4(%r13)
jmp 0x18066
movq 0x18(%r13), %rdi
movl %eax, %eax
movl $0x3, %r9d
shll %cl, %r9d
movq %r15, (%rdi,%rax,8)
notl %r9d
andl %r9d, %esi
movl %esi, (%r8,%rdx,4)
movq 0x4(%r13), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x4(%r13)
movq 0x20(%r13), %r14
leaq (%rax,%rax,2), %r15
movl 0x8(%rbx), %eax
movl %eax, (%r14,%r15,8)
movq 0x28(%rsp), %rax
addl $0x12, %eax
cltq
addq 0x10(%rbx), %rax
movq %rax, 0x10(%r14,%r15,8)
movl $0x10000, %edi          # imm = 0x10000
callq 0x33e0
movq %rax, 0x8(%r14,%r15,8)
movq 0x18(%rbx), %rsi
movl $0x10000, %edx          # imm = 0x10000
movq %rax, %rdi
callq 0x3370
jmp 0x17c3d