// File: /workspace/github_c_makefile_star2_O1/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, 0x8a9b(%rip)      # 0xa118
movslq %edi, %rbx
leaq (,%rbx,8), %rdi
callq 0x1120
movq %rax, %r15
movl %r14d, -0x2c(%rbp)
movl %r14d, %r14d
testl %ebx, %ebx
jle 0x16bc
leaq 0x5a42(%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 0x16a5
movq %r13, -0x38(%rbp)
movl $0xa, %edi
callq 0x1130
cmpl $0x0, -0x2c(%rbp)
jle 0x16e8
xorl %ebx, %ebx
movl $0x1e, %edi
callq 0x1120
movq %rax, (%r15,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x16d2
cmpl $0x2, -0x2c(%rbp)
movq -0x38(%rbp), %rbx
jl 0x1733
movl 0x8a1f(%rip), %r13d     # 0xa118
movl $0x1, %r12d
movq (%rbx,%r12,8), %rdi
leaq 0x59de(%rip), %rsi      # 0x70e8
callq 0x1140
testl %eax, %eax
jne 0x172b
movslq %r13d, %rax
leal 0x1(%r13), %ecx
movl %ecx, 0x89f8(%rip)      # 0xa118
movq (%r15,%rax,8), %rax
movq %rax, (%rbx,%r12,8)
movl %ecx, %r13d
incq %r12
cmpq %r12, %r14
jne 0x16ff
movl $0x0, 0x89df(%rip)      # 0xa11c
cmpl $0x0, 0x89d4(%rip)      # 0xa118
jle 0x176d
leaq 0x599f(%rip), %rbx      # 0x70ec
xorl %r14d, %r14d
movq (%r15,%r14,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10c0
incq %r14
movslq 0x89b0(%rip), %rax      # 0xa118
cmpq %rax, %r14
jl 0x1750
leaq -0x30(%rbp), %rdx
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
callq 0x1b00
xorl %edi, %edi
callq 0x10a0
movq %rax, %rbx
movq %rax, %rdi
callq 0x4250
movq 0x8832(%rip), %rax      # 0x9fc8
movq (%rax), %r12
leaq 0x5950(%rip), %rsi      # 0x70f0
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
movl 0x89c5(%rip), %esi      # 0xa178
movl 0x896b(%rip), %edi      # 0xa124
testl %esi, %esi
je 0x1843
incl %esi
callq 0x2a6f
movq %rax, %rbx
movslq 0x89a6(%rip), %rdi      # 0xa178
shlq $0x3, %rdi
callq 0x1120
movq %rax, 0x89a6(%rip)      # 0xa188
testq %rax, %rax
je 0x1ad4
movsd 0x897d(%rip), %xmm0     # 0xa170
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq %rbx, %rdi
jbe 0x1875
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x897f(%rip)      # 0xa190
movl 0x8961(%rip), %eax      # 0xa178
cmpl $0x2, %eax
jl 0x1875
movsd 0x57e4(%rip), %xmm0     # 0x7008
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
leal -0x1(%rax), %ecx
cmpl $0x2, %eax
movl %ecx, %eax
jg 0x1824
movsd %xmm0, 0x894f(%rip)     # 0xa190
jmp 0x1875
movl 0x88af(%rip), %esi      # 0xa0f8
incl %esi
callq 0x2a6f
movq %rax, %rbx
movl 0x889f(%rip), %edi      # 0xa0f8
shlq $0x3, %rdi
callq 0x1120
movq %rax, 0x891f(%rip)      # 0xa188
testq %rax, %rax
je 0x1ae5
movq %rbx, %rdi
movl -0x30(%rbp), %ecx
movl 0x889e(%rip), %eax      # 0xa11c
leal 0x1(%rax), %edx
movl %edx, 0x8895(%rip)      # 0xa11c
cmpl %eax, %ecx
je 0x1ac3
leaq 0x5884(%rip), %rbx      # 0x711a
movq %rdi, -0x48(%rbp)
movq %r15, -0x50(%rbp)
testl %eax, %eax
jle 0x18f7
cmpl $0x0, 0x886f(%rip)      # 0xa118
jle 0x18f7
movq %rdi, %r13
cmpl $0x0, 0x8863(%rip)      # 0xa118
jle 0x18e4
xorl %r14d, %r14d
movq (%r15,%r14,8), %rsi
leaq 0x5827(%rip), %rdi      # 0x70ec
xorl %eax, %eax
callq 0x10c0
cmpl $-0x1, %eax
je 0x1af6
incq %r14
movslq 0x8839(%rip), %rax      # 0xa118
cmpq %rax, %r14
jl 0x18ba
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x1b00
movq %r13, %rdi
leaq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rcx
leaq -0x3c(%rbp), %r8
callq 0x2af1
movl %eax, %r14d
movl $0x3, %esi
movl $0x1, %edx
leaq 0x57f6(%rip), %rdi      # 0x7116
movq %r12, %rcx
callq 0x11c0
cmpl $0x1, -0x3c(%rbp)
jne 0x193b
movl $0x2a, %edi
movq %r12, %rsi
callq 0x1110
cmpl $0x0, 0x87d6(%rip)      # 0xa118
jle 0x1964
xorl %r13d, %r13d
movq (%r15,%r13,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incq %r13
movslq 0x87b9(%rip), %rax      # 0xa118
cmpq %rax, %r13
jl 0x1947
movl $0xa, %edi
callq 0x1130
cmpl $0x0, 0x880b(%rip)      # 0xa180
je 0x1992
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movq %r12, %rdi
leaq 0x5793(%rip), %rsi      # 0x711e
movb $0x2, %al
callq 0x1150
movsd 0x87d6(%rip), %xmm0     # 0xa170
testl %r14d, %r14d
movq -0x48(%rbp), %rdi
movq %r12, %r15
jg 0x19b4
ucomisd 0x5662(%rip), %xmm0     # 0x7010
jbe 0x1aa2
cmpl $0x0, 0x87bd(%rip)      # 0xa178
movq %r15, %r12
jle 0x19e0
ucomisd 0x5648(%rip), %xmm0     # 0x7010
jbe 0x19e0
movsd -0x68(%rbp), %xmm0
movq %r12, %rdi
leaq 0x5754(%rip), %rsi      # 0x712d
movb $0x1, %al
callq 0x1150
movq %r12, %rdi
leaq 0x574d(%rip), %rsi      # 0x7137
movl %r14d, %edx
xorl %eax, %eax
callq 0x1150
testl %r14d, %r14d
jle 0x1a12
movl $0xb, %esi
movl $0x1, %edx
leaq 0x573b(%rip), %rdi      # 0x7145
movq %r12, %rcx
callq 0x11c0
movl %r14d, %r15d
testl %r14d, %r14d
leaq 0x5732(%rip), %rbx      # 0x7151
jle 0x1a49
movl %r15d, %r13d
xorl %r14d, %r14d
movq 0x875a(%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 0x1a27
movl $0xa, %edi
movq %r12, %rsi
callq 0x1110
testl %r15d, %r15d
movq -0x48(%rbp), %rdi
leaq 0x56b6(%rip), %rbx      # 0x711a
leaq 0x5827(%rip), %r13      # 0x7292
movq %r12, %r15
jle 0x1aa2
cmpl $0x0, 0x86ad(%rip)      # 0xa124
jle 0x1aa2
xorl %r14d, %r14d
movq (%rdi,%r14,8), %rdx
movq %rdi, %r12
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x1150
movq %r12, %rdi
incq %r14
movslq 0x8687(%rip), %rax      # 0xa124
cmpq %rax, %r14
jl 0x1a7c
movl -0x30(%rbp), %ecx
movl 0x8671(%rip), %eax      # 0xa11c
leal 0x1(%rax), %edx
movl %edx, 0x8668(%rip)      # 0xa11c
cmpl %eax, %ecx
movq %r15, %r12
movq -0x50(%rbp), %r15
jne 0x189e
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x561a(%rip), %rdi      # 0x70f5
callq 0x1090
jmp 0x17eb
leaq 0x5609(%rip), %rdi      # 0x70f5
callq 0x1090
jmp 0x1872
movl $0x1, %edi
callq 0x10f0