// File: /workspace/github_c_makefile_star2_O3/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 0x10ff8
movq %rcx, %r12
movl %edx, %r13d
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 0xef2e
movq 0x10(%rbx), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movl %r13d, %edi
testb %al, %al
je 0x10fc6
xorl %ecx, %ecx
movq %r14, -0x58(%rbp)
movq %rbx, -0x60(%rbp)
movq %r12, -0x70(%rbp)
movl %r13d, -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 0xcb8d
movl 0x4(%r14,%r15,8), %esi
movl 0x8(%r14,%r15,8), %edx
movq %rbx, %rdi
callq 0xc837
movq %r14, %rcx
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %rbx
movq -0x40(%rbp), %rax
testl %r13d, %r13d
jle 0x10f8c
leaq (%rcx,%r15,8), %rcx
movq %rcx, -0x78(%rbp)
xorl %r15d, %r15d
movq -0x30(%rbp), %rdi
movslq (%r12,%r15,4), %r13
testq %r13, %r13
js 0x10f7e
movq -0x78(%rbp), %rcx
movslq 0xc(%rcx), %r12
imulq %r12, %r13
addq 0x10(%rcx), %r13
leaq (%r14,%r12), %rdx
incq %rdx
cmpq %rbx, %rdx
jb 0x10f58
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
addq %r12, %r14
movq %r13, %rsi
movq %rax, %r13
movq %r12, %rdx
callq 0x2280
movq %r13, %rax
movb $0x0, (%r13,%r14)
movq -0x70(%rbp), %r12
movq -0x30(%rbp), %rdi
incq %r15
cmpq %r15, %rdi
jne 0x10ef0
jmp 0x10f90
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), %r13d
movq -0x58(%rbp), %r14
jb 0x10e9f
xorl %eax, %eax
testl %r13d, %r13d
jle 0x10fe6
xorl %ecx, %ecx
movl (%r12,%rcx,4), %edx
notl %edx
shrl $0x1f, %edx
addl %edx, %eax
incq %rcx
cmpq %rcx, %rdi
jne 0x10fcf
shlq $0x28, %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq %rcx, %rsi
orq %rax, %rsi
jmp 0x11005
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