// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/vcf.c
// Function: vcf_format1
int vcf_format1(const bcf_hdr_t *h, const bcf1_t *v, kstring_t *s)
{
	uint8_t *ptr = (uint8_t*)v->shared.s;
	int i;
	s->l = 0;
	bcf_unpack((bcf1_t*)v, BCF_UN_ALL);
	kputs(h->id[BCF_DT_CTG][v->rid].key, s); // CHROM
	kputc('\t', s); kputw(v->pos + 1, s); // POS
	kputc('\t', s); kputs(v->d.id, s); // ID
	kputc('\t', s); // REF
	if (v->n_allele > 0) kputs(v->d.allele[0], s);
	else kputc('.', s);
	kputc('\t', s); // ALT
	if (v->n_allele > 1) {
		for (i = 1; i < v->n_allele; ++i) {
			if (i > 1) kputc(',', s);
			kputs(v->d.allele[i], s);
		}
	} else kputc('.', s);
	kputc('\t', s); // QUAL
	if (memcmp(&v->qual, &bcf_float_missing, 4) == 0) kputc('.', s); // QUAL
	else ksprintf(s, "%g", v->qual);
	kputc('\t', s); // FILTER
	if (v->d.n_flt) {
		for (i = 0; i < v->d.n_flt; ++i) {
			if (i) kputc(';', s);
			kputs(h->id[BCF_DT_ID][v->d.flt[i]].key, s);
		}
	} else kputc('.', s);
	kputc('\t', s); // INFO
	if (v->n_info) {
		for (i = 0; i < v->n_info; ++i) {
			bcf_info_t *z = &v->d.info[i];
			if (i) kputc(';', s);
			kputs(h->id[BCF_DT_ID][z->key].key, s);
			if (z->len <= 0) continue;
			kputc('=', s);
			if (z->len == 1) {
				if (z->type == BCF_BT_FLOAT) ksprintf(s, "%g", z->v1.f);
				else if (z->type != BCF_BT_CHAR) kputw(z->v1.i, s);
				else kputc(z->v1.i, s);
			} else bcf_fmt_array(s, z->len, z->type, z->vptr);
		}
	} else kputc('.', s);
	// FORMAT and individual information
	ptr = (uint8_t*)v->indiv.s;
	if (v->n_sample && v->n_fmt) { // FORMAT
		int i, j, l, gt_i = -1;
		bcf_fmt_t *fmt;
		fmt = (bcf_fmt_t*)alloca(v->n_fmt * sizeof(bcf_fmt_t));
		ptr = bcf_unpack_fmt_core(ptr, v->n_sample, v->n_fmt, fmt);
		for (i = 0; i < (int)v->n_fmt; ++i) {
			kputc(i? ':' : '\t', s);
			kputs(h->id[BCF_DT_ID][fmt[i].id].key, s);
			if (strcmp(h->id[BCF_DT_ID][fmt[i].id].key, "GT") == 0) gt_i = i;
		}
		for (j = 0; j < v->n_sample; ++j) {
			kputc('\t', s);
			for (i = 0; i < (int)v->n_fmt; ++i) {
				bcf_fmt_t *f = &fmt[i];
				if (i) kputc(':', s);
				if (gt_i == i) {
					int8_t *x = (int8_t*)(f->p + j * f->size); // FIXME: does not work with n_alt >= 64
					for (l = 0; l < f->n && x[l] != bcf_int8_end; ++l) {
						if (l) kputc("/|"[x[l]&1], s);
						if (x[l]>>1) kputw((x[l]>>1) - 1, s);
						else kputc('.', s);
					}
					if (l == 0) kputc('.', s);
				} else bcf_fmt_array(s, f->n, f->type, f->p + j * f->size);
			}
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r15
andq $0x0, (%rdx)
pushq $0xf
popq %rsi
movq %r13, %rdi
callq 0xc692
movq 0x20(%r15), %rax
movslq (%r13), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rdi
movq %rbx, %rsi
callq 0xab21
pushq $0x9
popq %r12
movl %r12d, %edi
movq %rbx, %rsi
callq 0xacb6
movl 0x4(%r13), %edi
incl %edi
movq %rbx, %rsi
callq 0xab44
movl %r12d, %edi
movq %rbx, %rsi
callq 0xacb6
movq 0x60(%r13), %rdi
movq %rbx, %rsi
callq 0xab21
movl %r12d, %edi
movq %rbx, %rsi
callq 0xacb6
cmpw $0x0, 0x12(%r13)
je 0xcab9
movq 0x68(%r13), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0xab21
jmp 0xcac4
pushq $0x2e
popq %rdi
movq %rbx, %rsi
callq 0xacb6
pushq $0x9
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movq 0x10(%r13), %rax
testl $0xfffe0000, %eax       # imm = 0xFFFE0000
je 0xcb14
pushq $0x1
popq %r14
pushq $0x2c
popq %r12
shrl $0x10, %eax
cmpq %rax, %r14
jae 0xcb1f
cmpq $0x2, %r14
jb 0xcafb
movl %r12d, %edi
movq %rbx, %rsi
callq 0xacb6
movq 0x68(%r13), %rax
movq (%rax,%r14,8), %rdi
movq %rbx, %rsi
callq 0xab21
incq %r14
movq 0x10(%r13), %rax
jmp 0xcae2
pushq $0x2e
popq %rdi
movq %rbx, %rsi
callq 0xacb6
pushq $0x9
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movl 0xc(%r13), %eax
cmpl 0x1484c(%rip), %eax     # 0x21380
je 0xcb4a
leaq 0xc(%r13), %rax
cvtss2sd (%rax), %xmm0
movq %rbx, %rdi
movb $0x1, %al
callq 0xb2c3
jmp 0xcb55
pushq $0x2e
popq %rdi
movq %rbx, %rsi
callq 0xacb6
pushq $0x9
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movl 0x5c(%r13), %eax
testl %eax, %eax
je 0xcbab
xorl %r14d, %r14d
pushq $0x3b
popq %r12
cltq
cmpq %rax, %r14
jge 0xcbb6
testq %r14, %r14
je 0xcb86
movl %r12d, %edi
movq %rbx, %rsi
callq 0xacb6
movq 0x18(%r15), %rax
movq 0x70(%r13), %rcx
movslq (%rcx,%r14,4), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rdi
movq %rbx, %rsi
callq 0xab21
incq %r14
movl 0x5c(%r13), %eax
jmp 0xcb6f
pushq $0x2e
popq %rdi
movq %rbx, %rsi
callq 0xacb6
pushq $0x9
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movq 0x10(%r13), %rax
testw %ax, %ax
movq %r13, -0x38(%rbp)
je 0xcc90
pushq $0x10
popq %r14
xorl %r12d, %r12d
movzwl %ax, %ecx
cmpq %rcx, %r12
jae 0xcc9f
movq 0x78(%r13), %r13
testq %r12, %r12
je 0xcbf9
pushq $0x3b
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movq 0x18(%r15), %rax
movslq -0x10(%r13,%r14), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rdi
movq %rbx, %rsi
callq 0xab21
cmpl $0x0, -0x8(%r13,%r14)
jle 0xcc7c
pushq $0x3d
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movl -0xc(%r13,%r14), %edx
movl -0x8(%r13,%r14), %esi
cmpl $0x1, %esi
jne 0xcc51
cmpl $0x7, %edx
je 0xcc60
cmpl $0x5, %edx
jne 0xcc6f
cvtss2sd -0x4(%r13,%r14), %xmm0
movq %rbx, %rdi
movb $0x1, %al
callq 0xb2c3
jmp 0xcc7c
movq (%r13,%r14), %rcx
movq %rbx, %rdi
callq 0xb0b7
jmp 0xcc7c
movl -0x4(%r13,%r14), %edi
movq %rbx, %rsi
callq 0xacb6
jmp 0xcc7c
movl -0x4(%r13,%r14), %edi
movq %rbx, %rsi
callq 0xab44
incq %r12
movq -0x38(%rbp), %r13
movq 0x10(%r13), %rax
addq $0x18, %r14
jmp 0xcbd9
pushq $0x2e
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movq 0x10(%r13), %rax
movq %rax, %rsi
shrq $0x28, %rsi
je 0xce87
shrq $0x20, %rax
movl %eax, %edx
andl $0xff, %edx
je 0xce87
movq 0x40(%r13), %rdi
movzbl %al, %eax
imull $0x18, %eax, %eax
movq %rsp, %r13
addl $0xf, %eax
andl $-0x10, %eax
subq %rax, %r13
movq %r13, %rsp
movq %r13, %rcx
callq 0xc52c
pushq $-0x1
popq %rax
movl %eax, -0x2c(%rbp)
xorl %r12d, %r12d
movq %r13, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
cmpq %rcx, %r12
jae 0xcd59
testq %r12, %r12
pushq $0x3a
popq %rdi
pushq $0x9
popq %rax
cmovel %eax, %edi
movq %rbx, %rsi
callq 0xacb6
movq 0x18(%r15), %rax
movslq (%r13), %r14
shlq $0x4, %r14
movq (%rax,%r14), %rdi
movq %rbx, %rsi
callq 0xab21
movq 0x18(%r15), %rax
movq (%rax,%r14), %rax
cmpb $0x47, (%rax)
jne 0xcd50
cmpb $0x54, 0x1(%rax)
jne 0xcd50
cmpb $0x0, 0x2(%rax)
movl -0x2c(%rbp), %eax
cmovel %r12d, %eax
movl %eax, -0x2c(%rbp)
incq %r12
addq $0x18, %r13
jmp 0xccec
movl -0x2c(%rbp), %r15d
xorl %r13d, %r13d
movq -0x38(%rbp), %r14
movq %r15, -0x40(%rbp)
shrq $0x28, %rax
cmpl %eax, %r13d
jae 0xce87
pushq $0x9
popq %rdi
movq %rbx, %rsi
callq 0xacb6
movslq %r13d, %rax
movq %rax, -0x48(%rbp)
xorl %r12d, %r12d
movl %r13d, -0x2c(%rbp)
movq 0x10(%r14), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
cmpq %rcx, %r12
jae 0xce7f
testq %r12, %r12
je 0xcdb5
pushq $0x3a
popq %rdi
movq %rbx, %rsi
callq 0xacb6
imulq $0x18, %r12, %rax
addq -0x50(%rbp), %rax
cmpq %r15, %r12
jne 0xce3b
movl 0x4(%rax), %r14d
testl %r14d, %r14d
movl $0x0, %ecx
cmovlel %ecx, %r14d
movl 0xc(%rax), %ecx
imull %r13d, %ecx
movslq %ecx, %r13
addq 0x10(%rax), %r13
xorl %r15d, %r15d
cmpq %r15, %r14
je 0xce5b
movzbl (%r13,%r15), %eax
cmpq $0x81, %rax
je 0xce58
testq %r15, %r15
je 0xce16
andl $0x1, %eax
leaq 0xc612(%rip), %rcx      # 0x19417
movsbl (%rax,%rcx), %edi
movq %rbx, %rsi
callq 0xacb6
movb (%r13,%r15), %al
cmpb $0x2, %al
jae 0xce27
pushq $0x2e
popq %rdi
movq %rbx, %rsi
callq 0xacb6
jmp 0xce36
sarb %al
decb %al
movsbl %al, %edi
movq %rbx, %rsi
callq 0xab44
incq %r15
jmp 0xcde3
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
movslq 0xc(%rax), %rcx
imulq -0x48(%rbp), %rcx
addq 0x10(%rax), %rcx
movq %rbx, %rdi
callq 0xb0b7
jmp 0xce77
movl %r15d, %r14d
testl %r14d, %r14d
movq -0x38(%rbp), %r14
movq -0x40(%rbp), %r15
movl -0x2c(%rbp), %r13d
jne 0xce77
pushq $0x2e
popq %rdi
movq %rbx, %rsi
callq 0xacb6
incq %r12
jmp 0xcd8e
incl %r13d
jmp 0xcd68
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq