// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, %r13
movl %edi, %r14d
movl $0x0, 0x8aab(%rip)      # 0xa118
movslq %edi, %rbx
leaq (,%rbx,8), %rdi
callq 0x1120
movq %rax, %r15
testl %ebx, %ebx
movq %r13, -0x38(%rbp)
movl %r14d, -0x2c(%rbp)
jle 0x172a
movl %r14d, %r14d
leaq 0x5a4a(%rip), %rbx      # 0x70e4
xorl %r12d, %r12d
movq (%r13,%r12,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incq %r12
cmpq %r12, %r14
jne 0x169d
movl $0xa, %edi
callq 0x1130
cmpl $0x0, -0x2c(%rbp)
jle 0x1734
xorl %ebx, %ebx
movl $0x1e, %edi
callq 0x1120
movq %rax, (%r15,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x16c6
movl 0x8a35(%rip), %r12d     # 0xa118
cmpl $0x1, -0x2c(%rbp)
je 0x173b
movl $0x1, %r13d
movq -0x38(%rbp), %rbx
movq (%rbx,%r13,8), %rdi
leaq 0x59ea(%rip), %rsi      # 0x70e8
callq 0x1140
testl %eax, %eax
jne 0x1720
movslq %r12d, %rax
leal 0x1(%r12), %ecx
movl %ecx, 0x8a03(%rip)      # 0xa118
movq (%r15,%rax,8), %rax
movq %rax, (%rbx,%r13,8)
movl %ecx, %r12d
incq %r13
cmpq %r13, %r14
jne 0x16f3
jmp 0x173b
movl $0xa, %edi
callq 0x1130
movl 0x89dd(%rip), %r12d     # 0xa118
movl $0x0, 0x89d7(%rip)      # 0xa11c
testl %r12d, %r12d
jle 0x1771
leaq 0x599b(%rip), %rbx      # 0x70ec
xorl %r14d, %r14d
movq (%r15,%r14,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10c0
incq %r14
movslq 0x89ac(%rip), %rax      # 0xa118
cmpq %rax, %r14
jl 0x1754
leaq -0x30(%rbp), %rdx
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
callq 0x1af2
xorl %edi, %edi
callq 0x10a0
movq %rax, %rbx
movq %rax, %rdi
callq 0x42bc
movq 0x882e(%rip), %rax      # 0x9fc8
movq (%rax), %r12
leaq 0x594c(%rip), %rsi      # 0x70f0
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
movl 0x89c1(%rip), %esi      # 0xa178
movl 0x8967(%rip), %edi      # 0xa124
testl %esi, %esi
je 0x1848
incl %esi
callq 0x2ad8
movq %rax, %rbx
movslq 0x89a2(%rip), %rdi      # 0xa178
shlq $0x3, %rdi
callq 0x1120
movq %rax, 0x89a2(%rip)      # 0xa188
testq %rax, %rax
je 0x1ac6
movsd 0x8979(%rip), %xmm0     # 0xa170
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq %rbx, -0x40(%rbp)
jbe 0x187b
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x897a(%rip)      # 0xa190
movl 0x895c(%rip), %eax      # 0xa178
cmpl $0x2, %eax
jl 0x187b
movsd 0x57df(%rip), %xmm0     # 0x7008
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
leal -0x1(%rax), %ecx
cmpl $0x2, %eax
movl %ecx, %eax
ja 0x1829
movsd %xmm0, 0x894a(%rip)     # 0xa190
jmp 0x187b
movl 0x88aa(%rip), %esi      # 0xa0f8
incl %esi
callq 0x2ad8
movq %rax, %rbx
movl 0x889a(%rip), %edi      # 0xa0f8
shlq $0x3, %rdi
callq 0x1120
movq %rax, 0x891a(%rip)      # 0xa188
testq %rax, %rax
movq %rbx, -0x40(%rbp)
je 0x1ad7
movl -0x30(%rbp), %ecx
movl 0x8898(%rip), %eax      # 0xa11c
leal 0x1(%rax), %edx
movl %edx, 0x888f(%rip)      # 0xa11c
cmpl %eax, %ecx
je 0x1ab5
leaq 0x5850(%rip), %r14      # 0x70ec
leaq 0x5877(%rip), %rbx      # 0x711a
movq %r15, -0x50(%rbp)
testl %eax, %eax
jle 0x18ed
cmpl $0x0, 0x8866(%rip)      # 0xa118
jle 0x18ed
xorl %r13d, %r13d
movq (%r15,%r13,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x10c0
cmpl $-0x1, %eax
je 0x1ae8
incq %r13
movslq 0x8840(%rip), %rax      # 0xa118
cmpq %rax, %r13
jl 0x18b7
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x1af2
movq -0x40(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x2b5a
movl %eax, %r14d
movl $0x3, %esi
movl $0x1, %edx
leaq 0x57fc(%rip), %rdi      # 0x7116
movq %r12, %rcx
callq 0x11c0
cmpl $0x1, -0x44(%rbp)
jne 0x1935
movl $0x2a, %edi
movq %r12, %rsi
callq 0x1110
cmpl $0x0, 0x87dc(%rip)      # 0xa118
jle 0x195e
xorl %r13d, %r13d
movq (%r15,%r13,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incq %r13
movslq 0x87bf(%rip), %rax      # 0xa118
cmpq %rax, %r13
jl 0x1941
movl $0xa, %edi
callq 0x1130
cmpl $0x0, 0x8811(%rip)      # 0xa180
je 0x198c
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movq %r12, %rdi
leaq 0x5799(%rip), %rsi      # 0x711e
movb $0x2, %al
callq 0x1150
movsd 0x87dc(%rip), %xmm0     # 0xa170
testl %r14d, %r14d
movq %r12, %r15
jg 0x19aa
ucomisd 0x566c(%rip), %xmm0     # 0x7010
jbe 0x1a8d
cmpl $0x0, 0x87c7(%rip)      # 0xa178
movq %r15, %r12
jle 0x19d6
ucomisd 0x5652(%rip), %xmm0     # 0x7010
jbe 0x19d6
movsd -0x68(%rbp), %xmm0
movq %r12, %rdi
leaq 0x575e(%rip), %rsi      # 0x712d
movb $0x1, %al
callq 0x1150
movq %r12, %rdi
leaq 0x5757(%rip), %rsi      # 0x7137
movl %r14d, %edx
xorl %eax, %eax
callq 0x1150
movl %r14d, %r15d
testl %r14d, %r14d
leaq 0x575a(%rip), %rbx      # 0x7151
jle 0x1a3a
movl $0xb, %esi
movl $0x1, %edx
leaq 0x573b(%rip), %rdi      # 0x7145
movq %r12, %rcx
callq 0x11c0
movl %r15d, %r13d
xorl %r14d, %r14d
movq 0x8769(%rip), %rax      # 0xa188
movsd (%rax,%r14,8), %xmm0
movq %r12, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x1150
incq %r14
cmpq %r14, %r13
jne 0x1a18
movl $0xa, %edi
movq %r12, %rsi
callq 0x1110
testl %r15d, %r15d
movq -0x40(%rbp), %r14
leaq 0x56c5(%rip), %rbx      # 0x711a
movq %r12, %r15
leaq 0x5833(%rip), %r12      # 0x7292
jle 0x1a8d
cmpl $0x0, 0x86bc(%rip)      # 0xa124
jle 0x1a8d
xorl %r13d, %r13d
movq (%r14,%r13,8), %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1150
incq %r13
movslq 0x869c(%rip), %rax      # 0xa124
cmpq %rax, %r13
jl 0x1a6d
movl -0x30(%rbp), %ecx
movl 0x8686(%rip), %eax      # 0xa11c
leal 0x1(%rax), %edx
movl %edx, 0x867d(%rip)      # 0xa11c
cmpl %eax, %ecx
leaq 0x5644(%rip), %r14      # 0x70ec
movq %r15, %r12
movq -0x50(%rbp), %r15
jne 0x18a7
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5628(%rip), %rdi      # 0x70f5
callq 0x1090
jmp 0x17ef
leaq 0x5617(%rip), %rdi      # 0x70f5
callq 0x1090
jmp 0x187b
movl $0x1, %edi
callq 0x10f0