// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
callq 0xfde0
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x1501d
movl $0x0, -0x54(%rbp)
movl -0x14(%rbp), %edx
movl $0x7, %eax
movl $0x8, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
leaq 0x13420(%rip), %rsi     # 0x28302
callq 0x2460
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x14f10
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jbe 0x14f0e
movq -0x50(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0xa, %eax
jne 0x14f0e
jmp 0x14f10
jmp 0x14ed3
jmp 0x14f12
movq -0x50(%rbp), %rdi
movl $0x9, %esi
callq 0x2180
movq %rax, %rcx
movq %rcx, -0x50(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x59(%rbp)
je 0x14f3e
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
setl %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x14f47
jmp 0x14f5e
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x14f12
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x14f85
movq -0x48(%rbp), %rdi
callq 0x2040
movq -0x30(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
jmp 0x15061
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq %rcx, %rax
movl %eax, %esi
leaq -0x40(%rbp), %rdx
callq 0x10ab0
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1501b
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x2, %esi
callq 0x14b90
movl %eax, %edx
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x14fed
jmp 0x15010
movl $0x9, %edi
leaq -0x40(%rbp), %rsi
callq 0x10ce0
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x40(%rbp), %rsi
callq 0x10880
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x14fae
jmp 0x15034
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %esi
leaq -0x40(%rbp), %rdx
callq 0x10ab0
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rdi
callq 0xfb00
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)