LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_index.c
// Function: cram_index_query
cram_index *cram_index_query(cram_fd *fd, int refid, int pos, 
			     cram_index *from) {
    int i, j, k;
    cram_index *e;

    if (refid+1 < 0 || refid+1 >= fd->index_sz)
	return NULL;

    if (!from)
	from = &fd->index[refid+1];

    // Ref with nothing aligned against it.
    if (!from->e)
	return NULL;

    // This sequence is covered by the index, so binary search to find
    // the optimal starting block.
    i = 0, j = fd->index[refid+1].nslice-1;
    for (k = j/2; k != i; k = (j-i)/2 + i) {
	if (from->e[k].refid > refid) {
	    j = k;
	    continue;
	}

	if (from->e[k].refid < refid) {
	    i = k;
	    continue;
	}

	if (from->e[k].start >= pos) {
	    j = k;
	    continue;
	}

	if (from->e[k].start < pos) {
	    i = k;
	    continue;
	}
    }
    // i==j or i==j-1. Check if j is better.
    if (j >= 0 && from->e[j].start < pos && from->e[j].refid == refid)
	i = j;

    /* The above found *a* bin overlapping, but not necessarily the first */
    while (i > 0 && from->e[i-1].end >= pos)
	i--;

    /* We may be one bin before the optimum, so check */
    while (i+1 < from->nslice &&
	   (from->e[i].refid < refid ||
	    from->e[i].end < pos))
	i++;

    e = &from->e[i];

    return e;
}

