LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_sort.c
// Function: strnum_cmp
static int strnum_cmp(const char *_a, const char *_b)
{
	const unsigned char *a = (const unsigned char*)_a, *b = (const unsigned char*)_b;
	const unsigned char *pa = a, *pb = b;
	while (*pa && *pb) {
		if (isdigit(*pa) && isdigit(*pb)) {
			while (*pa == '0') ++pa;
			while (*pb == '0') ++pb;
			while (isdigit(*pa) && isdigit(*pb) && *pa == *pb) ++pa, ++pb;
			if (isdigit(*pa) && isdigit(*pb)) {
				int i = 0;
				while (isdigit(pa[i]) && isdigit(pb[i])) ++i;
				return isdigit(pa[i])? 1 : isdigit(pb[i])? -1 : (int)*pa - (int)*pb;
			} else if (isdigit(*pa)) return 1;
			else if (isdigit(*pb)) return -1;
			else if (pa - a != pb - b) return pa - a < pb - b? 1 : -1;
		} else {
			if (*pa != *pb) return (int)*pa - (int)*pb;
			++pa; ++pb;
		}
	}
	return *pa? 1 : *pb? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb (%rdi), %r12b
testb %r12b, %r12b
je 0x368ce
movq %rdi, %r15
movq %rsi, (%rsp)
movq %rsi, %r13
movq %rdi, %rbp
movl $0x1, %ebx
movzbl (%r13), %r14d
testq %r14, %r14
je 0x368d9
callq 0x33c0
movq (%rax), %rax
movzbl %r12b, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x367e0
testb $0x8, 0x1(%rax,%r14,2)
jne 0x367fd
cmpb %r14b, %r12b
jne 0x36936
incq %r13
movb 0x1(%rbp), %r12b
incq %rbp
testb %r12b, %r12b
jne 0x367b7
jmp 0x368d1
leaq -0x1(%rbp), %rdx
incq %rbp
movq %rbp, %rcx
movq %rdx, %rbp
movq %rcx, %rdx
movzbl 0x1(%rbp), %r12d
incq %rbp
incq %rcx
cmpq $0x30, %r12
je 0x3680a
leaq -0x1(%r13), %rcx
incq %r13
movq %r13, %rdi
movq %rcx, %r13
movq %rdi, %rsi
movb 0x1(%r13), %cl
incq %r13
incq %rdi
cmpb $0x30, %cl
je 0x3682b
testb $0x8, 0x1(%rax,%r12,2)
je 0x3689b
movzbl (%r13), %ecx
movzwl (%rax,%rcx,2), %edi
andl $0x800, %edi            # imm = 0x800
cmpb %cl, %r12b
jne 0x368f6
testw %di, %di
je 0x368f6
movzbl (%rdx), %r12d
testb $0x8, 0x1(%rax,%r12,2)
movb (%rsi), %cl
je 0x36895
movzbl %cl, %r8d
movzwl (%rax,%r8,2), %edi
andl $0x800, %edi            # imm = 0x800
incq %rdx
incq %rsi
cmpb %r8b, %r12b
jne 0x368ea
testw %di, %di
jne 0x36866
jmp 0x368ea
movq %rdx, %rbp
movq %rsi, %r13
movzbl %cl, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x3693d
movq %rbp, %rax
subq %r15, %rax
movq %r13, %rcx
subq (%rsp), %rcx
cmpq %rcx, %rax
je 0x367f3
setl %al
movzbl %al, %eax
leal -0x1(,%rax,2), %ebx
jmp 0x368d9
movq %rsi, %r13
xorl %ebx, %ebx
cmpb (%r13), %bl
sbbl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq %rdx
decq %rsi
movq %rsi, %r13
movq %rdx, %rbp
testw %di, %di
je 0x368d9
xorl %edx, %edx
movzbl (%r13,%rdx), %esi
testb $0x8, 0x1(%rax,%rsi,2)
je 0x368d9
movzbl 0x1(%rbp,%rdx), %esi
incq %rdx
testb $0x8, 0x1(%rax,%rsi,2)
jne 0x368fd
movzbl (%r13,%rdx), %edx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x8, 0x1(%rax,%rdx,2)
jne 0x368d9
movzbl %r12b, %ebx
movzbl %cl, %eax
subl %eax, %ebx
jmp 0x368d9
subl %r14d, %ecx
movl %ecx, %ebx
jmp 0x368d9
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x368d9
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_sort.c
// Function: worker
static void *worker(void *data)
{
	worker_t *w = (worker_t*)data;
	char *name;
	ks_mergesort(sort, w->buf_len, w->buf, 0);
	name = (char*)calloc(strlen(w->prefix) + 20, 1);
	sprintf(name, "%s.%.4d.bam", w->prefix, w->index);
	write_buffer(name, "w1", w->buf_len, w->buf, w->h, 0);
	free(name);
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movq 0x10(%rbx), %rsi
xorl %edx, %edx
callq 0x34a02
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x3360
leaq 0x14(%rax), %rdi
movl $0x1, %esi
callq 0x3610
movq %rax, %r15
movl 0x20(%rbx), %ecx
leaq 0xc6b6(%rip), %rsi      # 0x43037
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movq (%rbx), %rdx
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %r8
leaq 0xc6a3(%rip), %rsi      # 0x43043
movq %r15, %rdi
xorl %r9d, %r9d
callq 0x364ff
movq %r15, %rdi
callq 0x3350
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_reheader.c
// Function: bam_reheader
int bam_reheader(BGZF *in, const bam_header_t *h, int fd)
{
	BGZF *fp;
	bam_header_t *old;
	int len;
	uint8_t *buf;
	if (in->is_write) return -1;
	buf = malloc(BUF_SIZE);
	old = bam_header_read(in);
	fp = bgzf_fdopen(fd, "w");
	bam_header_write(fp, h);
	if (in->block_offset < in->block_length) {
		bgzf_write(fp, in->uncompressed_block + in->block_offset, in->block_length - in->block_offset);
		bgzf_flush(fp);
	}
#ifdef _USE_KNETFILE
	while ((len = knet_read(in->fp, buf, BUF_SIZE)) > 0)
		fwrite(buf, 1, len, fp->fp);
#else
	while (!feof(in->file) && (len = fread(buf, 1, BUF_SIZE, in->file)) > 0)
		fwrite(buf, 1, len, fp->file);
#endif
	free(buf);
	fp->block_offset = in->block_offset = 0;
	bgzf_close(fp);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testb $0x3, 0x2(%rdi)
jne 0x38197
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movl $0x10000, %edi          # imm = 0x10000
callq 0x3240
movq %rax, %r14
movq %rbx, %rdi
callq 0x235fb
leaq 0x714a(%rip), %rsi      # 0x3f25a
movl %ebp, %edi
callq 0x20487
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
callq 0x237d0
movslq 0xc(%rbx), %rax
movl 0x8(%rbx), %ecx
cmpl %eax, %ecx
jle 0x38167
movq %rax, %rsi
addq 0x18(%rbx), %rsi
subl %eax, %ecx
movslq %ecx, %rdx
movq %r15, %rdi
callq 0x21204
movq %r15, %rdi
callq 0x20f14
jmp 0x38167
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x30(%r15), %rcx
movl $0x1, %esi
movq %r14, %rdi
movq %rax, %rdx
callq 0x3700
movq 0x30(%rbx), %rdi
movl $0x10000, %edx          # imm = 0x10000
movq %r14, %rsi
callq 0x3262c
testl %eax, %eax
jg 0x3814e
movq %r14, %rdi
callq 0x3350
xorl %r14d, %r14d
movl %r14d, 0xc(%rbx)
movl %r14d, 0xc(%r15)
movq %r15, %rdi
callq 0x21311
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_reheader.c
// Function: main_reheader
int main_reheader(int argc, char *argv[])
{
	bam_header_t *h;
	BGZF *in;
	if (argc != 3) {
		fprintf(stderr, "Usage: samtools reheader <in.header.sam> <in.bam>\n");
		return 1;
	}
	{ // read the header
		tamFile fph = sam_open(argv[1]);
		if (fph == 0) {
			fprintf(stderr, "[%s] fail to read the header from %s.\n", __func__, argv[1]);
			return 1;
		}
		h = sam_header_read(fph);
		sam_close(fph);
	}
	in = strcmp(argv[2], "-")? bam_open(argv[2], "r") : bam_dopen(fileno(stdin), "r");
	if (in == 0) {
		fprintf(stderr, "[%s] fail to open file %s.\n", __func__, argv[2]);
		return 1;
	}
	bam_reheader(in, h, fileno(stdout));
	bgzf_close(in);
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpl $0x3, %edi
jne 0x3824a
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x27d11
testq %rax, %rax
je 0x38251
movq %rax, %r15
movq %rax, %rdi
callq 0x268b9
movq %rax, %r14
movq %r15, %rdi
callq 0x27db4
movq 0x10(%rbx), %rdi
cmpb $0x2d, (%rdi)
jne 0x381eb
cmpb $0x0, 0x1(%rdi)
je 0x3822b
leaq 0xdb5d(%rip), %rsi      # 0x45d4f
callq 0x20308
movq %rax, %r15
testq %rax, %rax
je 0x3825f
movq 0x17df2(%rip), %rax     # 0x4fff8
movq (%rax), %rdi
callq 0x3030
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x380d4
movq %r15, %rdi
callq 0x21311
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq 0x17d9e(%rip), %rax     # 0x4ffd0
movq (%rax), %rdi
callq 0x3030
leaq 0xdb0e(%rip), %rsi      # 0x45d4f
movl %eax, %edi
callq 0x20487
jmp 0x381f7
callq 0x5b69
jmp 0x3826b
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x5baa
jmp 0x3826b
addq $0x10, %rbx
movq %rbx, %rdi
callq 0x5b85
movl $0x1, %eax
jmp 0x38225
nop
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_cat.c
// Function: main_cat
int main_cat(int argc, char *argv[])
{
    bam_header_t *h = 0;
	char *outfn = 0;
	int c, ret;
	while ((c = getopt(argc, argv, "h:o:")) >= 0) {
		switch (c) {
			case 'h': {
        		tamFile fph = sam_open(optarg);
		        if (fph == 0) {
    		        fprintf(stderr, "[%s] ERROR: fail to read the header from '%s'.\n", __func__, argv[1]);
        		    return 1;
	        	}
	    	    h = sam_header_read(fph);
    	    	sam_close(fph);
				break;
			}
			case 'o': outfn = strdup(optarg); break;
		}
	}
	if (argc - optind < 2) {
        fprintf(stderr, "Usage: samtools cat [-h header.sam] [-o out.bam] <in1.bam> <in2.bam> [...]\n");
        return 1;
    }
    ret = bam_cat(argc - optind, argv + optind, h, outfn? outfn : "-");
	free(outfn);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
leaq 0xc74d(%rip), %rdx      # 0x45bfe
callq 0x3210
testl %eax, %eax
js 0x3952d
movq $0x0, (%rsp)
movq 0x16b17(%rip), %rbp     # 0x4ffe0
leaq 0xc72e(%rip), %r13      # 0x45bfe
xorl %r15d, %r15d
cmpl $0x6f, %eax
je 0x3950e
cmpl $0x68, %eax
jne 0x3951a
movq %rbp, %r12
movq (%rbp), %rdi
callq 0x27d11
testq %rax, %rax
je 0x3958d
movq %rax, %rbp
movq %rax, %rdi
callq 0x268b9
movq %rax, (%rsp)
movq %rbp, %rdi
callq 0x27db4
movq %r12, %rbp
jmp 0x3951a
movq (%rbp), %rdi
callq 0x3570
movq %rax, %r15
movl %ebx, %edi
movq %r14, %rsi
movq %r13, %rdx
callq 0x3210
testl %eax, %eax
jns 0x394d3
jmp 0x39538
xorl %r15d, %r15d
movq $0x0, (%rsp)
movq 0x16a79(%rip), %rax     # 0x4ffb8
movslq (%rax), %rax
subl %eax, %ebx
cmpl $0x1, %ebx
jle 0x39581
leaq (%r14,%rax,8), %rsi
testq %r15, %r15
leaq 0x6939(%rip), %rcx      # 0x3fe90
cmovneq %r15, %rcx
movl %ebx, %edi
movq (%rsp), %rdx
callq 0x391a4
movl %eax, %ebx
movq %r15, %rdi
callq 0x3350
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5c9f
movl $0x1, %eax
jmp 0x39572
movq %r14, %rdi
callq 0x5c79
jmp 0x39586
nop
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_open
bcf_t *bcf_open(const char *fn, const char *mode)
{
	bcf_t *b;
	b = calloc(1, sizeof(bcf_t));
	if (strchr(mode, 'w')) {
		b->fp = strcmp(fn, "-")? bgzf_open(fn, mode) : bgzf_fdopen(fileno(stdout), mode);
	} else {
		b->fp = strcmp(fn, "-")? bgzf_open(fn, mode) : bgzf_fdopen(fileno(stdin), mode);
	}
	return b;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
movl $0x1, %edi
movl $0x18, %esi
callq 0x3610
movq %rax, %rbx
movq %r14, %rdi
movl $0x77, %esi
callq 0x34f0
movb (%r15), %cl
testq %rax, %rax
je 0x3a7fb
cmpb $0x2d, %cl
jne 0x3a807
cmpb $0x0, 0x1(%r15)
jne 0x3a807
movq 0x157ff(%rip), %rax     # 0x4fff8
jmp 0x3a826
cmpb $0x2d, %cl
jne 0x3a807
cmpb $0x0, 0x1(%r15)
je 0x3a81f
movq %r15, %rdi
movq %r14, %rsi
callq 0x20308
movq %rax, 0x10(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq 0x157aa(%rip), %rax     # 0x4ffd0
movq (%rax), %rdi
callq 0x3030
movl %eax, %edi
movq %r14, %rsi
callq 0x20487
jmp 0x3a812
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_hdr_write
int bcf_hdr_write(bcf_t *b, const bcf_hdr_t *h)
{
	if (b == 0 || h == 0) return -1;
	bgzf_write(b->fp, "BCF\4", 4);
	bgzf_write(b->fp, &h->l_nm, 4);
	bgzf_write(b->fp, h->name, h->l_nm);
	bgzf_write(b->fp, &h->l_smpl, 4);
	bgzf_write(b->fp, h->sname, h->l_smpl);
	bgzf_write(b->fp, &h->l_txt, 4);
	bgzf_write(b->fp, h->txt, h->l_txt);
	bgzf_flush(b->fp);
	return 16 + h->l_nm + h->l_smpl + h->l_txt;
}

// Assembly:
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0x3a923
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10(%rdi), %rdi
leaq 0xb4f4(%rip), %rsi      # 0x45d86
movl $0x4, %edx
callq 0x21204
movq 0x10(%r14), %rdi
leaq 0x8(%rbx), %rsi
movl $0x4, %edx
callq 0x21204
movq 0x10(%r14), %rdi
movq 0x18(%rbx), %rsi
movslq 0x8(%rbx), %rdx
callq 0x21204
movq 0x10(%r14), %rdi
leaq 0xc(%rbx), %rsi
movl $0x4, %edx
callq 0x21204
movq 0x10(%r14), %rdi
movq 0x20(%rbx), %rsi
movslq 0xc(%rbx), %rdx
callq 0x21204
movq 0x10(%r14), %rdi
leaq 0x10(%rbx), %rsi
movl $0x4, %edx
callq 0x21204
movq 0x10(%r14), %rdi
movq 0x28(%rbx), %rsi
movslq 0x10(%rbx), %rdx
callq 0x21204
movq 0x10(%r14), %rdi
callq 0x20f14
movl 0x8(%rbx), %eax
movl 0x10(%rbx), %ecx
addl 0xc(%rbx), %eax
addl %ecx, %eax
addl $0x10, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_hdr_read
bcf_hdr_t *bcf_hdr_read(bcf_t *b)
{
	uint8_t magic[4];
	bcf_hdr_t *h;
	if (b == 0) return 0;
	h = calloc(1, sizeof(bcf_hdr_t));
	bgzf_read(b->fp, magic, 4);
	bgzf_read(b->fp, &h->l_nm, 4);
	h->name = malloc(h->l_nm);
	bgzf_read(b->fp, h->name, h->l_nm);
	bgzf_read(b->fp, &h->l_smpl, 4);
	h->sname = malloc(h->l_smpl);
	bgzf_read(b->fp, h->sname, h->l_smpl);
	bgzf_read(b->fp, &h->l_txt, 4);
	h->txt = malloc(h->l_txt);
	bgzf_read(b->fp, h->txt, h->l_txt);
	bcf_hdr_sync(h);
	return h;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x3a9fb
movq %rdi, %r14
movl $0x1, %edi
movl $0x40, %esi
callq 0x3610
movq %rax, %rbx
movq 0x10(%r14), %rdi
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
callq 0x20ca5
movq 0x10(%r14), %rdi
leaq 0x8(%rbx), %rsi
movl $0x4, %edx
callq 0x20ca5
movslq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x3240
movq %rax, 0x18(%rbx)
movq 0x10(%r14), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x20ca5
movq 0x10(%r14), %rdi
leaq 0xc(%rbx), %rsi
movl $0x4, %edx
callq 0x20ca5
movslq 0xc(%rbx), %r15
movq %r15, %rdi
callq 0x3240
movq %rax, 0x20(%rbx)
movq 0x10(%r14), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x20ca5
movq 0x10(%r14), %rdi
leaq 0x10(%rbx), %rsi
movl $0x4, %edx
callq 0x20ca5
movslq 0x10(%rbx), %r15
movq %r15, %rdi
callq 0x3240
movq %rax, 0x28(%rbx)
movq 0x10(%r14), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x20ca5
movq %rbx, %rdi
callq 0x3aa0a
jmp 0x3a9fd
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_hdr_sync
int bcf_hdr_sync(bcf_hdr_t *b)
{
	if (b == 0) return -1;
	if (b->ns) free(b->ns);
	if (b->sns) free(b->sns);
	if (b->l_nm) b->ns = cnt_null(b->l_nm, b->name, &b->n_ref);
	else b->ns = 0, b->n_ref = 0;
	b->sns = cnt_null(b->l_smpl, b->sname, &b->n_smpl);
	return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x3aaac
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
testq %rdi, %rdi
je 0x3aa2c
callq 0x3350
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x3aa3a
callq 0x3350
movslq 0x8(%rbx), %r14
testq %r14, %r14
je 0x3aab2
movq 0x18(%rbx), %r15
movl $0x0, (%rbx)
xorl %eax, %eax
testq %r15, %r15
je 0x3aaa6
leaq (%r15,%r14), %r12
xorl %ecx, %ecx
cmpb $0x1, (%r15,%rcx)
adcl $0x0, %eax
incq %rcx
cmpq %rcx, %r14
jne 0x3aa5a
movl %eax, (%rbx)
movl %eax, %edi
movl $0x8, %esi
callq 0x3610
movq %r15, (%rax)
decq %r12
cmpq %r15, %r12
jbe 0x3aaa6
incq %r15
decq %r14
movl $0x1, %ecx
cmpb $0x0, -0x1(%r15)
jne 0x3aa9e
movslq %ecx, %rdx
incl %ecx
movq %r15, (%rax,%rdx,8)
incq %r15
decq %r14
jne 0x3aa8e
movq %rax, 0x30(%rbx)
jmp 0x3aac0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
movq $0x0, 0x30(%rbx)
movl $0x0, (%rbx)
movslq 0xc(%rbx), %r14
testq %r14, %r14
sete %cl
movq 0x20(%rbx), %r15
movl $0x0, 0x4(%rbx)
testq %r15, %r15
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x3ab34
leaq (%r15,%r14), %r12
xorl %ecx, %ecx
cmpb $0x1, (%r15,%rcx)
adcl $0x0, %eax
incq %rcx
cmpq %rcx, %r14
jne 0x3aae7
movl %eax, 0x4(%rbx)
movl %eax, %edi
movl $0x8, %esi
callq 0x3610
movq %r15, (%rax)
decq %r12
cmpq %r15, %r12
jbe 0x3ab34
incq %r15
decq %r14
movl $0x1, %ecx
cmpb $0x0, -0x1(%r15)
jne 0x3ab2c
movslq %ecx, %rdx
incl %ecx
movq %r15, (%rax,%rdx,8)
incq %r15
decq %r14
jne 0x3ab1c
movq %rax, 0x38(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_write
int bcf_write(bcf_t *bp, const bcf_hdr_t *h, const bcf1_t *b)
{
	int i, l = 0;
	if (b == 0) return -1;
	bgzf_write(bp->fp, &b->tid, 4);
	bgzf_write(bp->fp, &b->pos, 4);
	bgzf_write(bp->fp, &b->qual, 4);
	bgzf_write(bp->fp, &b->l_str, 4);
	bgzf_write(bp->fp, b->str, b->l_str);
	l = 12 + b->l_str;
	for (i = 0; i < b->n_gi; ++i) {
		bgzf_write(bp->fp, b->gi[i].data, b->gi[i].len * h->n_smpl);
		l += b->gi[i].len * h->n_smpl;
	}
	return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x3af62
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x10(%rdi), %rdi
movl $0x4, %r12d
movl $0x4, %edx
movq %rbx, %rsi
callq 0x21204
movq 0x10(%r15), %rdi
leaq 0x4(%rbx), %rsi
movl $0x4, %edx
callq 0x21204
movq 0x10(%r15), %rdi
leaq 0x10(%rbx), %rsi
movl $0x4, %edx
callq 0x21204
movq 0x10(%r15), %rdi
leaq 0x8(%rbx), %rsi
movl $0x4, %edx
callq 0x21204
movq 0x10(%r15), %rdi
movq 0x18(%rbx), %rsi
movslq 0x8(%rbx), %rdx
callq 0x21204
movl 0x8(%rbx), %ebp
addl $0xc, %ebp
cmpl $0x0, 0x48(%rbx)
jle 0x3af67
movq 0x50(%rbx), %rax
movl 0x4(%r14), %ecx
xorl %r13d, %r13d
movq 0x10(%r15), %rdi
movq 0x4(%rax,%r12), %rsi
movslq (%rax,%r12), %rax
movslq %ecx, %rdx
imulq %rax, %rdx
callq 0x21204
movq 0x50(%rbx), %rax
movl 0x4(%r14), %ecx
movl (%rax,%r12), %edx
imull %ecx, %edx
addl %edx, %ebp
incq %r13
movslq 0x48(%rbx), %rdx
addq $0x10, %r12
cmpq %rdx, %r13
jl 0x3af26
jmp 0x3af67
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_read
int bcf_read(bcf_t *bp, const bcf_hdr_t *h, bcf1_t *b)
{
	int i, l = 0;
	if (b == 0) return -1;
	if (bgzf_read(bp->fp, &b->tid, 4) == 0) return -1;
	b->n_smpl = h->n_smpl;
	bgzf_read(bp->fp, &b->pos, 4);
	bgzf_read(bp->fp, &b->qual, 4);
	bgzf_read(bp->fp, &b->l_str, 4);
	if (b->l_str > b->m_str) {
		b->m_str = b->l_str;
		kroundup32(b->m_str);
		b->str = realloc(b->str, b->m_str);
	}
	bgzf_read(bp->fp, b->str, b->l_str);
	l = 12 + b->l_str;
	if (bcf_sync(b) < 0) return -2;
	for (i = 0; i < b->n_gi; ++i) {
		bgzf_read(bp->fp, b->gi[i].data, b->gi[i].len * h->n_smpl);
		l += b->gi[i].len * h->n_smpl;
	}
	return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdx, %rdx
je 0x3b0b4
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x10(%rdi), %rdi
movl $0x4, %edx
movq %rbx, %rsi
callq 0x20ca5
testq %rax, %rax
je 0x3b0b4
movl 0x4(%r14), %eax
movl %eax, 0x5c(%rbx)
movq 0x10(%r15), %rdi
leaq 0x4(%rbx), %rsi
movl $0x4, %edx
callq 0x20ca5
movq 0x10(%r15), %rdi
leaq 0x10(%rbx), %rsi
movl $0x4, %edx
callq 0x20ca5
movq 0x10(%r15), %rdi
leaq 0x8(%rbx), %rsi
movl $0x4, %edx
callq 0x20ca5
movl 0x8(%rbx), %eax
cmpl 0xc(%rbx), %eax
jle 0x3b03a
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
incl %ecx
movl %ecx, 0xc(%rbx)
movq 0x18(%rbx), %rdi
movslq %ecx, %rsi
callq 0x3720
movq %rax, %rsi
movq %rax, 0x18(%rbx)
movl 0x8(%rbx), %eax
jmp 0x3b03e
movq 0x18(%rbx), %rsi
movq 0x10(%r15), %rdi
movslq %eax, %rdx
callq 0x20ca5
movl 0x8(%rbx), %ebp
movq %rbx, %rdi
callq 0x3ab86
testl %eax, %eax
js 0x3b0af
addl $0xc, %ebp
cmpl $0x0, 0x48(%rbx)
jle 0x3b0b4
movq 0x50(%rbx), %rax
movl 0x4(%r14), %ecx
movl $0x4, %r12d
xorl %r13d, %r13d
movq 0x10(%r15), %rdi
movq 0x4(%rax,%r12), %rsi
movslq (%rax,%r12), %rax
movslq %ecx, %rdx
imulq %rax, %rdx
callq 0x20ca5
movq 0x50(%rbx), %rax
movl 0x4(%r14), %ecx
movl (%rax,%r12), %edx
imull %ecx, %edx
addl %edx, %ebp
incq %r13
movslq 0x48(%rbx), %rdx
addq $0x10, %r12
cmpq %rdx, %r13
jl 0x3b073
jmp 0x3b0b4
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_destroy
int bcf_destroy(bcf1_t *b)
{
	int i;
	if (b == 0) return -1;
	free(b->str);
	for (i = 0; i < b->m_gi; ++i)
		free(b->gi[i].data);
	free(b->gi);
	free(b);
	return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x3b120
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x3350
cmpl $0x0, 0x4c(%rbx)
jle 0x3b107
movl $0x8, %r14d
xorl %r15d, %r15d
movq 0x50(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x3350
incq %r15
movslq 0x4c(%rbx), %rax
addq $0x10, %r14
cmpq %rax, %r15
jl 0x3b0ea
movq 0x50(%rbx), %rdi
callq 0x3350
movq %rbx, %rdi
callq 0x3350
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: remove_tag
int remove_tag(char *str, const char *tag, char delim)
{
    char *tmp = str, *p;
    int len_diff = 0, ori_len = strlen(str);
    while ( *tmp && (p = strstr(tmp,tag)) )
    {
        if ( p>str )
        {
            if ( *(p-1)!=delim ) { tmp=p+1; continue; } // shared substring
            p--;
        }
        char *q=p+1;
        while ( *q && *q!=delim ) q++;
        if ( p==str && *q ) q++;        // the tag is first, don't move the delim char
        len_diff += q-p;
        if ( ! *q ) { *p = 0; break; }  // the tag was last, no delim follows
        else
            memmove(p,q,ori_len-(int)(p-str)-(int)(q-p));  // *q==delim
    }
    if ( len_diff==ori_len )
        str[0]='.', str[1]=0, len_diff--;

    return len_diff;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %rbx
callq 0x3360
movq %rax, %r14
cmpb $0x0, (%rbx)
je 0x3c208
movq %r14, %rax
addq %rbx, %rax
movq %rax, (%rsp)
xorl %ebp, %ebp
movq %rbx, %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x3460
testq %rax, %rax
je 0x3c20a
cmpq %rbx, %rax
jbe 0x3c1c0
cmpb %r15b, -0x1(%rax)
je 0x3c1bd
movq %rax, %r13
incq %r13
cmpb $0x0, 0x1(%rax)
jne 0x3c194
jmp 0x3c20a
decq %rax
leaq 0x1(%rax), %rsi
movb (%rsi), %cl
incq %rsi
testb %cl, %cl
je 0x3c1d2
cmpb %r15b, %cl
jne 0x3c1c4
leaq -0x1(%rsi), %rdx
testb %cl, %cl
cmoveq %rdx, %rsi
cmpq %rbx, %rax
cmovneq %rdx, %rsi
movl %esi, %ecx
subl %eax, %ecx
addl %ecx, %ebp
cmpb $0x0, (%rsi)
je 0x3c229
movq (%rsp), %rcx
subl %esi, %ecx
movslq %ecx, %rdx
movq %rax, %rdi
callq 0x34e0
cmpb $0x0, (%r13)
jne 0x3c194
jmp 0x3c20a
xorl %ebp, %ebp
cmpl %r14d, %ebp
jne 0x3c218
movw $0x2e, (%rbx)
leal -0x1(%r14), %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, (%rax)
jmp 0x3c20a
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: rm_info
void rm_info(kstring_t *s, const char *key)
{
    char *p = s->s; 
    int n = 0;
    while ( n<4 )
    {
        if ( !*p ) n++;
        p++;
    }
    char *q = p+1; 
    while ( *q && q-s->s<s->l ) q++;

    int nrm = remove_tag(p, key, ';');
    if ( nrm )
        memmove(q-nrm, q, s->s+s->l-q+1);
    s->l -= nrm;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %r14
xorl %eax, %eax
xorl %ecx, %ecx
cmpb $0x1, (%r14,%rax)
adcl $0x0, %ecx
incq %rax
cmpl $0x4, %ecx
jb 0x3c241
leaq (%r14,%rax), %rdi
movq %rax, %r15
cmpb $0x0, 0x1(%r14,%rax)
je 0x3c269
leaq 0x1(%r15), %rax
cmpq (%rbx), %rax
jb 0x3c255
movl $0x3b, %edx
callq 0x3c160
testl %eax, %eax
je 0x3c2a2
leaq (%r14,%r15), %rsi
incq %rsi
movslq %eax, %r12
movq %r14, %rax
subq %r12, %rax
leaq (%rax,%r15), %rdi
incq %rdi
movq 0x10(%rbx), %rdx
addq (%rbx), %rdx
subq %r14, %rdx
subq %r15, %rdx
callq 0x34e0
jmp 0x3c2a5
xorl %r12d, %r12d
subq %r12, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcf.c
// Function: bcf_cpy
int bcf_cpy(bcf1_t *r, const bcf1_t *b)
{
	char *t1 = r->str;
	bcf_ginfo_t *t2 = r->gi;
	int i, t3 = r->m_str, t4 = r->m_gi;
	*r = *b;
	r->str = t1; r->gi = t2; r->m_str = t3; r->m_gi = t4;
	if (r->m_str < b->m_str) {
		r->m_str = b->m_str;
		r->str = realloc(r->str, r->m_str);
	}
	memcpy(r->str, b->str, r->m_str);
	bcf_sync(r); // calling bcf_sync() is simple but inefficient
	for (i = 0; i < r->n_gi; ++i)
		memcpy(r->gi[i].data, b->gi[i].data, r->n_smpl * r->gi[i].len);
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %rax
movq 0x50(%rdi), %r8
movl 0xc(%rdi), %edx
movl 0x4c(%rdi), %r9d
movl $0xd, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq %rax, 0x18(%r14)
movq %r8, 0x50(%r14)
movl %edx, 0xc(%r14)
movl %r9d, 0x4c(%r14)
movl 0xc(%rbx), %ecx
cmpl %ecx, %edx
jge 0x3c307
movslq %ecx, %rsi
movl %ecx, 0xc(%r14)
movq %rax, %rdi
callq 0x3720
movq %rax, 0x18(%r14)
movl 0xc(%r14), %edx
movq 0x18(%rbx), %rsi
movslq %edx, %rdx
movq %rax, %rdi
callq 0x37d0
movq %r14, %rdi
callq 0x3ab86
cmpl $0x0, 0x48(%r14)
jle 0x3c360
movl $0x8, %r15d
xorl %r12d, %r12d
movq 0x50(%r14), %rax
movq (%rax,%r15), %rdi
movq 0x50(%rbx), %rcx
movq (%rcx,%r15), %rsi
movslq 0x5c(%r14), %rcx
movslq -0x4(%rax,%r15), %rdx
imulq %rcx, %rdx
callq 0x37d0
incq %r12
movslq 0x48(%r14), %rax
addq $0x10, %r15
cmpq %rax, %r12
jl 0x3c32e
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_build_refhash
void *bcf_build_refhash(bcf_hdr_t *h)
{
	khash_t(str2id) *hash;
	int i, ret;
	hash = kh_init(str2id);
	for (i = 0; i < h->n_ref; ++i) {
		khint_t k;
		k = kh_put(str2id, hash, h->ns[i], &ret); // FIXME: check ret
		kh_val(hash, k) = i;
	}
	return hash;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, %r14
cmpl $0x0, (%rbx)
jle 0x3c3fa
xorl %r12d, %r12d
leaq 0x4(%rsp), %r15
movq 0x30(%rbx), %rax
movq (%rax,%r12,8), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x3c409
movq 0x20(%r14), %rcx
movl %eax, %eax
movl %r12d, (%rcx,%rax,4)
incq %r12
movslq (%rbx), %rax
cmpq %rax, %r12
jl 0x3c3d2
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_str2id_thorough_destroy
void bcf_str2id_thorough_destroy(void *_hash)
{
	khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
	khint_t k;
	if (hash == 0) return;
	for (k = 0; k < kh_end(hash); ++k)
		if (kh_exist(hash, k)) free((char*)kh_key(hash, k));
	kh_destroy(str2id, hash);
}

// Assembly:
testq %rdi, %rdi
je 0x3c6bb
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %eax
testl %eax, %eax
je 0x3c693
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%rbx), %rcx
movq %r15, %rdx
shrq $0x4, %rdx
movl (%rcx,%rdx,4), %edx
movl %r14d, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0x3c685
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x3350
movl (%rbx), %eax
incq %r15
movl %eax, %ecx
addl $0x2, %r14d
cmpq %rcx, %r15
jb 0x3c65b
movq 0x18(%rbx), %rdi
callq 0x3350
movq 0x10(%rbx), %rdi
callq 0x3350
movq 0x20(%rbx), %rdi
callq 0x3350
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3350
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_str2id
int bcf_str2id(void *_hash, const char *str)
{
	khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
	khint_t k;
	if (!hash) return -1;
	k = kh_get(str2id, hash, str);
	return k == kh_end(hash)? -1 : kh_val(hash, k);
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x3c7ea
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl (%rdi), %r14d
testl %r14d, %r14d
je 0x3c720
movq %rsi, %r12
movsbl (%rsi), %r8d
xorl %r9d, %r9d
movl $0x0, %ecx
testl %r8d, %r8d
je 0x3c72b
movb 0x1(%r12), %al
testb %al, %al
je 0x3c728
leaq 0x2(%r12), %rdx
movl %r8d, %ecx
movl %ecx, %r8d
shll $0x5, %r8d
subl %ecx, %r8d
movsbl %al, %ecx
addl %r8d, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x3c705
jmp 0x3c72b
xorl %r15d, %r15d
jmp 0x3c7cd
movl %r8d, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movl %edx, %r10d
leal -0x1(%r14), %r8d
movl %ecx, %eax
xorl %edx, %edx
divl %r8d
incl %edx
movq 0x10(%rdi), %rbx
movl %r10d, %r15d
movq %rdi, 0x10(%rsp)
movl %edx, 0xc(%rsp)
movl %r10d, 0x8(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rbx,%rax,4), %ebp
leal (%r15,%r15), %r13d
andl $0x1e, %r13d
movl %ebp, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3c7bb
testb $0x1, %al
jne 0x3c79f
movq 0x18(%rdi), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r12, %rsi
callq 0x35a0
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %r10d
xorl %r9d, %r9d
movq 0x10(%rsp), %rdi
testl %eax, %eax
je 0x3c7bb
addl %edx, %r15d
cmpl %r14d, %r15d
movl %r14d, %eax
cmovbl %r9d, %eax
subl %eax, %r15d
cmpl %r10d, %r15d
jne 0x3c757
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x3c7dc
movl %r13d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r14d, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %r14d, %r15d
je 0x3c7dc
movq 0x20(%rdi), %rax
movl %r15d, %ecx
movl (%rax,%rcx,4), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_str2id_add
int bcf_str2id_add(void *_hash, const char *str)
{
	khint_t k;
	int ret;
	khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
	if (!hash) return -1;
	k = kh_put(str2id, hash, str, &ret);
	if (ret == 0) return kh_val(hash, k);
	kh_val(hash, k) = kh_size(hash) - 1;
	return kh_val(hash, k);
}

// Assembly:
testq %rdi, %rdi
je 0x3c81c
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4(%rsp), %r14
movq %r14, %rdx
callq 0x3c409
movl %eax, %ecx
cmpl $0x0, (%r14)
je 0x3c822
movl 0x4(%rbx), %eax
decl %eax
movq 0x20(%rbx), %rdx
movl %ecx, %ecx
movl %eax, (%rdx,%rcx,4)
jmp 0x3c82b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
movq 0x20(%rbx), %rax
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_shrink_alt
int bcf_shrink_alt(bcf1_t *b, int n)
{
	char *p;
	int i, j, k, n_smpl = b->n_smpl;
	if (b->n_alleles <= n) return -1;
	// update ALT
	if (n > 1) {
		for (p = b->alt, k = 1; *p; ++p)
			if (*p == ',' && ++k == n) break;
		*p = '\0';
	} else p = b->alt, *p = '\0';
	++p;
	memmove(p, b->flt, b->str + b->l_str - b->flt);
	b->l_str -= b->flt - p;
	// update PL
	for (i = 0; i < b->n_gi; ++i) {
		bcf_ginfo_t *g = b->gi + i;
		if (g->fmt == bcf_str2int("PL", 2)) {
			int l, x = b->n_alleles * (b->n_alleles + 1) / 2;
			uint8_t *d = (uint8_t*)g->data;
			g->len = n * (n + 1) / 2;
			for (l = k = 0; l < n_smpl; ++l) {
				uint8_t *dl = d + l * x;
				for (j = 0; j < g->len; ++j) d[k++] = dl[j];
			}
		} // FIXME: to add GL
	}
	b->n_alleles = n;
	bcf_sync(b);
	return 0;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %esi, 0x58(%rdi)
jle 0x3cd40
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
movq 0x28(%rdi), %r15
cmpl $0x2, %esi
jl 0x3cc53
movl $0x1, %eax
movzbl (%r15), %ecx
cmpl $0x2c, %ecx
je 0x3cc47
testl %ecx, %ecx
jne 0x3cc4e
jmp 0x3cc53
incl %eax
cmpl %r14d, %eax
je 0x3cc53
incq %r15
jmp 0x3cc38
movl 0x5c(%rbx), %r12d
movb $0x0, (%r15)
incq %r15
movq 0x30(%rbx), %rsi
movslq 0x8(%rbx), %rdx
addq 0x18(%rbx), %rdx
subq %rsi, %rdx
movq %r15, %rdi
callq 0x34e0
subl 0x30(%rbx), %r15d
addl %r15d, 0x8(%rbx)
movl 0x48(%rbx), %edi
testl %edi, %edi
jle 0x3cd29
leal 0x1(%r14), %ecx
imull %r14d, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
xorl %ecx, %ecx
movq 0x50(%rbx), %rdx
movq %rcx, %rsi
shlq $0x4, %rsi
cmpl $0x504c, (%rdx,%rsi)    # imm = 0x504C
jne 0x3cd1a
addq %rsi, %rdx
movl 0x58(%rbx), %r8d
movq 0x8(%rdx), %rsi
movl %eax, 0x4(%rdx)
testl %r12d, %r12d
jle 0x3cd1a
leal 0x1(%r8), %edi
imull %r8d, %edi
movl %edi, %r8d
shrl $0x1f, %r8d
addl %edi, %r8d
sarl %r8d
movslq %r8d, %rdi
xorl %r8d, %r8d
movq %rsi, %r9
movl %eax, %r11d
xorl %r10d, %r10d
testl %r11d, %r11d
jle 0x3cd0c
movslq %r10d, %r13
addq %rsi, %r13
xorl %r15d, %r15d
movb (%r9,%r15), %r11b
movb %r11b, (%r13,%r15)
incq %r15
movslq 0x4(%rdx), %r11
cmpq %r11, %r15
jl 0x3ccf4
addl %r15d, %r10d
incq %r8
addq %rdi, %r9
cmpq %r12, %r8
jne 0x3cce6
movl 0x48(%rbx), %edi
incq %rcx
movslq %edi, %rdx
cmpq %rdx, %rcx
jl 0x3cc9b
movl %r14d, 0x58(%rbx)
movq %rbx, %rdi
callq 0x3ab86
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_gl2pl
int bcf_gl2pl(bcf1_t *b)
{
	char *p;
	int i, n_smpl = b->n_smpl;
	bcf_ginfo_t *g;
	float *d0;
	uint8_t *d1;
	if (strstr(b->fmt, "PL")) return -1;
	if ((p = strstr(b->fmt, "GL")) == 0) return -1;
	*p = 'P';
	for (i = 0; i < b->n_gi; ++i)
		if (b->gi[i].fmt == bcf_str2int("GL", 2))
			break;
	g = b->gi + i;
	g->fmt = bcf_str2int("PL", 2);
	g->len /= 4; // 4 == sizeof(float)
	d0 = (float*)g->data; d1 = (uint8_t*)g->data;
	for (i = 0; i < n_smpl * g->len; ++i) {
		int x = (int)(-10. * d0[i] + .499);
		if (x > 255) x = 255;
		if (x < 0) x = 0;
		d1[i] = x;
	}
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movslq 0x5c(%rdi), %r12
movq 0x40(%rdi), %r15
leaq 0x8ad6(%rip), %rsi      # 0x45831
movq %r15, %rdi
callq 0x3460
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x3cd7b
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x90e2(%rip), %rsi      # 0x45e64
movq %r15, %rdi
callq 0x3460
testq %rax, %rax
je 0x3cd6d
movb $0x50, (%rax)
movl 0x48(%r14), %ecx
xorl %ebx, %ebx
movq 0x50(%r14), %rax
xorl %edx, %edx
testl %ecx, %ecx
jle 0x3cdbd
movq %rax, %rsi
cmpl $0x474c, (%rsi)         # imm = 0x474C
je 0x3cdbb
incq %rdx
addq $0x10, %rsi
cmpq %rdx, %rcx
jne 0x3cda5
movl %ecx, %edx
movl %edx, %edx
shlq $0x4, %rdx
movl $0x504c, (%rax,%rdx)    # imm = 0x504C
movl 0x4(%rax,%rdx), %ecx
leal 0x3(%rcx), %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
sarl $0x2, %esi
movl %esi, 0x4(%rax,%rdx)
imull %r12d, %esi
testl %esi, %esi
jle 0x3cd6d
leaq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rax
xorl %edx, %edx
movsd 0x901a(%rip), %xmm0     # 0x45e10
movsd 0x2232(%rip), %xmm1     # 0x3f030
movl $0xff, %edi
xorps %xmm2, %xmm2
cvtss2sd (%rax,%rdx,4), %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %esi
cmpl %edi, %esi
jl 0x3ce20
movl $0xff, %esi
xorl %ebx, %ebx
testl %esi, %esi
jg 0x3ce28
xorl %esi, %esi
movb %sil, (%rax,%rdx)
incq %rdx
movslq 0x4(%rcx), %rsi
imulq %r12, %rsi
cmpq %rsi, %rdx
jl 0x3ce03
jmp 0x3cd6d
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_fix_gt
int bcf_fix_gt(bcf1_t *b)
{
	char *s;
	int i;
	uint32_t tmp;
	bcf_ginfo_t gt;
	// check the presence of the GT FMT
	if ((s = strstr(b->fmt, ":GT")) == 0) return 0; // no GT or GT is already the first
	assert(s[3] == '\0' || s[3] == ':'); // :GTX in fact
	tmp = bcf_str2int("GT", 2);
	for (i = 0; i < b->n_gi; ++i)
		if (b->gi[i].fmt == tmp) break;
	if (i == b->n_gi) return 0; // no GT in b->gi; probably a bug...
	gt = b->gi[i];
	// move GT to the first
	for (; i > 0; --i) b->gi[i] = b->gi[i-1];
	b->gi[0] = gt;
    if ( s[3]==0 )
        memmove(b->fmt + 3, b->fmt, s - b->fmt);        // :GT
    else
        memmove(b->fmt + 3, b->fmt, s - b->fmt + 1);    // :GT:
	b->fmt[0] = 'G'; b->fmt[1] = 'T'; b->fmt[2] = ':';
	return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
leaq 0x9013(%rip), %rsi      # 0x45e67
callq 0x3460
testq %rax, %rax
je 0x3cf2e
movzbl 0x3(%rax), %ecx
testl %ecx, %ecx
je 0x3ce73
cmpl $0x3a, %ecx
jne 0x3cf36
movslq 0x48(%rbx), %rsi
testq %rsi, %rsi
jle 0x3ceab
movq 0x50(%rbx), %rdi
movq $-0x1, %rcx
xorl %edx, %edx
cmpl $0x4754, (%rdi,%rdx)    # imm = 0x4754
je 0x3cebc
addq $0x10, %rdx
leaq (%rsi,%rcx), %r8
decq %r8
decq %rcx
cmpq $-0x1, %r8
jne 0x3ce89
jmp 0x3cf2e
testl %esi, %esi
je 0x3cf2e
movq 0x50(%rbx), %rsi
movups (%rsi), %xmm0
movaps %xmm0, (%rsp)
jmp 0x3cef5
addl %ecx, %esi
cmpl $-0x1, %esi
je 0x3cf2e
movq 0x50(%rbx), %rsi
movups (%rsi,%rdx), %xmm0
movaps %xmm0, (%rsp)
testq %rdx, %rdx
je 0x3cef5
negq %rcx
movq 0x50(%rbx), %rsi
movups -0x10(%rsi,%rdx), %xmm0
movups %xmm0, (%rsi,%rdx)
decq %rcx
addq $-0x10, %rdx
cmpq $0x1, %rcx
ja 0x3ced7
movq 0x50(%rbx), %rsi
movaps (%rsp), %xmm0
movups %xmm0, (%rsi)
movq 0x40(%rbx), %rsi
cmpb $0x1, 0x3(%rax)
leaq 0x3(%rsi), %rdi
sbbq $-0x1, %rax
subq %rsi, %rax
movq %rax, %rdx
callq 0x34e0
movq 0x40(%rbx), %rax
movb $0x47, (%rax)
movq 0x40(%rbx), %rax
movb $0x54, 0x1(%rax)
movq 0x40(%rbx), %rax
movb $0x3a, 0x2(%rax)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
leaq 0x8f2e(%rip), %rdi      # 0x45e6b
leaq 0x8ef5(%rip), %rsi      # 0x45e39
leaq 0x8f3c(%rip), %rcx      # 0x45e87
movl $0xf3, %edx
callq 0x31b0
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_fix_pl
int bcf_fix_pl(bcf1_t *b)
{
	int i;
	uint32_t tmp;
	uint8_t *PL, *swap;
	bcf_ginfo_t *gi;
	// pinpoint PL
	tmp = bcf_str2int("PL", 2);
	for (i = 0; i < b->n_gi; ++i)
		if (b->gi[i].fmt == tmp) break;
	if (i == b->n_gi) return 0;
	// prepare
	gi = b->gi + i;
	PL = (uint8_t*)gi->data;
	swap = alloca(gi->len);
	// loop through individuals
	for (i = 0; i < b->n_smpl; ++i) {
		int k, l, x;
		uint8_t *PLi = PL + i * gi->len;
		memcpy(swap, PLi, gi->len);
		for (k = x = 0; k < b->n_alleles; ++k)
			for (l = k; l < b->n_alleles; ++l)
				PLi[l*(l+1)/2 + k] = swap[x++];
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movslq 0x48(%rdi), %rax
testq %rax, %rax
jle 0x3cf91
movq 0x50(%rbx), %rdx
xorl %ecx, %ecx
cmpl $0x504c, (%rdx)         # imm = 0x504C
je 0x3cf93
incq %rcx
addq $0x10, %rdx
cmpq %rcx, %rax
jne 0x3cf78
jmp 0x3d053
xorl %ecx, %ecx
cmpl %eax, %ecx
je 0x3d053
movq 0x50(%rbx), %rax
movl %ecx, %ecx
shlq $0x4, %rcx
movslq 0x4(%rax,%rcx), %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %r14
subq %rdx, %r14
movq %r14, %rsp
movl 0x5c(%rbx), %esi
testl %esi, %esi
jle 0x3d053
leaq (%rax,%rcx), %rdx
movq %rdx, -0x40(%rbp)
movq 0x8(%rax,%rcx), %rax
movq %rax, -0x38(%rbp)
movl 0x58(%rbx), %r13d
xorl %r12d, %r12d
movl %esi, -0x2c(%rbp)
movq -0x40(%rbp), %rax
movslq 0x4(%rax), %rdx
movslq %r12d, %r15
imulq %rdx, %r15
addq -0x38(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x37d0
testl %r13d, %r13d
jle 0x3d048
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %r13d, %ecx
jge 0x3d03c
movslq %eax, %rdx
addq %r14, %rdx
movl %ecx, %esi
movl %ecx, %edi
movb (%rdx), %r8b
leal 0x1(%rdi), %r9d
imull %r9d, %edi
shrl %edi
addq %rsi, %rdi
movb %r8b, (%r15,%rdi)
movl 0x58(%rbx), %r13d
incq %rdx
incl %eax
movl %r9d, %edi
cmpl %r13d, %r9d
jl 0x3d017
incl %ecx
cmpl %r13d, %ecx
jl 0x3d008
movl 0x5c(%rbx), %esi
jmp 0x3d04b
movl -0x2c(%rbp), %esi
incl %r12d
cmpl %esi, %r12d
jl 0x3cfde
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_smpl_covered
int bcf_smpl_covered(const bcf1_t *b)
{
	int i, j, n = 0;
	uint32_t tmp;
	bcf_ginfo_t *gi;
	// pinpoint PL
	tmp = bcf_str2int("PL", 2);
	for (i = 0; i < b->n_gi; ++i)
		if (b->gi[i].fmt == tmp) break;
	if (i == b->n_gi) return 0;
	// count how many samples having PL!=[0..0]
	gi = b->gi + i;
	for (i = 0; i < b->n_smpl; ++i) {
		uint8_t *PLi = ((uint8_t*)gi->data) + i * gi->len;
		for (j = 0; j < gi->len; ++j)
			if (PLi[j]) break;
		if (j < gi->len) ++n;
	}
	return n;
}

// Assembly:
movslq 0x48(%rdi), %rcx
xorl %eax, %eax
movl $0x0, %edx
testq %rcx, %rcx
jle 0x3d091
movq 0x50(%rdi), %rsi
xorl %edx, %edx
cmpl $0x504c, (%rsi)         # imm = 0x504C
je 0x3d091
incq %rdx
addq $0x10, %rsi
cmpq %rdx, %rcx
jne 0x3d07a
xorl %eax, %eax
retq
cmpl %ecx, %edx
je 0x3d10b
movslq 0x5c(%rdi), %rcx
testq %rcx, %rcx
jle 0x3d10b
movq 0x50(%rdi), %rax
movl %edx, %esi
shlq $0x4, %rsi
movq 0x8(%rax,%rsi), %rdx
movl 0x4(%rax,%rsi), %esi
movslq %esi, %rdi
xorl %r8d, %r8d
movq %rdx, %r9
xorl %eax, %eax
movl $0x0, %r10d
testl %esi, %esi
jle 0x3d0fd
movq %r8, %r11
imulq %rdi, %r11
movl $0x1, %r10d
cmpb $0x0, (%rdx,%r11)
jne 0x3d0fd
movl $0x1, %r10d
movq %r10, %r11
cmpq %r10, %rsi
je 0x3d0f3
leaq 0x1(%r11), %r10
cmpb $0x0, (%r9,%r11)
je 0x3d0e0
xorl %r10d, %r10d
cmpq %rdi, %r11
setl %r10b
addl %r10d, %eax
incq %r8
addq %rdi, %r9
cmpq %rcx, %r8
jne 0x3d0bc
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: locate_field
static void *locate_field(const bcf1_t *b, const char *fmt, int l)
{
	int i;
	uint32_t tmp;
	tmp = bcf_str2int(fmt, l);
	for (i = 0; i < b->n_gi; ++i)
		if (b->gi[i].fmt == tmp) break;
	return i == b->n_gi? 0 : b->gi[i].data;
}

// Assembly:
xorl %ecx, %ecx
movl $0x0, %r8d
testb %sil, %sil
je 0x3d2f7
movsbl %sil, %r8d
testb %dl, %dl
je 0x3d2f7
movsbl %dl, %eax
shll $0x8, %r8d
orl %eax, %r8d
movslq 0x48(%rdi), %rdx
testq %rdx, %rdx
jle 0x3d31a
movq 0x50(%rdi), %rsi
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %r8d, (%rsi)
je 0x3d31a
incq %rcx
addq $0x10, %rsi
cmpq %rcx, %rdx
jne 0x3d308
retq
cmpl %edx, %ecx
jne 0x3d321
xorl %eax, %eax
retq
movq 0x50(%rdi), %rax
movl %ecx, %ecx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_shuffle
int bcf_shuffle(bcf1_t *b, int seed)
{
	int i, j, *a;
	if (seed > 0) srand48(seed);
	a = malloc(b->n_smpl * sizeof(int));
	for (i = 0; i < b->n_smpl; ++i) a[i] = i;
	for (i = b->n_smpl; i > 1; --i) {
		int tmp;
		j = (int)(drand48() * i);
		tmp = a[j]; a[j] = a[i-1]; a[i-1] = tmp;
	}
	for (j = 0; j < b->n_gi; ++j) {
		bcf_ginfo_t *gi = b->gi + j;
		uint8_t *swap, *data = (uint8_t*)gi->data;
		swap = malloc(gi->len * b->n_smpl);
		for (i = 0; i < b->n_smpl; ++i)
			memcpy(swap + gi->len * a[i], data + gi->len * i, gi->len);
		free(gi->data);
		gi->data = swap;
	}
	free(a);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r13
testl %esi, %esi
jle 0x3d34d
movl %esi, %edi
callq 0x37e0
movslq 0x5c(%r13), %r15
leaq (,%r15,4), %rdi
callq 0x3240
movq %rax, %r14
testq %r15, %r15
jle 0x3d435
leal 0x1(%r15), %eax
andl $-0x2, %eax
leaq -0x1(%r15), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x62d9(%rip), %xmm1     # 0x43660
xorl %ecx, %ecx
movdqa 0x62df(%rip), %xmm2     # 0x43670
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x8a4f(%rip), %xmm4     # 0x45df0
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edx
notl %edx
testb $0x1, %dl
je 0x3d3d6
movl %ecx, (%r14,%rcx,4)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edx
testb $0x1, %dl
je 0x3d3ec
leal 0x1(%rcx), %edx
movl %edx, 0x4(%r14,%rcx,4)
addq $0x2, %rcx
paddq %xmm4, %xmm1
cmpq %rcx, %rax
jne 0x3d3a1
cmpl $0x1, %r15d
je 0x3d435
callq 0x3820
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
cltq
movl (%r14,%rax,4), %ecx
movl -0x4(%r14,%r15,4), %edx
movl %edx, (%r14,%rax,4)
movl %ecx, -0x4(%r14,%r15,4)
leaq -0x1(%r15), %rax
cmpq $0x2, %r15
movq %rax, %r15
ja 0x3d3ff
cmpl $0x0, 0x48(%r13)
jle 0x3d4c6
xorl %ecx, %ecx
movq %r13, 0x8(%rsp)
movq 0x50(%r13), %rax
movq %rcx, 0x10(%rsp)
shlq $0x4, %rcx
leaq (%rax,%rcx), %rbp
movq 0x8(%rax,%rcx), %r15
movslq 0x4(%rax,%rcx), %rdi
movslq 0x5c(%r13), %rbx
imulq %rbx, %rdi
callq 0x3240
movq %rax, %r12
testq %rbx, %rbx
jle 0x3d4a9
xorl %r13d, %r13d
movslq 0x4(%rbp), %rdx
movslq (%r14,%r13,4), %rdi
imulq %rdx, %rdi
addq %r12, %rdi
movslq %r13d, %rsi
imulq %rdx, %rsi
addq %r15, %rsi
callq 0x37d0
incq %r13
cmpq %r13, %rbx
jne 0x3d47a
movq 0x8(%rbp), %r15
movq 0x8(%rsp), %r13
movq %r15, %rdi
callq 0x3350
movq %r12, 0x8(%rbp)
movq 0x10(%rsp), %rcx
incq %rcx
movslq 0x48(%r13), %rax
cmpq %rax, %rcx
jl 0x3d447
movq %r14, %rdi
callq 0x3350
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_subsam
int bcf_subsam(int n_smpl, int *list, bcf1_t *b)
{
	int i, j;
	for (j = 0; j < b->n_gi; ++j) {
		bcf_ginfo_t *gi = b->gi + j;
		uint8_t *swap;
		swap = malloc(gi->len * b->n_smpl);
		for (i = 0; i < n_smpl; ++i)
			memcpy(swap + i * gi->len, (uint8_t*)gi->data + list[i] * gi->len, gi->len);
		free(gi->data);
		gi->data = swap;
	}
	b->n_smpl = n_smpl;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, 0xc(%rsp)
cmpl $0x0, 0x48(%rdx)
jle 0x3d946
movq %rsi, %r14
movl 0xc(%rsp), %r12d
xorl %r13d, %r13d
movq %rdx, 0x10(%rsp)
movq 0x50(%rdx), %rax
movq %r13, %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rbp
movslq 0x4(%rax,%rcx), %rax
movslq 0x5c(%rdx), %rdi
imulq %rax, %rdi
callq 0x3240
movq %rax, %r15
cmpl $0x0, 0xc(%rsp)
jle 0x3d928
xorl %ebx, %ebx
movslq 0x4(%rbp), %rdx
movslq %ebx, %rdi
imulq %rdx, %rdi
addq %r15, %rdi
movslq (%r14,%rbx,4), %rsi
imulq %rdx, %rsi
addq 0x8(%rbp), %rsi
callq 0x37d0
incq %rbx
cmpq %rbx, %r12
jne 0x3d901
movq 0x8(%rbp), %rdi
callq 0x3350
movq %r15, 0x8(%rbp)
incq %r13
movq 0x10(%rsp), %rdx
movslq 0x48(%rdx), %rax
cmpq %rax, %r13
jl 0x3d8d4
movl 0xc(%rsp), %eax
movl %eax, 0x5c(%rdx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_gl10_indel
int bcf_gl10_indel(const bcf1_t *b, uint8_t *gl)
{
	int k, l, j, i;
	const bcf_ginfo_t *PL;
	if (b->alt[0] == 0) return -1; // no alternate allele
	for (i = 0; i < b->n_gi; ++i)
		if (b->gi[i].fmt == bcf_str2int("PL", 2)) break;
	if (i == b->n_gi) return -1; // no PL
	PL = b->gi + i;
	for (i = 0; i < b->n_smpl; ++i) {
		const uint8_t *p = PL->data + i * PL->len; // the PL for the i-th individual
		uint8_t *g = gl + 10 * i;
		for (k = j = 0; k < 4; ++k) {
			for (l = k; l < 4; ++l) {
				int t, x = k, y = l;
				if (x > y) t = x, x = y, y = t; // make sure x is the smaller
				x = y * (y+1) / 2 + x;
				g[j++] = x < PL->len? p[x] : 255;
			}
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x28(%rdi), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x0, (%rcx)
je 0x3dc2f
movslq 0x48(%rdi), %rdx
testq %rdx, %rdx
jle 0x3db91
movq 0x50(%rdi), %r8
xorl %ecx, %ecx
cmpl $0x504c, (%r8)          # imm = 0x504C
je 0x3db93
incq %rcx
addq $0x10, %r8
cmpq %rcx, %rdx
jne 0x3db77
jmp 0x3dc2f
xorl %ecx, %ecx
cmpl %edx, %ecx
je 0x3dc2f
cmpl $0x0, 0x5c(%rdi)
jle 0x3dc2d
movl %ecx, %eax
shlq $0x4, %rax
addq 0x50(%rdi), %rax
xorl %ecx, %ecx
movslq 0x4(%rax), %r8
movslq %ecx, %rdx
imulq %r8, %rdx
addq 0x8(%rax), %rdx
movl $0x4, %r8d
xorl %r9d, %r9d
xorl %r10d, %r10d
movslq %r9d, %r11
addq %rsi, %r11
movl %r10d, %ebx
cmpl %ebx, %r10d
movl %ebx, %r14d
cmovbl %r10d, %r14d
movl %ebx, %r15d
cmoval %r10d, %r15d
leal 0x1(%r15), %r12d
imull %r15d, %r12d
shrl %r12d
addq %r12, %r14
movb $-0x1, %bpl
cmpl 0x4(%rax), %r14d
jge 0x3dc01
movb (%rdx,%r14), %bpl
movb %bpl, (%r11)
incl %ebx
incq %r11
cmpl $0x4, %ebx
jne 0x3dbd5
incl %r10d
addl %r8d, %r9d
decl %r8d
cmpl $0x4, %r10d
jne 0x3dbcc
incq %rcx
movslq 0x5c(%rdi), %rdx
addq $0xa, %rsi
cmpq %rdx, %rcx
jl 0x3dbb1
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq