// File: /workspace/github_c_makefile_star2_O1/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), %eax
cmpl $0x10001, %eax          # imm = 0x10001
jl 0x6791c
movl %esi, %ebp
movq %rdi, %rbx
movq 0x30(%rdi), %r14
movl 0x4(%r14), %ecx
shll $0x10, %ecx
addl $0x10000, %ecx          # imm = 0x10000
cmpl %eax, %ecx
jbe 0x677c0
movl (%r14), %eax
testl %eax, %eax
setne %cl
je 0x677c0
movq 0x10(%r14), %rdx
testb $0x3, (%rdx)
je 0x67773
movl $0x1, %r15d
movl $0x2, %esi
cmpl %r15d, %eax
je 0x677c0
movl %r15d, %ecx
shrl $0x4, %ecx
movl (%rdx,%rcx,4), %edi
movl %esi, %ecx
andb $0x1e, %cl
shrl %cl, %edi
incl %r15d
addl $0x2, %esi
testb $0x3, %dil
jne 0x67747
decl %r15d
cmpl %eax, %r15d
setb %cl
jmp 0x67776
xorl %r15d, %r15d
testb %cl, %cl
je 0x677c0
movq 0x20(%r14), %rax
movl %r15d, %ecx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %rdi
callq 0x68a0
cmpl %r15d, (%r14)
je 0x677c0
movq 0x10(%r14), %rax
movl %r15d, %edx
shrl $0x4, %edx
movl (%rax,%rdx,4), %esi
addl %r15d, %r15d
andl $0x1e, %r15d
movl %esi, %edi
movl %r15d, %ecx
shrl %cl, %edi
testb $0x3, %dil
jne 0x677c0
btsl %r15d, %esi
movl %esi, (%rax,%rdx,4)
decl 0x4(%r14)
movq 0x10(%rbx), %r15
movl 0x8(%r14), %eax
cmpl 0xc(%r14), %eax
jb 0x677f1
movl (%r14), %esi
movl 0x4(%r14), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0x677df
decl %esi
jmp 0x677e1
incl %esi
movq %r14, %rdi
callq 0x68f03
testl %eax, %eax
js 0x6787d
movl (%r14), %esi
leal -0x1(%rsi), %r9d
movq %r15, %rax
shrq $0x21, %rax
movl %r15d, %ecx
shll $0xb, %ecx
xorl %ecx, %eax
xorl %r15d, %eax
andl %r9d, %eax
movq 0x10(%r14), %rdx
movl %eax, %ecx
shrl $0x4, %ecx
movl (%rdx,%rcx,4), %edi
leal (%rax,%rax), %ecx
shrl %cl, %edi
testb $0x2, %dil
jne 0x678aa
movl $0x1, %r10d
movl %eax, %r8d
movl %esi, %edi
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%rdx,%rcx,4), %r11d
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %r11d, %r12d
shrl %cl, %r12d
testb $0x2, %r12b
jne 0x67885
testb $0x1, %r12b
jne 0x67863
movq 0x18(%r14), %r12
movl %r8d, %r13d
cmpq %r15, (%r12,%r13,8)
je 0x67885
btl %ecx, %r11d
cmovbl %r8d, %edi
addl %r10d, %r8d
andl %r9d, %r8d
incl %r10d
movl %edi, %ecx
cmpl %eax, %r8d
jne 0x67833
jmp 0x67887
movl (%r14), %eax
jmp 0x67914
movl %esi, %ecx
movl %ecx, %eax
cmpl %esi, %ecx
jne 0x678aa
movl %r8d, %eax
shrl $0x4, %eax
movl (%rdx,%rax,4), %eax
leal (%r8,%r8), %ecx
shrl %cl, %eax
cmpl %esi, %edi
cmovel %r8d, %edi
testb $0x2, %al
cmovel %r8d, %edi
movl %edi, %eax
movl %eax, %esi
shrl $0x4, %esi
movl (%rdx,%rsi,4), %edi
leal (%rax,%rax), %ecx
andl $0x1e, %ecx
movl %edi, %r9d
shrl %cl, %r9d
testb $0x2, %r9b
jne 0x678f0
movb $0x1, %r8b
testb $0x1, %r9b
je 0x67917
movq 0x18(%r14), %r8
movl %eax, %r9d
movl $0x3, %r10d
shll %cl, %r10d
movq %r15, (%r8,%r9,8)
notl %r10d
andl %r10d, %edi
movl %edi, (%rdx,%rsi,4)
incl 0x4(%r14)
jmp 0x67914
movq 0x18(%r14), %r8
movl $0x3, %r9d
shll %cl, %r9d
movl %eax, %ecx
movq %r15, (%r8,%rcx,8)
notl %r9d
andl %r9d, %edi
movl %edi, (%rdx,%rsi,4)
incl 0x4(%r14)
incl 0x8(%r14)
xorl %r8d, %r8d
testb %r8b, %r8b
je 0x6792b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r14), %r14
movl %eax, %eax
leaq (%rax,%rax,2), %r15
movl 0x8(%rbx), %eax
movl %eax, (%r14,%r15,8)
movslq %ebp, %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