// File: /workspace/github_c_makefile_star2_O1/lh3[P]bgt/vcf.c
// Function: bcf_subset
int bcf_subset(const bcf_hdr_t *h, bcf1_t *v, int n, int *imap)
{
	kstring_t ind;
	ind.s = 0; ind.l = ind.m = 0;
	if (n) {
		bcf_fmt_t *fmt;
		int i, j;
		fmt = (bcf_fmt_t*)alloca(v->n_fmt * sizeof(bcf_fmt_t));
		bcf_unpack_fmt_core((uint8_t*)v->indiv.s, v->n_sample, v->n_fmt, fmt);
		for (i = 0; i < (int)v->n_fmt; ++i) {
			bcf_fmt_t *f = &fmt[i];
			bcf_enc_int1(&ind, f->id);
			bcf_enc_size(&ind, f->n, f->type);
			for (j = 0; j < n; ++j)
				if (imap[j] >= 0) kputsn((char*)(f->p + imap[j] * f->size), f->size, &ind);
		}
		for (i = j = 0; j < n; ++j) if (imap[j] >= 0) ++i;
		v->n_sample = i;
	} else v->n_sample = 0;
	free(v->indiv.s);
	v->indiv = ind;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq 0x10(%rsi), %rsi
testl %edx, %edx
je 0x10e65
movq %rcx, %r13
movl %edx, %r12d
movq %rsi, %rax
shrq $0x20, %rax
movzbl %al, %edx
leal (%rdx,%rdx,2), %eax
leal 0xf(,%rax,8), %eax
andl $-0x10, %eax
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movq 0x40(%rbx), %rdi
shrq $0x28, %rsi
movq %r14, %rcx
callq 0xeeba
movq 0x10(%rbx), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movl %r12d, %edi
testb %al, %al
je 0x10e32
xorl %ecx, %ecx
movq %r14, -0x58(%rbp)
movq %rbx, -0x60(%rbp)
movq %r13, -0x70(%rbp)
movl %r12d, -0x34(%rbp)
movq %rdi, -0x30(%rbp)
movq %rcx, -0x68(%rbp)
leaq (%rcx,%rcx,2), %r15
movl (%r14,%r15,8), %esi
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0xc9cd
movl 0x4(%r14,%r15,8), %esi
movl 0x8(%r14,%r15,8), %edx
movq %rbx, %rdi
callq 0xc692
movq %r14, %rcx
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %rbx
movq -0x40(%rbp), %rax
testl %r12d, %r12d
jle 0x10df8
leaq (%rcx,%r15,8), %rcx
movq %rcx, -0x78(%rbp)
xorl %r15d, %r15d
movq -0x30(%rbp), %rdi
movslq (%r13,%r15,4), %r12
testq %r12, %r12
js 0x10dea
movq -0x78(%rbp), %rcx
movslq 0xc(%rcx), %r13
imulq %r13, %r12
addq 0x10(%rcx), %r12
leaq (%r14,%r13), %rdx
incq %rdx
cmpq %rbx, %rdx
jb 0x10dc5
movq %rdx, %rcx
shrq %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x4, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x8, %rdx
orq %rcx, %rdx
movq %rdx, %rbx
shrq $0x10, %rbx
orq %rdx, %rbx
incq %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2330
leaq (%rax,%r14), %rdi
movq %r12, %rsi
movq %rax, %r12
movq %r13, %rdx
callq 0x2280
movq %r12, %rax
addq %r13, %r14
movb $0x0, (%r12,%r14)
movq -0x70(%rbp), %r13
movq -0x30(%rbp), %rdi
incq %r15
cmpq %r15, %rdi
jne 0x10d5c
jmp 0x10dfc
movq -0x30(%rbp), %rdi
movq %r14, -0x50(%rbp)
movq %rbx, -0x48(%rbp)
movq %rax, -0x40(%rbp)
movq -0x68(%rbp), %rcx
incq %rcx
movq -0x60(%rbp), %rbx
movq 0x10(%rbx), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movzbl %al, %eax
cmpq %rax, %rcx
movl -0x34(%rbp), %r12d
movq -0x58(%rbp), %r14
jb 0x10d0b
xorl %eax, %eax
testl %r12d, %r12d
jle 0x10e53
xorl %ecx, %ecx
movl (%r13,%rcx,4), %edx
notl %edx
shrl $0x1f, %edx
addl %edx, %eax
incq %rcx
cmpq %rcx, %rdi
jne 0x10e3b
shlq $0x28, %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq %rcx, %rsi
orq %rax, %rsi
jmp 0x10e72
movabsq $0xffffffffff, %rax     # imm = 0xFFFFFFFFFF
andq %rax, %rsi
movq %rsi, 0x10(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2050
movq -0x40(%rbp), %rax
movq %rax, 0x40(%rbx)
movaps -0x50(%rbp), %xmm0
movups %xmm0, 0x30(%rbx)
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq