// File: /workspace/github_c_makefile_star2_O3/lh3[P]bgt/vcf.c
// Function: bcf_hdr_subset
bcf_hdr_t *bcf_hdr_subset(const bcf_hdr_t *h0, int n, char *const* samples, int *imap)
{
	kstring_t str;
	bcf_hdr_t *h;
	str.l = str.m = 0; str.s = 0;
	h = bcf_hdr_init();
	if (h0->n[BCF_DT_SAMPLE] > 0) {
		char *p;
		int i = 0, end = n? 8 : 7;
		while ((p = strstr(h0->text, "#CHROM\t")) != 0)
			if (p > h0->text && *(p-1) == '\n') break;
		while ((p = strchr(p, '\t')) != 0 && i < end) ++i, ++p;
		if (i != end) {
			free(h); free(str.s);
			return 0; // malformated header
		}
		kputsn(h0->text, p - h0->text, &str);
		for (i = 0; i < n; ++i) {
			imap[i] = bcf_id2int(h0, BCF_DT_SAMPLE, samples[i]);
			if (imap[i] < 0) continue;
			kputc('\t', &str);
			kputs(samples[i], &str);
		}
	} else kputsn(h0->text, h0->l_text, &str);
	h->text = str.s;
	h->l_text = str.l + 1; // including NULL
	bcf_hdr_parse(h);
	return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x30(%rsp)
movq %rdx, 0x18(%rsp)
movl %esi, %r12d
movq %rdi, %r14
callq 0xb93d
movq %rax, %r15
cmpl $0x0, 0x10(%r14)
jle 0x10d82
cmpl $0x1, %r12d
movl $0x8, %ebx
sbbl $0x0, %ebx
movq 0x48(%r14), %r13
leaq 0xe8df(%rip), %rsi      # 0x1f45f
movq %r13, %rdi
callq 0x2440
movq %rax, %rdi
movl $0x9, %esi
callq 0x2180
testq %rax, %rax
je 0x10d76
movq %r14, 0x10(%rsp)
movl $0x1, %r14d
incq %rax
movq %rax, %rdi
movl $0x9, %esi
callq 0x2180
leal 0x1(%r14), %ecx
testq %rax, %rax
je 0x10bca
cmpl %ebx, %r14d
movl %ecx, %r14d
jb 0x10ba9
subl %ebx, %ecx
cmpl $0x1, %ecx
movq 0x10(%rsp), %r14
jne 0x10d76
movq %r15, 0x8(%rsp)
subl %r13d, %eax
movslq %eax, %r15
leaq 0x1(%r15), %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, %rbx
shrq $0x10, %rbx
orq %rax, %rbx
incq %rbx
movq %rbx, %rdi
callq 0x22e0
movq %rax, %rbp
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2280
movq %r15, %r13
movb $0x0, (%rbp,%r15)
testl %r12d, %r12d
jle 0x10de5
movl %r12d, %eax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
movq 0x18(%rsp), %r15
movq (%r15,%r12,8), %rdx
movq %r14, %rdi
movl $0x2, %esi
callq 0x1088a
movq 0x30(%rsp), %rcx
movl %eax, (%rcx,%r12,4)
testl %eax, %eax
js 0x10d66
leaq 0x1(%r13), %rcx
cmpq %rbx, %rcx
movq %rcx, 0x28(%rsp)
jae 0x10c8d
movq %rbp, %r14
jmp 0x10ccf
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rbx
shrq $0x10, %rbx
orq %rcx, %rbx
incq %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2330
movq %rax, %r14
movq %r13, %rbp
movw $0x9, (%r14,%r13)
movq (%r15,%r12,8), %r15
movq %r15, %rdi
callq 0x2170
movslq %eax, %r13
leaq 0x2(,%r13), %rax
addq %rbp, %rax
cmpq %rbx, %rax
jae 0x10cfd
movq %r14, %rbp
jmp 0x10d3f
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, %rbx
shrq $0x10, %rbx
orq %rax, %rbx
incq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2330
movq %rax, %rbp
movq 0x28(%rsp), %r14
leaq (%r14,%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2280
addq %r14, %r13
movb $0x0, (%rbp,%r13)
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r15
incq %r12
cmpq %r12, 0x20(%rsp)
jne 0x10c58
jmp 0x10de5
movq %r15, %rdi
callq 0x2050
xorl %ebx, %ebx
jmp 0x10dfc
movq %r15, 0x8(%rsp)
movq 0x48(%r14), %rbx
movslq (%r14), %r14
leaq 0x1(%r14), %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, %rdi
shrq $0x10, %rdi
orq %rax, %rdi
incq %rdi
callq 0x22e0
movq %rax, %rbp
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2280
movq %r14, %r13
movb $0x0, (%rbp,%r14)
movq 0x8(%rsp), %rbx
movq %rbp, 0x48(%rbx)
incl %r13d
movl %r13d, (%rbx)
movq %rbx, %rdi
callq 0xb797
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq