// File: /workspace/github_c_makefile_star2_O2/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, %r15
movl %edi, %r12d
movq $0x0, 0x10(%rsp)
pushq $0x1
popq %rbx
leaq 0x15529(%rip), %r13     # 0x18391
xorl %ebp, %ebp
movl $0x0, 0xc(%rsp)
xorl %r14d, %r14d
movl %r12d, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0x23e0
testl %eax, %eax
js 0x2ec7
cmpl $0x30, %eax
je 0x2ebe
cmpl $0x4d, %eax
je 0x2ec2
cmpl $0x53, %eax
je 0x2eaf
cmpl $0x62, %eax
je 0x2eb5
cmpl $0x74, %eax
jne 0x2e75
movq 0x1e109(%rip), %rax     # 0x20fb0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %r14
jmp 0x2e75
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
jmp 0x2e75
xorl %ebx, %ebx
jmp 0x2e75
pushq $0x1
popq %rbp
jmp 0x2e75
movq 0x1e0ca(%rip), %rax     # 0x20f98
movslq (%rax), %r13
cmpl %r12d, %r13d
je 0x3012
movw $0x72, 0x20(%rsp)
testl %r14d, %r14d
jne 0x2ef7
leaq 0x20(%rsp), %rdi
callq 0x2170
movw $0x62, 0x20(%rsp,%rax)
movq (%r15,%r13,8), %rdi
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x5e33
testq %rax, %rax
je 0x30b7
movq %rax, 0x10(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0xebec
movq %rax, %r15
movw $0x77, 0x18(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x2f44
leaq 0x18(%rsp), %rdi
callq 0x2170
movw $0x62, 0x18(%rsp,%rax)
leaq 0x15569(%rip), %rdi     # 0x184b4
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x5e33
movq %rax, %r12
movq 0x28(%r15), %rsi
movq %rax, %rdi
callq 0xad39
movq 0x28(%r15), %rdi
leaq 0x1534f(%rip), %rdx     # 0x182c0
xorl %esi, %esi
callq 0xcee5
movl %eax, %r13d
testl %eax, %eax
jns 0x2fa4
movq 0x28(%r15), %rdi
leaq 0x15339(%rip), %rsi     # 0x182c3
callq 0xa387
movq 0x28(%r15), %rdi
leaq 0x15326(%rip), %rdx     # 0x182c0
xorl %esi, %esi
callq 0xcee5
movl %eax, %r13d
xorl %eax, %eax
callq 0xa6a8
movq %rax, %r14
movq %r15, %rdi
callq 0xed42
testq %rax, %rax
je 0x2fdf
movq %rax, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %r13d, %ecx
movl %ebx, %r8d
callq 0xeec7
movq 0x28(%r15), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0xce98
jmp 0x2fae
movq %r14, %rdi
callq 0xa6b5
movq %r12, %rdi
callq 0x601f
movq %r15, %rdi
callq 0xece2
movq 0x10(%rsp), %rdi
callq 0x601f
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1dfdf(%rip), %r14     # 0x20ff8
movq (%r14), %rcx
leaq 0x15375(%rip), %rdi     # 0x18398
pushq $0x2f
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x2410
movq (%r14), %rcx
leaq 0x15183(%rip), %rdi     # 0x181be
pushq $0x9
popq %rsi
movq %rbx, %rdx
callq 0x2410
movq (%r14), %rcx
leaq 0x15378(%rip), %rdi     # 0x183c8
pushq $0x16
popq %rsi
movq %rbx, %rdx
callq 0x2410
movq (%r14), %rcx
leaq 0x1537a(%rip), %rdi     # 0x183df
pushq $0x15
popq %rsi
movq %rbx, %rdx
callq 0x2410
movq (%r14), %rcx
leaq 0x1537b(%rip), %rdi     # 0x183f5
pushq $0x37
popq %rsi
movq %rbx, %rdx
callq 0x2410
movq (%r14), %rcx
leaq 0x1539e(%rip), %rdi     # 0x1842d
pushq $0x39
popq %rsi
movq %rbx, %rdx
callq 0x2410
movq (%r14), %rcx
leaq 0x153c3(%rip), %rdi     # 0x18467
pushq $0x2d
popq %rsi
movq %rbx, %rdx
callq 0x2410
pushq $0x1
popq %rax
jmp 0x3003
leaq 0x14fa1(%rip), %rdi     # 0x1805f
leaq 0x151b8(%rip), %rsi     # 0x1827d
leaq 0x153c9(%rip), %rcx     # 0x18495
movl $0xa5, %edx
callq 0x21b0
nop