// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/view.c
// Function: main_getalt
int main_getalt(int argc, char *argv[])
{
	int c;
	char *fn;
	BGZF *fp;
	bcf1_t *b;
	bcf_hdr_t *h;
	kstring_t s = {0,0,0};

	while ((c = getopt(argc, argv, "")) >= 0) {
	}
	if (argc - optind == 0) {
		fprintf(stderr, "Usage: bgt getalt <bgt-base>\n");
		return 1;
	}

	fn = (char*)calloc(strlen(argv[optind]) + 5, 1);
	sprintf(fn, "%s.bcf", argv[optind]);
	fp = bgzf_open(fn, "r");
	free(fn);
	assert(fp);

	h = bcf_hdr_read(fp);
	b = bcf_init1();
	while (bcf_read1(fp, b) >= 0) {
		char *ref, *alt;
		int l_ref, l_alt, i, min_l;
		bcf_get_ref_alt1(b, &l_ref, &ref, &l_alt, &alt);
		min_l = l_ref < l_alt? l_ref : l_alt;
		for (i = 0; i < min_l && ref[i] == alt[i]; ++i);
		s.l = 0;
		kputs(h->id[BCF_DT_CTG][b->rid].key, &s);
		kputc(':', &s); kputw(b->pos + 1 + i, &s);
		kputc(':', &s); kputw(b->rlen - i, &s);
		kputc(':', &s); kputsn(alt + i, l_alt - i, &s);
		puts(s.s);
	}
	bcf_destroy1(b);
	bcf_hdr_destroy(h);

	bgzf_close(fp);
	free(s.s);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rsp)
leaq 0x15cb5(%rip), %r14     # 0x19794
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x23e0
testl %eax, %eax
jns 0x3adf
movq 0x1d4a1(%rip), %rax     # 0x20f98
movslq (%rax), %rax
cmpl %ebp, %eax
je 0x3cbe
movq (%rbx,%rax,8), %rbx
movq %rbx, %rdi
callq 0x2170
leaq 0x5(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x2220
movq %rax, %r14
leaq 0x14834(%rip), %rsi     # 0x18358
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2400
leaq 0x156c0(%rip), %rsi     # 0x191f8
movq %r14, %rdi
callq 0x3ef4
movq %rax, %rbx
movq %r14, %rdi
callq 0x2050
testq %rbx, %rbx
je 0x3cdf
movq %rbx, %rdi
callq 0xa5ac
movq %rax, 0x10(%rsp)
xorl %eax, %eax
callq 0xa6a8
movq %rax, %r15
leaq 0x30(%rsp), %r13
pushq $0x3a
popq %rbp
xorl %r12d, %r12d
movq %rbx, 0x20(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa71b
testl %eax, %eax
js 0x3c8b
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0xd45d
movl 0xc(%rsp), %eax
movl 0x8(%rsp), %r14d
cmpl %r14d, %eax
cmovll %eax, %r14d
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rcx
testl %r14d, %r14d
movl $0x0, %edx
cmovlel %edx, %r14d
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x3be7
movb (%rax,%r12), %dl
cmpb (%rcx,%r12), %dl
jne 0x3bec
incq %r12
jmp 0x3bd3
movq %r14, %r12
jmp 0x3bef
movl %r12d, %r14d
andq $0x0, 0x30(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movslq (%r15), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rbx
movq %rbx, %rdi
callq 0x2170
movq %rbx, %rdi
movl %eax, %esi
movq %r13, %rdx
callq 0x3e5f
movl %ebp, %edi
movq %r13, %rsi
callq 0x3cfe
movl 0x4(%r15), %eax
leal (%r14,%rax), %edi
incl %edi
movq %r13, %rsi
callq 0x3d81
movl %ebp, %edi
movq %r13, %rsi
callq 0x3cfe
movl 0x8(%r15), %edi
subl %r14d, %edi
movq %r13, %rsi
callq 0x3d81
movl %ebp, %edi
movq %r13, %rsi
callq 0x3cfe
addq 0x18(%rsp), %r12
movl 0x8(%rsp), %esi
subl %r14d, %esi
movq %r12, %rdi
movq %r13, %rdx
callq 0x3e5f
movq 0x40(%rsp), %r12
movq %r12, %rdi
callq 0x20e0
movq 0x20(%rsp), %rbx
jmp 0x3b7b
movq %r15, %rdi
callq 0xa6b5
movq 0x10(%rsp), %rdi
callq 0xa500
movq %rbx, %rdi
callq 0x4ddc
movq %r12, %rdi
callq 0x2050
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1d333(%rip), %rax     # 0x20ff8
movq (%rax), %rcx
leaq 0x1511c(%rip), %rdi     # 0x18deb
pushq $0x1d
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
pushq $0x1
popq %rax
jmp 0x3caf
leaq 0x15123(%rip), %rdi     # 0x18e09
leaq 0x1511f(%rip), %rsi     # 0x18e0c
leaq 0x1511f(%rip), %rcx     # 0x18e13
movl $0xcd, %edx
callq 0x21b0