// Assembly:
cmpl $-0x1, %esi
jl 0x2f564
leal 0x1(%rsi), %eax
cmpl 0x8834(%rdi), %eax
jge 0x2f564
movl %eax, %r9d
testq %rcx, %rcx
jne 0x2f451
leaq (%r9,%r9,2), %rcx
shlq $0x4, %rcx
addq 0x8838(%rdi), %rcx
movq 0x8(%rcx), %rax
xorl %r8d, %r8d
testq %rax, %rax
je 0x2f564
movq 0x8838(%rdi), %rdi
leaq (%r9,%r9,2), %r9
shlq $0x4, %r9
movl (%rdi,%r9), %r9d
leal -0x1(%r9), %edi
cmpl $0x3, %r9d
jb 0x2f4d4
movl %edi, %r9d
shrl $0x1f, %r9d
addl %edi, %r9d
sarl %r9d
xorl %r8d, %r8d
movslq %r9d, %r10
leaq (%r10,%r10,2), %r11
shlq $0x4, %r11
leaq (%rax,%r11), %r10
cmpl %esi, 0x10(%rax,%r11)
jg 0x2f4b2
jl 0x2f4ac
cmpl %edx, 0x14(%r10)
jge 0x2f4b2
movl %r9d, %r8d
movl %edi, %r9d
movl %r9d, %edi
movl %r9d, %r10d
subl %r8d, %r10d
movl %r10d, %r9d
shrl $0x1f, %r9d
addl %r10d, %r9d
sarl %r9d
addl %r8d, %r9d
incl %r10d
cmpl $0x2, %r10d
ja 0x2f48e
testl %edi, %edi
js 0x2f4f5
movl %edi, %r9d
leaq (%r9,%r9,2), %r9
shlq $0x4, %r9
cmpl %edx, 0x14(%rax,%r9)
jge 0x2f4f5
addq %rax, %r9
cmpl %esi, 0x10(%r9)
cmovel %edi, %r8d
testl %r8d, %r8d
jle 0x2f51f
leaq -0x18(%rax), %rdi
movl %r8d, %r9d
leaq (%r9,%r9,2), %r9
shlq $0x4, %r9
cmpl %edx, (%rdi,%r9)
jl 0x2f51f
leal -0x1(%r8), %r9d
cmpl $0x1, %r8d
movl %r9d, %r8d
jg 0x2f4fe
xorl %r8d, %r8d
movl (%rcx), %ecx
leal 0x1(%r8), %edi
cmpl %ecx, %edi
jge 0x2f555
movslq %r8d, %rdi
decl %ecx
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
addq $0x18, %rdi
cmpl %esi, -0x8(%rdi)
jl 0x2f546
cmpl %edx, (%rdi)
jge 0x2f555
incl %r8d
addq $0x30, %rdi
cmpl %r8d, %ecx
jne 0x2f53d
movl %ecx, %r8d
movslq %r8d, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_index.c
// Function: cram_seek_to_refpos
int cram_seek_to_refpos(cram_fd *fd, cram_range *r) {
    cram_index *e;

    // Ideally use an index, so see if we have one.
    if ((e = cram_index_query(fd, r->refid, r->start, NULL))) {
	if (0 != cram_seek(fd, e->offset, SEEK_SET))
	    if (0 != cram_seek(fd, e->offset - fd->first_container, SEEK_CUR))
		return -1;
    } else {
	// Absent from index, but this most likely means it simply has no data.
	return -2;
    }

    if (fd->ctr) {
	cram_free_container(fd->ctr);
	fd->ctr = NULL;
	fd->ooc = 0;
    }

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rsi), %eax
movl 0x4(%rsi), %edx
movl %eax, %esi
xorl %ecx, %ecx
callq 0x2f422
testq %rax, %rax
je 0x2f5dd
movq %rax, %r14
movq 0x28(%rax), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x38546
testl %eax, %eax
je 0x2f5b9
movq 0x28(%r14), %rsi
subq 0x8840(%rbx), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x38546
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x2f5e2
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2f5d9
callq 0x34f02
movq $0x0, 0x38(%rbx)
movl $0x0, 0x88f8(%rbx)
xorl %eax, %eax
jmp 0x2f5e2
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: itf8_put_blk
int itf8_put_blk(cram_block *blk, int val) {
    char buf[5];
    int sz;

    sz = itf8_put(buf, val);
    BLOCK_APPEND(blk, buf, sz);
    return sz;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %eax
movq %rdi, %rbx
cmpl $0x7f, %esi
ja 0x3152d
movb %al, 0xb(%rsp)
movl $0x1, %eax
jmp 0x315c4
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x3154b
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, 0xb(%rsp)
movb %al, 0xc(%rsp)
movl $0x2, %eax
jmp 0x315c4
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x3156b
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, 0xb(%rsp)
movb %ah, 0xc(%rsp)
movb %al, 0xd(%rsp)
movl $0x3, %eax
jmp 0x315c4
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x31594
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, 0xb(%rsp)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0xc(%rsp)
movb %ah, 0xd(%rsp)
movb %al, 0xe(%rsp)
movl $0x4, %eax
jmp 0x315c4
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, 0xb(%rsp)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0xc(%rsp)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0xd(%rsp)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0xe(%rsp)
andb $0xf, %al
movb %al, 0xf(%rsp)
movl $0x5, %eax
movl %eax, %r14d
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%r14), %rsi
cmpq %rsi, %rcx
ja 0x31652
movl $0x400, %r15d           # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x1f391(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1f399(%rip), %xmm0    # 0x50990
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x20455(%rip), %xmm1    # 0x51a60
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0x1f2e9(%rip), %xmm1    # 0x50908
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %r15, %rsi
movq %rsi, 0x28(%rbx)
movq %rax, %rdi
callq 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%r14), %rsi
cmpq %rsi, %rcx
jbe 0x315e2
addq %rdx, %rax
leaq 0xb(%rsp), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x4420
addq %r14, 0x30(%rbx)
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: int32_decode
int int32_decode(cram_fd *fd, int32_t *val) {
    int32_t i;
    if (4 != hread(fd->fp, &i, 4))
	return -1;

    *val = le_int4(i);
    return 4;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq (%rdi), %r15
movq 0x8(%r15), %r12
movq 0x10(%r15), %r13
subq %r12, %r13
cmpq $0x4, %r13
movl $0x4, %r14d
cmovbq %r13, %r14
leaq 0xc(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x4420
addq %r14, %r12
movq %r12, 0x8(%r15)
cmpq $0x3, %r13
ja 0x316d7
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x4716b
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0x4, %r14
jne 0x316ed
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
movl $0x4, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: int32_get_blk
int int32_get_blk(cram_block *b, int32_t *val) {
    if (b->uncomp_size - BLOCK_SIZE(b) < 4)
	return -1;

    *val =
	 b->data[b->byte  ]        |
	(b->data[b->byte+1] <<  8) |
	(b->data[b->byte+2] << 16) |
	(b->data[b->byte+3] << 24);
    BLOCK_SIZE(b) += 4;
    return 4;
}

// Assembly:
movslq 0x14(%rdi), %rdx
movq 0x30(%rdi), %rcx
subq %rcx, %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0x4, %rdx
jb 0x317f9
movq 0x20(%rdi), %rax
movl (%rax,%rcx), %eax
movl %eax, (%rsi)
addq $0x4, %rcx
movq %rcx, 0x30(%rdi)
movl $0x4, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: int32_put_blk
int int32_put_blk(cram_block *b, int32_t val) {
    unsigned char cp[4];
    cp[0] = ( val      & 0xff);
    cp[1] = ((val>>8)  & 0xff);
    cp[2] = ((val>>16) & 0xff);
    cp[3] = ((val>>24) & 0xff);

    BLOCK_APPEND(b, cp, 4);
    return b->data ? 0 : -1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movq 0x20(%rdi), %rax
movq 0x28(%rdi), %rcx
movq 0x30(%rdi), %rdx
leaq 0x4(%rdx), %rsi
cmpq %rsi, %rcx
ja 0x3188e
movl $0x400, %r14d           # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x1f155(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1f15d(%rip), %xmm0    # 0x50990
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x20219(%rip), %xmm1    # 0x51a60
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0x1f0ad(%rip), %xmm1    # 0x50908
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %r14, %rsi
movq %rsi, 0x28(%rbx)
movq %rax, %rdi
callq 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq 0x4(%rdx), %rsi
cmpq %rsi, %rcx
jbe 0x3181e
movl %ebp, (%rax,%rdx)
addq $0x4, 0x30(%rbx)
xorl %eax, %eax
cmpq $0x1, 0x20(%rbx)
sbbl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_new_block
cram_block *cram_new_block(enum cram_content_type content_type,
			   int content_id) {
    cram_block *b = malloc(sizeof(*b));
    if (!b)
	return NULL;
    b->method = b->orig_method = RAW;
    b->content_type = content_type;
    b->content_id = content_id;
    b->comp_size = 0;
    b->uncomp_size = 0;
    b->data = NULL;
    b->alloc = 0;
    b->byte = 0;
    b->bit = 7; // MSB

    return b;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
movl $0x40, %edi
callq 0x4700
testq %rax, %rax
je 0x31aa4
xorl %ecx, %ecx
movq %rcx, (%rax)
movl %ebp, 0x8(%rax)
movl %ebx, 0xc(%rax)
movq %rcx, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movq %rcx, 0x30(%rax)
movl $0x7, 0x38(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_block_size
uint32_t cram_block_size(cram_block *b) {
    unsigned char dat[100], *cp = dat;;
    uint32_t sz;

    *cp++ = b->method;
    *cp++ = b->content_type;
    cp += itf8_put(cp, b->content_id);
    cp += itf8_put(cp, b->comp_size);
    cp += itf8_put(cp, b->uncomp_size);

    sz = cp-dat + 4;
    sz += b->method == RAW ? b->uncomp_size : b->comp_size;

    return sz;
}

// Assembly:
movl 0xc(%rdi), %edx
movl $0x1, %ecx
movl $0x1, %eax
cmpl $0x80, %edx
jb 0x31d26
movl $0x2, %eax
cmpl $0x4000, %edx           # imm = 0x4000
jb 0x31d26
movl $0x3, %eax
cmpl $0x200000, %edx         # imm = 0x200000
jb 0x31d26
cmpl $0x10000000, %edx       # imm = 0x10000000
movl $0x5, %eax
sbbq $0x0, %rax
movl 0x10(%rdi), %edx
cmpl $0x80, %edx
jb 0x31d5a
movl $0x2, %ecx
cmpl $0x4000, %edx           # imm = 0x4000
jb 0x31d5a
movl $0x3, %ecx
cmpl $0x200000, %edx         # imm = 0x200000
jb 0x31d5a
cmpl $0x10000000, %edx       # imm = 0x10000000
movl $0x5, %ecx
sbbq $0x0, %rcx
movl (%rdi), %esi
leaq 0x10(%rdi), %rdx
movl 0x14(%rdi), %r9d
addq $0x14, %rdi
movl $0x1, %r8d
cmpl $0x80, %r9d
jb 0x31da6
movl $0x2, %r8d
cmpl $0x4000, %r9d           # imm = 0x4000
jb 0x31da6
movl $0x3, %r8d
cmpl $0x200000, %r9d         # imm = 0x200000
jb 0x31da6
cmpl $0x10000000, %r9d       # imm = 0x10000000
movl $0x5, %r8d
sbbq $0x0, %r8
leaq -0x68(%rsp), %r9
addl %r9d, %eax
addl %ecx, %r8d
addl %eax, %r8d
testl %esi, %esi
cmoveq %rdi, %rdx
movl (%rdx), %eax
subl %r9d, %r8d
addl %r8d, %eax
addl $0x6, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_free_block
void cram_free_block(cram_block *b) {
    if (!b)
	return;
    if (b->data)
	free(b->data);
    free(b);
}

// Assembly:
testq %rdi, %rdi
je 0x321d4
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
testq %rdi, %rdi
je 0x321cb
callq 0x4610
movq %rbx, %rdi
popq %rbx
jmp 0x4610
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: refs_free
void refs_free(refs_t *r) {
    RP("refs_free()\n");

    if (--r->count > 0)
	return;

    if (!r)
	return;

    if (r->pool)
	string_pool_destroy(r->pool);

    if (r->h_meta) {
	khint_t k;

	for (k = kh_begin(r->h_meta); k != kh_end(r->h_meta); k++) {
	    ref_entry *e;

	    if (!kh_exist(r->h_meta, k))
		continue;
	    if (!(e = kh_val(r->h_meta, k)))
		continue;
	    ref_entry_free_seq(e);
	    free(e);
	}

	kh_destroy(refs, r->h_meta);
    }
    
    if (r->ref_id)
	free(r->ref_id);

    if (r->fp)
	bgzf_close(r->fp);

    pthread_mutex_destroy(&r->lock);

    free(r);
}

// Assembly:
movl 0x30(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x30(%rdi)
cmpl $0x2, %eax
setge %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x32ee9
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x32e31
callq 0x40e23
movq 0x8(%rbx), %r14
testq %r14, %r14
je 0x32eb4
movl (%r14), %eax
testl %eax, %eax
je 0x32e91
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x10(%r14), %rcx
movl %r12d, %edx
shrl $0x4, %edx
movl (%rcx,%rdx,4), %edx
movl %ebp, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0x32e86
movq 0x20(%r14), %rcx
movl %r12d, %edx
movq (%rcx,%rdx,8), %r15
testq %r15, %r15
je 0x32e86
movq %r15, %rdi
callq 0x32eea
movq %r15, %rdi
callq 0x4610
movq 0x8(%rbx), %r14
movl (%r14), %eax
incl %r12d
addl $0x2, %ebp
cmpl %eax, %r12d
jne 0x32e46
movq 0x18(%r14), %rdi
callq 0x4610
movq 0x10(%r14), %rdi
callq 0x4610
movq 0x20(%r14), %rdi
callq 0x4610
movq %r14, %rdi
callq 0x4610
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x32ec2
callq 0x4610
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x32ed0
callq 0x441e8
leaq 0x38(%rbx), %rdi
callq 0x45e0
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4610
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: ref_entry_free_seq
static void ref_entry_free_seq(ref_entry *e) {
    if (e->mf)
	mfclose(e->mf);
    if (e->seq && !e->mf)
	free(e->seq);

    e->seq = NULL;
    e->mf = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x32eff
callq 0x3a63f
leaq 0x30(%rbx), %r14
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x32f18
cmpq $0x0, 0x38(%rbx)
jne 0x32f18
callq 0x4610
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: refs2id
int refs2id(refs_t *r, SAM_hdr *h) {
    int i;

    if (r->ref_id)
	free(r->ref_id);
    if (r->last)
	r->last = NULL;

    r->ref_id = calloc(h->nref, sizeof(*r->ref_id));
    if (!r->ref_id)
	return -1;

    r->nref = h->nref;
    for (i = 0; i < h->nref; i++) {
	khint_t k = kh_get(refs, r->h_meta, h->ref[i].name);
	if (k != kh_end(r->h_meta)) {
	    r->ref_id[i] = kh_val(r->h_meta, k);
	} else {
	    fprintf(stderr, "Unable to find ref name '%s'\n",
		    h->ref[i].name);
	}
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
je 0x32f4b
callq 0x4610
cmpq $0x0, 0x60(%rbx)
je 0x32f5a
movq $0x0, 0x60(%rbx)
movq 0x8(%rsp), %rax
movl 0x38(%rax), %ebp
movslq %ebp, %rdi
movl $0x8, %esi
callq 0x4360
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x330f8
movl %ebp, 0x18(%rbx)
testl %ebp, %ebp
jle 0x330f4
xorl %ecx, %ecx
movq %rbx, 0x20(%rsp)
movl %ebp, 0x1c(%rsp)
movq 0x8(%rbx), %rdx
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rax
movq %rcx, 0x28(%rsp)
shlq $0x5, %rcx
movq (%rax,%rcx), %r8
movq %rdx, 0x10(%rsp)
movl (%rdx), %esi
movl $0x0, %r13d
testl %esi, %esi
je 0x33086
movsbl (%r8), %r14d
testl %r14d, %r14d
je 0x32ff1
movb 0x1(%r8), %al
testb %al, %al
je 0x32ff4
leaq 0x2(%r8), %rcx
movl %r14d, %edx
shll $0x5, %edx
subl %r14d, %edx
movsbl %al, %r14d
addl %edx, %r14d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x32fd6
jmp 0x32ff4
xorl %r14d, %r14d
movq %rsi, 0x30(%rsp)
leal -0x1(%rsi), %r12d
andl %r12d, %r14d
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %ebx
movl %r14d, %r13d
movq %r8, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r15d
leal (,%r13,2), %ebp
andl $0x1e, %ebp
movl %r15d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x33074
testb $0x1, %al
jne 0x33065
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x4750
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %r8
testl %eax, %eax
je 0x33074
addl %ebx, %r13d
andl %r12d, %r13d
incl %ebx
cmpl %r14d, %r13d
jne 0x3301b
jmp 0x330c5
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x30(%rsp), %rsi
cmovnel %esi, %r13d
cmpl %esi, %r13d
je 0x330c5
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rax
movq 0x20(%rsp), %rbx
movq 0x10(%rbx), %rcx
movq 0x28(%rsp), %rdx
movq %rax, (%rcx,%rdx,8)
movq %rdx, %rcx
movl 0x1c(%rsp), %ebp
incq %rcx
movslq %ebp, %rax
cmpq %rax, %rcx
jl 0x32f8e
jmp 0x330f4
movq 0x2eefc(%rip), %rax     # 0x61fc8
movq (%rax), %rdi
leaq 0x1fcbb(%rip), %rsi     # 0x52d91
movq %r8, %rdx
xorl %eax, %eax
callq 0x4770
movq 0x8(%rsp), %rax
movl 0x38(%rax), %ebp
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %rcx
jmp 0x330b4
xorl %eax, %eax
jmp 0x330fd
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_set_header
int cram_set_header(cram_fd *fd, SAM_hdr *hdr) {
    if (fd->header)
	sam_hdr_free(fd->header);
    fd->header = hdr;
    return refs_from_header(fd->refs, fd, hdr);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x33124
callq 0x3face
movq %rbx, 0x18(%r14)
movq 0x48(%r14), %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x33138
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: expand_cache_path
void expand_cache_path(char *path, char *dir, char *fn) {
    char *cp;

    while ((cp = strchr(dir, '%'))) {
	strncpy(path, dir, cp-dir);
	path += cp-dir;

	if (*++cp == 's') {
	    strcpy(path, fn);
	    path += strlen(fn);
	    fn += strlen(fn);
	    cp++;
	} else if (*cp >= '0' && *cp <= '9') {
	    char *endp;
	    long l;

	    l = strtol(cp, &endp, 10);
	    l = MIN(l, strlen(fn));
	    if (*endp == 's') {
		strncpy(path, fn, l);
		path += l;
		fn += l;
		*path = 0;
		cp = endp+1;
	    } else {
		*path++ = '%';
		*path++ = *cp++;
	    }
	} else {
	    *path++ = '%';
	    *path++ = *cp++;
	}
	dir = cp;
    }
    strcpy(path, dir);
    path += strlen(dir);
    if (*fn && path[-1] != '/')
	*path++ = '/';
    strcpy(path, fn);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r12
movq %rsi, %rdi
movl $0x25, %esi
callq 0x4200
testq %rax, %rax
je 0x334ea
movq %rax, %r15
movq %rsp, %r14
movq %r15, %r13
subq %rbp, %r13
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x42b0
addq %r12, %r13
movb 0x1(%r15), %al
cmpb $0x73, %al
jne 0x3345d
movq %r13, %rdi
movq %rbx, %rsi
callq 0x44e0
movq %rbx, %rdi
callq 0x4230
addq %rax, %r13
addq %rax, %rbx
addq $0x2, %r15
jmp 0x334cb
addb $-0x30, %al
cmpb $0x9, %al
ja 0x334b6
leaq 0x1(%r15), %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0x4760
movq %rax, %r12
movq (%rsp), %rax
cmpb $0x73, (%rax)
jne 0x334b6
movq %rbx, %rdi
callq 0x4230
movq %rax, %r15
cmpq %rax, %r12
cmovbq %r12, %r15
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x42b0
leaq (%r15,%r13), %r12
addq %r15, %rbx
movb $0x0, (%r13,%r15)
movq (%rsp), %rbp
incq %rbp
jmp 0x334d1
movb $0x25, (%r13)
movb 0x1(%r15), %al
addq $0x2, %r15
movb %al, 0x1(%r13)
addq $0x2, %r13
movq %r13, %r12
movq %r15, %rbp
movq %rbp, %rdi
movl $0x25, %esi
callq 0x4200
movq %rax, %r15
testq %rax, %rax
jne 0x3341f
movq %r12, %rdi
movq %rbp, %rsi
callq 0x44e0
movq %rbp, %rdi
callq 0x4230
addq %r12, %rax
cmpb $0x0, (%rbx)
je 0x33511
cmpb $0x2f, -0x1(%rax)
je 0x33511
movb $0x2f, (%rax)
incq %rax
movq %rax, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x44e0
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: mkdir_prefix
void mkdir_prefix(char *path, int mode) {
    char *cp = strrchr(path, '/');
    if (!cp)
	return;

    *cp = 0;
    if (is_directory(path)) {
	*cp = '/';
	return;
    }

    if (mkdir(path, mode) == 0) {
	chmod(path, mode);
	*cp = '/';
	return;
    }

    mkdir_prefix(path, mode);
    mkdir(path, mode);
    chmod(path, mode);
    *cp = '/';
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl $0x2f, %esi
callq 0x45a0
testq %rax, %rax
je 0x33585
movq %rax, %r15
movb $0x0, (%rax)
movq %r14, %rdi
callq 0x3a0bc
testl %eax, %eax
jne 0x33581
movq %r14, %rdi
movl %ebx, %esi
callq 0x4240
testl %eax, %eax
je 0x33577
movq %r14, %rdi
movl %ebx, %esi
callq 0x3352a
movq %r14, %rdi
movl %ebx, %esi
callq 0x4240
movq %r14, %rdi
movl %ebx, %esi
callq 0x44b0
movb $0x2f, (%r15)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_ref_load
ref_entry *cram_ref_load(refs_t *r, int id, int is_md5) {
    ref_entry *e = r->ref_id[id];
    int start = 1, end = e->length;
    char *seq;

    if (e->seq) {
	return e;
    }

    assert(e->count == 0);

    if (r->last) {
#ifdef REF_DEBUG
	int idx = 0;
	for (idx = 0; idx < r->nref; idx++)
	    if (r->last == r->ref_id[idx])
		break;
	RP("%d cram_ref_load DECR %d\n", gettid(), idx);
#endif
	assert(r->last->count > 0);
	if (--r->last->count <= 0) {
	    RP("%d FREE REF %d (%p)\n", gettid(), id, r->ref_id[id]->seq);
	    if (r->last->seq)
		ref_entry_free_seq(r->last);
	}
    }

    /* Open file if it's not already the current open reference */
    if (strcmp(r->fn, e->fn) || r->fp == NULL) {
	if (r->fp)
	    if (bgzf_close(r->fp) != 0)
		return NULL;
	r->fn = e->fn;
	if (!(r->fp = bgzf_open_ref(r->fn, "r", is_md5)))
	    return NULL;
    }

    RP("%d Loading ref %d (%d..%d)\n", gettid(), id, start, end);

    if (!(seq = load_ref_portion(r->fp, e, start, end))) {
	return NULL;
    }

    RP("%d Loaded ref %d (%d..%d) = %p\n", gettid(), id, start, end, seq);

    RP("%d INC REF %d, %d\n", gettid(), id, (int)(e->count+1));
    e->seq = seq;
    e->mf = NULL;
    e->count++;

    /*
     * Also keep track of last used ref so incr/decr loops on the same
     * sequence don't cause load/free loops.
     */
    RP("%d cram_ref_load INCR %d => %d\n", gettid(), id, e->count+1);
    r->last = e;
    e->count++; 

    return e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x10(%rdi), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %rbx
cmpq $0x0, 0x30(%rbx)
jne 0x33788
cmpq $0x0, 0x28(%rbx)
jne 0x33794
movl %edx, %r15d
movq %rdi, %r14
movl 0x10(%rbx), %ebp
movq 0x60(%rdi), %rdi
testq %rdi, %rdi
je 0x33708
movq 0x28(%rdi), %rax
testq %rax, %rax
jle 0x337b3
leaq -0x1(%rax), %rcx
movq %rcx, 0x28(%rdi)
cmpq $0x1, %rax
jne 0x33708
cmpq $0x0, 0x30(%rdi)
je 0x33708
callq 0x32eea
movq 0x20(%r14), %rdi
movq 0x8(%rbx), %r12
movq %r12, %rsi
callq 0x4750
movq 0x28(%r14), %rdi
testl %eax, %eax
je 0x33734
testq %rdi, %rdi
je 0x33739
callq 0x441e8
testl %eax, %eax
jne 0x33786
movq 0x8(%rbx), %r12
jmp 0x33739
testq %rdi, %rdi
jne 0x33754
movq %r12, 0x20(%r14)
movq %r12, %rdi
movl %r15d, %esi
callq 0x337d2
movq %rax, %rdi
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x33786
movq %rbx, %rsi
movl $0x1, %edx
movl %ebp, %ecx
callq 0x338a7
testq %rax, %rax
je 0x33786
movq %rax, 0x30(%rbx)
movq $0x0, 0x38(%rbx)
movq 0x28(%rbx), %rax
movq %rbx, 0x60(%r14)
addq $0x2, %rax
movq %rax, 0x28(%rbx)
jmp 0x33788
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f614(%rip), %rdi     # 0x52daf
leaq 0x1f47c(%rip), %rsi     # 0x52c1e
leaq 0x1f614(%rip), %rcx     # 0x52dbd
movl $0x9d8, %edx            # imm = 0x9D8
callq 0x4350
leaq 0x1f630(%rip), %rdi     # 0x52dea
leaq 0x1f45d(%rip), %rsi     # 0x52c1e
leaq 0x1f5f5(%rip), %rcx     # 0x52dbd
movl $0x9e2, %edx            # imm = 0x9E2
callq 0x4350
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: bgzf_open_ref
static BGZF *bgzf_open_ref(char *fn, char *mode, int is_md5) {
    BGZF *fp;

    if (!is_md5) {
	char fai_file[PATH_MAX];

	snprintf(fai_file, PATH_MAX, "%s.fai", fn);
	if (access(fai_file, R_OK) != 0)
	    if (fai_build(fn) != 0)
		return NULL;
    }

    if (!(fp = bgzf_open(fn, mode))) {
	perror(fn);
	return NULL;
    }

    if (fp->is_compressed == 1 && bgzf_index_load(fp, fn, ".gzi") < 0) {
	fprintf(stderr, "Unable to load .gzi index '%s.gzi'\n", fn);
	bgzf_close(fp);
	return NULL;
    }

    return fp;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movq %rdi, %rbx
testl %esi, %esi
je 0x3384c
leaq 0x1e157(%rip), %rsi     # 0x51941
movq %rbx, %rdi
callq 0x42768
testq %rax, %rax
je 0x3388e
movq %rax, %r14
movl $0x60000000, %eax       # imm = 0x60000000
andl (%r14), %eax
cmpl $0x20000000, %eax       # imm = 0x20000000
jne 0x33899
leaq 0x1f877(%rip), %rdx     # 0x5308f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x44c1e
testl %eax, %eax
jns 0x33899
movq 0x2e79a(%rip), %rax     # 0x61fc8
movq (%rax), %rdi
leaq 0x1f85c(%rip), %rsi     # 0x53094
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4770
movq %r14, %rdi
callq 0x441e8
jmp 0x33896
leaq 0x1f835(%rip), %rdx     # 0x53088
movq %rsp, %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x4890
movq %r14, %rdi
movl $0x4, %esi
callq 0x4900
testl %eax, %eax
je 0x337e3
movq %rbx, %rdi
callq 0x45c72
testl %eax, %eax
jne 0x33896
jmp 0x337e3
movq %rbx, %rdi
callq 0x4440
xorl %r14d, %r14d
movq %r14, %rax
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_load_reference
int cram_load_reference(cram_fd *fd, char *fn) {
    int ret = 0;

    if (fn) {
	fd->refs = refs_load_fai(fd->refs, fn,
				 !(fd->embed_ref && fd->mode == 'r'));
	fn = fd->refs ? fd->refs->fn : NULL;
	if (!fn)
	    ret = -1;
	sanitise_SQ_lines(fd);
    }
    fd->ref_fn = fn;

    if ((!fd->refs || (fd->refs->nref == 0 && !fn)) && fd->header) {
	if (fd->refs)
	    refs_free(fd->refs);
	if (!(fd->refs = refs_create()))
	    return -1;
	if (-1 == refs_from_header(fd->refs, fd, fd->header))
	    return -1;
    }

    if (fd->header)
	if (-1 == refs2id(fd->refs, fd->header))
	    return -1;

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testq %rsi, %rsi
je 0x345d8
movq 0x48(%rbx), %rdi
cmpl $0x0, 0x208(%rbx)
je 0x345e0
xorl %edx, %edx
cmpl $0x72, 0x8(%rbx)
setne %dl
jmp 0x345e5
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0x3460e
movl $0x1, %edx
callq 0x34694
movq %rax, 0x48(%rbx)
xorl %r14d, %r14d
testq %rax, %rax
je 0x345fc
movq 0x20(%rax), %r15
jmp 0x345ff
xorl %r15d, %r15d
cmpq $0x1, %r15
sbbl %r14d, %r14d
movq %rbx, %rdi
callq 0x34ad5
movq %r15, 0x70(%rbx)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x34638
testq %r15, %r15
jne 0x34666
cmpl $0x0, 0x18(%rdi)
jne 0x34666
cmpq $0x0, 0x18(%rbx)
je 0x34666
leaq 0x18(%rbx), %r15
callq 0x32dfc
jmp 0x34643
cmpq $0x0, 0x18(%rbx)
je 0x34666
leaq 0x18(%rbx), %r15
callq 0x34cf5
movq %rax, 0x48(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x34687
movq (%r15), %rsi
movq %rax, %rdi
callq 0x33138
cmpl $-0x1, %eax
je 0x34687
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x3467d
movq 0x48(%rbx), %rdi
callq 0x32f27
cmpl $-0x1, %eax
je 0x34682
movl %r14d, %ebp
jmp 0x34687
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: refs_create
static refs_t *refs_create(void) {
    refs_t *r = calloc(1, sizeof(*r));

    RP("refs_create()\n");

    if (!r)
	return NULL;

    if (!(r->pool = string_pool_create(8192)))
	goto err;

    r->ref_id = NULL; // see refs2id() to populate.
    r->count = 1;
    r->last = NULL;
    r->last_id = -1;

    if (!(r->h_meta = kh_init(refs)))
	goto err;

    pthread_mutex_init(&r->lock, NULL);

    return r;

 err:
    refs_free(r);
    return NULL;
}

// Assembly:
pushq %rbx
movl $0x1, %edi
movl $0x70, %esi
callq 0x4360
testq %rax, %rax
je 0x34d5d
movq %rax, %rbx
movl $0x2000, %edi           # imm = 0x2000
callq 0x40df4
movq %rax, (%rbx)
testq %rax, %rax
je 0x34d55
movl $0x1, 0x30(%rbx)
movl $0xffffffff, 0x68(%rbx) # imm = 0xFFFFFFFF
movl $0x1, %edi
movl $0x28, %esi
callq 0x4360
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x34d55
movq %rbx, %rdi
addq $0x38, %rdi
xorl %esi, %esi
callq 0x47c0
jmp 0x34d5f
movq %rbx, %rdi
callq 0x32dfc
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_new_container
cram_container *cram_new_container(int nrec, int nslice) {
    cram_container *c = calloc(1, sizeof(*c));
    enum cram_DS_ID id;

    if (!c)
	return NULL;

    c->curr_ref = -2;

    c->max_c_rec = nrec * nslice;
    c->curr_c_rec = 0;

    c->max_rec = nrec;
    c->record_counter = 0;
    c->num_bases = 0;

    c->max_slice = nslice;
    c->curr_slice = 0;

    c->pos_sorted = 1;
    c->max_apos   = 0;
    c->multi_seq  = 0;

    c->bams = NULL;

    if (!(c->slices = (cram_slice **)calloc(nslice, sizeof(cram_slice *))))
	goto err;
    c->slice = NULL;

    if (!(c->comp_hdr = cram_new_compression_header()))
	goto err;
    c->comp_hdr_block = NULL;

    for (id = DS_RN; id < DS_TN; id++)
	if (!(c->stats[id] = cram_stats_create())) goto err;
    
    //c->aux_B_stats = cram_stats_create();

    if (!(c->tags_used = kh_init(s_i2i)))
	goto err;
    c->refs_used = 0;

    return c;

 err:
    if (c) {
	if (c->slices)
	    free(c->slices);
	free(c);
    }
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movl %edi, %r14d
movl $0x1, %edi
movl $0x250, %esi            # imm = 0x250
callq 0x4360
testq %rax, %rax
je 0x34e28
movq %rax, %rbx
movl $0xfffffffe, 0x6c(%rax) # imm = 0xFFFFFFFE
movl %ebp, %eax
imull %r14d, %eax
movl %eax, 0x60(%rbx)
movl %r14d, 0x58(%rbx)
movl %ebp, 0x50(%rbx)
movl $0x1, 0x88(%rbx)
movslq %ebp, %rdi
movl $0x8, %esi
callq 0x4360
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0x34e20
movq %rax, %r14
callq 0x34e38
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x34e18
movl $0x23, %r15d
callq 0x39920
movq %rax, (%rbx,%r15,8)
testq %rax, %rax
je 0x34e18
incq %r15
cmpq $0x3f, %r15
jne 0x34dd9
movl $0x1, %edi
movl $0x28, %esi
callq 0x4360
movq %rax, 0x238(%rbx)
testq %rax, %rax
je 0x34e18
movq $0x0, 0x240(%rbx)
jmp 0x34e2a
movq %r14, %rdi
callq 0x4610
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_new_compression_header
cram_block_compression_hdr *cram_new_compression_header(void) {
    cram_block_compression_hdr *hdr = calloc(1, sizeof(*hdr));
    if (!hdr)
	return NULL;

    if (!(hdr->TD_blk = cram_new_block(CORE, 0))) {
	free(hdr);
	return NULL;
    }

    if (!(hdr->TD_hash = kh_init(m_s2i))) {
	cram_free_block(hdr->TD_blk);
	free(hdr);
	return NULL;
    }

    if (!(hdr->TD_keys = string_pool_create(8192))) {
	kh_destroy(m_s2i, hdr->TD_hash);
	cram_free_block(hdr->TD_blk);
	free(hdr);
	return NULL;
    }

    return hdr;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl $0x1, %edi
movl $0x418, %esi            # imm = 0x418
callq 0x4360
testq %rax, %rax
je 0x34ef7
movq %rax, %rbx
movl $0x40, %edi
callq 0x4700
testq %rax, %rax
je 0x34eef
movq %rax, %r14
movaps 0x1db4b(%rip), %xmm0    # 0x529c0
movups %xmm0, (%rax)
xorl %eax, %eax
movq %rax, 0x10(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movq %rax, 0x30(%r14)
movl $0x7, 0x38(%r14)
movq %r14, 0x50(%rbx)
movl $0x1, %edi
movl $0x28, %esi
callq 0x4360
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x34ee7
movq %rax, %r15
movl $0x2000, %edi           # imm = 0x2000
callq 0x40df4
movq %rax, 0x70(%rbx)
testq %rax, %rax
jne 0x34ef9
movq 0x18(%r15), %rdi
callq 0x4610
movq 0x10(%r15), %rdi
callq 0x4610
movq 0x20(%r15), %rdi
callq 0x4610
movq %r15, %rdi
callq 0x4610
movq %r14, %rdi
callq 0x321b4
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_free_container
void cram_free_container(cram_container *c) {
    enum cram_DS_ID id;
    int i;

    if (!c)
	return;

    if (c->refs_used)
	free(c->refs_used);

    if (c->landmark)
	free(c->landmark);

    if (c->comp_hdr)
	cram_free_compression_header(c->comp_hdr);

    if (c->comp_hdr_block)
	cram_free_block(c->comp_hdr_block);

    if (c->slices) {
	for (i = 0; i < c->max_slice; i++)
	    if (c->slices[i])
		cram_free_slice(c->slices[i]);
	free(c->slices);
    }

    for (id = DS_RN; id < DS_TN; id++)
	if (c->stats[id]) cram_stats_free(c->stats[id]);

    //if (c->aux_B_stats) cram_stats_free(c->aux_B_stats);
    
    if (c->tags_used) kh_destroy(s_i2i, c->tags_used);

    free(c);
}

// Assembly:
testq %rdi, %rdi
je 0x34fe4
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x240(%rdi), %rdi
testq %rdi, %rdi
je 0x34f23
callq 0x4610
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x34f31
callq 0x4610
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x34f3f
callq 0x34fe5
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x34f4d
callq 0x321b4
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x34f89
movl 0x50(%rbx), %eax
testl %eax, %eax
jle 0x34f84
xorl %r14d, %r14d
movq 0x78(%rbx), %rcx
movq (%rcx,%r14,8), %rdi
testq %rdi, %rdi
je 0x34f75
callq 0x35120
movl 0x50(%rbx), %eax
incq %r14
movslq %eax, %rcx
cmpq %rcx, %r14
jl 0x34f60
movq 0x78(%rbx), %rdi
callq 0x4610
movl $0x23, %r14d
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x34f9d
callq 0x39e0a
incq %r14
cmpq $0x3f, %r14
jne 0x34f8f
movq 0x238(%rbx), %r14
testq %r14, %r14
je 0x34fd5
movq 0x18(%r14), %rdi
callq 0x4610
movq 0x10(%r14), %rdi
callq 0x4610
movq 0x20(%r14), %rdi
callq 0x4610
movq %r14, %rdi
callq 0x4610
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4610
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_free_compression_header
void cram_free_compression_header(cram_block_compression_hdr *hdr) {
    int i;

    if (hdr->landmark)
	free(hdr->landmark);

    if (hdr->preservation_map)
	kh_destroy(map, hdr->preservation_map);

    for (i = 0; i < CRAM_MAP_HASH; i++) {
	cram_map *m, *m2;
	for (m = hdr->rec_encoding_map[i]; m; m = m2) {
	    m2 = m->next;
	    if (m->codec)
		m->codec->free(m->codec);
	    free(m);
	}
    }

    for (i = 0; i < CRAM_MAP_HASH; i++) {
	cram_map *m, *m2;
	for (m = hdr->tag_encoding_map[i]; m; m = m2) {
	    m2 = m->next;
	    if (m->codec)
		m->codec->free(m->codec);
	    free(m);
	}
    }

    for (i = 0; i < DS_END; i++) {
	if (hdr->codecs[i])
	    hdr->codecs[i]->free(hdr->codecs[i]);
    }

    if (hdr->TL)
	free(hdr->TL);
    if (hdr->TD_blk)
	cram_free_block(hdr->TD_blk);
    if (hdr->TD_hash)
	kh_destroy(m_s2i, hdr->TD_hash);
    if (hdr->TD_keys)
	string_pool_destroy(hdr->TD_keys);

    free(hdr);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x34ffe
callq 0x4610
movq 0x78(%rbx), %r14
testq %r14, %r14
je 0x3502a
movq 0x18(%r14), %rdi
callq 0x4610
movq 0x10(%r14), %rdi
callq 0x4610
movq 0x20(%r14), %rdi
callq 0x4610
movq %r14, %rdi
callq 0x4610
xorl %r15d, %r15d
movq 0x80(%rbx,%r15,8), %r14
testq %r14, %r14
je 0x3505a
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r12
testq %rdi, %rdi
je 0x3504a
callq *0x10(%rdi)
movq %r14, %rdi
callq 0x4610
movq %r12, %r14
testq %r12, %r12
jne 0x3503a
incq %r15
cmpq $0x20, %r15
jne 0x3502d
xorl %r15d, %r15d
movq 0x180(%rbx,%r15,8), %r14
testq %r14, %r14
je 0x35093
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r12
testq %rdi, %rdi
je 0x35083
callq *0x10(%rdi)
movq %r14, %rdi
callq 0x4610
movq %r12, %r14
testq %r12, %r12
jne 0x35073
incq %r15
cmpq $0x20, %r15
jne 0x35066
movl $0x50, %r14d
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x350ae
callq *0x10(%rdi)
incq %r14
cmpq $0x7f, %r14
jne 0x350a2
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x350c5
callq 0x4610
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x350d3
callq 0x321b4
movq 0x68(%rbx), %r14
testq %r14, %r14
je 0x350ff
movq 0x18(%r14), %rdi
callq 0x4610
movq 0x10(%r14), %rdi
callq 0x4610
movq 0x20(%r14), %rdi
callq 0x4610
movq %r14, %rdi
callq 0x4610
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x3510d
callq 0x40e23
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x4610
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_flush_container2
static int cram_flush_container2(cram_fd *fd, cram_container *c) {
    int i, j;

    if (c->curr_slice > 0 && !c->slices)
	return -1;

    //fprintf(stderr, "Writing container %d, sum %u\n", c->record_counter, sum);

    /* Write the container struct itself */
    if (0 != cram_write_container(fd, c))
	return -1;

    /* And the compression header */
    if (0 != cram_write_block(fd, c->comp_hdr_block))
	return -1;

    /* Followed by the slice blocks */
    for (i = 0; i < c->curr_slice; i++) {
	cram_slice *s = c->slices[i];

	if (0 != cram_write_block(fd, s->hdr_block))
	    return -1;

	for (j = 0; j < s->hdr->num_blocks; j++) {
	    if (0 != cram_write_block(fd, s->block[j]))
		return -1;
	}
    }

    return hflush(fd->fp) == 0 ? 0 : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x0, 0x54(%rsi)
jle 0x36747
cmpq $0x0, 0x78(%r15)
je 0x367dd
movq %r14, %rdi
movq %r15, %rsi
callq 0x35eec
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x367e2
movq 0x48(%r15), %rsi
movq %r14, %rdi
callq 0x31dc6
testl %eax, %eax
jne 0x367e2
cmpl $0x0, 0x54(%r15)
jle 0x367cd
xorl %r12d, %r12d
movq 0x78(%r15), %rax
movq (%rax,%r12,8), %r13
movq 0x8(%r13), %rsi
movq %r14, %rdi
callq 0x31dc6
testl %eax, %eax
jne 0x367e2
movq (%r13), %rax
cmpl $0x0, 0x20(%rax)
jle 0x367c1
xorl %ebp, %ebp
movq 0x10(%r13), %rax
movq (%rax,%rbp,8), %rsi
movq %r14, %rdi
callq 0x31dc6
testl %eax, %eax
jne 0x367e2
incq %rbp
movq (%r13), %rax
movslq 0x20(%rax), %rax
cmpq %rax, %rbp
jl 0x3679d
incq %r12
movslq 0x54(%r15), %rax
cmpq %rax, %r12
jl 0x36779
movq (%r14), %rdi
callq 0x47234
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
jmp 0x367e2
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_flush_container_mt
int cram_flush_container_mt(cram_fd *fd, cram_container *c) {
    cram_job *j;

    if (!fd->pool)
	return cram_flush_container(fd, c);

    if (!(j = malloc(sizeof(*j))))
	return -1;
    j->fd = fd;
    j->c = c;
    
    t_pool_dispatch(fd->pool, fd->rqueue, cram_flush_thread, j);

    return cram_flush_result(fd);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8860(%rdi), %r15
testq %r15, %r15
je 0x36865
movl $0x10, %edi
callq 0x4700
testq %rax, %rax
je 0x36875
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movq 0x8868(%rbx), %rsi
leaq -0x5d(%rip), %rdx       # 0x367f3
movq %r15, %rdi
movq %rax, %rcx
callq 0x414e4
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x36880
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x366f6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_flush_result
static int cram_flush_result(cram_fd *fd) {
    int i, ret = 0;
    t_pool_result *r;

    while ((r = t_pool_next_result(fd->rqueue))) {
	cram_job *j = (cram_job *)r->data;
	cram_container *c;

	if (!j) {
	    t_pool_delete_result(r, 0);
	    return -1;
	}

	fd = j->fd;
	c = j->c;

	if (0 != cram_flush_container2(fd, c))
	    return -1;

	/* Free the container */
	for (i = 0; i < c->max_slice; i++) {
	    cram_free_slice(c->slices[i]);
	    c->slices[i] = NULL;
	}

	c->slice = NULL;
	c->curr_slice = 0;

	cram_free_container(c);

	ret |= hflush(fd->fp) == 0 ? 0 : -1;

	t_pool_delete_result(r, 1);
    }

    return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x8868(%rdi), %rdi
callq 0x40f74
testq %rax, %rax
je 0x36954
movq %rax, %r14
xorl %ebx, %ebx
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x36958
movq (%rax), %r15
movq 0x8(%rax), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x36725
testl %eax, %eax
jne 0x36962
cmpl $0x0, 0x50(%r12)
jle 0x368fd
xorl %r13d, %r13d
movq 0x78(%r12), %rax
movq (%rax,%r13,8), %rdi
callq 0x35120
movq 0x78(%r12), %rax
movq $0x0, (%rax,%r13,8)
incq %r13
movslq 0x50(%r12), %rax
cmpq %rax, %r13
jl 0x368d5
movq $0x0, 0x80(%r12)
movl $0x0, 0x54(%r12)
movq %r12, %rdi
callq 0x34f02
movq (%r15), %rdi
callq 0x47234
negl %eax
movl $0x0, %eax
sbbl %eax, %eax
orl %eax, %ebx
movq %r14, %rdi
movl $0x1, %esi
callq 0x4110d
movq 0x8868(%r15), %rdi
callq 0x40f74
movq %rax, %r14
testq %rax, %rax
jne 0x368a3
jmp 0x36967
xorl %ebx, %ebx
jmp 0x36967
movq %r14, %rdi
xorl %esi, %esi
callq 0x4110d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_free_slice_header
void cram_free_slice_header(cram_block_slice_hdr *hdr) {
    if (!hdr)
	return;

    if (hdr->block_content_ids)
	free(hdr->block_content_ids);

    free(hdr);

    return;
}

// Assembly:
testq %rdi, %rdi
je 0x36993
pushq %rbx
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x3698a
callq 0x4610
movq %rbx, %rdi
popq %rbx
jmp 0x4610
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_read_file_def
cram_file_def *cram_read_file_def(cram_fd *fd) {
    cram_file_def *def = malloc(sizeof(*def));
    if (!def)
	return NULL;

    if (26 != hread(fd->fp, &def->magic[0], 26)) {
	free(def);
	return NULL;
    }

    if (memcmp(def->magic, "CRAM", 4) != 0) {
	free(def);
	return NULL;
    }

    if (def->major_version > 3) {
	fprintf(stderr, "CRAM version number mismatch\n"
		"Expected 1.x, 2.x or 3.x, got %d.%d\n",
		def->major_version, def->minor_version);
	free(def);
	return NULL;
    }

    fd->first_container += 26;
    fd->last_slice = 0;

    return def;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x1a, %r15d
movl $0x1a, %edi
callq 0x4700
testq %rax, %rax
je 0x36ecd
movq %rax, %rbx
movq (%r14), %r12
movq 0x8(%r12), %r13
movq 0x10(%r12), %rbp
subq %r13, %rbp
cmpq $0x1a, %rbp
cmovbq %rbp, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x4420
addq %r15, %r13
movq %r13, 0x8(%r12)
cmpq $0x19, %rbp
ja 0x36eb7
movl $0x1a, %edx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x4716b
movq %rax, %r15
cmpq $0x1a, %r15
jne 0x36ec5
cmpl $0x4d415243, (%rbx)     # imm = 0x4D415243
je 0x36ee1
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0x4(%rbx), %al
cmpb $0x4, %al
jae 0x36efd
addq $0x1a, 0x8840(%r14)
movl $0x0, 0x884c(%r14)
jmp 0x36ecf
movzbl %al, %edi
movq %rbx, %rsi
callq 0x57b9
jmp 0x36ecd
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_open
cram_fd *cram_open(const char *filename, const char *mode) {
    hFILE *fp;
    cram_fd *fd;
    char fmode[3]= { mode[0], '\0', '\0' };

    if (strlen(mode) > 1 && (mode[1] == 'b' || mode[1] == 'c')) {
	fmode[1] = 'b';
    }

    fp = hopen(filename, fmode);
    if (!fp)
	return NULL;

    fd = cram_dopen(fp, filename, mode);
    if (!fd)
	hclose_abruptly(fp);

    return fd;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movb (%rsi), %al
movb %al, 0xd(%rsp)
movw $0x0, 0xe(%rsp)
movq %rsi, %rdi
callq 0x4230
cmpq $0x2, %rax
jb 0x37df6
movb 0x1(%rbx), %al
andb $-0x2, %al
cmpb $0x62, %al
jne 0x37df6
movb $0x62, 0xe(%rsp)
leaq 0xd(%rsp), %rsi
movq %r14, %rdi
callq 0x477e9
testq %rax, %rax
je 0x37e26
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x37e32
testq %rax, %rax
jne 0x37e28
movq %r15, %rdi
callq 0x474b5
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_seek
int cram_seek(cram_fd *fd, off_t offset, int whence) {
    char buf[65536];

    fd->ooc = 0;

    if (hseek(fd->fp, offset, whence) >= 0)
	return 0;

    if (!(whence == SEEK_CUR && offset >= 0))
	return -1;

    /* Couldn't fseek, but we're in SEEK_CUR mode so read instead */
    while (offset > 0) {
	int len = MIN(65536, offset);
	if (len != hread(fd->fp, buf, len))
	    return -1;
	offset -= len;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10018, %rsp          # imm = 0x10018
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movl $0x0, 0x88f8(%rdi)
movq (%rdi), %rdi
callq 0x473bc
testq %rax, %rax
js 0x3857d
xorl %eax, %eax
jmp 0x38605
cmpl $0x1, %ebp
setne %al
testq %rbx, %rbx
sets %cl
orb %al, %cl
jne 0x38600
leaq 0x10(%rsp), %r14
movq %r15, 0x8(%rsp)
testq %rbx, %rbx
jle 0x38576
movl $0x10000, %eax          # imm = 0x10000
cmpq %rax, %rbx
movl $0x10000, %r12d         # imm = 0x10000
cmovbq %rbx, %r12
movq (%r15), %rbp
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %r15
subq %rsi, %r15
cmpq %r12, %r15
movq %r12, %r13
cmovbq %r15, %r13
movq %r14, %rdi
movq %r13, %rdx
callq 0x4420
addq %r13, 0x8(%rbp)
cmpq %r12, %r15
jae 0x385ee
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x4716b
movq %rax, %r13
subq %r12, %rbx
cmpq %r13, %r12
leaq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
je 0x38597
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10018, %rsp          # imm = 0x10018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_flush
int cram_flush(cram_fd *fd) {
    if (!fd)
	return -1;

    if (fd->mode == 'w' && fd->ctr) {
	if(fd->ctr->slice)
	    cram_update_curr_slice(fd->ctr);

	if (-1 == cram_flush_container_mt(fd, fd->ctr))
	    return -1;
    }

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x3865c
movq %rdi, %r14
cmpl $0x77, 0x8(%rdi)
jne 0x3865a
movq 0x38(%r14), %rsi
testq %rsi, %rsi
je 0x3865a
cmpq $0x0, 0x80(%rsi)
je 0x3864d
movq %rsi, %rdi
callq 0x2d5ca
movq 0x38(%r14), %rsi
movq %r14, %rdi
callq 0x36815
cmpl $-0x1, %eax
je 0x3865c
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq