// File: /workspace/github_cpp_makefile_star2_O1/Mengjintao[P]SWAPCounter/src/sequence.cpp
// Function: parameter::getopt(int, char**)
void parameter::getopt(int argc, char **argv)
{
    this->fastaPath[0] = 0;
    this->outputPath[0] = 0;
    this->hashLength=23;
    this->cutoffThreshold = 5;
    this->groupProc = 1;
	
    this->kmerGraphFlag=0;
    this->JungGraphFlag=0;
    this->distGraphFlag=0;
    this->performanceFlag=0;
    this->refSize = 0;

    char comStr[100], localChar;
    int  ret;
    for(int i=1;i<argc;i++)
    {
	sscanf(argv[i], "%s", comStr);
 	if(comStr[0] != '-')  
	{
	  	printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
//	    MPI_Abort(MPI_COMM_WORLD,1);		
	    exit(0);
	}	
	switch(comStr[1])
	{
	    case 'h':
	    	printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		exit(0);
	    case 'v':
		printf("SWAP-Assembler version 0.5\n");
		exit(0);
	    case 'k':
		if(i+1 == argc) 
		{
		    printf("Error: -k needs a value for the kmer size\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		ret = sscanf(argv[i+1], "%d", &this->hashLength);
		i++;
		if(ret!=1 || this->hashLength<3 || this->hashLength>31 || this->hashLength%2!=1)	
		{
		    printf("Error: -k needs a value (odd number between 18 and 32) for the kmer size\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
	            exit(0);
		}
		break;	
	    case 'c':
		if(i+1 == argc) 
		{
		    printf("Error: -c needs a value for the cutoff threshold\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		ret = sscanf(argv[i+1], "%d", &this->cutoffThreshold);
		i++;
		if(ret!=1)	
		{
		    printf("Error: -c needs a value for the cutoff threshold (it is suggested to be 3~10 percent of the coverage of dataset)\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
	            exit(0);
		}
		break;
            case 'i':
		if(i+1 == argc) 
		{
		    printf("Error: -i needs a path for the file in fasta format\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		ret = sscanf(argv[i+1], "%s", this->fastaPath);
		i++;
		if(ret==0)
		{
		    printf("Error: -i needs a path for the file in fasta format\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		break;
            case 'o':
		if(i+1 == argc) 
		{
		    printf("Error: -o needs a directory name used for the output data\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		ret = sscanf(argv[i+1], "%s", this->outputPath);
		i++;
		if(ret==0)
		{
		    printf("Error: -o needs a directory path for the output data\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		break;
	    case 'r':
		if(i+1 == argc) 
		{
		    printf("Error: -r needs a reference size for the Bloom filter\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		localChar = 0;
		ret = sscanf(argv[i+1], "%lf%c", &this->refSize, &localChar);
		if(localChar=='G')	this->refSize *= (1024*1024*1024);
		if(localChar=='M')	this->refSize *= (1024*1024);
		if(localChar=='K')	this->refSize *= 1024;
		i++;
		if(ret==0)
		{
		    printf("Error: -r needs a reference size for the Bloom filter\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
	            exit(0);
		}
		break;
	    case 'g':
		if(i+1 == argc) 
		{
		    printf("Error: -g needs a value for the grouped processes number for reading input data (suggested value should be larger than 1 and less than the number of cores in computing nodes)\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
		    exit(0);
		}
		ret = sscanf(argv[i+1], "%d", &this->groupProc);
		i++;
		if(ret!=1)	
		{
		    printf("Error: -g needs a value for the grouped processes number for reading input data (suggested value should be larger than 1 and less than the number of cores in computing nodes)\n");
	    	    printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -g <grouped processes> -i <input Fasta data> -o <output data directory>\n",argv[0]);
	            exit(0);
		}
		break;
		this->groupProc = 4;
	    case 's':
		this->kmerGraphFlag = 1;
		break;
	    case 'j':
		this->JungGraphFlag = 1;
		break;
	    case 'd':
		this->distGraphFlag = 1;
		break;
	    case 'p':
		this->performanceFlag = 1;
		break;
		
	}	
    }
    if(this->fastaPath[0]==0 || this->outputPath[0]==0)
    {
        printf("Usage: %s -k <kmerlength> -r <reference size> -c <cutoff Threshod> -i <input Fasta data> -o <output data directory>\n",argv[0]);
        exit(0);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %rbx
movq %rdi, %r14
xorl %eax, %eax
movb %al, (%rdi)
movb %al, 0xff(%rdi)
movl $0x17, 0xaf8(%rdi)
movl $0x5, 0xb0c(%rdi)
movl $0x1, 0xb20(%rdi)
movq $0x0, 0xb28(%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xb10(%rdi)
cmpl $0x2, %esi
jl 0x4ff0
movl %esi, %ebp
leaq 0xff(%r14), %rax
movq %rax, 0x30(%rsp)
leaq 0xaf8(%r14), %rax
movq %rax, 0x18(%rsp)
leaq 0xb0c(%r14), %rax
movq %rax, 0x28(%rsp)
leaq 0xb20(%r14), %rax
movq %rax, 0x20(%rsp)
leaq 0xb10(%r14), %rax
movq %rax, 0x38(%rsp)
leaq 0xb28(%r14), %rax
movq %rax, 0x10(%rsp)
movl $0x1, %r13d
leaq 0x187e(%rip), %r15      # 0x6660
leaq 0x1827(%rip), %r12      # 0x6610
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
cmpb $0x2d, 0x40(%rsp)
jne 0x506e
movzbl 0x41(%rsp), %eax
addl $-0x63, %eax
cmpl $0x13, %eax
ja 0x4fe4
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
incl %r13d
cmpl %ebp, %r13d
je 0x5062
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x18b1(%rip), %rsi      # 0x66ef
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
cmpl $0x1, %eax
je 0x4fe4
jmp 0x5059
movq 0x38(%rsp), %rax
movl $0x1, (%rax)
jmp 0x4fe4
incl %r13d
cmpl %ebp, %r13d
je 0x501a
movb $0x0, 0xf(%rsp)
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x186b(%rip), %rsi      # 0x66f2
movq 0x10(%rsp), %rdx
leaq 0xf(%rsp), %rcx
xorl %eax, %eax
callq 0x2260
movzbl 0xf(%rsp), %ecx
movsd 0x1753(%rip), %xmm0     # 0x65f8
cmpl $0x47, %ecx
je 0x4fd3
cmpl $0x4b, %ecx
je 0x4fcb
cmpl $0x4d, %ecx
jne 0x4fe0
movsd 0x1740(%rip), %xmm0     # 0x6608
jmp 0x4fd3
movl $0x1, 0xb1c(%r14)
jmp 0x4fe4
incl %r13d
cmpl %ebp, %r13d
je 0x5047
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
testl %eax, %eax
jne 0x4fe4
jmp 0x503e
movl $0x1, 0xb14(%r14)
jmp 0x4fe4
movl $0x1, 0xb18(%r14)
jmp 0x4fe4
incl %r13d
cmpl %ebp, %r13d
je 0x5035
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x17a9(%rip), %rsi      # 0x66ef
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
cmpl $0x1, %eax
je 0x4fe4
jmp 0x5035
incl %r13d
cmpl %ebp, %r13d
je 0x5050
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x1775(%rip), %rsi      # 0x66ef
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
cmpl $0x1, %eax
jne 0x5023
movq 0x18(%rsp), %rax
movl (%rax), %eax
leal -0x20(%rax), %ecx
cmpl $-0x1d, %ecx
jb 0x5023
andl $0x1, %eax
jne 0x4fe4
jmp 0x5023
incl %r13d
cmpl %ebp, %r13d
je 0x502c
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2260
testl %eax, %eax
jne 0x4fe4
jmp 0x502c
movsd 0x162d(%rip), %xmm0     # 0x6600
movq 0x10(%rsp), %rcx
mulsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
testl %eax, %eax
je 0x501a
incl %r13d
cmpl %ebp, %r13d
jl 0x4de9
cmpb $0x0, (%r14)
je 0x5094
cmpb $0x0, 0xff(%r14)
je 0x5094
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1906(%rip), %rdi      # 0x6927
jmp 0x5069
leaq 0x1a78(%rip), %rdi      # 0x6aa2
jmp 0x5069
leaq 0x1999(%rip), %rdi      # 0x69cc
jmp 0x5069
leaq 0x183c(%rip), %rdi      # 0x6878
jmp 0x5069
leaq 0x1918(%rip), %rdi      # 0x695d
jmp 0x5069
leaq 0x1944(%rip), %rdi      # 0x6992
jmp 0x5069
leaq 0x1a94(%rip), %rdi      # 0x6aeb
jmp 0x5069
leaq 0x19a0(%rip), %rdi      # 0x6a00
jmp 0x5069
leaq 0x1a08(%rip), %rdi      # 0x6a71
callq 0x2410
movq (%rbx), %rsi
leaq 0x15eb(%rip), %rdi      # 0x6663
xorl %eax, %eax
callq 0x2050
xorl %edi, %edi
callq 0x2300
leaq 0x1a88(%rip), %rdi      # 0x6b15
callq 0x2410
jmp 0x507f
movq (%rbx), %rsi
leaq 0x165a(%rip), %rdi      # 0x66f8
jmp 0x5078