// File: /workspace/github_cpp_makefile_star2_O3/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
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 0x5148
movl %esi, %ebp
movq %rdi, %r14
leaq 0xff(%rdi), %rax
movq %rax, 0x30(%rsp)
leaq 0xaf8(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0xb0c(%rdi), %rax
movq %rax, 0x28(%rsp)
leaq 0xb20(%rdi), %rax
movq %rax, 0x20(%rsp)
leaq 0xb10(%rdi), %rax
movq %rax, 0x38(%rsp)
leaq 0xb28(%rdi), %rax
movq %rax, 0x10(%rsp)
movl $0x1, %r13d
leaq 0x17ca(%rip), %r15      # 0x6660
leaq 0x1773(%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 0x5122
movzbl 0x41(%rsp), %eax
addl $-0x63, %eax
cmpl $0x13, %eax
ja 0x5098
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
incl %r13d
cmpl %ebp, %r13d
je 0x5116
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x17fd(%rip), %rsi      # 0x66ef
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
cmpl $0x1, %eax
je 0x5098
jmp 0x510d
movq 0x38(%rsp), %rax
movl $0x1, (%rax)
jmp 0x5098
incl %r13d
cmpl %ebp, %r13d
je 0x50ce
movb $0x0, 0xf(%rsp)
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x17b7(%rip), %rsi      # 0x66f2
movq 0x10(%rsp), %rdx
leaq 0xf(%rsp), %rcx
xorl %eax, %eax
callq 0x2260
movzbl 0xf(%rsp), %ecx
movsd 0x169f(%rip), %xmm0     # 0x65f8
cmpl $0x47, %ecx
je 0x5087
cmpl $0x4b, %ecx
je 0x507f
cmpl $0x4d, %ecx
jne 0x5094
movsd 0x168c(%rip), %xmm0     # 0x6608
jmp 0x5087
movl $0x1, 0xb1c(%r14)
jmp 0x5098
incl %r13d
cmpl %ebp, %r13d
je 0x50fb
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
testl %eax, %eax
jne 0x5098
jmp 0x50f2
movl $0x1, 0xb14(%r14)
jmp 0x5098
movl $0x1, 0xb18(%r14)
jmp 0x5098
incl %r13d
cmpl %ebp, %r13d
je 0x50e9
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x16f5(%rip), %rsi      # 0x66ef
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
cmpl $0x1, %eax
je 0x5098
jmp 0x50e9
incl %r13d
cmpl %ebp, %r13d
je 0x5104
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x16c1(%rip), %rsi      # 0x66ef
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
cmpl $0x1, %eax
jne 0x50d7
movq 0x18(%rsp), %rax
movl (%rax), %eax
leal -0x20(%rax), %ecx
cmpl $-0x1d, %ecx
jb 0x50d7
andl $0x1, %eax
jne 0x5098
jmp 0x50d7
incl %r13d
cmpl %ebp, %r13d
je 0x50e0
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2260
testl %eax, %eax
jne 0x5098
jmp 0x50e0
movsd 0x1579(%rip), %xmm0     # 0x6600
movq 0x10(%rsp), %rcx
mulsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
testl %eax, %eax
je 0x50ce
incl %r13d
cmpl %ebp, %r13d
jl 0x4e9d
cmpb $0x0, (%r14)
je 0x5148
cmpb $0x0, 0xff(%r14)
je 0x5148
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1852(%rip), %rdi      # 0x6927
jmp 0x511d
leaq 0x19c4(%rip), %rdi      # 0x6aa2
jmp 0x511d
leaq 0x18e5(%rip), %rdi      # 0x69cc
jmp 0x511d
leaq 0x1788(%rip), %rdi      # 0x6878
jmp 0x511d
leaq 0x1864(%rip), %rdi      # 0x695d
jmp 0x511d
leaq 0x1890(%rip), %rdi      # 0x6992
jmp 0x511d
leaq 0x19e0(%rip), %rdi      # 0x6aeb
jmp 0x511d
leaq 0x18ec(%rip), %rdi      # 0x6a00
jmp 0x511d
leaq 0x1954(%rip), %rdi      # 0x6a71
callq 0x2410
movq (%rbx), %rsi
leaq 0x1537(%rip), %rdi      # 0x6663
xorl %eax, %eax
callq 0x2050
xorl %edi, %edi
callq 0x2300
leaq 0x19d4(%rip), %rdi      # 0x6b15
callq 0x2410
jmp 0x5133
movq (%rbx), %rsi
leaq 0x15a6(%rip), %rdi      # 0x66f8
jmp 0x512c