// File: /workspace/github_c_makefile_star2_O2/genevalab[P]msmove/ms.c
// Function: main
int main(int argc, char *argv[])
{
	int i, k, howmany, segsites;
	int migflag;
	unsigned long int seed;
	double probss, tmrca, ttot;
	char **list, **tbsparamstrs;
	FILE *pf;

	ntbs = 0;
	tbsparamstrs = (char**)malloc((size_t)argc*sizeof(char*));

	for (i=0; i < argc; i++)
		printf("%s ", argv[i]);
	printf("\n");
	for (i=0; i < argc; i++)
		tbsparamstrs[i] = (char*)malloc(30*sizeof(char));
	for (i=1; i < argc; i++)
		if (strcmp(argv[i], "tbs") == 0)
			argv[i] = tbsparamstrs[ntbs++];

	count = 0;

	if (ntbs > 0)
		for (k = 0; k < ntbs; k++)
			scanf(" %s", tbsparamstrs[k]);
	getpars(argc, argv, &howmany);

	/* Initialize MT19937 rng from system clock */
	seed = (unsigned long int)time(0);
	init_genrand(seed);

	pf = stdout;
	fprintf(pf, "%ld\n", seed);

	if (pars.mp.segsitesin ==  0) 
	{
	     list = cmatrix(pars.cp.nsam, maxsites+1);
	     posit = (double*)malloc((size_t)maxsites*sizeof(double));
		 if (posit == NULL)
			 perror("Cannot allocate memory for posit");
	}
	else 
	{
	     list = cmatrix(pars.cp.nsam, pars.mp.segsitesin+1);
	     posit = (double*)malloc((size_t)pars.mp.segsitesin*sizeof(double));
		 if (posit == NULL)
			 perror("Cannot allocate memory for posit");
	     if (pars.mp.theta > 0) 
		 {
		    segfac = 1.0;
		    for (i=pars.mp.segsitesin; i > 1; i--)
				segfac *= i;
		 }
	}

	while (howmany-count++)
	{
		if ((ntbs > 0) && (count > 1)) 
		{
			for (k=0; k < ntbs; k++)
				if (scanf(" %s", tbsparamstrs[k]) == EOF)
					exit(EXIT_FAILURE);
			getpars(argc, argv, &howmany);
		}

		// generate coalescent history
		segsites = gensam(list, &probss, &tmrca, &ttot, &migflag);
		fprintf(pf, "\n//");
		if (migflag == 1)
			fprintf(pf, "*");
		if (ntbs > 0)
		{
			for (k=0; k < ntbs; k++)
				printf("\t%s", tbsparamstrs[k]);
		}
		printf("\n");
  		if (pars.mp.timeflag)
			fprintf(pf, "time:\t%lf\t%lf\n", tmrca, ttot);
        if ((segsites > 0) || (pars.mp.theta > 0))
		{
			if ((pars.mp.segsitesin > 0) && (pars.mp.theta > 0)) 
				fprintf(pf, "prob: %g\n", probss);
			fprintf(pf, "segsites: %d\n", segsites);
			if (segsites > 0)
				fprintf(pf, "positions: ");
			for (i=0; i < segsites; i++)
				fprintf(pf, "%6.4lf ", posit[i]);
			fprintf(pf, "\n");
			if (segsites > 0) 
				for (i=0; i < pars.cp.nsam; i++)
					fprintf(pf, "%s\n", list[i]); 
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
andl $0x0, 0x7e44(%rip)      # 0x9108
movq %rsi, -0x40(%rbp)
movl %edi, %ebx
movslq %edi, %r14
leaq (,%r14,8), %rdi
callq 0x1100
movq %rax, %r15
testl %r14d, %r14d
movl $0x0, %r12d
movl %ebx, -0x30(%rbp)
cmovgl %ebx, %r12d
leaq 0x4df0(%rip), %rbx      # 0x60e4
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x1313
movq -0x40(%rbp), %rax
movq (%rax,%r13,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incq %r13
jmp 0x12f7
pushq $0xa
popq %rdi
callq 0x1110
xorl %r13d, %r13d
pushq $0x1e
popq %rbx
cmpq %r13, %r12
je 0x1337
movq %rbx, %rdi
callq 0x1100
movq %rax, (%r15,%r13,8)
incq %r13
jmp 0x1321
pushq $0x1
popq %r13
movl 0x7dc6(%rip), %r12d     # 0x9108
movq -0x40(%rbp), %rbx
cmpq %r14, %r13
jge 0x137d
movq (%rbx,%r13,8), %rdi
leaq 0x4d92(%rip), %rsi      # 0x60e8
callq 0x1120
testl %eax, %eax
jne 0x1378
movslq %r12d, %rax
leal 0x1(%r12), %ecx
movl %ecx, 0x7d9b(%rip)      # 0x9108
movq (%r15,%rax,8), %rax
movq %rax, (%rbx,%r13,8)
movl %ecx, %r12d
incq %r13
jmp 0x1346
andl $0x0, 0x7d88(%rip)      # 0x910c
testl %r12d, %r12d
jle 0x13b5
leaq 0x4d5c(%rip), %rbx      # 0x60ec
xorl %r14d, %r14d
movslq %r12d, %rax
cmpq %rax, %r14
jge 0x13b5
movq (%r15,%r14,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10a0
incq %r14
movl 0x7d55(%rip), %r12d     # 0x9108
jmp 0x1393
leaq -0x34(%rbp), %rdx
movl -0x30(%rbp), %edi
movq -0x40(%rbp), %rsi
callq 0x16e4
xorl %edi, %edi
callq 0x1080
movq %rax, %rbx
movq %rax, %rdi
callq 0x3a9c
movq 0x7bea(%rip), %rax      # 0x8fc8
movq (%rax), %r12
leaq 0x4d08(%rip), %rsi      # 0x60f0
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
movl 0x7d6d(%rip), %esi      # 0x9168
movl 0x7d13(%rip), %edi      # 0x9114
testl %esi, %esi
je 0x1479
incl %esi
callq 0x259a
movq %rax, %r14
movslq 0x7d52(%rip), %rdi      # 0x9168
shlq $0x3, %rdi
callq 0x1100
movq %rax, 0x7d52(%rip)      # 0x9178
testq %rax, %rax
je 0x16ba
movsd 0x7d29(%rip), %xmm0     # 0x9160
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x14a8
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x7d2e(%rip)      # 0x9180
movsd 0x4bae(%rip), %xmm0     # 0x6008
movl 0x7d08(%rip), %eax      # 0x9168
cmpl $0x2, %eax
jl 0x14a8
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x7d0b(%rip)     # 0x9180
decl %eax
jmp 0x1460
movl 0x7c69(%rip), %esi      # 0x90e8
incl %esi
callq 0x259a
movq %rax, %r14
movl 0x7c59(%rip), %edi      # 0x90e8
shlq $0x3, %rdi
callq 0x1100
movq %rax, 0x7cd9(%rip)      # 0x9178
testq %rax, %rax
je 0x16cb
leaq 0x4c6b(%rip), %rbx      # 0x611a
movq %r14, -0x50(%rbp)
movl -0x34(%rbp), %ecx
movl 0x7c50(%rip), %eax      # 0x910c
leal 0x1(%rax), %edx
movl %edx, 0x7c47(%rip)      # 0x910c
cmpl %eax, %ecx
je 0x16a9
testl %eax, %eax
jle 0x1518
cmpl $0x0, 0x7c30(%rip)      # 0x9108
jle 0x1518
xorl %r13d, %r13d
movslq 0x7c24(%rip), %rax      # 0x9108
cmpq %rax, %r13
jge 0x1508
movq (%r15,%r13,8), %rsi
leaq 0x4bf8(%rip), %rdi      # 0x60ec
xorl %eax, %eax
callq 0x10a0
incq %r13
cmpl $-0x1, %eax
jne 0x14dd
jmp 0x16dc
movl -0x30(%rbp), %edi
movq -0x40(%rbp), %rsi
leaq -0x34(%rbp), %rdx
callq 0x16e4
movq %r14, %rdi
leaq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x2619
movl %eax, -0x2c(%rbp)
leaq 0x4bdc(%rip), %rdi      # 0x6116
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x11a0
cmpl $0x1, -0x44(%rbp)
jne 0x1559
pushq $0x2a
popq %rdi
movq %r12, %rsi
callq 0x10f0
movl 0x7ba9(%rip), %eax      # 0x9108
testl %eax, %eax
jle 0x1586
xorl %r13d, %r13d
cltq
cmpq %rax, %r13
jge 0x1586
movq (%r15,%r13,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incq %r13
movl 0x7b84(%rip), %eax      # 0x9108
jmp 0x1566
pushq $0xa
popq %rdi
callq 0x1110
cmpl $0x0, 0x7bdb(%rip)      # 0x9170
je 0x15b2
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movq %r12, %rdi
leaq 0x4b73(%rip), %rsi      # 0x611e
movb $0x2, %al
callq 0x1130
movsd 0x7ba6(%rip), %xmm0     # 0x9160
cmpl $0x0, -0x2c(%rbp)
jg 0x15ce
ucomisd 0x4a48(%rip), %xmm0     # 0x6010
jbe 0x14b3
cmpl $0x0, 0x7b93(%rip)      # 0x9168
jle 0x15f7
ucomisd 0x4a31(%rip), %xmm0     # 0x6010
jbe 0x15f7
movsd -0x68(%rbp), %xmm0
movq %r12, %rdi
leaq 0x4b3d(%rip), %rsi      # 0x612d
movb $0x1, %al
callq 0x1130
movq %r12, %rdi
leaq 0x4b36(%rip), %rsi      # 0x6137
movl -0x2c(%rbp), %r14d
movl %r14d, %edx
xorl %eax, %eax
callq 0x1130
testl %r14d, %r14d
jle 0x1629
leaq 0x4b2a(%rip), %rdi      # 0x6145
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x11a0
movl -0x2c(%rbp), %eax
testl %eax, %eax
movl $0x0, %r13d
cmovgl %eax, %r13d
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x1663
movq 0x7b31(%rip), %rax      # 0x9178
movsd (%rax,%r14,8), %xmm0
movq %r12, %rdi
leaq 0x4afa(%rip), %rsi      # 0x6151
movb $0x1, %al
callq 0x1130
incq %r14
jmp 0x163b
pushq $0xa
popq %rdi
movq %r12, %rsi
callq 0x10f0
cmpl $0x0, -0x2c(%rbp)
movq -0x50(%rbp), %r14
jle 0x14b3
xorl %r13d, %r13d
movslq 0x7a8e(%rip), %rax      # 0x9114
cmpq %rax, %r13
jge 0x14b3
movq (%r14,%r13,8), %rdx
movq %r12, %rdi
leaq 0x4bf5(%rip), %rsi      # 0x6292
xorl %eax, %eax
callq 0x1130
incq %r13
jmp 0x167f
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a34(%rip), %rdi      # 0x60f5
callq 0x1070
jmp 0x142f
leaq 0x4a23(%rip), %rdi      # 0x60f5
callq 0x1070
jmp 0x14a8
pushq $0x1
popq %rdi
callq 0x10d0