LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/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 0x32083
movb %al, 0xb(%rsp)
movl $0x1, %eax
jmp 0x3211a
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x320a1
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, 0xb(%rsp)
movb %al, 0xc(%rsp)
movl $0x2, %eax
jmp 0x3211a
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x320c1
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, 0xb(%rsp)
movb %ah, 0xc(%rsp)
movb %al, 0xd(%rsp)
movl $0x3, %eax
jmp 0x3211a
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x320ea
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 0x3211a
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 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r14), %rcx
cmpq %rcx, %rax
ja 0x321a5
movl $0x400, %r15d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x207ef(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x207f7(%rip), %xmm0    # 0x52940
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x218ab(%rip), %xmm1    # 0x53a08
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x2079b(%rip), %xmm1    # 0x52908
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r15, %rsi
movq %rsi, 0x28(%rbx)
movq 0x20(%rbx), %rdi
callq 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r14), %rcx
cmpq %rcx, %rax
jbe 0x32134
addq 0x20(%rbx), %rdi
leaq 0xb(%rsp), %rsi
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_O1/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 0x32228
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x48187
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0x4, %r14
jne 0x3223e
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_O1/karel-brinda[P]ococo/ext/htslib/./htslib/hfile.h
// Function: hread
static inline ssize_t HTS_RESULT_USED
hread(hFILE *fp, void *buffer, size_t nbytes)
{
    extern ssize_t hread2(hFILE *, void *, size_t, size_t);

    size_t n = fp->end - fp->begin;
    if (n > nbytes) n = nbytes;
    memcpy(buffer, fp->begin, n);
    fp->begin += n;
    return (n == nbytes)? (ssize_t) n : hread2(fp, buffer, nbytes, n);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %r13
subq %rsi, %r13
cmpq %rdx, %r13
movq %rdx, %r12
cmovbq %r13, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0x4420
addq %r12, 0x8(%r15)
cmpq %rbx, %r13
jae 0x322a1
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x48187
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: int32_encode
int int32_encode(cram_fd *fd, int32_t val) {
    val = le_int4(val);
    if (4 != hwrite(fd->fp, &val, 4))
	return -1;

    return 4;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0xc(%rsp), %rax
movl %esi, (%rax)
movq (%rdi), %r14
movq 0x8(%r14), %rdi
movq 0x18(%r14), %r15
subq %rdi, %r15
cmpq $0x4, %r15
movl $0x4, %ebx
cmovbq %r15, %rbx
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4420
addq %rbx, 0x8(%r14)
cmpq $0x3, %r15
ja 0x32306
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x48356
movq %rax, %rbx
xorl %eax, %eax
cmpq $0x4, %rbx
sete %al
leal (%rax,%rax,4), %eax
decl %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x3234a
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_O1/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 0x28(%rdi), %rax
movq 0x30(%rdi), %rcx
leaq 0x4(%rcx), %rdx
cmpq %rdx, %rax
ja 0x323dc
movl $0x400, %r14d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x205b8(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x205c0(%rip), %xmm0    # 0x52940
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x21674(%rip), %xmm1    # 0x53a08
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x20564(%rip), %xmm1    # 0x52908
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x28(%rbx)
movq 0x20(%rbx), %rdi
callq 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
leaq 0x4(%rcx), %rdx
cmpq %rdx, %rax
jbe 0x3236b
movq 0x20(%rbx), %rax
movl %ebp, (%rax,%rcx)
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_O1/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 0x32628
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)
jmp 0x3262a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x32ec8
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
testq %rdi, %rdi
je 0x32ebf
callq 0x4610
movq %rbx, %rdi
popq %rbx
jmp 0x4610
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_new_metrics
cram_metrics *cram_new_metrics(void) {
    cram_metrics *m = calloc(1, sizeof(*m));
    if (!m)
	return NULL;
    m->trial = NTRIALS-1;
    m->next_trial = TRIAL_SPAN;
    m->method = RAW;
    m->strat = 0;
    m->revised_method = 0;

    return m;
}

// Assembly:
pushq %rax
movl $0x1, %edi
movl $0x78, %esi
callq 0x4360
testq %rax, %rax
je 0x33b18
movabsq $0x3200000002, %rcx     # imm = 0x3200000002
movq %rcx, (%rax)
movq $0x0, 0x20(%rax)
movl $0x0, 0x40(%rax)
jmp 0x33b1a
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x33c22
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x33b6b
callq 0x41e2f
cmpq $0x0, 0x8(%rbx)
je 0x33beb
movq 0x8(%rbx), %r14
cmpl $0x0, (%r14)
je 0x33bc8
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x10(%r14), %rax
movl %r15d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %ebp, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x33bb9
movq 0x20(%r14), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %r14
testq %r14, %r14
je 0x33bb9
movq %r14, %rdi
callq 0x33c23
movq %r14, %rdi
callq 0x4610
incl %r15d
movq 0x8(%rbx), %r14
addl $0x2, %ebp
cmpl (%r14), %r15d
jne 0x33b81
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 0x33bf9
callq 0x4610
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x33c07
callq 0x4514a
leaq 0x38(%rbx), %rdi
callq 0x45e0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4610
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x33c38
callq 0x3b31f
leaq 0x30(%rbx), %r14
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x33c51
cmpq $0x0, 0x38(%rbx)
jne 0x33c51
callq 0x4610
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
je 0x33c82
callq 0x4610
cmpq $0x0, 0x60(%r15)
je 0x33c91
movq $0x0, 0x60(%r15)
movl 0x38(%r14), %ebx
movslq %ebx, %rdi
movl $0x8, %esi
callq 0x4360
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x33e16
movl %ebx, 0x18(%r15)
cmpl $0x0, 0x38(%r14)
jle 0x33e12
xorl %r12d, %r12d
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq 0x8(%r15), %rdx
movq 0x40(%r14), %rax
movq %r12, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %r8
movq %rdx, (%rsp)
movl (%rdx), %esi
movl $0x0, %ebx
testl %esi, %esi
je 0x33dc9
movsbl (%r8), %r14d
testl %r14d, %r14d
movq %r12, 0x20(%rsp)
je 0x33d26
movb 0x1(%r8), %al
testb %al, %al
je 0x33d29
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 0x33d0b
jmp 0x33d29
xorl %r14d, %r14d
movq %rsi, 0x18(%rsp)
leal -0x1(%rsi), %r15d
andl %r15d, %r14d
movq (%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r13d
movl %r14d, %ebx
movq %r8, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r12d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r12d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x33da9
testb $0x1, %al
jne 0x33d92
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x4750
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r8
testl %eax, %eax
je 0x33da9
addl %r13d, %ebx
andl %r15d, %ebx
incl %r13d
cmpl %r14d, %ebx
jne 0x33d50
movq 0x18(%rsp), %rsi
movl %esi, %ebx
jmp 0x33dba
movl %ebp, %ecx
shrl %cl, %r12d
testb $0x3, %r12b
movq 0x18(%rsp), %rsi
cmovnel %esi, %ebx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
movq 0x20(%rsp), %r12
cmpl %esi, %ebx
je 0x33df5
movq (%rsp), %rax
movq 0x20(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rax
movq 0x10(%r15), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
movslq 0x38(%r14), %rax
cmpq %rax, %r12
jl 0x33ccb
jmp 0x33e12
movq 0x301cc(%rip), %rax     # 0x63fc8
movq (%rax), %rdi
leaq 0x20ce3(%rip), %rsi     # 0x54ae9
movq %r8, %rdx
xorl %eax, %eax
callq 0x4770
jmp 0x33de3
xorl %eax, %eax
jmp 0x33e1b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x33e42
callq 0x40b06
movq %rbx, 0x18(%r14)
movq 0x48(%r14), %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x33e56
// File: /workspace/github_cpp_makefile_star2_O1/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 0x34223
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 0x34196
movq %r13, %rdi
movq %rbx, %rsi
callq 0x44e0
movq %rbx, %rdi
callq 0x4230
addq %rax, %r13
addq %rax, %rbx
addq $0x2, %r15
jmp 0x34204
addb $-0x30, %al
cmpb $0x9, %al
ja 0x341ef
leaq 0x1(%r15), %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0x4760
movq %rax, %r12
movq (%rsp), %rax
cmpb $0x73, (%rax)
jne 0x341ef
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 0x3420a
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 0x34158
movq %r12, %rdi
movq %rbp, %rsi
callq 0x44e0
movq %rbp, %rdi
callq 0x4230
addq %r12, %rax
cmpb $0x0, (%rbx)
je 0x3424a
cmpb $0x2f, -0x1(%rax)
je 0x3424a
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_O1/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 0x342be
movq %rax, %r15
movb $0x0, (%rax)
movq %r14, %rdi
callq 0x3adc0
testl %eax, %eax
jne 0x342ba
movq %r14, %rdi
movl %ebx, %esi
callq 0x4240
testl %eax, %eax
je 0x342b0
movq %r14, %rdi
movl %ebx, %esi
callq 0x34263
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_O1/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 %rbx
pushq %rax
movq 0x10(%rdi), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %rbx
cmpq $0x0, 0x30(%rbx)
jne 0x344c9
cmpq $0x0, 0x28(%rbx)
jne 0x344d7
movl %edx, %r15d
movq %rdi, %r14
movl 0x10(%rbx), %ebp
movq 0x60(%rdi), %rdi
testq %rdi, %rdi
je 0x34444
movq 0x28(%rdi), %rax
testq %rax, %rax
jle 0x344f6
leaq -0x1(%rax), %rcx
movq %rcx, 0x28(%rdi)
cmpq $0x1, %rax
jne 0x34444
cmpq $0x0, 0x30(%rdi)
je 0x34444
callq 0x33c23
movq 0x20(%r14), %rdi
movq 0x8(%rbx), %rsi
callq 0x4750
testl %eax, %eax
je 0x34482
movq 0x28(%r14), %rdi
testq %rdi, %rdi
je 0x34467
callq 0x4514a
testl %eax, %eax
jne 0x344c7
movq 0x8(%rbx), %rdi
movq %rdi, 0x20(%r14)
movl %r15d, %esi
callq 0x34515
movq %rax, 0x28(%r14)
testq %rax, %rax
jne 0x34489
jmp 0x344c7
cmpq $0x0, 0x28(%r14)
je 0x34455
movq 0x28(%r14), %rdi
movq %rbx, %rsi
movl $0x1, %edx
movl %ebp, %ecx
callq 0x345ea
testq %rax, %rax
je 0x344c7
movq %rax, 0x30(%rbx)
movq $0x0, 0x38(%rbx)
movq 0x28(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x28(%rbx)
movq %rbx, 0x60(%r14)
addq $0x2, %rax
movq %rax, 0x28(%rbx)
jmp 0x344c9
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20629(%rip), %rdi     # 0x54b07
leaq 0x20491(%rip), %rsi     # 0x54976
leaq 0x20629(%rip), %rcx     # 0x54b15
movl $0x9d8, %edx            # imm = 0x9D8
callq 0x4350
leaq 0x20645(%rip), %rdi     # 0x54b42
leaq 0x20472(%rip), %rsi     # 0x54976
leaq 0x2060a(%rip), %rcx     # 0x54b15
movl $0x9e2, %edx            # imm = 0x9E2
callq 0x4350
// File: /workspace/github_cpp_makefile_star2_O1/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 0x3458f
leaq 0x1f3ec(%rip), %rsi     # 0x53919
movq %rbx, %rdi
callq 0x436f0
testq %rax, %rax
je 0x345d1
movq %rax, %r14
movl $0x60000000, %eax       # imm = 0x60000000
andl (%r14), %eax
cmpl $0x20000000, %eax       # imm = 0x20000000
jne 0x345dc
leaq 0x20889(%rip), %rdx     # 0x54de4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x45b5e
testl %eax, %eax
jns 0x345dc
movq 0x2fa57(%rip), %rax     # 0x63fc8
movq (%rax), %rdi
leaq 0x2086e(%rip), %rsi     # 0x54de9
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4770
movq %r14, %rdi
callq 0x4514a
jmp 0x345d9
leaq 0x20847(%rip), %rdx     # 0x54ddd
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 0x34526
movq %rbx, %rdi
callq 0x46c0b
testl %eax, %eax
jne 0x345d9
jmp 0x34526
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_O1/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 0x353bc
movq 0x48(%rbx), %rdi
cmpl $0x0, 0x208(%rbx)
je 0x353c4
xorl %edx, %edx
cmpl $0x72, 0x8(%rbx)
setne %dl
jmp 0x353c9
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0x353f2
movl $0x1, %edx
callq 0x3546d
movq %rax, 0x48(%rbx)
xorl %r14d, %r14d
testq %rax, %rax
je 0x353e0
movq 0x20(%rax), %r15
jmp 0x353e3
xorl %r15d, %r15d
cmpq $0x1, %r15
sbbl %r14d, %r14d
movq %rbx, %rdi
callq 0x35885
movq %r15, 0x70(%rbx)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x3540a
testq %r15, %r15
jne 0x3543f
cmpl $0x0, 0x18(%rdi)
jne 0x3543f
cmpq $0x0, 0x18(%rbx)
je 0x3543f
testq %rdi, %rdi
je 0x3541b
callq 0x33b37
callq 0x35a93
movq %rax, 0x48(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x35460
movq 0x18(%rbx), %rsi
movq %rax, %rdi
callq 0x33e56
cmpl $-0x1, %eax
je 0x35460
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x35456
movq 0x48(%rbx), %rdi
callq 0x33c60
cmpl $-0x1, %eax
je 0x3545b
movl %r14d, %ebp
jmp 0x35460
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_O1/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 0x35b05
movq %rax, %rbx
movl $0x2000, %edi           # imm = 0x2000
callq 0x41dfc
movq %rax, (%rbx)
testq %rax, %rax
je 0x35afd
xorl %eax, %eax
movq %rax, 0x10(%rbx)
movl $0x1, 0x30(%rbx)
movq %rax, 0x60(%rbx)
movl $0xffffffff, 0x68(%rbx) # imm = 0xFFFFFFFF
movl $0x1, %edi
movl $0x28, %esi
callq 0x4360
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x35afd
movq %rbx, %rdi
addq $0x38, %rdi
xorl %esi, %esi
callq 0x47c0
jmp 0x35b07
movq %rbx, %rdi
callq 0x33b37
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %r14d
movl $0x1, %edi
movl $0x250, %esi            # imm = 0x250
callq 0x4360
movq %rax, %rbx
xorl %eax, %eax
testq %rbx, %rbx
je 0x35c04
movl $0xfffffffe, 0x6c(%rbx) # imm = 0xFFFFFFFE
movl %ebp, %ecx
imull %r14d, %ecx
movl %ecx, 0x60(%rbx)
movl %eax, 0x64(%rbx)
movl %r14d, 0x58(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movl %ebp, 0x50(%rbx)
movl %eax, 0x54(%rbx)
movq $0x1, 0x88(%rbx)
movl %eax, 0x94(%rbx)
movq $0x0, 0xb8(%rbx)
movslq %ebp, %rdi
movl $0x8, %esi
callq 0x4360
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0x35bee
movq $0x0, 0x80(%rbx)
callq 0x35c0e
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x35bee
movq $0x0, 0x48(%rbx)
movl $0x23, %r14d
callq 0x3a5ac
movq %rax, (%rbx,%r14,8)
testq %rax, %rax
je 0x35bee
incq %r14
cmpq $0x3f, %r14
jne 0x35baf
movl $0x1, %edi
movl $0x28, %esi
callq 0x4360
movq %rax, 0x238(%rbx)
testq %rax, %rax
je 0x35bee
movq $0x0, 0x240(%rbx)
jmp 0x35c06
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x35bfc
callq 0x4610
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x35cd3
movq %rax, %rbx
movl $0x40, %edi
callq 0x4700
testq %rax, %rax
je 0x35c66
movq %rax, %r14
movaps 0x1ebc9(%rip), %xmm0    # 0x54810
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)
jmp 0x35c69
xorl %r14d, %r14d
movq %r14, 0x50(%rbx)
testq %r14, %r14
je 0x35ccb
movl $0x1, %edi
movl $0x28, %esi
callq 0x4360
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x35cc3
movq %rax, %r15
movl $0x2000, %edi           # imm = 0x2000
callq 0x41dfc
movq %rax, 0x70(%rbx)
testq %rax, %rax
jne 0x35cd5
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 0x32ea8
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x35dbb
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x240(%rdi), %rdi
testq %rdi, %rdi
je 0x35cff
callq 0x4610
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x35d0d
callq 0x4610
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x35d1b
callq 0x35dbc
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x35d29
callq 0x32ea8
cmpq $0x0, 0x78(%rbx)
je 0x35d60
cmpl $0x0, 0x50(%rbx)
jle 0x35d57
xorl %r14d, %r14d
movq 0x78(%rbx), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x35d4b
callq 0x35ef7
incq %r14
movslq 0x50(%rbx), %rax
cmpq %rax, %r14
jl 0x35d39
movq 0x78(%rbx), %rdi
callq 0x4610
movl $0x23, %r14d
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x35d74
callq 0x3aad1
incq %r14
cmpq $0x3f, %r14
jne 0x35d66
movq 0x238(%rbx), %r14
testq %r14, %r14
je 0x35dac
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_O1/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 0x35dd5
callq 0x4610
movq 0x78(%rbx), %r14
testq %r14, %r14
je 0x35e01
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 0x35e31
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r12
testq %rdi, %rdi
je 0x35e21
callq *0x10(%rdi)
movq %r14, %rdi
callq 0x4610
movq %r12, %r14
testq %r12, %r12
jne 0x35e11
incq %r15
cmpq $0x20, %r15
jne 0x35e04
xorl %r15d, %r15d
movq 0x180(%rbx,%r15,8), %r14
testq %r14, %r14
je 0x35e6a
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r12
testq %rdi, %rdi
je 0x35e5a
callq *0x10(%rdi)
movq %r14, %rdi
callq 0x4610
movq %r12, %r14
testq %r12, %r12
jne 0x35e4a
incq %r15
cmpq $0x20, %r15
jne 0x35e3d
movl $0x50, %r14d
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x35e85
callq *0x10(%rdi)
incq %r14
cmpq $0x7f, %r14
jne 0x35e79
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x35e9c
callq 0x4610
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x35eaa
callq 0x32ea8
movq 0x68(%rbx), %r14
testq %r14, %r14
je 0x35ed6
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 0x35ee4
callq 0x41e2f
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x4610
// File: /workspace/github_cpp_makefile_star2_O1/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 0x37514
cmpq $0x0, 0x78(%r15)
je 0x375aa
movq %r14, %rdi
movq %r15, %rsi
callq 0x36cb9
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x375af
movq 0x48(%r15), %rsi
movq %r14, %rdi
callq 0x32aba
testl %eax, %eax
jne 0x375af
cmpl $0x0, 0x54(%r15)
jle 0x3759a
xorl %r12d, %r12d
movq 0x78(%r15), %rax
movq (%rax,%r12,8), %r13
movq 0x8(%r13), %rsi
movq %r14, %rdi
callq 0x32aba
testl %eax, %eax
jne 0x375af
movq (%r13), %rax
cmpl $0x0, 0x20(%rax)
jle 0x3758e
xorl %ebp, %ebp
movq 0x10(%r13), %rax
movq (%rax,%rbp,8), %rsi
movq %r14, %rdi
callq 0x32aba
testl %eax, %eax
jne 0x375af
incq %rbp
movq (%r13), %rax
movslq 0x20(%rax), %rax
cmpq %rax, %rbp
jl 0x3756a
incq %r12
movslq 0x54(%r15), %rax
cmpq %rax, %r12
jl 0x37546
movq (%r14), %rdi
callq 0x48277
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
jmp 0x375af
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_O1/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 0x37632
movl $0x10, %edi
callq 0x4700
testq %rax, %rax
je 0x37642
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movq 0x8868(%rbx), %rsi
leaq -0x5d(%rip), %rdx       # 0x375c0
movq %r15, %rdi
movq %rax, %rcx
callq 0x4251a
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3764d
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x374c3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
xorl %ebx, %ebx
movq 0x8868(%r14), %rdi
callq 0x41f94
testq %rax, %rax
je 0x3771e
movq %rax, %r15
movq 0x10(%rax), %rax
testq %rax, %rax
setne %bpl
je 0x3769c
movq (%rax), %r14
movq 0x8(%rax), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x374f2
testl %eax, %eax
je 0x376a0
xorl %ebp, %ebp
jmp 0x37710
xorl %esi, %esi
jmp 0x37708
cmpl $0x0, 0x50(%r12)
jle 0x376d3
xorl %r13d, %r13d
movq 0x78(%r12), %rax
movq (%rax,%r13,8), %rdi
callq 0x35ef7
movq 0x78(%r12), %rax
movq $0x0, (%rax,%r13,8)
incq %r13
movslq 0x50(%r12), %rax
cmpq %rax, %r13
jl 0x376ab
movq $0x0, 0x80(%r12)
movl $0x0, 0x54(%r12)
movq %r12, %rdi
callq 0x35cde
movq (%r14), %rdi
callq 0x48277
negl %eax
movl $0x0, %eax
sbbl %eax, %eax
orl %eax, %ebx
movl $0x1, %esi
movq %r15, %rdi
callq 0x4212d
testb %bpl, %bpl
jne 0x3765d
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_O1/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 0x3774f
pushq %rbx
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x37746
callq 0x4610
movq %rbx, %rdi
popq %rbx
jmp 0x4610
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movl $0x1a, %r15d
movl $0x1a, %edi
callq 0x4700
testq %rax, %rax
je 0x37cdb
movq %rax, %rbx
movq (%r14), %r12
movq 0x8(%r12), %rsi
movq 0x10(%r12), %r13
subq %rsi, %r13
cmpq $0x1a, %r13
cmovbq %r13, %r15
movq %rax, %rdi
movq %r15, %rdx
callq 0x4420
addq %r15, 0x8(%r12)
cmpq $0x19, %r13
ja 0x37cc5
movl $0x1a, %edx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x48187
movq %rax, %r15
cmpq $0x1a, %r15
jne 0x37cd3
cmpl $0x4d415243, (%rbx)     # imm = 0x4D415243
je 0x37cea
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movb 0x4(%rbx), %al
cmpb $0x4, %al
jae 0x37d06
addq $0x1a, 0x8840(%r14)
movl $0x0, 0x884c(%r14)
jmp 0x37cdd
movzbl %al, %edi
movq %rbx, %rsi
callq 0x586f
jmp 0x37cdb
// File: /workspace/github_cpp_makefile_star2_O1/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 0x38c01
movb 0x1(%rbx), %al
andb $-0x2, %al
cmpb $0x62, %al
jne 0x38c01
movb $0x62, 0xe(%rsp)
leaq 0xd(%rsp), %rsi
movq %r14, %rdi
callq 0x4883b
testq %rax, %rax
je 0x38c36
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x38c45
movq %rax, %rbx
testq %rax, %rax
jne 0x38c38
movq %r15, %rdi
callq 0x4850c
jmp 0x38c38
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq %rdi, %r12
movl $0x0, 0x88f8(%rdi)
movq (%rdi), %rdi
callq 0x48413
xorl %edx, %edx
testq %rax, %rax
jns 0x3927a
cmpl $0x1, %ebp
setne %al
testq %r15, %r15
sets %cl
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x3927a
leaq 0x10(%rsp), %r14
movq %r12, 0x8(%rsp)
testq %r15, %r15
jle 0x39278
movl $0x10000, %eax          # imm = 0x10000
movq %r15, %rbx
cmpq %rax, %r15
jl 0x39213
movl $0x10000, %ebx          # imm = 0x10000
movq (%r12), %rbp
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %r13
subq %rsi, %r13
movq %r13, %r12
cmpq %rbx, %r13
jb 0x3922d
movq %rbx, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0x4420
addq %r12, 0x8(%rbp)
cmpq %rbx, %r13
jae 0x39255
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x48187
movq %rax, %r12
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rax
cmpq %r12, %rbx
je 0x39264
xorl %eax, %eax
subq %rax, %r15
cmpq %r12, %rbx
leaq 0x10(%rsp), %r14
movq 0x8(%rsp), %r12
je 0x391fc
jmp 0x3927a
xorl %edx, %edx
movl %edx, %eax
addq $0x10018, %rsp          # imm = 0x10018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x392d0
movq %rdi, %r14
cmpl $0x77, 0x8(%rdi)
jne 0x392ce
movq 0x38(%r14), %rdi
testq %rdi, %rdi
je 0x392ce
cmpq $0x0, 0x80(%rdi)
je 0x392bd
callq 0x2e1a2
movq 0x38(%r14), %rsi
movq %r14, %rdi
callq 0x375e2
cmpl $-0x1, %eax
je 0x392d0
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_set_option
int cram_set_option(cram_fd *fd, enum hts_fmt_option opt, ...) {
    int r;
    va_list args;

    va_start(args, opt);
    r = cram_set_voption(fd, opt, args);
    va_end(args);

    return r;
}

// Assembly:
subq $0xd8, %rsp
leaq 0x20(%rsp), %r10
movq %rdx, 0x10(%r10)
movq %rcx, 0x18(%r10)
movq %r8, 0x20(%r10)
movq %r9, 0x28(%r10)
testb %al, %al
je 0x395c4
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rdx
movq %r10, 0x10(%rdx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
callq 0x395f1
addq $0xd8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/cram/cram_samtools.c
// Function: cram_header_to_bam
bam_hdr_t *cram_header_to_bam(SAM_hdr *h) {
    int i;
    bam_hdr_t *header = bam_hdr_init();

    header->l_text = ks_len(&h->text);
    header->text = malloc(header->l_text+1);
    memcpy(header->text, ks_str(&h->text), header->l_text);
    header->text[header->l_text] = 0;

    header->n_targets = h->nref;
    header->target_name = (char **)calloc(header->n_targets,
					  sizeof(char *));
    header->target_len = (uint32_t *)calloc(header->n_targets, 4);

    for (i = 0; i < h->nref; i++) {
	header->target_name[i] = strdup(h->ref[i].name);
	header->target_len[i] = h->ref[i].len;
    }

    return header;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x14070
movq %rax, %r14
movq (%rbx), %r15
movl %r15d, 0x8(%rax)
leal 0x1(%r15), %edi
callq 0x4700
movq %rax, 0x28(%r14)
movq 0x10(%rbx), %rsi
movl %r15d, %edx
movq %rax, %rdi
callq 0x4420
movq 0x28(%r14), %rax
movl 0x8(%r14), %ecx
movb $0x0, (%rax,%rcx)
movslq 0x38(%rbx), %r15
movl %r15d, (%r14)
movl $0x8, %esi
movq %r15, %rdi
callq 0x4360
movq %rax, 0x20(%r14)
movl $0x4, %esi
movq %r15, %rdi
callq 0x4360
movq %rax, 0x10(%r14)
cmpl $0x0, 0x38(%rbx)
jle 0x3a58e
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x49c0
movq 0x20(%r14), %rcx
movq %rax, (%rcx,%r15,2)
movq 0x40(%rbx), %rax
movl 0x8(%rax,%r15,8), %eax
movq 0x10(%r14), %rcx
movl %eax, (%rcx,%r15)
incq %r12
movslq 0x38(%rbx), %rax
addq $0x4, %r15
cmpq %rax, %r12
jl 0x3a558
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq