LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: sam_header2list
char **sam_header2list(const void *_dict, char type[2], char key_tag[2], int *_n)
{
	const HeaderDict *dict = (const HeaderDict*)_dict;
    const list_t *l   = dict;
    int max, n;
	char **ret;

	ret = 0; *_n = max = n = 0;
    while (l)
    {
        HeaderLine *hline = l->data;
        if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] ) 
        {
            l = l->next;
            continue;
        }
        
        HeaderTag *key;
        key   = header_line_has_tag(hline,key_tag);
        if ( !key )
        {
            l = l->next;
            continue;
        }

		if (n == max) {
			max = max? max<<1 : 4;
			ret = realloc(ret, max * sizeof(void*));
		}
		ret[n++] = key->value;

        l = l->next;
    }
	*_n = n;
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, -0x40(%rbp)
movq %rsi, %r15
movq %rdi, %r12
movq %rcx, -0x38(%rbp)
andl $0x0, (%rcx)
xorl %r14d, %r14d
xorl %r13d, %r13d
movl $0x0, -0x2c(%rbp)
testq %r12, %r12
je 0x761f
movq 0x10(%r12), %rdi
movb (%rdi), %al
cmpb (%r15), %al
jne 0x7618
movb 0x1(%rdi), %al
cmpb 0x1(%r15), %al
jne 0x7618
movq -0x40(%rbp), %rsi
callq 0x89dc
testq %rax, %rax
je 0x7618
movq %rax, %rbx
cmpl -0x2c(%rbp), %r14d
jne 0x7609
leal (%r14,%r14), %ecx
testl %r14d, %r14d
pushq $0x4
popq %rax
cmovel %eax, %ecx
movl %ecx, -0x2c(%rbp)
movslq %ecx, %rsi
shlq $0x3, %rsi
movq %r13, %rdi
callq 0x3590
movq %rax, %r13
movq 0x8(%rbx), %rax
movslq %r14d, %rcx
incl %r14d
movq %rax, (%r13,%rcx,8)
movq 0x8(%r12), %r12
jmp 0x75b6
movq -0x38(%rbp), %rax
movl %r14d, (%rax)
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: append_text
static inline void append_text(bam_header_t *header, kstring_t *str)
{
	size_t x = header->l_text, y = header->l_text + str->l + 2; // 2 = 1 byte dret + 1 byte null
	kroundup32(x); kroundup32(y);
	if (x < y) 
    {
        header->n_text = y;
        header->text = (char*)realloc(header->text, y);
        if ( !header->text ) 
        {
            fprintf(stderr,"realloc failed to alloc %ld bytes\n", y);
            abort();
        }
    }
    // Sanity check
    if ( header->l_text+str->l+1 >= header->n_text )
    {
        fprintf(stderr,"append_text FIXME: %ld>=%ld, x=%ld,y=%ld\n",  header->l_text+str->l+1,(long)header->n_text,x,y);
        abort();
    }
	strncpy(header->text + header->l_text, str->s, str->l+1); // we cannot use strcpy() here.
	header->l_text += str->l + 1;
	header->text[header->l_text] = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl 0x30(%rdi), %edi
movq (%rsi), %rdx
leaq -0x1(%rdi), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %r15
shrq $0x10, %r15
orq %rax, %r15
incq %r15
leaq (%rdi,%rdx), %rax
incq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %r12
shrq $0x10, %r12
orq %rax, %r12
incq %r12
cmpq %r12, %r15
jae 0x76e6
movl %r12d, 0x34(%rbx)
movq 0x38(%rbx), %rdi
movq %r12, %rsi
callq 0x3590
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x7749
movl 0x30(%rbx), %edi
movq (%r14), %rdx
leaq (%rdx,%rdi), %rax
incq %rax
movl 0x34(%rbx), %ecx
cmpq %rcx, %rax
jae 0x7723
incq %rdx
addq 0x38(%rbx), %rdi
movq 0x10(%r14), %rsi
callq 0x3160
movl (%r14), %eax
movl 0x30(%rbx), %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x30(%rbx)
movq 0x38(%rbx), %rcx
movb $0x0, (%rcx,%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x78a6(%rip), %rdx      # 0xefd0
movq (%rdx), %rdi
leaq 0x4011(%rip), %rsi      # 0xb745
movq %rax, %rdx
movq %r15, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x34c0
callq 0x3180
movq 0x7880(%rip), %rax      # 0xefd0
movq (%rax), %rdi
leaq 0x3fc8(%rip), %rsi      # 0xb722
movq %r12, %rdx
xorl %eax, %eax
callq 0x34c0
callq 0x3180
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: alloc_data
static inline uint8_t *alloc_data(bam1_t *b, int size)
{
	if (b->m_data < size) {
		b->m_data = size;
		kroundup32(b->m_data);
		b->data = (uint8_t*)realloc(b->data, b->m_data);
	}
	return b->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl %esi, 0x2c(%rdi)
jge 0x77b2
decl %esi
movl %esi, %eax
sarl %eax
orl %esi, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x10, %eax
orl %ecx, %eax
incl %eax
movl %eax, 0x2c(%rbx)
movq 0x30(%rbx), %rdi
movslq %eax, %rsi
callq 0x3590
movq %rax, 0x30(%rbx)
jmp 0x77b6
movq 0x30(%rbx), %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/./bamcat.h
// Function: bam_reg2bin
static inline int bam_reg2bin(uint32_t beg, uint32_t end)
{
	--end;
	if (beg>>14 == end>>14) return 4681 + (beg>>14);
	if (beg>>17 == end>>17) return  585 + (beg>>17);
	if (beg>>20 == end>>20) return   73 + (beg>>20);
	if (beg>>23 == end>>23) return    9 + (beg>>23);
	if (beg>>26 == end>>26) return    1 + (beg>>26);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
decl %esi
movl %edi, %eax
shrl $0xe, %eax
movl %esi, %ecx
shrl $0xe, %ecx
cmpl %ecx, %eax
jne 0x77ff
addl $0x1249, %eax           # imm = 0x1249
jmp 0x784a
movl %edi, %eax
shrl $0x11, %eax
movl %esi, %ecx
shrl $0x11, %ecx
cmpl %ecx, %eax
jne 0x7814
addl $0x249, %eax            # imm = 0x249
jmp 0x784a
movl %edi, %eax
shrl $0x14, %eax
movl %esi, %ecx
shrl $0x14, %ecx
cmpl %ecx, %eax
jne 0x7827
addl $0x49, %eax
jmp 0x784a
movl %edi, %eax
shrl $0x17, %eax
movl %esi, %ecx
shrl $0x17, %ecx
cmpl %ecx, %eax
jne 0x783a
addl $0x9, %eax
jmp 0x784a
shrl $0x1a, %edi
shrl $0x1a, %esi
leal 0x1(%rdi), %ecx
xorl %eax, %eax
cmpl %esi, %edi
cmovel %ecx, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_write_init
static BGZF *bgzf_write_init(int compress_level) // compress_level==-1 for the default level
{
	BGZF *fp;
	fp = calloc(1, sizeof(BGZF));
	fp->is_write = 1;
	fp->uncompressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
	fp->compressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
	fp->compress_level = compress_level < 0? Z_DEFAULT_COMPRESSION : compress_level; // Z_DEFAULT_COMPRESSION==-1
	if (fp->compress_level > 9) fp->compress_level = Z_DEFAULT_COMPRESSION;
	return fp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
pushq $0x1
popq %rdi
pushq $0x40
popq %rsi
callq 0x31c0
movq %rax, %r14
movl $0x10000, %edi          # imm = 0x10000
callq 0x3470
movq %rax, 0x18(%r14)
movl $0x10000, %edi          # imm = 0x10000
callq 0x3470
movq %rax, 0x20(%r14)
testl %ebx, %ebx
pushq $-0x1
popq %rax
cmovnsl %ebx, %eax
shll $0x12, %eax
leal 0x10000(%rax), %ecx
cmpl $0x240001, %eax         # imm = 0x240001
movl $0xfffd0000, %eax       # imm = 0xFFFD0000
cmovll %ecx, %eax
movl %eax, (%r14)
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: mode2level
static int mode2level(const char *__restrict mode)
{
	int i, compress_level = -1;
	for (i = 0; mode[i]; ++i)
		if (mode[i] >= '0' && mode[i] <= '9') break;
	if (mode[i]) compress_level = (int)mode[i] - '0';
	if (strchr(mode, 'u')) compress_level = 0;
	return compress_level;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rcx
movzbl (%rcx), %eax
testl %eax, %eax
je 0x78c4
leal -0x30(%rax), %edx
incq %rcx
cmpb $0x9, %dl
ja 0x78b2
leal -0x30(%rax), %ecx
xorl %r14d, %r14d
cmpl $0x1, %eax
movl $0x0, %ebx
sbbl %ebx, %ebx
orl %ecx, %ebx
pushq $0x75
popq %rsi
callq 0x3100
testq %rax, %rax
cmovnel %r14d, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_read_block
int bgzf_read_block(BGZF *fp)
{
	uint8_t header[BLOCK_HEADER_LENGTH], *compressed_block;
	int count, size = 0, block_length, remaining;
	int64_t block_address;
	block_address = _bgzf_tell((_bgzf_file_t)fp->fp);
	if (fp->cache_size && load_block_from_cache(fp, block_address)) return 0;
	count = _bgzf_read(fp->fp, header, sizeof(header));
	if (count == 0) { // no data read
		fp->block_length = 0;
		return 0;
	}
	if (count != sizeof(header) || !check_header(header)) {
		fp->errcode |= BGZF_ERR_HEADER;
		return -1;
	}
	size = count;
	block_length = unpackInt16((uint8_t*)&header[16]) + 1; // +1 because when writing this number, we used "-1"
	compressed_block = (uint8_t*)fp->compressed_block;
	memcpy(compressed_block, header, BLOCK_HEADER_LENGTH);
	remaining = block_length - BLOCK_HEADER_LENGTH;
	count = _bgzf_read(fp->fp, &compressed_block[BLOCK_HEADER_LENGTH], remaining);
	if (count != remaining) {
		fp->errcode |= BGZF_ERR_IO;
		return -1;
	}
	size += count;
	if ((count = inflate_block(fp, block_length)) < 0) return -1;
	if (fp->block_length != 0) fp->block_offset = 0; // Do not reset offset if this read follows a seek.
	fp->block_address = block_address;
	fp->block_length = count;
	cache_block(fp, size);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
callq 0x3410
movq %rax, %r14
movq 0x30(%rbx), %rcx
leaq -0x40(%rbp), %rdi
pushq $0x1
popq %rsi
pushq $0x12
popq %rdx
callq 0x3510
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rax, %rcx
je 0x7a50
cmpl $0x12, %ecx
jne 0x7a48
cmpb $0x1f, -0x40(%rbp)
jne 0x7a48
cmpb $-0x75, -0x3f(%rbp)
jne 0x7a48
cmpb $0x8, -0x3e(%rbp)
jne 0x7a48
testb $0x4, -0x3d(%rbp)
je 0x7a48
cmpw $0x6, -0x36(%rbp)
jne 0x7a48
cmpb $0x42, -0x34(%rbp)
jne 0x7a48
cmpb $0x43, -0x33(%rbp)
jne 0x7a48
cmpw $0x2, -0x32(%rbp)
jne 0x7a48
movzwl -0x30(%rbp), %r12d
movq 0x20(%rbx), %rdi
movw %r12w, 0x10(%rdi)
movaps -0x40(%rbp), %xmm0
movups %xmm0, (%rdi)
leaq -0x11(%r12), %r15
addq $0x12, %rdi
movq 0x30(%rbx), %rcx
pushq $0x1
popq %rsi
movq %r15, %rdx
callq 0x3510
cmpl %eax, %r15d
jne 0x7a66
xorps %xmm0, %xmm0
leaq -0xb0(%rbp), %rdi
movups %xmm0, 0x40(%rdi)
movq 0x20(%rbx), %rax
addq $0x12, %rax
movq %rax, (%rdi)
addl $-0xf, %r12d
movl %r12d, 0x8(%rdi)
movq 0x18(%rbx), %rax
movq %rax, 0x18(%rdi)
movl $0x10000, 0x20(%rdi)    # imm = 0x10000
leaq 0x3d97(%rip), %rdx      # 0xb78d
pushq $-0xf
popq %rsi
pushq $0x70
popq %rcx
callq 0x3270
testl %eax, %eax
jne 0x7a6b
leaq -0xb0(%rbp), %r15
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x3250
movl %eax, %r12d
xorl $0x1, %r12d
movq %r15, %rdi
callq 0x3350
orl %r12d, %eax
jne 0x7a6b
movl -0x88(%rbp), %eax
testl %eax, %eax
js 0x7a4b
cmpl $0x0, 0x8(%rbx)
je 0x7a3f
andl $0x0, 0xc(%rbx)
movq %r14, 0x10(%rbx)
movl %eax, 0x8(%rbx)
jmp 0x7a54
orb $0x2, (%rbx)
pushq $-0x1
popq %rax
jmp 0x7a56
andl $0x0, 0x8(%rbx)
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
orb $0x4, (%rbx)
jmp 0x7a4b
orb $0x1, (%rbx)
jmp 0x7a4b
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_mt
int bgzf_mt(BGZF *fp, int n_threads, int n_sub_blks)
{
	int i;
	mtaux_t *mt;
	pthread_attr_t attr;
	if (!fp->is_write || fp->mt || n_threads <= 1) return -1;
	mt = calloc(1, sizeof(mtaux_t));
	mt->n_threads = n_threads;
	mt->n_blks = n_threads * n_sub_blks;
	mt->len = calloc(mt->n_blks, sizeof(int));
	mt->blk = calloc(mt->n_blks, sizeof(void*));
	for (i = 0; i < mt->n_blks; ++i)
		mt->blk[i] = malloc(BGZF_MAX_BLOCK_SIZE);
	mt->tid = calloc(mt->n_threads, sizeof(pthread_t)); // tid[0] is not used, as the worker 0 is launched by the master
	mt->w = calloc(mt->n_threads, sizeof(worker_t));
	for (i = 0; i < mt->n_threads; ++i) {
		mt->w[i].i = i;
		mt->w[i].mt = mt;
		mt->w[i].fp = fp;
		mt->w[i].buf = malloc(BGZF_MAX_BLOCK_SIZE);
	}
	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
	pthread_mutex_init(&mt->lock, 0);
	pthread_cond_init(&mt->cv, 0);
	for (i = 1; i < mt->n_threads; ++i) // worker 0 is effectively launched by the master thread
		pthread_create(&mt->tid[i], &attr, mt_worker, &mt->w[i]);
	fp->mt = mt;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
pushq $-0x1
popq %rax
movq %rdi, -0x30(%rbp)
testb $0x3, 0x2(%rdi)
je 0x7be5
movl %esi, %r12d
cmpl $0x2, %esi
jl 0x7be5
movq -0x30(%rbp), %rcx
cmpq $0x0, 0x38(%rcx)
jne 0x7be5
movl %edx, %ebx
pushq $0x1
popq %rdi
movl $0x90, %esi
callq 0x31c0
movq %rax, %r15
movl %r12d, (%rax)
imull %r12d, %ebx
movl %ebx, 0x4(%rax)
movslq %ebx, %rbx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x31c0
movq %rax, 0x20(%r15)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x31c0
movq %rax, %r13
movq %rax, 0x18(%r15)
xorl %r14d, %r14d
testl %ebx, %ebx
cmovlel %r14d, %ebx
cmpq %r14, %rbx
je 0x7b0f
movl $0x10000, %edi          # imm = 0x10000
callq 0x3470
movq %rax, (%r13,%r14,8)
incq %r14
jmp 0x7af6
movl %r12d, %ebx
pushq $0x8
popq %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x31c0
movq %rax, 0x30(%r15)
pushq $0x28
popq %r13
movq %rbx, -0x38(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x31c0
movq %rax, %rbx
movq %rax, 0x28(%r15)
addq $0x18, %rbx
xorl %r14d, %r14d
cmpq %r14, -0x38(%rbp)
je 0x7b72
movl %r14d, (%rbx)
movq %r15, -0x10(%rbx)
movq -0x30(%rbp), %rax
movq %rax, -0x18(%rbx)
movl $0x10000, %edi          # imm = 0x10000
callq 0x3470
movq %rax, -0x8(%rbx)
incq %r14
addq $0x28, %rbx
jmp 0x7b46
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x3400
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3460
leaq 0x38(%r15), %rdi
xorl %esi, %esi
callq 0x3500
movq %r15, %rdi
addq $0x60, %rdi
xorl %esi, %esi
callq 0x33e0
leaq 0x4c(%rip), %rbx        # 0x7bf4
pushq $0x1
popq %r14
movslq (%r15), %rax
cmpq %rax, %r14
jge 0x7bdb
movq 0x30(%r15), %rdi
addq %r12, %rdi
movq 0x28(%r15), %rcx
addq %r13, %rcx
leaq -0x70(%rbp), %rsi
movq %rbx, %rdx
callq 0x35f0
incq %r14
addq $0x28, %r13
addq $0x8, %r12
jmp 0x7bac
movq -0x30(%rbp), %rax
movq %r15, 0x38(%rax)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_flush
int bgzf_flush(BGZF *fp)
{
	if (!fp->is_write) return 0;
	if (fp->mt) return mt_flush(fp);
	while (fp->block_offset > 0) {
		int block_length;
		block_length = deflate_block(fp, fp->block_offset);
		if (block_length < 0) return -1;
		if (fwrite(fp->compressed_block, 1, block_length, fp->fp) != block_length) {
			fp->errcode |= BGZF_ERR_IO; // possibly truncated file
			return -1;
		}
		fp->block_address += block_length;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testb $0x3, 0x2(%rdi)
je 0x7c80
movq %rdi, %r14
cmpq $0x0, 0x38(%rdi)
je 0x7c3c
movq %r14, %rdi
callq 0x7c91
jmp 0x7c80
pushq $-0x1
popq %r13
pushq $0x1
popq %r15
movl 0xc(%r14), %esi
testl %esi, %esi
jle 0x7c80
movq %r14, %rdi
callq 0x7d81
testl %eax, %eax
js 0x7c7d
movl %eax, %r12d
movq 0x20(%r14), %rdi
movq 0x30(%r14), %rcx
movq %r15, %rsi
movq %r12, %rdx
callq 0x3660
cmpq %r12, %rax
jne 0x7c79
addq %r12, 0x10(%r14)
jmp 0x7c44
orb $0x4, (%r14)
movl %r13d, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: mt_flush
static int mt_flush(BGZF *fp)
{
	int i;
	mtaux_t *mt = (mtaux_t*)fp->mt;
	if (fp->block_offset) mt_queue(fp); // guaranteed that assertion does not fail
	// signal all the workers to compress
	pthread_mutex_lock(&mt->lock);
	for (i = 0; i < mt->n_threads; ++i) mt->w[i].toproc = 1;
	mt->proc_cnt = 0;
	pthread_cond_broadcast(&mt->cv);
	pthread_mutex_unlock(&mt->lock);
	// worker 0 is doing things here
	worker_aux(&mt->w[0]);
	// wait for all the threads to complete
	while (mt->proc_cnt < mt->n_threads);
	// dump data to disk
	for (i = 0; i < mt->n_threads; ++i) fp->errcode |= mt->w[i].errcode;
	for (i = 0; i < mt->curr; ++i)
		if (fwrite(mt->blk[i], 1, mt->len[i], fp->fp) != mt->len[i])
			fp->errcode |= BGZF_ERR_IO;
	mt->curr = 0;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %r15
cmpl $0x0, 0xc(%rdi)
je 0x7cb1
movq %rbx, %rdi
callq 0x9353
leaq 0x38(%r15), %r14
movq %r14, %rdi
callq 0x34e0
movl (%r15), %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0x28, %rcx, %rcx
cmpq %rax, %rcx
je 0x7ce2
movq 0x28(%r15), %rdx
movl $0x1, 0x20(%rdx,%rax)
addq $0x28, %rax
jmp 0x7ccb
movl $0x0, 0x10(%r15)
leaq 0x60(%r15), %rdi
callq 0x30e0
movq %r14, %rdi
callq 0x3210
movq 0x28(%r15), %rdi
callq 0x9167
movl (%r15), %edx
movl 0x10(%r15), %eax
cmpl %edx, %eax
jl 0x7d07
pushq $0x1c
popq %rax
xorl %ecx, %ecx
movslq %edx, %rdx
cmpq %rdx, %rcx
jge 0x7d32
movq 0x28(%r15), %rdx
movzwl (%rdx,%rax), %edx
orl %edx, (%rbx)
incq %rcx
movl (%r15), %edx
addq $0x28, %rax
jmp 0x7d14
xorl %r12d, %r12d
pushq $0x1
popq %r14
movslq 0x8(%r15), %rax
cmpq %rax, %r12
jge 0x7d73
movq 0x18(%r15), %rax
movq 0x20(%r15), %rcx
movq (%rax,%r12,8), %rdi
movslq (%rcx,%r12,4), %rdx
movq 0x30(%rbx), %rcx
movq %r14, %rsi
callq 0x3660
movq 0x20(%r15), %rcx
movslq (%rcx,%r12,4), %rcx
cmpq %rcx, %rax
je 0x7d6e
orb $0x4, (%rbx)
incq %r12
jmp 0x7d39
andl $0x0, 0x8(%r15)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: deflate_block
static int deflate_block(BGZF *fp, int block_length)
{
	int comp_size = BGZF_MAX_BLOCK_SIZE;
	if (bgzf_compress(fp->compressed_block, &comp_size, fp->uncompressed_block, block_length, fp->compress_level) != 0) {
		fp->errcode |= BGZF_ERR_ZLIB;
		return -1;
	}
	fp->block_offset = 0;
	return comp_size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %esi, %ecx
movq %rdi, %rbx
leaq -0xc(%rbp), %rsi
movl $0x10000, (%rsi)        # imm = 0x10000
movq 0x20(%rdi), %rdi
movq 0x18(%rbx), %rdx
movl (%rbx), %r8d
sarl $0x12, %r8d
callq 0x9266
testl %eax, %eax
je 0x7db6
orb $0x1, (%rbx)
pushq $-0x1
popq %rax
jmp 0x7dbd
andl $0x0, 0xc(%rbx)
movl -0xc(%rbp), %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: mt_lazy_flush
static int mt_lazy_flush(BGZF *fp)
{
	mtaux_t *mt = (mtaux_t*)fp->mt;
	if (fp->block_offset) mt_queue(fp);
	if (mt->curr == mt->n_blks)
		return mt_flush(fp);
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %r14
cmpl $0x0, 0xc(%rdi)
je 0x7e0a
movq %rbx, %rdi
callq 0x9353
movl 0x8(%r14), %eax
cmpl 0x4(%r14), %eax
jne 0x7e20
movq %rbx, %rdi
callq 0x7c91
xorl %eax, %eax
jmp 0x7e23
pushq $-0x1
popq %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_write
ssize_t bgzf_write(BGZF *fp, const void *data, ssize_t length)
{
	const uint8_t *input = data;
	int block_length = BGZF_BLOCK_SIZE, bytes_written = 0;
	assert(fp->is_write);
	if (fp->mt) return mt_write(fp, data, length);
	while (bytes_written < length) {
		uint8_t* buffer = fp->uncompressed_block;
		int copy_length = block_length - fp->block_offset < length - bytes_written? block_length - fp->block_offset : length - bytes_written;
		memcpy(buffer + fp->block_offset, input, copy_length);
		fp->block_offset += copy_length;
		input += copy_length;
		bytes_written += copy_length;
		if (fp->block_offset == block_length && bgzf_flush(fp)) break;
	}
	return bytes_written;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testb $0x3, 0x2(%rdi)
je 0x7f0e
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
cmpq $0x0, 0x38(%rdi)
je 0x7eb3
movq %rbx, %r13
testq %r13, %r13
je 0x7ea1
movslq 0xc(%r15), %rdi
movl $0xff00, %eax           # imm = 0xFF00
subq %rdi, %rax
cmpq %rax, %r13
movl %r13d, %ecx
cmovgl %eax, %ecx
addq 0x18(%r15), %rdi
movslq %ecx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x3260
movl 0xc(%r15), %eax
addl %r12d, %eax
movl %eax, 0xc(%r15)
addq %r12, %r14
subq %r12, %r13
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0x7e53
movq %r15, %rdi
callq 0x7dee
jmp 0x7e53
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
movslq %r13d, %rax
movq %rbx, %rcx
subq %rax, %rcx
jle 0x7ea4
movslq 0xc(%r15), %rdi
movl $0xff00, %eax           # imm = 0xFF00
subq %rdi, %rax
cmpq %rax, %rcx
cmovgl %eax, %ecx
addq 0x18(%r15), %rdi
movslq %ecx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x3260
movl 0xc(%r15), %eax
addl %r12d, %eax
movl %eax, 0xc(%r15)
addq %r12, %r14
addl %r12d, %r13d
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0x7eb6
movq %r15, %rdi
callq 0x7c12
testl %eax, %eax
je 0x7eb6
movslq %r13d, %rax
jmp 0x7ea4
leaq 0x371c(%rip), %rdi      # 0xb631
leaq 0x3340(%rip), %rsi      # 0xb25c
leaq 0x371b(%rip), %rcx      # 0xb63e
movl $0x679, %edx            # imm = 0x679
callq 0x31b0
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_seek
int64_t bgzf_seek(BGZF* fp, int64_t pos, int where)
{
	int block_offset;
	int64_t block_address;

	if (fp->is_write || where != SEEK_SET) {
		fp->errcode |= BGZF_ERR_MISUSE;
		return -1;
	}
	block_offset = pos & 0xFFFF;
	block_address = pos >> 16;
	if (_bgzf_seek(fp->fp, block_address, SEEK_SET) < 0) {
		fp->errcode |= BGZF_ERR_IO;
		return -1;
	}
	fp->block_length = 0;  // indicates current block has not been loaded
	fp->block_address = block_address;
	fp->block_offset = block_offset;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rdi), %eax
movl %eax, %ecx
andl $0x30000, %ecx          # imm = 0x30000
orl %edx, %ecx
je 0x7f60
orl $0x8, %eax
movl %eax, (%rbx)
pushq $-0x1
popq %rax
jmp 0x7f8d
movq %rsi, %r14
movq %rsi, %r15
sarq $0x10, %r15
movq 0x30(%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3190
testl %eax, %eax
js 0x7f98
andl $0x0, 0x8(%rbx)
movzwl %r14w, %eax
movq %r15, 0x10(%rbx)
movl %eax, 0xc(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
orb $0x4, (%rbx)
jmp 0x7f5b
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_is_bgzf
int bgzf_is_bgzf(const char *fn)
{
	uint8_t buf[16];
	int n;
	_bgzf_file_t fp;
	if ((fp = _bgzf_open(fn, "r")) == 0) return 0;
	n = _bgzf_read(fp, buf, 16);
	_bgzf_close(fp);
	if (n != 16) return 0;
	return memcmp(g_magic, buf, 16) == 0? 1 : 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0x33f1(%rip), %rsi      # 0xb3a2
callq 0x33c0
xorl %ebx, %ebx
testq %rax, %rax
je 0x7ffe
movq %rax, %r14
leaq -0x30(%rbp), %rdi
pushq $0x1
popq %rsi
pushq $0x10
popq %rdx
movq %rax, %rcx
callq 0x3510
movq %rax, %r15
movq %r14, %rdi
callq 0x32e0
cmpl $0x10, %r15d
jne 0x7ffe
movdqa -0x30(%rbp), %xmm0
pcmpeqb 0x3140(%rip), %xmm0     # 0xb130
pmovmskb %xmm0, %eax
xorl %ebx, %ebx
cmpl $0xffff, %eax           # imm = 0xFFFF
sete %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_getc
int bgzf_getc(BGZF *fp)
{
	int c;
	if (fp->block_offset >= fp->block_length) {
		if (bgzf_read_block(fp) != 0) return -2; /* error */
		if (fp->block_length == 0) return -1; /* end-of-file */
	}
	c = ((unsigned char*)fp->uncompressed_block)[fp->block_offset++];
    if (fp->block_offset == fp->block_length) {
        fp->block_address = _bgzf_tell((_bgzf_file_t)fp->fp);
        fp->block_offset = 0;
        fp->block_length = 0;
    }
	return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ecx
cmpl %eax, %ecx
jge 0x8049
movq 0x18(%rbx), %rdx
leal 0x1(%rcx), %esi
movl %esi, 0xc(%rbx)
movslq %ecx, %rcx
movzbl (%rdx,%rcx), %r14d
cmpl %eax, %esi
jne 0x8059
movq 0x30(%rbx), %rdi
callq 0x3410
movq %rax, 0x10(%rbx)
andq $0x0, 0x8(%rbx)
jmp 0x8059
movq %rbx, %rdi
callq 0x78ec
testl %eax, %eax
je 0x8061
pushq $-0x2
popq %r14
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x806d
movl 0xc(%rbx), %ecx
jmp 0x801f
pushq $-0x1
jmp 0x8057
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_getline
int bgzf_getline(BGZF *fp, int delim, kstring_t *str)
{
	int l, state = 0;
	unsigned char *buf = (unsigned char*)fp->uncompressed_block;
	str->l = 0;
	do {
		if (fp->block_offset >= fp->block_length) {
			if (bgzf_read_block(fp) != 0) { state = -2; break; }
			if (fp->block_length == 0) { state = -1; break; }
		}
		for (l = fp->block_offset; l < fp->block_length && buf[l] != delim; ++l);
		if (l < fp->block_length) state = 1;
		l -= fp->block_offset;
		if (str->l + l + 1 >= str->m) {
			str->m = str->l + l + 2;
			kroundup32(str->m);
			str->s = (char*)realloc(str->s, str->m);
		}
		memcpy(str->s + str->l, buf + fp->block_offset, l);
		str->l += l;
		fp->block_offset += l + 1;
		if (fp->block_offset >= fp->block_length) {
			fp->block_address = _bgzf_tell((_bgzf_file_t)fp->fp);
			fp->block_offset = 0;
			fp->block_length = 0;
		} 
	} while (state == 0);
	if (str->l == 0 && state < 0) return state;
	str->s[str->l] = 0;
	return str->l;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r15d
movq %rdi, %r13
movq 0x18(%rdi), %r14
andq $0x0, (%rdx)
movl 0x8(%rdi), %ecx
movl 0xc(%rdi), %eax
movq %rdx, -0x30(%rbp)
movl %esi, -0x34(%rbp)
movq %rdi, -0x40(%rbp)
cmpl %ecx, %eax
jl 0x80c9
movq %r13, %rdi
callq 0x78ec
testl %eax, %eax
jne 0x81c0
movl 0x8(%r13), %ecx
testl %ecx, %ecx
movq -0x30(%rbp), %rdx
je 0x81c8
movl 0xc(%r13), %eax
movslq %eax, %rsi
movslq %ecx, %rbx
cmpl %ebx, %esi
movl %ebx, %ecx
cmovgl %esi, %ecx
movq %rsi, %r12
cmpq %rbx, %r12
jge 0x80f0
movzbl (%r14,%r12), %edi
cmpl %r15d, %edi
je 0x80ed
incq %r12
jmp 0x80d9
movl %r12d, %ecx
subl %eax, %ecx
movq (%rdx), %rdi
movq 0x10(%rdx), %rax
movslq %ecx, %r8
leaq (%r8,%rdi), %rcx
incq %rcx
cmpq 0x8(%rdx), %rcx
jae 0x810f
movq -0x40(%rbp), %r13
jmp 0x8167
movq %rcx, %rsi
shrq %rsi
orq %rcx, %rsi
movq %rsi, %rcx
shrq $0x2, %rcx
orq %rsi, %rcx
movq %rcx, %rsi
shrq $0x4, %rsi
orq %rcx, %rsi
movq %rsi, %rcx
shrq $0x8, %rcx
orq %rsi, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rdx)
movq %rax, %rdi
movq %rdx, %r15
movq %r8, %r13
callq 0x3590
movq %r13, %r8
movq %rax, 0x10(%r15)
movq (%r15), %rdi
movq -0x40(%rbp), %r13
movslq 0xc(%r13), %rsi
addq %rax, %rdi
addq %r14, %rsi
movq %r8, %rdx
movq %r8, %r15
callq 0x3260
movq -0x30(%rbp), %rdx
addq %r15, (%rdx)
movl 0x8(%r13), %ecx
movl 0xc(%r13), %eax
addl %r15d, %eax
incl %eax
movl %eax, 0xc(%r13)
cmpl %ecx, %eax
jl 0x81ae
movq 0x30(%r13), %rdi
callq 0x3410
movq -0x30(%rbp), %rdx
movq %rax, 0x10(%r13)
andq $0x0, 0x8(%r13)
xorl %ecx, %ecx
xorl %eax, %eax
cmpq %rbx, %r12
movl -0x34(%rbp), %r15d
jge 0x80a1
movq (%rdx), %rsi
jmp 0x81d3
movq -0x30(%rbp), %rdx
pushq $-0x2
jmp 0x81ca
pushq $-0x1
popq %rax
movq (%rdx), %rsi
testq %rsi, %rsi
je 0x81dd
movq 0x10(%rdx), %rcx
movb $0x0, (%rcx,%rsi)
movl (%rdx), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: list_free
static void list_free(list_t *root)
{
    list_t *l = root;
    while (root)
    {
        l = root;
        root = root->next;
        free(l);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x8205
movq 0x8(%rdi), %rbx
callq 0x33d0
movq %rbx, %rdi
jmp 0x81f2
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: sam_header_clone
HeaderDict *sam_header_clone(const HeaderDict *dict)
{
    HeaderDict *out = NULL;
    while (dict)
    {
        HeaderLine *hline = dict->data;
        out = list_append(out, sam_header_line_clone(hline));
        dict = dict->next;
    }
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
testq %rbx, %rbx
je 0x823b
movq 0x10(%rbx), %rdi
callq 0x8297
movq %r14, %rdi
movq %rax, %rsi
callq 0x8243
movq %rax, %r14
movq 0x8(%rbx), %rbx
jmp 0x8219
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: list_append
static list_t *list_append(list_t *root, void *data)
{
    list_t *l = root;
    while (l && l->next)
        l = l->next;
    if ( l ) 
    {
        l->next = malloc(sizeof(list_t));
        l = l->next;
    }
    else
    {
        l = malloc(sizeof(list_t));
        root = l;
    }
    l->data = data;
    l->next = NULL;
    return root;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rdi, %rax
testq %rax, %rax
je 0x8275
movq %rax, %r15
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x8256
pushq $0x18
popq %rdi
callq 0x3470
movq %rax, 0x8(%r15)
jmp 0x8280
pushq $0x18
popq %rdi
callq 0x3470
movq %rax, %r14
movq %rbx, 0x10(%rax)
andq $0x0, 0x8(%rax)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: sam_header_line_clone
static HeaderLine *sam_header_line_clone(const HeaderLine *hline)
{
    list_t *tags;
    HeaderLine *out = malloc(sizeof(HeaderLine));
    out->type[0] = hline->type[0];
    out->type[1] = hline->type[1];
    out->tags = NULL;

    tags = hline->tags;
    while (tags)
    {
        HeaderTag *old = tags->data;

        HeaderTag *new = malloc(sizeof(HeaderTag));
        new->key[0] = old->key[0];
        new->key[1] = old->key[1];
        new->value  = strdup(old->value);
        out->tags = list_append(out->tags, new);

        tags = tags->next;
    }
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
pushq $0x10
popq %r14
movq %r14, %rdi
callq 0x3470
movb (%rbx), %cl
movb %cl, (%rax)
movb 0x1(%rbx), %cl
movq %rax, -0x30(%rbp)
movb %cl, 0x1(%rax)
xorl %r12d, %r12d
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x8309
movq 0x10(%rbx), %r15
movq %r14, %rdi
callq 0x3470
movq %rax, %r13
movb (%r15), %al
movb %al, (%r13)
movb 0x1(%r15), %al
movb %al, 0x1(%r13)
movq 0x8(%r15), %rdi
callq 0x3600
movq %rax, 0x8(%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x8243
movq %rax, %r12
jmp 0x82c5
movq -0x30(%rbp), %rax
movq %r12, 0x8(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: sam_header_write
char *sam_header_write(const void *_header)
{
	const HeaderDict *header = (const HeaderDict*)_header;
    char *out = NULL;
    int len=0, nout=0;
    const list_t *hlines;

    // Calculate the length of the string to allocate
    hlines = header;
    while (hlines)
    {
        len += 4;   // @XY and \n

        HeaderLine *hline = hlines->data;
        list_t *tags = hline->tags;
        while (tags)
        {
            HeaderTag *tag = tags->data;
            len += strlen(tag->value) + 1;                  // \t
            if ( tag->key[0]!=' ' || tag->key[1]!=' ' )
                len += strlen(tag->value) + 3;              // XY:
            tags = tags->next;
        }
        hlines = hlines->next;
    }

    nout = 0;
    out  = malloc(len+1);
    hlines = header;
    while (hlines)
    {
        HeaderLine *hline = hlines->data;

        nout += sprintf(out+nout,"@%c%c",hline->type[0],hline->type[1]);

        list_t *tags = hline->tags;
        while (tags)
        {
            HeaderTag *tag = tags->data;
            nout += sprintf(out+nout,"\t");
            if ( tag->key[0]!=' ' || tag->key[1]!=' ' )
                nout += sprintf(out+nout,"%c%c:", tag->key[0],tag->key[1]);
            nout += sprintf(out+nout,"%s", tag->value);
            tags = tags->next;
        }
        hlines = hlines->next;
        nout += sprintf(out+nout,"\n");
    }
    out[len] = 0;
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %r12d, %r12d
movq %rdi, -0x30(%rbp)
movq %rdi, %rbx
testq %rbx, %rbx
je 0x8380
addl $0x4, %r12d
movq 0x10(%rbx), %r14
movq 0x8(%r14), %r14
testq %r14, %r14
je 0x837a
movq 0x10(%r14), %r15
movq 0x8(%r15), %rdi
callq 0x3120
addl %eax, %r12d
incl %r12d
cmpb $0x20, (%r15)
jne 0x8371
cmpb $0x20, 0x1(%r15)
je 0x8348
addl %eax, %r12d
addl $0x3, %r12d
jmp 0x8348
movq 0x8(%rbx), %rbx
jmp 0x833b
movq %r12, -0x38(%rbp)
leal 0x1(%r12), %eax
movslq %eax, %rdi
callq 0x3470
movq %rax, %r14
xorl %r13d, %r13d
movq -0x30(%rbp), %rcx
testq %rcx, %rcx
je 0x8449
movq %rcx, -0x30(%rbp)
movq 0x10(%rcx), %rbx
movslq %r13d, %r12
leaq (%r14,%r12), %rdi
movsbl (%rbx), %edx
movsbl 0x1(%rbx), %ecx
leaq 0x32f4(%rip), %rsi      # 0xb6b5
xorl %eax, %eax
callq 0x30b0
addl %eax, %r12d
movq 0x8(%rbx), %rbx
leal 0x1(%r12), %r13d
movslq %r12d, %rax
testq %rbx, %rbx
je 0x8435
movq 0x10(%rbx), %r15
movw $0x9, (%r14,%rax)
movsbl (%r15), %edx
movl %edx, %ecx
xorb $0x20, %cl
movb 0x1(%r15), %al
movl %eax, %esi
xorb $0x20, %sil
orb %cl, %sil
je 0x841a
movsbl %al, %ecx
movslq %r13d, %r13
leaq (%r14,%r13), %rdi
leaq 0x32ab(%rip), %rsi      # 0xb6bb
xorl %eax, %eax
callq 0x30b0
addl %eax, %r13d
movslq %r13d, %r12
leaq (%r14,%r12), %r13
movq 0x8(%r15), %rsi
movq %r13, %rdi
callq 0x3330
subl %r13d, %eax
addl %eax, %r12d
jmp 0x83cb
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movw $0xa, (%r14,%rax)
jmp 0x839b
movslq -0x38(%rbp), %rax
movb $0x0, (%r14,%rax)
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: header_line_has_tag
static HeaderTag *header_line_has_tag(HeaderLine *hline, const char *key)
{
    list_t *tags = hline->tags;
    while (tags)
    {
        HeaderTag *tag = tags->data;
        if ( tag->key[0]==key[0] && tag->key[1]==key[1] ) return tag;
        tags = tags->next;
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x89fd
movq 0x10(%rdi), %rax
movb (%rax), %cl
cmpb (%rsi), %cl
jne 0x89e0
movb 0x1(%rax), %cl
cmpb 0x1(%rsi), %cl
jne 0x89e0
jmp 0x89ff
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: sam_header2key_val
void *sam_header2key_val(void *iter, const char type[2], const char key_tag[2], const char value_tag[2], const char **_key, const char **_value)
{
    list_t *l = iter;
    if ( !l ) return NULL;

    while (l)
    {
        HeaderLine *hline = l->data;
        if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] )
        {
            l = l->next;
            continue;
        }

        HeaderTag *key, *value;
        key   = header_line_has_tag(hline,key_tag);
        value = header_line_has_tag(hline,value_tag);
        if ( !key && !value ) 
        {
            l = l->next;
            continue;
        }

        *_key = key->value;
        *_value = value->value;
        return l->next;
    }
    return l;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
testq %rdi, %rdi
je 0x8bd4
movq %rsi, %r14
movq %rdi, %r12
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movb (%rsi), %bl
testq %r12, %r12
je 0x8bd4
movq 0x10(%r12), %r15
cmpb %bl, (%r15)
jne 0x8bcd
movb 0x1(%r15), %al
cmpb 0x1(%r14), %al
jne 0x8bcd
movq %r15, %rdi
movq -0x40(%rbp), %rsi
callq 0x89dc
movq %rax, %r13
movq %r15, %rdi
movq -0x48(%rbp), %rsi
callq 0x89dc
movq %r13, %rcx
orq %rax, %rcx
jne 0x8be5
movq 0x8(%r12), %r12
jmp 0x8b91
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r13), %rcx
movq -0x30(%rbp), %rdx
movq %rcx, (%rdx)
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq %rax, (%rcx)
movq 0x8(%r12), %rax
jmp 0x8bd6
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: print_header_line
static void print_header_line(FILE *fp, HeaderLine *hline)
{
    list_t *tags = hline->tags;
    HeaderTag *tag;

    fprintf(fp, "@%c%c", hline->type[0],hline->type[1]);
    while (tags)
    {
        tag = tags->data;

        fprintf(fp, "\t");
        if ( tag->key[0]!=' ' || tag->key[1]!=' ' )
            fprintf(fp, "%c%c:", tag->key[0],tag->key[1]);
        fprintf(fp, "%s", tag->value);

        tags = tags->next;
    }
    fprintf(fp,"\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rsi), %r12
movsbl (%rsi), %edx
movsbl 0x1(%rsi), %ecx
leaq 0x271b(%rip), %rsi      # 0xb6b5
xorl %eax, %eax
callq 0x34c0
pushq $0x9
popq %r14
leaq 0x270f(%rip), %r15      # 0xb6bb
testq %r12, %r12
je 0x8ffd
movq 0x10(%r12), %r13
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3430
movsbl (%r13), %edx
movl %edx, %ecx
xorb $0x20, %cl
movb 0x1(%r13), %al
movl %eax, %esi
xorb $0x20, %sil
orb %cl, %sil
je 0x8fea
movsbl %al, %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x34c0
movq 0x8(%r13), %rdi
movq %rbx, %rsi
callq 0x3390
movq 0x8(%r12), %r12
jmp 0x8fac
pushq $0xa
popq %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3430
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: sam_header2tbl_n
char **sam_header2tbl_n(const void *dict, const char type[2], const char *tags[], int *n)
{
    int nout = 0;
    char **out = NULL;

    *n = 0;
    list_t *l = (list_t *)dict;
    if ( !l ) return NULL;

    int i, ntags = 0;
    while ( tags[ntags] ) ntags++;

    while (l)
    {
        HeaderLine *hline = l->data;
        if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] )
        {
            l = l->next;
            continue;
        }
        out = (char**) realloc(out, sizeof(char*)*(nout+1)*ntags);
        for (i=0; i<ntags; i++)
        {
            HeaderTag *key = header_line_has_tag(hline, tags[i]);
            if ( !key ) 
            {
                out[nout*ntags+i] = NULL;
                continue;
            }
            out[nout*ntags+i] = key->value;
        }
        nout++;
        l = l->next;
    }
    *n = nout;
    return out;
}

// Assembly:
andl $0x0, (%rcx)
testq %rdi, %rdi
je 0x9106
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rcx, -0x38(%rbp)
pushq $-0x1
popq %r15
pushq $0x8
popq %rcx
addq $-0x8, %rcx
cmpq $0x0, 0x8(%r14,%r15,8)
leaq 0x1(%r15), %r15
jne 0x9041
negq %rcx
xorl %edx, %edx
xorl %r12d, %r12d
movq %rsi, -0x48(%rbp)
movq %rcx, -0x40(%rbp)
testq %rdi, %rdi
je 0x90ef
movq 0x10(%rdi), %rbx
movb (%rbx), %al
cmpb (%rsi), %al
jne 0x90e6
movb 0x1(%rbx), %al
cmpb 0x1(%rsi), %al
jne 0x90e6
movq %rdi, -0x58(%rbp)
leal 0x1(%r12), %eax
movl %eax, -0x2c(%rbp)
movslq %eax, %rsi
imulq %rcx, %rsi
movq %rdx, %rdi
callq 0x3590
imull %r15d, %r12d
movslq %r12d, %rcx
movq %rax, -0x50(%rbp)
leaq (%rax,%rcx,8), %r12
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x90d0
movq (%r14,%r13,8), %rsi
movq %rbx, %rdi
callq 0x89dc
testq %rax, %rax
je 0x90c5
movq 0x8(%rax), %rax
jmp 0x90c7
xorl %eax, %eax
movq %rax, (%r12,%r13,8)
incq %r13
jmp 0x90a9
movl -0x2c(%rbp), %eax
movl %eax, %r12d
movq -0x48(%rbp), %rsi
movq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq 0x8(%rdi), %rdi
jmp 0x9061
movq -0x38(%rbp), %rax
movl %r12d, (%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9108
xorl %edx, %edx
movq %rdx, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_read_init
static BGZF *bgzf_read_init()
{
	BGZF *fp;
	fp = calloc(1, sizeof(BGZF));
	fp->is_write = 0;
	fp->uncompressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
	fp->compressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
#ifdef BGZF_CACHE
	fp->cache = kh_init(cache);
#endif
	return fp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
pushq $0x1
popq %rdi
pushq $0x40
popq %rsi
callq 0x31c0
movq %rax, %rbx
movl $0x10000, %edi          # imm = 0x10000
callq 0x3470
movq %rax, 0x18(%rbx)
movl $0x10000, %edi          # imm = 0x10000
callq 0x3470
movq %rax, 0x20(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: worker_aux
static int worker_aux(worker_t *w)
{
	int i, tmp, stop = 0;
	// wait for condition: to process or all done
	pthread_mutex_lock(&w->mt->lock);
	while (!w->toproc && !w->mt->done)
		pthread_cond_wait(&w->mt->cv, &w->mt->lock);
	if (w->mt->done) stop = 1;
	w->toproc = 0;
	pthread_mutex_unlock(&w->mt->lock);
	if (stop) return 1; // to quit the thread
	w->errcode = 0;
	for (i = w->i; i < w->mt->curr; i += w->mt->n_threads) {
		int clen = BGZF_MAX_BLOCK_SIZE;
		if (bgzf_compress(w->buf, &clen, w->mt->blk[i], w->mt->len[i], w->fp->compress_level) != 0)
			w->errcode |= BGZF_ERR_ZLIB;
		memcpy(w->mt->blk[i], w->buf, clen);
		w->mt->len[i] = clen;
	}
	tmp = __sync_fetch_and_add(&w->mt->proc_cnt, 1);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
addq $0x38, %rdi
callq 0x34e0
cmpl $0x0, 0x20(%rbx)
movq 0x8(%rbx), %rdi
movl 0xc(%rdi), %r14d
jne 0x91ab
leaq 0x38(%rdi), %rsi
testl %r14d, %r14d
jne 0x9240
addq $0x60, %rdi
callq 0x3520
jmp 0x9185
andl $0x0, 0x20(%rbx)
addq $0x38, %rdi
callq 0x3210
testl %r14d, %r14d
jne 0x924c
andl $0x0, 0x1c(%rbx)
movl 0x18(%rbx), %r12d
movq 0x8(%rbx), %rax
leaq -0x2c(%rbp), %r14
cmpl 0x8(%rax), %r12d
jge 0x925e
movl $0x10000, -0x2c(%rbp)   # imm = 0x10000
movq (%rbx), %rsi
movq 0x10(%rbx), %rdi
movslq %r12d, %r13
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rax
movq (%rcx,%r13,8), %rdx
movl (%rax,%r13,4), %ecx
movl (%rsi), %r8d
sarl $0x12, %r8d
movq %r14, %rsi
callq 0x9266
testl %eax, %eax
je 0x9213
orb $0x1, 0x1c(%rbx)
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rsi
movq 0x18(%rax), %rax
movq (%rax,%r13,8), %rdi
movslq -0x2c(%rbp), %r15
movq %r15, %rdx
callq 0x3260
movq 0x8(%rbx), %rax
movq 0x20(%rax), %rcx
movl %r15d, (%rcx,%r13,4)
addl (%rax), %r12d
jmp 0x91d1
andl $0x0, 0x20(%rbx)
movq %rsi, %rdi
callq 0x3210
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x10(%rax)
xorl %eax, %eax
jmp 0x924f
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: bgzf_compress
static int bgzf_compress(void *_dst, int *dlen, void *src, int slen, int level)
{
	uint32_t crc;
	z_stream zs;
	uint8_t *dst = (uint8_t*)_dst;

	// compress the body
	zs.zalloc = NULL; zs.zfree = NULL;
	zs.next_in  = src;
	zs.avail_in = slen;
	zs.next_out = dst + BLOCK_HEADER_LENGTH;
	zs.avail_out = *dlen - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH;
	if (deflateInit2(&zs, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) return -1; // -15 to disable zlib header/footer
	if (deflate(&zs, Z_FINISH) != Z_STREAM_END) return -1;
	if (deflateEnd(&zs) != Z_OK) return -1;
	*dlen = zs.total_out + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH;
	// write the header
	memcpy(dst, g_magic, BLOCK_HEADER_LENGTH); // the last two bytes are a place holder for the length of the block
	packInt16(&dst[16], *dlen - 1); // write the compressed length; -1 to fit 2 bytes
	// write the footer
	crc = crc32(crc32(0L, NULL, 0L), src, slen);
	packInt32((uint8_t*)&dst[*dlen - 8], crc);
	packInt32((uint8_t*)&dst[*dlen - 4], slen);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, %ebx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq -0x98(%rbp), %rdi
movups %xmm0, 0x40(%rdi)
movq %rdx, (%rdi)
movl %ecx, 0x8(%rdi)
leaq 0x12(%r14), %rax
movq %rax, 0x18(%rdi)
movl (%rsi), %eax
addl $-0x1a, %eax
movl %eax, 0x20(%rdi)
leaq 0x24e0(%rip), %rax      # 0xb78d
pushq $-0xf
popq %rcx
pushq $0x8
popq %rdx
movl %r8d, %esi
movl %edx, %r8d
xorl %r9d, %r9d
pushq $0x70
pushq %rax
callq 0x3060
popq %rcx
popq %rdx
pushq $-0x1
popq %r13
testl %eax, %eax
jne 0x9341
leaq -0x98(%rbp), %rdi
pushq $0x4
popq %rsi
callq 0x3140
cmpl $0x1, %eax
jne 0x9341
leaq -0x98(%rbp), %rdi
callq 0x31a0
testl %eax, %eax
jne 0x9341
movl -0x70(%rbp), %eax
addl $0x1a, %eax
movl %eax, (%r15)
movaps 0x1d8e(%rip), %xmm0     # 0xb090
andw $0x0, 0x10(%r14)
movups %xmm0, (%r14)
movl (%r15), %eax
decl %eax
movw %ax, 0x10(%r14)
xorl %r13d, %r13d
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3200
movq %rax, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x3200
movslq (%r15), %rcx
movl %eax, -0x8(%r14,%rcx)
movslq (%r15), %rax
movl %ebx, -0x4(%r14,%rax)
movl %r13d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: mt_queue
static void mt_queue(BGZF *fp)
{
	mtaux_t *mt = (mtaux_t*)fp->mt;
	assert(mt->curr < mt->n_blks); // guaranteed by the caller
	memcpy(mt->blk[mt->curr], fp->uncompressed_block, fp->block_offset);
	mt->len[mt->curr] = fp->block_offset;
	fp->block_offset = 0;
	++mt->curr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x38(%rdi), %r14
movslq 0x8(%r14), %rax
cmpl 0x4(%r14), %eax
jge 0x939b
movq %rdi, %rbx
movq 0x18(%r14), %rcx
movq (%rcx,%rax,8), %rdi
movq 0x18(%rbx), %rsi
movslq 0xc(%rbx), %rdx
callq 0x3260
movl 0xc(%rbx), %eax
movq 0x20(%r14), %rcx
movslq 0x8(%r14), %rdx
movl %eax, (%rcx,%rdx,4)
andl $0x0, 0xc(%rbx)
incl 0x8(%r14)
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x23f2(%rip), %rdi      # 0xb794
leaq 0x1eb3(%rip), %rsi      # 0xb25c
leaq 0x23fa(%rip), %rcx      # 0xb7aa
movl $0x624, %edx            # imm = 0x624
callq 0x31b0
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: new_tag
static HeaderTag *new_tag(const char *name, const char *value_from, const char *value_to)
{
    HeaderTag *tag = malloc(sizeof(HeaderTag));
    int len = value_to-value_from+1;

    tag->key[0] = name[0];
    tag->key[1] = name[1];
    tag->value = malloc(len+1);
    memcpy(tag->value,value_from,len+1);
    tag->value[len] = 0;
    return tag;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
pushq $0x10
popq %rdi
callq 0x3470
movq %rax, %r14
subl %r15d, %ebx
movb (%r12), %al
movb %al, (%r14)
movb 0x1(%r12), %al
movb %al, 0x1(%r14)
shlq $0x20, %rbx
movabsq $0x200000000, %r12      # imm = 0x200000000
addq %rbx, %r12
sarq $0x20, %r12
movq %r12, %rdi
callq 0x3470
movq %rax, %r13
movq %rax, 0x8(%r14)
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3260
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rbx, %rax
sarq $0x20, %rax
movb $0x0, (%r13,%rax)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/samToErrorRate.C
// Function: rc(char*, int)
char *rc(char *input, int len) {
   char *seq = new char[len+1];
   input+=len-1;
   for (int i = 0; i < len; i++) {
      seq[i]=basemap[*input];
      input--;
   }
   return seq;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
leal 0x1(%rbx), %eax
movslq %eax, %rdi
callq 0x3030
movslq %ebx, %rsi
xorl %ecx, %ecx
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
addq %r14, %rsi
decq %rsi
leaq 0x24a9(%rip), %rdi      # 0xb960
cmpq %rcx, %rdx
je 0x94d0
movsbq (%rsi), %r8
movb (%r8,%rdi), %r8b
movb %r8b, (%rax,%rcx)
incq %rcx
decq %rsi
jmp 0x94b7
popq %rbx
popq %r14
popq %rbp
retq