// File: /workspace/github_c_makefile_star2_O3/lh3[P]bgt/import.c
// Function: main_atomize
int main_atomize(int argc, char *argv[])
{
	int c, vcf_in = 0, bcf_out = 0, write_M = 0, id_GT = -1, use_missing = 1;
	char moder[8], modew[8], *fn_ref = 0;
	htsFile *in, *out;
	bcf_atombuf_t *ab;
	const bcf_atom_t *a;
	bcf1_t *b;

	while ((c = getopt(argc, argv, "0bSMt:")) >= 0) {
		if (c == 'S') vcf_in = 1;
		else if (c == 't') vcf_in = 1, fn_ref = optarg;
		else if (c == 'b') bcf_out = 1;
		else if (c == 'M') write_M = 1;
		else if (c == '0') use_missing = 0;
	}
	if (optind == argc) {
		fprintf(stderr, "Usage: bgt atomize [options] <in.bcf>|<in.vcf>\n");
		fprintf(stderr, "Options:\n");
		fprintf(stderr, "  -b       BCF output\n");
		fprintf(stderr, "  -S       VCF input\n");
		fprintf(stderr, "  -t FILE  list of contig names and lengths (force -S)\n");
		fprintf(stderr, "  -M       use <M> at a multi-allelic site (override -0)\n");
		fprintf(stderr, "  -0       use 0 at a multi-allelic genotype\n");
		return 1;
	}

	strcpy(moder, "r");
	if (vcf_in == 0) strcat(moder, "b");
	in = hts_open(argv[optind], moder, fn_ref);
	assert(in);
	ab = bcf_atombuf_init(in, 0);

	strcpy(modew, "w");
	if (bcf_out) strcat(modew, "b");
	out = hts_open("-", modew, 0);
	vcf_hdr_write(out, ab->h);

	id_GT = bcf_id2int(ab->h, BCF_DT_ID, "GT");
	if (id_GT < 0) {
		bcf_hdr_append(ab->h, "##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">");
		id_GT = bcf_id2int(ab->h, BCF_DT_ID, "GT");
	}

	b = bcf_init1();
	while ((a = bcf_atom_read(ab)) != 0) {
		bcf_atom2bcf2(a, b, write_M, id_GT, use_missing);
		vcf_write1(out, ab->h, b);
	}
	bcf_destroy1(b);

	hts_close(out);
	bcf_atombuf_destroy(ab);
	hts_close(in);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %r12d
leaq 0x1af0c(%rip), %rdx     # 0x1e391
callq 0x23d0
testl %eax, %eax
js 0x353d
movl $0x1, %ebx
xorl %r15d, %r15d
leaq 0x1aef0(%rip), %r13     # 0x1e391
movl $0x0, 0xc(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x10(%rsp)
cmpl $0x52, %eax
jle 0x34df
cmpl $0x53, %eax
je 0x34d7
cmpl $0x62, %eax
je 0x34f0
cmpl $0x74, %eax
jne 0x34fc
movq 0x22ae1(%rip), %rax     # 0x25fb0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl $0x1, %r15d
jmp 0x34fc
cmpl $0x30, %eax
je 0x34fa
cmpl $0x4d, %eax
jne 0x34fc
movl $0x1, %ebp
jmp 0x34fc
movl $0x1, 0xc(%rsp)
jmp 0x34fc
xorl %ebx, %ebx
movl %r12d, %edi
movq %r14, %rsi
movq %r13, %rdx
callq 0x23d0
testl %eax, %eax
jns 0x34b4
movq 0x22a83(%rip), %rax     # 0x25f98
movl (%rax), %r13d
cmpl %r12d, %r13d
je 0x368f
cmpl $0x0, 0xc(%rsp)
sete %r12b
movw $0x72, 0x18(%rsp)
testl %r15d, %r15d
movq 0x10(%rsp), %r15
jne 0x3575
jmp 0x3564
movq 0x22a54(%rip), %rax     # 0x25f98
movl (%rax), %r13d
cmpl %r12d, %r13d
je 0x368f
movw $0x72, 0x18(%rsp)
movb $0x1, %r12b
xorl %r15d, %r15d
movl $0x1, %ebx
xorl %ebp, %ebp
leaq 0x18(%rsp), %rdi
callq 0x2170
movw $0x62, 0x18(%rsp,%rax)
movslq %r13d, %rax
movq (%r14,%rax,8), %rdi
leaq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0x6553
testq %rax, %rax
je 0x369b
movq %rax, 0x10(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x13331
movq %rax, %r15
movw $0x77, 0x20(%rsp)
testb %r12b, %r12b
jne 0x35c1
leaq 0x20(%rsp), %rdi
callq 0x2170
movw $0x62, 0x20(%rsp,%rax)
leaq 0x1aeec(%rip), %rdi     # 0x1e4b4
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x6553
movq %rax, %r12
movq 0x28(%r15), %rsi
movq %rax, %rdi
callq 0xc494
movq 0x28(%r15), %rdi
leaq 0x1acd2(%rip), %rdx     # 0x1e2c0
xorl %esi, %esi
callq 0x1088a
movl %eax, %r13d
testl %eax, %eax
jns 0x3621
movq 0x28(%r15), %rdi
leaq 0x1acbc(%rip), %rsi     # 0x1e2c3
callq 0xb817
movq 0x28(%r15), %rdi
leaq 0x1aca9(%rip), %rdx     # 0x1e2c0
xorl %esi, %esi
callq 0x1088a
movl %eax, %r13d
xorl %eax, %eax
callq 0xbb1a
movq %rax, %r14
movq %r15, %rdi
callq 0x13483
testq %rax, %rax
je 0x365c
movq %rax, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %r13d, %ecx
movl %ebx, %r8d
callq 0x1365a
movq 0x28(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x10839
jmp 0x362b
movq %r14, %rdi
callq 0xbb29
movq %r12, %rdi
callq 0x677e
movq %r15, %rdi
callq 0x1341b
movq 0x10(%rsp), %rdi
callq 0x677e
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x25ef
movl $0x1, %eax
jmp 0x3680
leaq 0x1a9bd(%rip), %rdi     # 0x1e05f
leaq 0x1abd4(%rip), %rsi     # 0x1e27d
leaq 0x1ade5(%rip), %rcx     # 0x1e495
movl $0xa5, %edx
callq 0x21b0
nop