// File: /workspace/github_cpp_makefile_star2_O2/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
movl %esi, %ebp
movq %rdi, %r14
xorl %eax, %eax
movb %al, (%rdi)
leaq 0xff(%rdi), %rcx
movq %rcx, 0x30(%rsp)
movb %al, 0xff(%rdi)
leaq 0xaf8(%rdi), %rax
movq %rax, 0x18(%rsp)
movl $0x17, 0xaf8(%rdi)
leaq 0xb0c(%rdi), %rax
movq %rax, 0x28(%rsp)
movl $0x5, 0xb0c(%rdi)
leaq 0xb20(%rdi), %rax
movq %rax, 0x20(%rsp)
movl $0x1, 0xb20(%rdi)
leaq 0xb10(%rdi), %rax
movq %rax, 0x38(%rsp)
leaq 0xb28(%rdi), %rax
movq %rax, 0x10(%rsp)
andq $0x0, 0xb28(%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xb10(%rdi)
pushq $0x1
popq %r13
leaq 0x1aec(%rip), %r15      # 0x6660
leaq 0x1a95(%rip), %r12      # 0x6610
cmpl %ebp, %r13d
jge 0x4d83
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
xorl %eax, %eax
callq 0x2220
cmpb $0x2d, 0x40(%rsp)
jne 0x4e01
movzbl 0x41(%rsp), %eax
addl $-0x63, %eax
cmpl $0x13, %eax
ja 0x4d7b
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
incl %r13d
cmpl %ebp, %r13d
je 0x4dda
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x1b16(%rip), %rsi      # 0x66ef
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x2220
cmpl $0x1, %eax
je 0x4d7b
jmp 0x4dec
movq 0x38(%rsp), %rax
movl $0x1, (%rax)
jmp 0x4d7b
incl %r13d
cmpl %ebp, %r13d
je 0x4dad
movb $0x0, 0xf(%rsp)
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x1ad0(%rip), %rsi      # 0x66f2
movq 0x10(%rsp), %rdx
leaq 0xf(%rsp), %rcx
xorl %eax, %eax
callq 0x2220
movzbl 0xf(%rsp), %ecx
movsd 0x19b8(%rip), %xmm0     # 0x65f8
cmpl $0x47, %ecx
je 0x4d6a
cmpl $0x4b, %ecx
je 0x4d62
cmpl $0x4d, %ecx
jne 0x4d77
movsd 0x19a5(%rip), %xmm0     # 0x6608
jmp 0x4d6a
movl $0x1, 0xb1c(%r14)
jmp 0x4d7b
incl %r13d
cmpl %ebp, %r13d
je 0x4dd1
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x2220
testl %eax, %eax
jne 0x4d7b
jmp 0x4df5
movl $0x1, 0xb14(%r14)
jmp 0x4d7b
movl $0x1, 0xb18(%r14)
jmp 0x4d7b
incl %r13d
cmpl %ebp, %r13d
je 0x4dc8
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x1a0e(%rip), %rsi      # 0x66ef
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2220
cmpl $0x1, %eax
je 0x4d7b
jmp 0x4dc8
incl %r13d
cmpl %ebp, %r13d
je 0x4de3
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x19da(%rip), %rsi      # 0x66ef
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x2220
cmpl $0x1, %eax
jne 0x4db6
movq 0x18(%rsp), %rax
movl (%rax), %eax
leal -0x20(%rax), %ecx
cmpl $-0x1d, %ecx
jb 0x4db6
andl $0x1, %eax
jne 0x4d7b
jmp 0x4db6
incl %r13d
cmpl %ebp, %r13d
je 0x4dbf
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2220
testl %eax, %eax
jne 0x4d7b
jmp 0x4dbf
movsd 0x1896(%rip), %xmm0     # 0x6600
movq 0x10(%rsp), %rcx
mulsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
testl %eax, %eax
je 0x4dad
incl %r13d
jmp 0x4b7b
cmpb $0x0, (%r14)
je 0x4e27
cmpb $0x0, 0xff(%r14)
je 0x4e27
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b73(%rip), %rdi      # 0x6927
jmp 0x4dfc
leaq 0x1ce5(%rip), %rdi      # 0x6aa2
jmp 0x4dfc
leaq 0x1c06(%rip), %rdi      # 0x69cc
jmp 0x4dfc
leaq 0x1aa9(%rip), %rdi      # 0x6878
jmp 0x4dfc
leaq 0x1bba(%rip), %rdi      # 0x6992
jmp 0x4dfc
leaq 0x1c90(%rip), %rdi      # 0x6a71
jmp 0x4dfc
leaq 0x1d01(%rip), %rdi      # 0x6aeb
jmp 0x4dfc
leaq 0x1c0d(%rip), %rdi      # 0x6a00
jmp 0x4dfc
leaq 0x1b61(%rip), %rdi      # 0x695d
callq 0x23d0
movq (%rbx), %rsi
leaq 0x1858(%rip), %rdi      # 0x6663
xorl %eax, %eax
callq 0x2040
xorl %edi, %edi
callq 0x22c0
leaq 0x1cf5(%rip), %rdi      # 0x6b15
callq 0x23d0
jmp 0x4e12
movq (%rbx), %rsi
leaq 0x18c7(%rip), %rdi      # 0x66f8
jmp 0x4e0b
nop