// File: /workspace/github_c_makefile_star2_O1/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, %r15d
leaq 0x1af34(%rip), %rdx     # 0x1e391
callq 0x23d0
testl %eax, %eax
js 0x34f7
movl $0x1, %ebx
xorl %r12d, %r12d
leaq 0x1af18(%rip), %r13     # 0x1e391
movl $0x0, 0x14(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
cmpl $0x52, %eax
jle 0x34b7
cmpl $0x53, %eax
je 0x34af
cmpl $0x62, %eax
je 0x34c8
cmpl $0x74, %eax
jne 0x34d4
movq 0x22b09(%rip), %rax     # 0x25fb0
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl $0x1, %r12d
jmp 0x34d4
cmpl $0x30, %eax
je 0x34d2
cmpl $0x4d, %eax
jne 0x34d4
movl $0x1, %ebp
jmp 0x34d4
movl $0x1, 0x14(%rsp)
jmp 0x34d4
xorl %ebx, %ebx
movl %r15d, %edi
movq %r14, %rsi
movq %r13, %rdx
callq 0x23d0
testl %eax, %eax
jns 0x348c
testl %r12d, %r12d
sete %al
cmpl $0x0, 0x14(%rsp)
sete %r12b
jmp 0x350c
movb $0x1, %r12b
movq $0x0, 0x8(%rsp)
movl $0x1, %ebx
xorl %ebp, %ebp
movb $0x1, %al
movq 0x22a85(%rip), %rcx     # 0x25f98
movslq (%rcx), %r13
cmpl %r15d, %r13d
je 0x3654
movw $0x72, 0x20(%rsp)
testb %al, %al
je 0x353b
leaq 0x20(%rsp), %rdi
callq 0x2170
movw $0x62, 0x20(%rsp,%rax)
movq (%r14,%r13,8), %rdi
leaq 0x20(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x6414
testq %rax, %rax
je 0x3660
movq %rax, 0x8(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x12f62
movq %rax, %r15
movw $0x77, 0x18(%rsp)
testb %r12b, %r12b
jne 0x3586
leaq 0x18(%rsp), %rdi
callq 0x2170
movw $0x62, 0x18(%rsp,%rax)
leaq 0x1af27(%rip), %rdi     # 0x1e4b4
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x6414
movq %rax, %r12
movq 0x28(%r15), %rsi
movq %rax, %rdi
callq 0xc2f1
movq 0x28(%r15), %rdi
leaq 0x1ad0d(%rip), %rdx     # 0x1e2c0
xorl %esi, %esi
callq 0x106de
movl %eax, %r13d
testl %eax, %eax
jns 0x35e6
movq 0x28(%r15), %rdi
leaq 0x1acf7(%rip), %rsi     # 0x1e2c3
callq 0xb6db
movq 0x28(%r15), %rdi
leaq 0x1ace4(%rip), %rdx     # 0x1e2c0
xorl %esi, %esi
callq 0x106de
movl %eax, %r13d
xorl %eax, %eax
callq 0xb9db
movq %rax, %r14
movq %r15, %rdi
callq 0x130ba
testq %rax, %rax
je 0x3621
movq %rax, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %r13d, %ecx
movl %ebx, %r8d
callq 0x13289
movq 0x28(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x1068d
jmp 0x35f0
movq %r14, %rdi
callq 0xb9ea
movq %r12, %rdi
callq 0x660f
movq %r15, %rdi
callq 0x13052
movq 0x8(%rsp), %rdi
callq 0x660f
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 0x3645
leaq 0x1a9f8(%rip), %rdi     # 0x1e05f
leaq 0x1ac0f(%rip), %rsi     # 0x1e27d
leaq 0x1ae20(%rip), %rcx     # 0x1e495
movl $0xa5, %edx
callq 0x21b0
nop