// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/bgzf.c
// Function: cache_block
static void cache_block(BGZF *fp, int size)
{
    int ret;
    khint_t k;
    cache_t *p;
    khash_t(cache) *h = (khash_t(cache)*)fp->cache;
    if (BGZF_MAX_BLOCK_SIZE >= fp->cache_size) return;
    if ((kh_size(h) + 1) * BGZF_MAX_BLOCK_SIZE > (uint32_t)fp->cache_size) {
        /* A better way would be to remove the oldest block in the
         * cache, but here we remove a random one for simplicity. This
         * should not have a big impact on performance. */
        for (k = kh_begin(h); k < kh_end(h); ++k)
            if (kh_exist(h, k)) break;
        if (k < kh_end(h)) {
            free(kh_val(h, k).block);
            kh_del(cache, h, k);
        }
    }
    k = kh_put(cache, h, fp->block_address, &ret);
    if (ret == 0) return; // if this happens, a bug!
    p = &kh_val(h, k);
    p->size = fp->block_length;
    p->end_offset = fp->block_address + size;
    p->block = (uint8_t*)malloc(BGZF_MAX_BLOCK_SIZE);
    memcpy(kh_val(h, k).block, fp->uncompressed_block, BGZF_MAX_BLOCK_SIZE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x4(%rdi), %ecx
cmpl $0x10001, %ecx          # imm = 0x10001
jge 0x6770f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movq 0x30(%rdi), %r14
movl (%r14), %eax
movl 0x4(%r14), %edx
shll $0x10, %edx
addl $0x10000, %edx          # imm = 0x10000
cmpl %ecx, %edx
jbe 0x67769
testl %eax, %eax
je 0x6776e
movq 0x10(%r14), %r8
movl $0x4, %edx
xorl %edi, %edi
xorl %r15d, %r15d
movl %edi, %r12d
andl $0x1e, %r12d
movl $0x3, %ebp
movl %r12d, %ecx
shll %cl, %ebp
movl %r15d, %r13d
shrl $0x4, %r13d
testl %ebp, (%r8,%r13,4)
je 0x67773
incl %r15d
addq $0xc, %rdx
addl $0x2, %edi
cmpl %r15d, %eax
jne 0x6773c
movl %eax, %r15d
jmp 0x677ae
xorl %r15d, %r15d
jmp 0x677ae
movq 0x20(%r14), %rax
movq (%rax,%rdx,2), %rdi
movl %esi, 0x4(%rsp)
callq 0x68a0
movl 0x4(%rsp), %esi
movl (%r14), %edx
cmpl %r15d, %edx
je 0x677ae
movq 0x10(%r14), %rax
movl (%rax,%r13,4), %ecx
movl %edx, %r15d
testl %ebp, %ecx
jne 0x677ae
btsl %r12d, %ecx
movl %ecx, (%rax,%r13,4)
decl 0x4(%r14)
movl (%r14), %r15d
movq 0x10(%rbx), %r12
movl 0x8(%r14), %eax
cmpl 0xc(%r14), %eax
jb 0x677ec
movl %esi, %ebp
movl 0x4(%r14), %eax
addl %eax, %eax
cmpl %eax, %r15d
jbe 0x677ce
decl %r15d
jmp 0x677d1
incl %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x69001
movl (%r14), %r15d
movl %r15d, %edx
testl %eax, %eax
movl %ebp, %esi
js 0x67918
leal -0x1(%r15), %edi
movq %r12, %rbp
shrq $0x21, %rbp
movl %r12d, %eax
shll $0xb, %eax
xorl %eax, %ebp
xorl %r12d, %ebp
andl %edi, %ebp
movq 0x10(%r14), %rax
movl %ebp, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %edx
leal (,%rbp,2), %ecx
shrl %cl, %edx
testb $0x2, %dl
je 0x67822
movl %ebp, %edx
jmp 0x6789c
movl $0x1, %r9d
movl %ebp, %r8d
movl %r15d, %edx
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %r10d
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %r10d, %r11d
shrl %cl, %r11d
testb $0x2, %r11b
jne 0x67880
testb $0x1, %r11b
jne 0x6785e
movq 0x18(%r14), %r11
movl %r8d, %r13d
cmpq %r12, (%r11,%r13,8)
je 0x67880
btl %ecx, %r10d
cmovbl %r8d, %edx
addl %r9d, %r8d
andl %edi, %r8d
incl %r9d
cmpl %ebp, %r8d
jne 0x6782e
movb $0x1, %cl
movl %r15d, %edi
cmpl %r15d, %edx
je 0x6788f
jmp 0x6789c
shrl %cl, %r10d
testb $0x2, %r10b
sete %cl
movl %edx, %edi
movl %r8d, %ebp
cmpl %r15d, %edi
cmovel %ebp, %edi
testb %cl, %cl
cmovnel %ebp, %edi
movl %edi, %edx
movl %edx, %r11d
shrl $0x4, %r11d
movl (%rax,%r11,4), %edi
leal (%rdx,%rdx), %ecx
andl $0x1e, %ecx
movl %edi, %r8d
shrl %cl, %r8d
testb $0x2, %r8b
jne 0x678e6
testb $0x1, %r8b
je 0x67700
movq 0x18(%r14), %r8
movl $0x3, %r9d
shll %cl, %r9d
movl %edx, %ecx
movq %r12, (%r8,%rcx,8)
notl %r9d
andl %r9d, %edi
movl %edi, (%rax,%r11,4)
incl 0x4(%r14)
jmp 0x67918
movq 0x18(%r14), %r8
movl %edx, %r9d
movl $0x3, %r10d
shll %cl, %r10d
movq %r12, (%r8,%r9,8)
notl %r10d
andl %r10d, %edi
movl %edi, (%rax,%r11,4)
movq 0x4(%r14), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x4(%r14)
movq 0x20(%r14), %r14
movl %edx, %eax
leaq (%rax,%rax,2), %r15
movl 0x8(%rbx), %eax
movl %eax, (%r14,%r15,8)
movslq %esi, %rax
addq 0x10(%rbx), %rax
movq %rax, 0x10(%r14,%r15,8)
movl $0x10000, %edi          # imm = 0x10000
callq 0x69d0
movq %rax, 0x8(%r14,%r15,8)
movq 0x20(%rbx), %rsi
movl $0x10000, %edx          # imm = 0x10000
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6570