// File: /workspace/github_c_makefile_star2_O1/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, 0x38(%rsp)
movq %rdx, 0x48(%rsp)
movl %esi, %r12d
movq %rdi, %r15
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, %rbp
cmpl $0x0, 0x4(%r15)
jle 0x3cca4
xorl %r14d, %r14d
leaq 0x64(%rsp), %rbx
movq 0x38(%r15), %rax
movq (%rax,%r14,8), %rsi
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x3bc49
movq 0x20(%rbp), %rcx
movl %eax, %eax
movl %r14d, (%rcx,%rax,4)
incq %r14
movslq 0x4(%r15), %rax
cmpq %rax, %r14
jl 0x3cc7b
movq %r15, 0x30(%rsp)
testl %r12d, %r12d
movl %r12d, 0x18(%rsp)
jle 0x3cef4
movl %r12d, %eax
movq %rax, 0x40(%rsp)
xorl %ecx, %ecx
movl $0x0, 0x4(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
movq %rbp, 0x10(%rsp)
movq %r12, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq %rcx, 0x50(%rsp)
movq (%rax,%rcx,8), %rsi
movl (%rbp), %r12d
movl $0x0, %r14d
testl %r12d, %r12d
je 0x3cdd6
movsbl (%rsi), %ecx
testl %ecx, %ecx
movq %r13, 0x20(%rsp)
je 0x3cd31
movb 0x1(%rsi), %al
testb %al, %al
je 0x3cd33
leaq 0x2(%rsi), %rdx
movl %ecx, %edi
shll $0x5, %edi
subl %ecx, %edi
movsbl %al, %ecx
addl %edi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x3cd1a
jmp 0x3cd33
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r12d
movl %edx, %ebx
leal -0x1(%r12), %edi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
incl %edx
movq 0x10(%rbp), %rdi
movl %ebx, %r14d
movl %edx, 0x1c(%rsp)
movq %rdi, 0x58(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %ebp
leal (%r14,%r14), %r15d
andl $0x1e, %r15d
movl %ebp, %eax
movl %r15d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3cdbf
testb $0x1, %al
jne 0x3cda1
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %r13
callq 0x35a0
movq 0x58(%rsp), %rdi
movl 0x1c(%rsp), %edx
movq %r13, %rsi
testl %eax, %eax
je 0x3cdbf
addl %edx, %r14d
cmpl %r12d, %r14d
movl %r12d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r14d
cmpl %ebx, %r14d
jne 0x3cd59
movl %r12d, %r14d
jmp 0x3cdcc
movl %r15d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r12d, %r14d
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %rbp
cmpl %r12d, %r14d
jne 0x3cde5
movq 0x28(%rsp), %r12
jmp 0x3cedb
movq 0x20(%rbp), %rax
movl %r14d, %ecx
movl (%rax,%rcx,4), %eax
movslq 0x4(%rsp), %rcx
movq 0x38(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movq %rsi, %r14
movq %rsi, %rdi
callq 0x3360
movslq %eax, %rbx
leaq (%rbx,%r13), %rax
incq %rax
movq 0x8(%rsp), %r15
cmpq %r15, %rax
movq 0x28(%rsp), %r12
jb 0x3ce62
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
movq %r12, %rdi
movq %r15, %rsi
callq 0x3720
movq %rax, %r12
leaq (%r12,%r13), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x37d0
leaq (%rbx,%r13), %r14
movb $0x0, (%r12,%r14)
addq %rbx, %r13
incq %r13
cmpq %r15, %r13
jae 0x3ce8c
movq %r15, 0x8(%rsp)
jmp 0x3ced0
movq %r13, %rax
shrq %rax
orq %r13, %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 %r12, %rdi
movq %rsi, 0x8(%rsp)
callq 0x3720
movq %rax, %r12
incl 0x4(%rsp)
movw $0x0, (%r12,%r14)
movq 0x50(%rsp), %rcx
incq %rcx
cmpq 0x40(%rsp), %rcx
jne 0x3ccdd
movl 0x4(%rsp), %esi
jmp 0x3cefc
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %esi, %esi
movl 0x18(%rsp), %edi
cmpl %edi, %esi
jl 0x3cfd6
testq %rbp, %rbp
je 0x3cf30
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, %rbx
movq 0x30(%rsp), %r15
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups 0x30(%r15), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm0, (%rax)
movups %xmm1, 0x10(%rax)
movups %xmm2, 0x20(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movslq 0x8(%rax), %r14
movq %r14, %rdi
callq 0x3240
movq %rax, 0x18(%rbx)
movq 0x18(%r15), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x37d0
movslq 0x10(%rbx), %r14
leaq 0x1(%r14), %rsi
movl $0x1, %edi
callq 0x3610
movq %rax, 0x28(%rbx)
movq 0x28(%r15), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x37d0
movl %r13d, 0xc(%rbx)
movq %r12, 0x20(%rbx)
movq %rbx, %rdi
callq 0x3a2ba
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5ace