LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/annot-tsv.c
// Function: read_next_line
static int read_next_line(dat_t *dat)
{
    if ( dat->line.l ) return dat->line.l;
    int ret = hts_getline(dat->fp, KS_SEP_LINE, &dat->line);
    if ( ret > 0 ) return dat->line.l;
    if ( ret < -1 ) error("Error encountered while reading %s\n",dat->fname);
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x80(%rdi), %rax
testq %rax, %rax
jne 0x7b97
movq %rdi, %rbx
leaq 0x80(%rdi), %r14
movq 0x98(%rdi), %rdi
movl $0x2, %esi
movq %r14, %rdx
callq 0x15cc5
testl %eax, %eax
jle 0x7b8e
movl (%r14), %eax
jmp 0x7b97
movl %eax, %ecx
xorl %eax, %eax
cmpl $-0x2, %ecx
jle 0x7b9f
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq (%rbx), %rsi
leaq 0x8ec20(%rip), %rdi     # 0x967c9
xorl %eax, %eax
callq 0x5ed4
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/kstring.c
// Function: kvsprintf
int kvsprintf(kstring_t *s, const char *fmt, va_list ap)
{
	va_list args;
	int l;
	va_copy(args, ap);

	if (fmt[0] == '%' && fmt[1] == 'g' && fmt[2] == 0) {
		double d = va_arg(args, double);
		l = kputd(d, s);
		va_end(args);
		return l;
	}

	if (!s->s) {
		const size_t sz = 64;
		s->s = malloc(sz);
		if (!s->s)
			return -1;
		s->m = sz;
		s->l = 0;
	}

	l = vsnprintf(s->s + s->l, s->m - s->l, fmt, args); // This line does not work with glibc 2.0. See `man snprintf'.
	va_end(args);
	if (l + 1 > s->m - s->l) {
		if (ks_resize(s, s->l + l + 2) < 0)
			return -1;
		va_copy(args, ap);
		l = vsnprintf(s->s + s->l, s->m - s->l, fmt, args);
		va_end(args);
	}
	s->l += l;
	return l;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rdx), %rax
movq %rax, 0x10(%rsp)
movups (%rdx), %xmm0
movaps %xmm0, (%rsp)
cmpb $0x25, (%rsi)
jne 0x998b
cmpb $0x67, 0x1(%r14)
jne 0x998b
cmpb $0x0, 0x2(%r14)
je 0x9a67
cmpq $0x0, 0x10(%rbx)
jne 0x99b8
movl $0x40, %edi
callq 0x4680
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x9a60
movq $0x40, 0x8(%rbx)
movq $0x0, (%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdi
addq %rax, %rdi
subq %rax, %rsi
movq %rsp, %rcx
movq %r14, %rdx
callq 0x42d0
leal 0x1(%rax), %ecx
movslq %ecx, %rsi
movq (%rbx), %rdx
movq 0x8(%rbx), %rcx
movq %rcx, %rdi
subq %rdx, %rdi
cmpq %rsi, %rdi
jae 0x9a58
cltq
addq %rdx, %rax
addq $0x2, %rax
cmpq %rax, %rcx
jae 0x9a2d
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r12d, %r12d
testq %rcx, %rcx
cmoveq %rdx, %r12
addq %rax, %r12
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0x4840
testq %rax, %rax
je 0x9a60
movq %rax, 0x10(%rbx)
movq %r12, 0x8(%rbx)
movq 0x10(%r15), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
movups (%r15), %xmm0
movaps %xmm0, (%rcx)
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdi
addq %rax, %rdi
subq %rax, %rsi
movq %r14, %rdx
callq 0x42d0
movslq %eax, %rcx
addq %rcx, (%rbx)
jmp 0x9a9f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x9a9f
movl 0x4(%rsp), %ecx
cmpq $0xa0, %rcx
ja 0x9a85
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x10, %ecx
movl %ecx, 0x4(%rsp)
jmp 0x9a93
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movsd (%rax), %xmm0
movq %rbx, %rdi
callq 0x941c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/kstring.c
// Function: kstrtok
char *kstrtok(const char *str, const char *sep_in, ks_tokaux_t *aux)
{
	const unsigned char *p, *start, *sep = (unsigned char *) sep_in;
	if (sep) { // set up the table
		if (str == 0 && aux->finished) return 0; // no need to set up if we have finished
		aux->finished = 0;
		if (sep[0] && sep[1]) {
			aux->sep = -1;
			aux->tab[0] = aux->tab[1] = aux->tab[2] = aux->tab[3] = 0;
			for (p = sep; *p; ++p) aux->tab[*p>>6] |= 1ull<<(*p&0x3f);
		} else aux->sep = sep[0];
	}
	if (aux->finished) return 0;
	else if (str) start = (unsigned char *) str, aux->finished = 0;
	else start = (unsigned char *) aux->p + 1;
	if (aux->sep < 0) {
		for (p = start; *p; ++p)
			if (aux->tab[*p>>6]>>(*p&0x3f)&1) break;
	} else {
		// Using strchr is fast for next token, but slower for
		// last token due to extra pass from strlen.  Overall
		// on a VCF parse this func was 146% faster with // strchr.
		// Equiv to:
		// for (p = start; *p; ++p) if (*p == aux->sep) break;

		// NB: We could use strchrnul() here from glibc if detected,
		// which is ~40% faster again, but it's not so portable.
		// i.e.   p = (uint8_t *)strchrnul((char *)start, aux->sep);
		uint8_t *p2 = (uint8_t *)strchr((char *)start, aux->sep);
		p = p2 ? p2 : start + strlen((char *)start);
	}
	aux->p = (const char *) p; // end of token
	if (*p == 0) aux->finished = 1; // no more tokens
	return (char*)start;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x9b9b
testq %rbx, %rbx
je 0x9bb1
movl $0x0, 0x24(%r14)
movzbl (%rsi), %eax
testl %eax, %eax
je 0x9b97
cmpb $0x0, 0x1(%rsi)
je 0x9b97
movl $0xffffffff, 0x20(%r14) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x10(%r14)
movb (%rsi), %cl
testb %cl, %cl
je 0x9b9b
incq %rsi
movl %ecx, %eax
shrb $0x3, %al
movl $0x1, %edx
shlq %cl, %rdx
movzbl %al, %eax
andl $0x18, %eax
orq %rdx, (%r14,%rax)
movb (%rsi), %cl
incq %rsi
testb %cl, %cl
jne 0x9b75
jmp 0x9b9b
movl %eax, 0x20(%r14)
cmpl $0x0, 0x24(%r14)
jne 0x9bb8
testq %rbx, %rbx
je 0x9bbc
movl $0x0, 0x24(%r14)
jmp 0x9bc3
cmpl $0x0, 0x24(%r14)
je 0x9b43
xorl %ebx, %ebx
jmp 0x9c22
movq 0x28(%r14), %rbx
incq %rbx
movl 0x20(%r14), %esi
testl %esi, %esi
js 0x9be5
movq %rbx, %rdi
callq 0x4190
testq %rax, %rax
jne 0x9c11
movq %rbx, %rdi
callq 0x41d0
addq %rbx, %rax
jmp 0x9c11
movb (%rbx), %cl
movq %rbx, %rax
testb %cl, %cl
je 0x9c11
movq %rbx, %rax
movzbl %cl, %edx
shrb $0x3, %cl
movzbl %cl, %ecx
andl $0x18, %ecx
movq (%r14,%rcx), %rcx
btq %rdx, %rcx
jb 0x9c11
movb 0x1(%rax), %cl
incq %rax
testb %cl, %cl
jne 0x9bf1
movq %rax, 0x28(%r14)
cmpb $0x0, (%rax)
jne 0x9c22
movl $0x1, 0x24(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/kstring.c
// Function: kgetline
int kgetline(kstring_t *s, kgets_func *fgets_fn, void *fp)
{
	size_t l0 = s->l;

	while (s->l == l0 || s->s[s->l-1] != '\n') {
		if (s->m - s->l < 200) {
			if (ks_resize(s, s->m + 200) < 0)
				return EOF;
		}
		if (fgets_fn(s->s + s->l, s->m - s->l, fp) == NULL) break;
		s->l += strlen(s->s + s->l);
	}

	if (s->l == l0) return EOF;

	if (s->l > l0 && s->s[s->l-1] == '\n') {
		s->l--;
		if (s->l > l0 && s->s[s->l-1] == '\r') s->l--;
	}
	s->s[s->l] = '\0';
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %r13
xorl %ebp, %ebp
movq (%rbx), %rcx
cmpq %r13, %rcx
je 0x9e7b
movq 0x10(%rbx), %rax
cmpb $0xa, -0x1(%rax,%rcx)
je 0x9f0c
movq 0x8(%rbx), %rax
movq %rax, %rdx
subq %rcx, %rdx
cmpq $0xc8, %rdx
setae %cl
cmpq $-0xc8, %rax
setae %dl
orb %cl, %dl
jne 0x9ed8
leaq 0xc8(%rax), %rcx
movq %rcx, %rdx
shrq $0x3e, %rdx
shrq %rcx
testq %rdx, %rdx
cmovneq %rbp, %rcx
leaq (%rcx,%rax), %r12
addq $0xc8, %r12
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0x4840
testq %rax, %rax
je 0x9f4f
movq %rax, 0x10(%rbx)
movq %r12, 0x8(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rdi
addq %rax, %rdi
movl 0x8(%rbx), %esi
subl %eax, %esi
movq %r14, %rdx
callq *%r15
testq %rax, %rax
je 0x9f0c
movq (%rbx), %r12
movq 0x10(%rbx), %rdi
addq %r12, %rdi
callq 0x41d0
addq %r12, %rax
movq %rax, (%rbx)
jmp 0x9e64
movq (%rbx), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %r13, %rcx
je 0x9f54
jbe 0x9f40
movq 0x10(%rbx), %rax
cmpb $0xa, -0x1(%rax,%rcx)
jne 0x9f40
leaq -0x1(%rcx), %rdx
movq %rdx, (%rbx)
cmpq %r13, %rdx
jbe 0x9f40
cmpb $0xd, -0x2(%rax,%rcx)
jne 0x9f40
addq $-0x2, %rcx
movq %rcx, (%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
xorl %eax, %eax
jmp 0x9f54
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/kstring.c
// Function: kgetline2
int kgetline2(kstring_t *s, kgets_func2 *fgets_fn, void *fp)
{
	size_t l0 = s->l;

	while (s->l == l0 || s->s[s->l-1] != '\n') {
		if (s->m - s->l < 200) {
			// We return EOF for both EOF and error and the caller
			// needs to check for errors in fp, and we haven't
			// even got there yet.
			//
			// The only way of propagating memory errors is to
			// deliberately call something that we know triggers
			// and error so fp is also set.  This works for
			// hgets, but not for gets where reading <= 0 bytes
			// isn't an error.
			if (ks_resize(s, s->m + 200) < 0) {
				fgets_fn(s->s + s->l, 0, fp);
				return EOF;
			}
		}
		ssize_t len = fgets_fn(s->s + s->l, s->m - s->l, fp);
		if (len <= 0) break;
		s->l += len;
	}

	if (s->l == l0) return EOF;

	if (s->l > l0 && s->s[s->l-1] == '\n') {
		s->l--;
		if (s->l > l0 && s->s[s->l-1] == '\r') s->l--;
	}
	s->s[s->l] = '\0';
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r13
xorl %ebp, %ebp
movq (%rbx), %rcx
cmpq %r13, %rcx
je 0x9f93
movq 0x10(%rbx), %rax
cmpb $0xa, -0x1(%rax,%rcx)
je 0xa014
movq 0x8(%rbx), %rax
movq %rax, %rdx
subq %rcx, %rdx
cmpq $0xc8, %rdx
setae %cl
cmpq $-0xc8, %rax
setae %dl
orb %cl, %dl
jne 0x9ff0
leaq 0xc8(%rax), %rcx
movq %rcx, %rdx
shrq $0x3e, %rdx
shrq %rcx
testq %rdx, %rdx
cmovneq %rbp, %rcx
leaq (%rcx,%rax), %r12
addq $0xc8, %r12
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0x4840
testq %rax, %rax
je 0xa057
movq %rax, 0x10(%rbx)
movq %r12, 0x8(%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdi
addq %rax, %rdi
subq %rax, %rsi
movq %r15, %rdx
callq *%r14
testq %rax, %rax
jle 0xa014
addq %rax, (%rbx)
jmp 0x9f7c
movq (%rbx), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %r13, %rcx
je 0xa06b
jbe 0xa048
movq 0x10(%rbx), %rax
cmpb $0xa, -0x1(%rax,%rcx)
jne 0xa048
leaq -0x1(%rcx), %rdx
movq %rdx, (%rbx)
cmpq %r13, %rdx
jbe 0xa048
cmpb $0xd, -0x2(%rax,%rcx)
jne 0xa048
addq $-0x2, %rcx
movq %rcx, (%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
xorl %eax, %eax
jmp 0xa06b
movq 0x10(%rbx), %rdi
addq (%rbx), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq *%r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_idx_push
int bgzf_idx_push(BGZF *fp, hts_idx_t *hidx, int tid, hts_pos_t beg, hts_pos_t end, uint64_t offset, int is_mapped) {
    hts_idx_cache_entry *e;
    mtaux_t *mt = fp->mt;

    if (!mt)
        return hts_idx_push(hidx, tid, beg, end, offset, is_mapped);

    // Early check for out of range positions which would fail in hts_idx_push()
    if (hts_idx_check_range(hidx, tid, beg, end) < 0)
        return -1;

    pthread_mutex_lock(&mt->idx_m);

    mt->hts_idx = hidx;
    hts_idx_cache_t *ic = &mt->idx_cache;

    if (ic->nentries >= ic->mentries) {
        int new_sz = ic->mentries ? ic->mentries*2 : 1024;
        if (!(e = realloc(ic->e, new_sz * sizeof(*ic->e)))) {
            pthread_mutex_unlock(&mt->idx_m);
            return -1;
        }
        ic->e = e;
        ic->mentries = new_sz;
    }

    e = &ic->e[ic->nentries++];
    e->tid = tid;
    e->beg = beg;
    e->end = end;
    e->is_mapped = is_mapped;
    e->offset = offset & 0xffff;
    e->block_number = mt->block_number;

    pthread_mutex_unlock(&mt->idx_m);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r14
movq %rcx, %r15
movl %edx, %r12d
movq %rsi, %rbx
movl 0x50(%rsp), %eax
movq 0x48(%rdi), %rbp
testq %rbp, %rbp
je 0xa405
movl %eax, 0x4(%rsp)
movq %r9, 0x10(%rsp)
movq %rbx, %rdi
movl %r12d, %esi
movq %r15, %rdx
movq %r14, %rcx
callq 0x16e2c
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0xa493
leaq 0xe0(%rbp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x4750
movq %rbx, 0x108(%rbp)
movl 0x124(%rbp), %eax
cmpl %eax, 0x120(%rbp)
jl 0xa43f
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x400, %ebx            # imm = 0x400
cmovnel %ecx, %ebx
movq 0x128(%rbp), %rdi
movslq %ebx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
callq 0x4840
testq %rax, %rax
je 0xa42a
movq %rax, 0x128(%rbp)
movl %ebx, 0x124(%rbp)
jmp 0xa43a
movq %rbx, %rdi
movl %r12d, %esi
movq %r15, %rdx
movq %r14, %rcx
movq %r9, %r8
movl %eax, %r9d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16eed
movq 0x8(%rsp), %rdi
movq %rax, %rbx
callq 0x4340
movq %rbx, %rax
testq %rax, %rax
je 0xa493
movq 0x128(%rbp), %rax
movslq 0x120(%rbp), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x120(%rbp)
leaq (%rcx,%rcx,4), %rcx
movl %r12d, 0x10(%rax,%rcx,8)
movq %r15, (%rax,%rcx,8)
movq %r14, 0x8(%rax,%rcx,8)
movl 0x4(%rsp), %edx
movl %edx, 0x14(%rax,%rcx,8)
movzwl 0x10(%rsp), %edx
movq %rdx, 0x18(%rax,%rcx,8)
movq 0x110(%rbp), %rdx
movq %rdx, 0x20(%rax,%rcx,8)
movq 0x8(%rsp), %rdi
callq 0x4340
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_open
BGZF *bgzf_open(const char *path, const char *mode)
{
    BGZF *fp = 0;
    if (strchr(mode, 'r')) {
        hFILE *fpr;
        if ((fpr = hopen(path, mode)) == 0) return 0;
        fp = bgzf_read_init(fpr, path);
        if (fp == 0) { hclose_abruptly(fpr); return NULL; }
        fp->fp = fpr;
    } else if (strchr(mode, 'w') || strchr(mode, 'a')) {
        hFILE *fpw;
        if ((fpw = hopen(path, mode)) == 0) return 0;
        fp = bgzf_write_init(mode);
        if (fp == NULL) return NULL;
        fp->fp = fpw;
    }
    else { errno = EINVAL; return 0; }

    fp->is_be = ed_is_big();
    return fp;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x72, %esi
callq 0x4190
testq %rax, %rax
je 0xa4f0
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x10014
testq %rax, %rax
je 0xa542
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0xa571
testq %rax, %rax
je 0xa546
movq %r14, 0x40(%rax)
jmp 0xa53d
movq %r14, %rdi
movl $0x77, %esi
callq 0x4190
testq %rax, %rax
jne 0xa514
movq %r14, %rdi
movl $0x61, %esi
callq 0x4190
testq %rax, %rax
je 0xa55e
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x10014
testq %rax, %rax
je 0xa542
movq %rax, %rbx
movq %r14, %rdi
callq 0xa868
testq %rax, %rax
je 0xa54e
movq %rbx, 0x40(%rax)
movb $0x1, %r15b
jmp 0xa553
xorl %eax, %eax
jmp 0xa553
movq %r14, %rdi
callq 0xf730
xorl %eax, %eax
xorl %r15d, %r15d
testb %r15b, %r15b
je 0xa569
andb $-0x9, 0x2(%rax)
jmp 0xa56b
callq 0x4050
movl $0x16, (%rax)
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_dopen
BGZF *bgzf_dopen(int fd, const char *mode)
{
    BGZF *fp = 0;
    if (strchr(mode, 'r')) {
        hFILE *fpr;
        if ((fpr = hdopen(fd, mode)) == 0) return 0;
        fp = bgzf_read_init(fpr, NULL);
        if (fp == 0) { hclose_abruptly(fpr); return NULL; } // FIXME this closes fd
        fp->fp = fpr;
    } else if (strchr(mode, 'w') || strchr(mode, 'a')) {
        hFILE *fpw;
        if ((fpw = hdopen(fd, mode)) == 0) return 0;
        fp = bgzf_write_init(mode);
        if (fp == NULL) return NULL;
        fp->fp = fpw;
    }
    else { errno = EINVAL; return 0; }

    fp->is_be = ed_is_big();
    return fp;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movq %rsi, %rdi
movl $0x72, %esi
callq 0x4190
testq %rax, %rax
je 0xaae7
movl %ebp, %edi
movq %rbx, %rsi
callq 0xf761
testq %rax, %rax
je 0xab3a
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
callq 0xa571
testq %rax, %rax
je 0xab32
movq %rbx, 0x40(%rax)
jmp 0xab2e
movq %rbx, %rdi
movl $0x77, %esi
callq 0x4190
testq %rax, %rax
jne 0xab0b
movq %rbx, %rdi
movl $0x61, %esi
callq 0x4190
testq %rax, %rax
je 0xab48
movl %ebp, %edi
movq %rbx, %rsi
callq 0xf761
testq %rax, %rax
je 0xab3a
movq %rax, %r14
movq %rbx, %rdi
callq 0xa868
testq %rax, %rax
je 0xab3a
movq %r14, 0x40(%rax)
movb $0x1, %cl
jmp 0xab3e
movq %rbx, %rdi
callq 0xf730
xorl %eax, %eax
xorl %ecx, %ecx
testb %cl, %cl
je 0xab53
andb $-0x9, 0x2(%rax)
jmp 0xab55
callq 0x4050
movl $0x16, (%rax)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_hopen
BGZF *bgzf_hopen(hFILE *hfp, const char *mode)
{
    BGZF *fp = NULL;
    if (strchr(mode, 'r')) {
        fp = bgzf_read_init(hfp, NULL);
        if (fp == NULL) return NULL;
    } else if (strchr(mode, 'w') || strchr(mode, 'a')) {
        fp = bgzf_write_init(mode);
        if (fp == NULL) return NULL;
    }
    else { errno = EINVAL; return 0; }

    fp->fp = hfp;
    fp->is_be = ed_is_big();
    return fp;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x72, %esi
callq 0x4190
testq %rax, %rax
je 0xab8a
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
callq 0xa571
testq %rax, %rax
jne 0xabbb
jmp 0xabd6
movq %r14, %rdi
movl $0x77, %esi
callq 0x4190
testq %rax, %rax
jne 0xabae
movq %r14, %rdi
movl $0x61, %esi
callq 0x4190
testq %rax, %rax
je 0xabc8
movq %r14, %rdi
callq 0xa868
testq %rax, %rax
je 0xabd3
movq %rax, %r14
movq %rbx, 0x40(%rax)
andb $-0x9, 0x2(%rax)
jmp 0xabd6
callq 0x4050
movl $0x16, (%rax)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_zerr
static const char *bgzf_zerr(int errnum, z_stream *zs)
{
    static char buffer[32];

    /* Return zs->msg if available.
       zlib doesn't set this very reliably.  Looking at the source suggests
       that it may get set to a useful message for deflateInit2, inflateInit2
       and inflate when it returns Z_DATA_ERROR. For inflate with other
       return codes, deflate, deflateEnd and inflateEnd it doesn't appear
       to be useful.  For the likely non-useful cases, the caller should
       pass NULL into zs. */

    if (zs && zs->msg) return zs->msg;

    // gzerror OF((gzFile file, int *errnum)
    switch (errnum) {
    case Z_ERRNO:
        return strerror(errno);
    case Z_STREAM_ERROR:
        return "invalid parameter/compression level, or inconsistent stream state";
    case Z_DATA_ERROR:
        return "invalid or incomplete IO";
    case Z_MEM_ERROR:
        return "out of memory";
    case Z_BUF_ERROR:
        return "progress temporarily not possible, or in() / out() returned an error";
    case Z_VERSION_ERROR:
        return "zlib version mismatch";
    case Z_NEED_DICT:
        return "data was compressed using a dictionary";
    case Z_OK: // 0: maybe gzgets error Z_NULL
    default:
        snprintf(buffer, sizeof(buffer), "[%d] unknown", errnum);
        return buffer;  // FIXME: Not thread-safe.
    }
}

// Assembly:
pushq %rbx
movl %edi, %ecx
testq %rsi, %rsi
je 0xade6
movq 0x30(%rsi), %rbx
testq %rbx, %rbx
je 0xade6
movq %rbx, %rax
popq %rbx
retq
leal 0x6(%rcx), %eax
cmpl $0x8, %eax
ja 0xae07
leaq 0x8caeb(%rip), %rdx     # 0x978e0
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x8d3bd(%rip), %rbx     # 0x981c2
jmp 0xade1
leaq 0xae9a2(%rip), %rbx     # 0xb97b0
leaq 0x8d3ea(%rip), %rdx     # 0x981ff
movl $0x20, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4800
jmp 0xade1
callq 0x4050
movl (%rax), %edi
popq %rbx
jmp 0x4150
leaq 0x8d343(%rip), %rbx     # 0x9817d
jmp 0xade1
leaq 0x8d395(%rip), %rbx     # 0x981d8
jmp 0xade1
leaq 0x8d323(%rip), %rbx     # 0x9816f
jmp 0xade1
leaq 0x8d301(%rip), %rbx     # 0x98156
jmp 0xade1
leaq 0x8d2b6(%rip), %rbx     # 0x98114
jmp 0xade1
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: mt_destroy
static int mt_destroy(mtaux_t *mt)
{
    int ret = 0;

    // Tell the reader to shut down
    pthread_mutex_lock(&mt->command_m);
    mt->command = CLOSE;
    pthread_cond_signal(&mt->command_c);
    hts_tpool_wake_dispatch(mt->out_queue); // unstick the reader
    pthread_mutex_unlock(&mt->command_m);

    // Check for thread worker failure, indicated by is_shutdown returning 2
    // It's possible really late errors might be missed, but we can live with
    // that.
    ret = -(hts_tpool_process_is_shutdown(mt->out_queue) > 1);
    // Destroying the queue first forces the writer to exit.
    // mt->out_queue is reference counted, so destroy gets called in both
    // this and the IO threads.  The last to do it will clean up.
    hts_tpool_process_destroy(mt->out_queue);

    // IO thread will now exit.  Wait for it and perform final clean-up.
    // If it returned non-NULL, it was not happy.
    void *retval = NULL;
    pthread_join(mt->io_task, &retval);
    ret = retval != NULL ? -1 : ret;

    pthread_mutex_destroy(&mt->job_pool_m);
    pthread_mutex_destroy(&mt->command_m);
    pthread_mutex_destroy(&mt->idx_m);
    pthread_cond_destroy(&mt->command_c);
    if (mt->curr_job)
        pool_free(mt->job_pool, mt->curr_job);

    if (mt->own_pool)
        hts_tpool_destroy(mt->pool);

    pool_destroy(mt->job_pool);

    if (mt->idx_cache.e)
        free(mt->idx_cache.e);

    free(mt);
    fflush(stderr);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x80(%rdi), %r15
movq %r15, %rdi
callq 0x4750
movl $0x5, 0xd8(%rbx)
leaq 0xa8(%rbx), %r14
movq %r14, %rdi
callq 0x4040
movq 0x20(%rbx), %rdi
callq 0x3817e
movq %r15, %rdi
callq 0x4340
movq 0x20(%rbx), %rdi
callq 0x37527
movl %eax, %ebp
movq 0x20(%rbx), %rdi
callq 0x37316
leaq 0x8(%rsp), %r12
movq $0x0, (%r12)
movq 0x28(%rbx), %rdi
movq %r12, %rsi
callq 0x4410
movq (%r12), %r12
leaq 0x30(%rbx), %rdi
callq 0x4590
movq %r15, %rdi
callq 0x4590
leaq 0xe0(%rbx), %rdi
callq 0x4590
movq %r14, %rdi
callq 0x49a0
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0xb721
movq (%rbx), %rdi
callq 0x5a8fd
cmpl $0x0, 0x14(%rbx)
je 0xb730
movq 0x18(%rbx), %rdi
callq 0x3831c
movq (%rbx), %rdi
callq 0x5a7dd
movq 0x128(%rbx), %rdi
testq %rdi, %rdi
je 0xb749
callq 0x45c0
testq %r12, %r12
setne %al
cmpl $0x2, %ebp
setge %cl
orb %al, %cl
movzbl %cl, %ebp
negl %ebp
movq %rbx, %rdi
callq 0x45c0
movq 0xad86d(%rip), %rax     # 0xb8fd8
movq (%rax), %rdi
callq 0x45a0
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_index_add_block
int bgzf_index_add_block(BGZF *fp)
{
    fp->idx->noffs++;
    if ( fp->idx->noffs > fp->idx->moffs )
    {
        fp->idx->moffs = fp->idx->noffs;
        kroundup32(fp->idx->moffs);
        fp->idx->offs = (bgzidx1_t*) realloc(fp->idx->offs, fp->idx->moffs*sizeof(bgzidx1_t));
        if ( !fp->idx->offs ) return -1;
    }
    fp->idx->offs[ fp->idx->noffs-1 ].uaddr = fp->idx->ublock_addr;
    fp->idx->offs[ fp->idx->noffs-1 ].caddr = fp->block_address;
    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x50(%rdi), %rax
movl (%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, (%rax)
cmpl 0x4(%rax), %ecx
jl 0xb7e6
testl %ecx, %ecx
js 0xb7c6
movl %ecx, %edx
shrl %edx
orl %ecx, %edx
movl %edx, %esi
shrl $0x2, %esi
orl %edx, %esi
movl %esi, %edx
shrl $0x4, %edx
orl %esi, %edx
movl %edx, %esi
shrl $0x8, %esi
orl %edx, %esi
movl %esi, %edx
shrl $0x10, %edx
orl %esi, %edx
shrl $0x1e, %ecx
xorl $0x1, %ecx
addl %edx, %ecx
movl %ecx, %edx
movl %edx, 0x4(%rax)
movq 0x8(%rax), %rdi
movslq %edx, %rsi
shlq $0x4, %rsi
callq 0x4840
movq 0x50(%rbx), %rcx
movq %rax, 0x8(%rcx)
testq %rax, %rax
je 0xb80b
movq 0x50(%rbx), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rdx
movslq (%rax), %rax
shlq $0x4, %rax
movq %rdx, -0x10(%rcx,%rax)
movq 0x18(%rbx), %rdx
movq %rdx, -0x8(%rcx,%rax)
xorl %eax, %eax
popq %rbx
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xb809
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_htell
static off_t bgzf_htell(BGZF *fp) {
    if (fp->mt) {
        pthread_mutex_lock(&fp->mt->job_pool_m);
        off_t pos = fp->block_address + fp->block_clength;
        pthread_mutex_unlock(&fp->mt->job_pool_m);
        return pos;
    } else {
        return htell(fp->fp);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x48(%rdi), %rdi
testq %rdi, %rdi
je 0xb842
addq $0x30, %rdi
callq 0x4750
movslq 0xc(%r14), %rbx
addq 0x18(%r14), %rbx
movq 0x48(%r14), %rdi
addq $0x30, %rdi
callq 0x4340
jmp 0xb851
movq 0x40(%r14), %rax
movq 0x28(%rax), %rbx
addq 0x8(%rax), %rbx
subq (%rax), %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/./htslib/hfile.h
// Function: hread
static inline ssize_t HTS_RESULT_USED
hread(hFILE *fp, void *buffer, size_t nbytes)
{
    HTSLIB_EXPORT
    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 || !fp->mobile)? (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 0x43c0
addq %r12, 0x8(%r15)
cmpq %rbx, %r13
jae 0xb89e
testb $0x2, 0x30(%r15)
jne 0xb8ab
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xf2cd
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: load_block_from_cache
static int load_block_from_cache(BGZF *fp, int64_t block_address)
{
    khint_t k;
    cache_t *p;

    khash_t(cache) *h = fp->cache->h;
    k = kh_get(cache, h, block_address);
    if (k == kh_end(h)) return 0;
    p = &kh_val(h, k);
    if (fp->block_length != 0) fp->block_offset = 0;
    fp->block_address = block_address;
    fp->block_length = p->size;
    memcpy(fp->uncompressed_block, p->block, p->size);
    if ( hseek(fp->fp, p->end_offset, SEEK_SET) < 0 )
    {
        // todo: move the error up
        hts_log_error("Could not hseek to %" PRId64, p->end_offset);
        exit(1);
    }
    return p->size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq (%rax), %rdx
movl (%rdx), %edi
xorl %eax, %eax
movl $0x0, %r8d
testl %edi, %edi
je 0xbb8e
leal -0x1(%rdi), %r9d
movq %rsi, %r10
shrq $0x21, %r10
movl %esi, %ecx
shll $0xb, %ecx
xorl %ecx, %r10d
xorl %esi, %r10d
andl %r9d, %r10d
movq 0x10(%rdx), %r11
movl $0x1, %ebp
movl %r10d, %r8d
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%r11,%rcx,4), %r14d
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %r14d, %r15d
shrl %cl, %r15d
testb $0x2, %r15b
jne 0xbb83
testb $0x1, %r15b
jne 0xbb71
movq 0x18(%rdx), %r15
movl %r8d, %r12d
cmpq %rsi, (%r15,%r12,8)
je 0xbb83
addl %ebp, %r8d
andl %r9d, %r8d
incl %ebp
cmpl %r10d, %r8d
jne 0xbb41
movl %edi, %r8d
jmp 0xbb8e
shrl %cl, %r14d
testb $0x3, %r14b
cmovnel %edi, %r8d
cmpl %edi, %r8d
je 0xbbdd
movl %r8d, %eax
leaq (%rax,%rax,2), %r14
shlq $0x3, %r14
addq 0x20(%rdx), %r14
cmpl $0x0, 0x8(%rbx)
je 0xbbaf
movl $0x0, 0x10(%rbx)
movq %rsi, 0x18(%rbx)
movslq (%r14), %rdx
movl %edx, 0x8(%rbx)
movq 0x28(%rbx), %rdi
movq 0x8(%r14), %rsi
callq 0x43c0
movq 0x40(%rbx), %rdi
movq 0x10(%r14), %rsi
xorl %edx, %edx
callq 0xf583
testq %rax, %rax
js 0xbbe6
movl (%r14), %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r14), %rcx
leaq 0x8c67f(%rip), %rsi     # 0x98270
leaq 0x8c68e(%rip), %rdx     # 0x98286
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movl $0x1, %edi
callq 0x45e0
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: check_header
static int check_header(const uint8_t *header)
{
    if ( header[0] != 31 || header[1] != 139 || header[2] != 8 ) return -2;
    return ((header[3] & 4) != 0
            && unpackInt16((uint8_t*)&header[10]) == 6
            && header[12] == 'B' && header[13] == 'C'
            && unpackInt16((uint8_t*)&header[14]) == 2) ? 0 : -1;
}

// Assembly:
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpb $0x1f, (%rdi)
jne 0xbc4e
cmpb $-0x75, 0x1(%rdi)
jne 0xbc4e
cmpb $0x8, 0x2(%rdi)
jne 0xbc4e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x4, 0x3(%rdi)
je 0xbc4e
cmpw $0x6, 0xa(%rdi)
jne 0xbc4e
cmpb $0x42, 0xc(%rdi)
jne 0xbc4e
cmpb $0x43, 0xd(%rdi)
jne 0xbc4e
xorl %eax, %eax
cmpw $0x2, 0xe(%rdi)
setne %al
negl %eax
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: inflate_block
static int inflate_block(BGZF* fp, int block_length)
{
    size_t dlen = BGZF_MAX_BLOCK_SIZE;
    uint32_t crc = le_to_u32((uint8_t *)fp->compressed_block + block_length-8);
    int ret = bgzf_uncompress(fp->uncompressed_block, &dlen,
                              (Bytef*)fp->compressed_block + 18,
                              block_length - 18, crc);
    if (ret < 0) {
        if (ret == -2)
            fp->errcode |= BGZF_ERR_CRC;
        else
            fp->errcode |= BGZF_ERR_ZLIB;
        return -1;
    }

    return dlen;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rax
movq $0x10000, (%rax)        # imm = 0x10000
movq 0x28(%rdi), %rdi
movq 0x30(%rbx), %rdx
movl %esi, %ecx
movl -0x8(%rdx,%rcx), %r8d
addq $0x12, %rdx
leal -0x12(%rsi), %ecx
movq %rax, %rsi
callq 0xe7a8
testl %eax, %eax
js 0xbc8b
movl 0x8(%rsp), %eax
jmp 0xbca2
cmpl $-0x2, %eax
movl $0x20, %eax
movl $0x1, %ecx
cmovel %eax, %ecx
orl %ecx, (%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_peek
int bgzf_peek(BGZF *fp) {
    int available = fp->block_length - fp->block_offset;
    if (available <= 0) {
        if (bgzf_read_block(fp) < 0) {
            hts_log_error("Read block operation failed with error %d", fp->errcode);
            fp->errcode = BGZF_ERR_ZLIB;
            return -2;
        }
    }
    available = fp->block_length - fp->block_offset;
    if (available)
        return ((unsigned char *)fp->uncompressed_block)[fp->block_offset];

    return -1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %eax
cmpl 0x10(%rdi), %eax
jg 0xc114
movq %rbx, %rdi
callq 0xae60
testl %eax, %eax
js 0xc12c
movslq 0x10(%rbx), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, 0x8(%rbx)
je 0xc153
movq 0x28(%rbx), %rax
movzbl (%rax,%rcx), %eax
jmp 0xc153
movzwl (%rbx), %ecx
leaq 0x8bb54(%rip), %rsi     # 0x97c8a
leaq 0x8bb57(%rip), %rdx     # 0x97c94
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movw $0x1, (%rbx)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_thread_pool
int bgzf_thread_pool(BGZF *fp, hts_tpool *pool, int qsize) {
    // No gain from multi-threading when not compressed
    if (!fp->is_compressed)
        return 0;

    mtaux_t *mt;
    mt = (mtaux_t*)calloc(1, sizeof(mtaux_t));
    if (!mt) return -1;
    fp->mt = mt;

    mt->pool = pool;
    mt->n_threads = hts_tpool_size(pool);
    if (!qsize)
        qsize = mt->n_threads*2;
    if (!(mt->out_queue = hts_tpool_process_init(mt->pool, qsize, 0)))
        goto err;
    hts_tpool_process_ref_incr(mt->out_queue);

    mt->job_pool = pool_create(sizeof(bgzf_job));
    if (!mt->job_pool)
        goto err;

    pthread_mutex_init(&mt->job_pool_m, NULL);
    pthread_mutex_init(&mt->command_m, NULL);
    pthread_mutex_init(&mt->idx_m, NULL);
    pthread_cond_init(&mt->command_c, NULL);
    mt->flush_pending = 0;
    mt->jobs_pending = 0;
    mt->free_block = fp->uncompressed_block; // currently in-use block
    mt->block_address = fp->block_address;
    pthread_create(&mt->io_task, NULL,
                   fp->is_write ? bgzf_mt_writer : bgzf_mt_reader, fp);

    return 0;

 err:
    free(mt);
    fp->mt = NULL;
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %ebx, %ebx
testb $0x40, 0x3(%rdi)
je 0xc44b
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r14
movl $0x1, %edi
movl $0x130, %esi            # imm = 0x130
callq 0x4300
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xc44b
movq %rax, %r15
movq %rax, 0x48(%r14)
movq %r12, 0x18(%rax)
movq %r12, %rdi
callq 0x37f2c
movl %eax, 0x10(%r15)
leal (%rax,%rax), %esi
testl %ebp, %ebp
cmovnel %ebp, %esi
movq 0x18(%r15), %rdi
xorl %edx, %edx
callq 0x3757b
movq %rax, 0x20(%r15)
testq %rax, %rax
je 0xc43b
movq %rax, %rdi
callq 0x37405
movl $0x20030, %edi          # imm = 0x20030
callq 0x5a760
movq %rax, (%r15)
testq %rax, %rax
je 0xc43b
leaq 0x30(%r15), %rdi
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x4780
leaq 0x80(%r15), %rdi
xorl %esi, %esi
callq 0x4780
leaq 0xe0(%r15), %rdi
xorl %esi, %esi
callq 0x4780
leaq 0xa8(%r15), %rdi
xorl %esi, %esi
callq 0x45d0
movq $0x0, 0x58(%r15)
movq 0x28(%r14), %rax
movq %rax, 0x60(%r15)
movq 0x18(%r14), %rax
movq %rax, 0x70(%r15)
addq $0x28, %r15
btl $0x11, (%r14)
leaq 0x4bc(%rip), %rax       # 0xc8dd
leaq 0x2e(%rip), %rdx        # 0xc456
cmovaeq %rax, %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0x4920
jmp 0xc44b
movq %r15, %rdi
callq 0x45c0
movq $0x0, 0x48(%r14)
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_mt
int bgzf_mt(BGZF *fp, int n_threads, int n_sub_blks)
{
    // No gain from multi-threading when not compressed
    if (!fp->is_compressed || fp->is_gzip)
        return 0;

    if (n_threads < 1) return -1;
    hts_tpool *p = hts_tpool_init(n_threads);
    if (!p)
        return -1;

    if (bgzf_thread_pool(fp, p, 0) != 0) {
        hts_tpool_destroy(p);
        return -1;
    }

    fp->mt->own_pool = 1;

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl $0xc0000000, %eax       # imm = 0xC0000000
andl (%rdi), %eax
xorl %ebx, %ebx
cmpl $0x40000000, %eax       # imm = 0x40000000
jne 0xcc21
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %esi, %esi
jle 0xcc21
movq %rdi, %r14
movl %esi, %edi
callq 0x378ae
testq %rax, %rax
je 0xcc21
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc338
testl %eax, %eax
je 0xcc14
movq %r15, %rdi
callq 0x3831c
jmp 0xcc21
movq 0x48(%r14), %rax
movl $0x1, 0x14(%rax)
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: mt_queue
static int mt_queue(BGZF *fp)
{
    mtaux_t *mt = fp->mt;

    mt->block_number++;

    // Also updated by writer thread
    pthread_mutex_lock(&mt->job_pool_m);
    bgzf_job *j = pool_alloc(mt->job_pool);
    if (j) mt->jobs_pending++;
    pthread_mutex_unlock(&mt->job_pool_m);
    if (!j) return -1;

    j->fp = fp;
    j->errcode = 0;
    j->uncomp_len  = fp->block_offset;
    if (fp->compress_level == 0) {
        memcpy(j->comp_data + BLOCK_HEADER_LENGTH + 5, fp->uncompressed_block,
               j->uncomp_len);
        if (hts_tpool_dispatch3(mt->pool, mt->out_queue,
                                bgzf_encode_level0_func, j,
                                job_cleanup, job_cleanup, 0) < 0) {
            goto fail;
        }
    } else {
        memcpy(j->uncomp_data, fp->uncompressed_block, j->uncomp_len);

        // Need non-block vers & job_pending?
        if (hts_tpool_dispatch3(mt->pool, mt->out_queue, bgzf_encode_func, j,
                                job_cleanup, job_cleanup, 0) < 0) {
            goto fail;
        }
    }

    fp->block_offset = 0;
    return 0;

 fail:
    job_cleanup(j);
    pthread_mutex_lock(&mt->job_pool_m);
    mt->jobs_pending--;
    pthread_mutex_unlock(&mt->job_pool_m);
    return -1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x48(%rdi), %r12
incq 0x110(%r12)
leaq 0x30(%r12), %rbx
movq %rbx, %rdi
callq 0x4750
movq (%r12), %rdi
callq 0x5a822
testq %rax, %rax
je 0xcf71
movq %rax, %r15
incl 0x58(%r12)
movq %rbx, %rdi
callq 0x4340
movq %r14, (%r15)
movl $0x0, 0x20018(%r15)
movslq 0x10(%r14), %rdx
movq %rdx, 0x20010(%r15)
movzwl 0x2(%r14), %eax
movq 0x28(%r14), %rsi
movq %r15, %rdi
testl $0x1ff0, %eax           # imm = 0x1FF0
je 0xcf19
addq $0x10010, %rdi          # imm = 0x10010
callq 0x43c0
movq 0x18(%r12), %rdi
movq 0x20(%r12), %rsi
movl $0x0, (%rsp)
leaq 0x1ed7(%rip), %rdx      # 0xedee
jmp 0xcf3a
addq $0x1f, %rdi
callq 0x43c0
movq 0x18(%r12), %rdi
movq 0x20(%r12), %rsi
movl $0x0, (%rsp)
leaq 0x1e58(%rip), %rdx      # 0xed92
leaq 0x1d61(%rip), %r8       # 0xeca2
movq %r15, %rcx
movq %r8, %r9
callq 0x37f45
testl %eax, %eax
js 0xcf5c
movl $0x0, 0x10(%r14)
xorl %eax, %eax
jmp 0xcf7e
movq %r15, %rdi
callq 0xeca2
movq %rbx, %rdi
callq 0x4750
decl 0x58(%r12)
movq %rbx, %rdi
callq 0x4340
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: deflate_block
static int deflate_block(BGZF *fp, int block_length)
{
    size_t comp_size = BGZF_MAX_BLOCK_SIZE;
    int ret;
    if ( !fp->is_gzip )
        ret = bgzf_compress(fp->compressed_block, &comp_size, fp->uncompressed_block, block_length, fp->compress_level);
    else
        ret = bgzf_gzip_compress(fp, fp->compressed_block, &comp_size, fp->uncompressed_block, block_length, fp->compress_level);

    if ( ret != 0 )
    {
        hts_log_debug("Compression error %d", ret);
        fp->errcode |= BGZF_ERR_ZLIB;
        return -1;
    }
    fp->block_offset = 0;
    return comp_size;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq $0x10000, 0x8(%rsp)     # imm = 0x10000
movl (%rdi), %r8d
movq 0x30(%rdi), %rdi
movq 0x28(%rbx), %rdx
testl %r8d, %r8d
js 0xcfcc
movslq %esi, %rcx
shll $0x3, %r8d
sarl $0x17, %r8d
leaq 0x8(%rsp), %rsi
callq 0xabe8
testl %eax, %eax
jne 0xd041
jmp 0xd07b
movq 0x60(%rbx), %r14
xorl %eax, %eax
testl %esi, %esi
sete %al
leal 0x1(%rax,%rax,2), %eax
movq %rdx, (%r14)
movl %esi, 0x8(%r14)
movq %rdi, 0x18(%r14)
movl $0x10000, 0x20(%r14)    # imm = 0x10000
movq %r14, %rdi
movl %eax, %esi
callq 0x41f0
cmpl $-0x2, %eax
jne 0xd020
leaq 0x8b3df(%rip), %rsi     # 0x983e3
leaq 0x8a9aa(%rip), %rdx     # 0x979b5
leaq 0x8b102(%rip), %rcx     # 0x98114
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
jmp 0xd041
cmpl $0x0, 0x8(%r14)
je 0xd06a
leaq 0x8b3b5(%rip), %rsi     # 0x983e3
leaq 0x8b3c1(%rip), %rdx     # 0x983f6
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
leaq 0x8b378(%rip), %rsi     # 0x983c0
leaq 0x8b37f(%rip), %rdx     # 0x983ce
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x5, %edi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x14378
orb $0x1, (%rbx)
jmp 0xd086
movl 0x20(%r14), %eax
movl $0x10000, %ecx          # imm = 0x10000
subq %rax, %rcx
movq %rcx, 0x8(%rsp)
movl $0x0, 0x10(%rbx)
movl 0x8(%rsp), %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_write
ssize_t bgzf_write(BGZF *fp, const void *data, size_t length)
{
    if ( !fp->is_compressed ) {
        size_t push = length + (size_t) fp->block_offset;
        fp->block_offset = push % BGZF_MAX_BLOCK_SIZE;
        fp->block_address += (push - fp->block_offset);
        return hwrite(fp->fp, data, length);
    }

    const uint8_t *input = (const uint8_t*)data;
    ssize_t remaining = length;
    assert(fp->is_write);
    while (remaining > 0) {
        uint8_t* buffer = (uint8_t*)fp->uncompressed_block;
        int copy_length = BGZF_BLOCK_SIZE - fp->block_offset;
        if (copy_length > remaining) copy_length = remaining;
        memcpy(buffer + fp->block_offset, input, copy_length);
        fp->block_offset += copy_length;
        input += copy_length;
        remaining -= copy_length;
        if (fp->block_offset == BGZF_BLOCK_SIZE) {
            if (lazy_flush(fp) != 0) return -1;
        }
    }
    return length - remaining;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl (%rdi), %eax
btl $0x1e, %eax
jb 0xd16e
movslq 0x10(%r15), %rax
addq %rbx, %rax
movzwl %ax, %ecx
movl %ecx, 0x10(%r15)
andq $-0x10000, %rax         # imm = 0xFFFF0000
addq %rax, 0x18(%r15)
movq 0x40(%r15), %r15
testb $0x2, 0x30(%r15)
jne 0xd122
movq 0x18(%r15), %rsi
movq %rsi, %rax
subq 0x8(%r15), %rax
cmpq %rbx, %rax
jae 0xd122
addq %rbx, %rsi
subq (%r15), %rsi
movq %r15, %rdi
callq 0xefdd
movq 0x18(%r15), %rax
movq %rax, 0x10(%r15)
movq 0x8(%r15), %rdi
movq 0x18(%r15), %r13
subq %rdi, %r13
cmpq %rbx, %r13
ja 0xd13b
cmpq (%r15), %rdi
je 0xd1ef
cmpq %rbx, %r13
movq %rbx, %r12
cmovbq %r13, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x8(%r15)
cmpq %rbx, %r13
jae 0xd1e2
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
jmp 0xd1fa
btl $0x11, %eax
jae 0xd208
movq %rbx, %r13
testq %rbx, %rbx
jle 0xd1d3
movq %rbx, %r13
movslq 0x10(%r15), %rdi
movl $0xff00, %eax           # imm = 0xFF00
subq %rdi, %rax
cmpq %rax, %r13
movl %r13d, %ecx
cmovgel %eax, %ecx
addq 0x28(%r15), %rdi
movslq %ecx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x43c0
movl 0x10(%r15), %eax
addl %r12d, %eax
movl %eax, 0x10(%r15)
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0xd1c8
movq %r15, %rdi
callq 0xd0a3
testl %eax, %eax
jne 0xd1db
addq %r12, %r14
subq %r12, %r13
testq %r13, %r13
jg 0xd183
subq %r13, %rbx
movq %rbx, %r12
jmp 0xd1e2
movq $-0x1, %r12
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xf4c6
leaq 0x8aafc(%rip), %rdi     # 0x97d0b
leaq 0x8a9ca(%rip), %rsi     # 0x97be0
leaq 0x8aafb(%rip), %rcx     # 0x97d18
movl $0x7d8, %edx            # imm = 0x7D8
callq 0x42f0
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_close_mt
static void bgzf_close_mt(BGZF *fp) {
    if (fp->mt) {
        if (!fp->mt->free_block)
            fp->uncompressed_block = NULL;
        if (mt_destroy(fp->mt) < 0)
            fp->errcode = BGZF_ERR_IO;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x48(%rdi), %rdi
testq %rdi, %rdi
je 0xd750
cmpq $0x0, 0x60(%rdi)
jne 0xd742
movq $0x0, 0x28(%rbx)
callq 0xb672
testl %eax, %eax
jns 0xd750
movw $0x4, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_index_destroy
void bgzf_index_destroy(BGZF *fp)
{
    if ( !fp->idx ) return;
    free(fp->idx->offs);
    free(fp->idx);
    fp->idx = NULL;
    fp->idx_build_otf = 0;
}

// Assembly:
movq 0x50(%rdi), %rax
testq %rax, %rax
je 0xd781
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rax), %rdi
callq 0x45c0
movq 0x50(%rbx), %rdi
callq 0x45c0
movq $0x0, 0x50(%rbx)
movl $0x0, 0x58(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_check_EOF
int bgzf_check_EOF(BGZF *fp) {
    int has_eof;

    if (fp->mt) {
        pthread_mutex_lock(&fp->mt->command_m);
        // fp->mt->command state transitions should be:
        // NONE -> HAS_EOF -> HAS_EOF_DONE -> NONE
        // (HAS_EOF -> HAS_EOF_DONE happens in bgzf_mt_reader thread)
        if (fp->mt->command != CLOSE)
            fp->mt->command = HAS_EOF;
        pthread_cond_signal(&fp->mt->command_c);
        hts_tpool_wake_dispatch(fp->mt->out_queue);
        do {
            if (fp->mt->command == CLOSE) {
                // possible error in bgzf_mt_reader
                pthread_mutex_unlock(&fp->mt->command_m);
                return 0;
            }
            pthread_cond_wait(&fp->mt->command_c, &fp->mt->command_m);
            switch (fp->mt->command) {
            case HAS_EOF_DONE: break;
            case HAS_EOF:
                // Resend signal intended for bgzf_mt_reader()
                pthread_cond_signal(&fp->mt->command_c);
                break;
            case CLOSE:
                continue;
            default:
                abort();  // Should not get to any other state
            }
        } while (fp->mt->command != HAS_EOF_DONE);
        fp->mt->command = NONE;
        has_eof = fp->mt->eof;
        pthread_mutex_unlock(&fp->mt->command_m);
    } else {
        has_eof = bgzf_check_EOF_common(fp);
    }

    fp->no_eof_block = (has_eof == 0);

    return has_eof;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x48(%rdi), %rdi
testq %rdi, %rdi
je 0xd84b
subq $-0x80, %rdi
callq 0x4750
movq 0x48(%rbx), %rdi
cmpl $0x5, 0xd8(%rdi)
je 0xd7cd
movl $0x3, 0xd8(%rdi)
addq $0xa8, %rdi
callq 0x4040
movq 0x48(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x3817e
movq 0x48(%rbx), %rsi
cmpl $0x5, 0xd8(%rsi)
je 0xd86c
leaq 0xa8(%rsi), %rdi
subq $-0x80, %rsi
callq 0x47c0
movq 0x48(%rbx), %rdi
movl 0xd8(%rdi), %eax
leal -0x4(%rax), %ecx
cmpl $0x2, %ecx
jb 0xd826
cmpl $0x3, %eax
jne 0xd883
addq $0xa8, %rdi
callq 0x4040
movq 0x48(%rbx), %rdi
cmpl $0x4, 0xd8(%rdi)
jne 0xd7e6
movl $0x0, 0xd8(%rdi)
movl 0x78(%rdi), %ebp
subq $-0x80, %rdi
callq 0x4340
jmp 0xd855
movq %rbx, %rdi
callq 0xd888
movl %eax, %ebp
xorl %eax, %eax
testl %ebp, %ebp
sete %al
shll $0x12, %eax
movl $0xfffbffff, %ecx       # imm = 0xFFFBFFFF
andl (%rbx), %ecx
orl %eax, %ecx
movl %ecx, (%rbx)
jmp 0xd87a
subq $-0x80, %rsi
movq %rsi, %rdi
callq 0x4340
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x4270
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_check_EOF_common
static int bgzf_check_EOF_common(BGZF *fp)
{
    uint8_t buf[28];
    off_t offset = htell(fp->fp);
    if (hseek(fp->fp, -28, SEEK_END) < 0) {
        if (errno == ESPIPE) { hclearerr(fp->fp); return 2; }
#ifdef _WIN32
        if (errno == EINVAL) { hclearerr(fp->fp); return 2; }
#else
        // Assume that EINVAL was due to the file being less than 28 bytes
        // long, rather than being a random error return from an hfile backend.
        // This should be reported as "no EOF block" rather than an error.
        if (errno == EINVAL) { hclearerr(fp->fp); return 0; }
#endif
        return -1;
    }
    if ( hread(fp->fp, buf, 28) != 28 ) return -1;
    if ( hseek(fp->fp, offset, SEEK_SET) < 0 ) return -1;
    return (memcmp("\037\213\010\4\0\0\0\0\0\377\6\0\102\103\2\0\033\0\3\0\0\0\0\0\0\0\0\0", buf, 28) == 0)? 1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
movq 0x28(%rdi), %r14
addq 0x8(%rdi), %r14
subq (%rdi), %r14
movq $-0x1c, %rsi
movl $0x2, %edx
callq 0xf583
testq %rax, %rax
js 0xd963
movq 0x40(%rbx), %r12
movq 0x8(%r12), %rsi
movq 0x10(%r12), %r13
subq %rsi, %r13
cmpq $0x1c, %r13
movl $0x1c, %r15d
cmovbq %r13, %r15
movq %rsp, %rdi
movq %r15, %rdx
callq 0x43c0
addq %r15, 0x8(%r12)
cmpq $0x1b, %r13
ja 0xd915
testb $0x2, 0x30(%r12)
je 0xd915
movq %rsp, %rsi
movl $0x1c, %edx
movq %r12, %rdi
movq %r15, %rcx
callq 0xf2cd
movq %rax, %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq $0x1c, %r15
jne 0xd998
movq 0x40(%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xf583
testq %rax, %rax
js 0xd998
movdqu 0xc(%rsp), %xmm0
pcmpeqb 0x8a01f(%rip), %xmm0    # 0x97960
movdqa (%rsp), %xmm1
pcmpeqb 0x8a022(%rip), %xmm1    # 0x97970
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
xorl %ebp, %ebp
cmpl $0xffff, %eax           # imm = 0xFFFF
sete %bpl
jmp 0xd998
callq 0x4050
movl (%rax), %eax
cmpl $0x16, %eax
je 0xd98b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x1d, %eax
jne 0xd998
movq 0x40(%rbx), %rax
movl $0x0, 0x34(%rax)
movl $0x2, %ebp
jmp 0xd998
movq 0x40(%rbx), %rax
movl $0x0, 0x34(%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq