// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/bcfutils.c
// Function: bcf_hdr_subsam
bcf_hdr_t *bcf_hdr_subsam(const bcf_hdr_t *h0, int n, char *const* samples, int *list)
{
	int i, ret, j;
	khint_t k;
	bcf_hdr_t *h;
	khash_t(str2id) *hash;
	kstring_t s;
	s.l = s.m = 0; s.s = 0;
	hash = kh_init(str2id);
	for (i = 0; i < h0->n_smpl; ++i) {
		k = kh_put(str2id, hash, h0->sns[i], &ret);
		kh_val(hash, k) = i;
	}
	for (i = j = 0; i < n; ++i) {
		k = kh_get(str2id, hash, samples[i]);
		if (k != kh_end(hash)) {
			list[j++] = kh_val(hash, k);
			kputs(samples[i], &s); kputc('\0', &s);
		}
	}
	if (j < n) 
    {
        fprintf(stderr, "<%s> %d samples in the list but not in BCF.", __func__, n - j);
        exit(1);
    }
	kh_destroy(str2id, hash);
	h = calloc(1, sizeof(bcf_hdr_t));
	*h = *h0;
	h->ns = 0; h->sns = 0;
	h->name = malloc(h->l_nm); memcpy(h->name, h0->name, h->l_nm);
	h->txt = calloc(1, h->l_txt + 1); memcpy(h->txt, h0->txt, h->l_txt);
	h->l_smpl = s.l; h->sname = s.s;
	bcf_hdr_sync(h);
	return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, 0x40(%rsp)
movq %rdx, 0x50(%rsp)
movl %esi, %r15d
movq %rdi, %r13
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, %rbp
cmpl $0x0, 0x4(%r13)
jle 0x3d547
xorl %r14d, %r14d
leaq 0x64(%rsp), %rbx
movq 0x38(%r13), %rax
movq (%rax,%r14,8), %rsi
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x3c409
movq 0x20(%rbp), %rcx
movl %eax, %eax
movl %r14d, (%rcx,%rax,4)
incq %r14
movslq 0x4(%r13), %rax
cmpq %rax, %r14
jl 0x3d51e
testl %r15d, %r15d
movl %r15d, 0x38(%rsp)
jle 0x3d7cb
movl %r15d, %eax
movq %rax, 0x48(%rsp)
xorl %ecx, %ecx
xorl %esi, %esi
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
xorl %r14d, %r14d
movq %r13, 0x8(%rsp)
movq %rbp, 0x30(%rsp)
movq %r14, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq 0x50(%rsp), %rax
movq (%rax,%rcx,8), %r8
movl (%rbp), %r15d
movl $0x0, %r12d
testl %r15d, %r15d
movl %esi, 0x4(%rsp)
movq %rcx, 0x10(%rsp)
je 0x3d6a2
movsbl (%r8), %ecx
testl %ecx, %ecx
je 0x3d5d4
movb 0x1(%r8), %al
testb %al, %al
je 0x3d5d6
leaq 0x2(%r8), %rdx
movl %ecx, %esi
shll $0x5, %esi
subl %ecx, %esi
movsbl %al, %ecx
addl %esi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x3d5bd
jmp 0x3d5d6
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r15d
movl %edx, %edi
leal -0x1(%r15), %esi
movl %ecx, %eax
xorl %edx, %edx
divl %esi
movl %edx, %r14d
incl %r14d
movq 0x10(%rbp), %rsi
movl %edi, %r12d
movl %edi, 0x3c(%rsp)
movq %rsi, 0x58(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %ebp
leal (%r12,%r12), %ebx
andl $0x1e, %ebx
movl %ebp, %eax
movl %ebx, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3d683
testb $0x1, %al
jne 0x3d648
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
movq %r8, %r13
callq 0x35a0
movq 0x58(%rsp), %rsi
movl 0x3c(%rsp), %edi
movq %r13, %r8
testl %eax, %eax
je 0x3d683
addl %r14d, %r12d
cmpl %r15d, %r12d
movl %r15d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r12d
cmpl %edi, %r12d
jne 0x3d5ff
movq 0x8(%rsp), %r13
movq 0x30(%rsp), %rbp
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %r14
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rcx
jmp 0x3d7bb
movl %ebx, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r15d, %r12d
movq 0x8(%rsp), %r13
movq 0x30(%rsp), %rbp
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rcx
cmpl %r15d, %r12d
jne 0x3d6b6
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %r14
jmp 0x3d7bb
movq 0x20(%rbp), %rax
movl %r12d, %ecx
movl (%rax,%rcx,4), %eax
movslq %esi, %rcx
movq 0x40(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movq %r8, %rbx
movq %r8, %rdi
callq 0x3360
movslq %eax, %r15
movq 0x28(%rsp), %r12
leaq (%r12,%r15), %rax
incq %rax
movq 0x18(%rsp), %r13
cmpq %r13, %rax
movq 0x20(%rsp), %r14
jb 0x3d736
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, %r13
shrq $0x10, %r13
orq %rax, %r13
incq %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x3720
movq %rax, %r14
leaq (%r14,%r12), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x37d0
leaq (%r15,%r12), %rbx
movb $0x0, (%r14,%rbx)
addq %r15, %r12
incq %r12
cmpq %r13, %r12
jae 0x3d760
movq %r13, 0x18(%rsp)
jmp 0x3d7a4
movq %r12, %rax
shrq %rax
orq %r12, %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, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %r14, %rdi
movq %rsi, 0x18(%rsp)
callq 0x3720
movq %rax, %r14
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %r13
incl %esi
movw $0x0, (%r14,%rbx)
incq %rcx
cmpq 0x48(%rsp), %rcx
jne 0x3d57a
jmp 0x3d7d3
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %esi, %esi
movl 0x38(%rsp), %edi
cmpl %edi, %esi
jl 0x3d8a3
movq %r14, %r15
testq %rbp, %rbp
je 0x3d80a
movq 0x18(%rbp), %rdi
callq 0x3350
movq 0x10(%rbp), %rdi
callq 0x3350
movq 0x20(%rbp), %rdi
callq 0x3350
movq %rbp, %rdi
callq 0x3350
movl $0x1, %edi
movl $0x40, %esi
callq 0x3610
movq %rax, %r14
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm0, (%rax)
movups %xmm1, 0x10(%rax)
movups %xmm2, 0x20(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movslq 0x8(%rax), %rbx
movq %rbx, %rdi
callq 0x3240
movq %rax, 0x18(%r14)
movq 0x18(%r13), %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x37d0
movslq 0x10(%r14), %rbx
leaq 0x1(%rbx), %rsi
movl $0x1, %edi
callq 0x3610
movq %rax, 0x28(%r14)
movq 0x28(%r13), %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x37d0
movl %r12d, 0xc(%r14)
movq %r15, 0x20(%r14)
movq %r14, %rdi
callq 0x3aa0a
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5d29