// File: /workspace/github_cpp_makefile_star2_O3/Ahhgust[P]STRaitRazor/parseConfig.cpp
// Function: parseConfig(char*, unsigned int*, char*)
vector<Config>*
parseConfig(char *file, unsigned *numStrs, char *filt) {


  if (file==NULL) {
    cerr << "Empty filename for the config file detected..." << endl;
    exit(EXIT_FAILURE);
  }


  ifstream myfile(file);
  
  if (! myfile.is_open() ) {
    cerr << "Failed to open " << file << " for reading" << endl;
    exit(EXIT_FAILURE);
  }
  
  vector<Config> *c = new vector<Config>;

  string line;
  *numStrs=0;
  
  while (getline(myfile, line)) {
    if (line[0] == COMMENT)
      continue;

    Config conf;
    conf.forwardCount=1; // defaults
    conf.reverseCount=1;

    stringstream ss(line);

    getline(ss, conf.locusName, SEP);
    getline(ss, conf.markerType, SEP);
    getline(ss, conf.forwardFlank, SEP);
    getline(ss, conf.reverseFlank, SEP);
    getline(ss, conf.strMotif, SEP);

    if (filt != NULL) {
      const char *type = conf.markerType.c_str();
      const char *f = filt;
      while (*f && *type) {
	if (*f != *type)
	  break;

	++f;
	++type;
      }
      if (*f && *type)
	continue; // grab the next record from the configuration file
    }

    // quantifier is tacked to the end
    // assume it's, EG:
    // GGATTTCCCCC,2   
    char lastChar = conf.forwardFlank[ conf.forwardFlank.length() -1];
    if (lastChar >= '0' && lastChar <= '9') {
      conf.forwardCount = lastChar - '0';
      conf.forwardFlank.resize( conf.forwardFlank.length() - 2);
    }

    lastChar = conf.reverseFlank[ conf.reverseFlank.length() -1];

    if (lastChar >= '0' && lastChar <= '9') {
      conf.reverseCount = lastChar - '0';
      conf.reverseFlank.resize( conf.reverseFlank.length() - 2);
    }

    conf.motifLength = conf.strMotif.length();
    conf.forwardLength = conf.forwardFlank.length();
    conf.reverseLength = conf.reverseFlank.length();

    if (conf.motifLength < 1 || conf.forwardLength < 1 || conf.reverseLength < 1) {
      cerr << "Problem with the lengths for locus:" << endl <<
	conf.locusName << endl;
    }
    
    if (! validDNAWithAmbiguities( conf.forwardFlank.c_str() ) ) {
	cerr << "Locus " << conf.locusName << " has illegal characters in " <<
	  conf.forwardFlank << endl;
	exit(EXIT_FAILURE);
    }


    if (! validDNAWithAmbiguities( conf.reverseFlank.c_str() ) ) {
	cerr << "Locus " << conf.locusName << " has illegal characters in " <<
	  conf.reverseFlank << endl;
	exit(EXIT_FAILURE);
    }
      
    if (! validDNA( conf.strMotif.c_str() ) ) {
	cerr << "Locus " << conf.locusName << " has illegal characters in motif " <<
	  conf.strMotif << endl;
	exit(EXIT_FAILURE);
    }

    // parsing integers (period and offset)
    string s;
    getline(ss, s, SEP);
    istringstream(s)  >>   conf.motifPeriod;

    getline(ss, s, SEP);
    istringstream(s)  >>   conf.motifOffset;

    if (conf.motifPeriod < 1) {
      cerr << "Locus " << conf.locusName << " has illegal spacing characteristics " <<
	conf.motifPeriod << "\t" << conf.motifOffset  << endl;
	exit(EXIT_FAILURE);
    }

    c->push_back(conf);

    ++(*numStrs);
  }

  
  return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x628, %rsp            # imm = 0x628
movq %rsi, 0xe0(%rsp)
testq %rdi, %rdi
je 0x8e35
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x420(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x34c0
leaq 0x498(%rsp), %rdi
callq 0x30a0
testb %al, %al
je 0x8e5a
movl $0x18, %edi
callq 0x32c0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %ebx, %ebx
movq %rax, 0xd8(%rsp)
movq %rbx, 0x10(%rax)
leaq 0xc8(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rbx, -0x8(%rax)
movb $0x0, (%rax)
movq 0xe0(%rsp), %rax
movl $0x0, (%rax)
movl $0x80, %eax
movq %rsp, %rcx
addq %rax, %rcx
movq %rcx, 0x110(%rsp)
leaq 0x298(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0xe8(%rsp)
movl $0x80045, %r12d         # imm = 0x80045
movl $0x14e1445, %r13d       # imm = 0x14E1445
movq 0x420(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x420(%rsp), %rbp
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %edx
movq %rbp, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x34d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
movq 0xb8(%rsp), %rdi
jne 0x8c3d
cmpb $0x23, (%rdi)
je 0x8717
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, 0x8(%rsp)
movb %bl, 0x10(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movb %bl, 0x30(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %rbx, 0x48(%rsp)
movb %bl, 0x50(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %rbx, 0x68(%rsp)
movb %bl, 0x70(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rbx, 0x88(%rsp)
movb %bl, 0x90(%rsp)
movl $0x10001, 0xb0(%rsp) # imm = 0x10001
leaq 0x298(%rsp), %r15
movq %r15, %rdi
leaq 0xb8(%rsp), %rsi
movl $0x18, %edx
callq 0x3400
movq %r15, %rdi
movq %rsp, %rsi
movl $0x9, %edx
callq 0x34d0
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
movq %r15, %rdi
movq 0x110(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
testq %r14, %r14
je 0x888a
movb (%r14), %al
testb %al, %al
je 0x888a
movq 0x20(%rsp), %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
cmpb %sil, %al
jne 0x8881
movb 0x1(%r14,%rdx), %al
incq %rdx
testb %al, %al
jne 0x886a
jmp 0x888a
testb %sil, %sil
jne 0x8b7f
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rsi
movzbl -0x1(%rax,%rsi), %eax
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x88bf
movzwl %ax, %eax
addl $-0x30, %eax
movw %ax, 0xb0(%rsp)
addq $-0x2, %rsi
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
callq 0x30d0
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rsi
movzbl -0x1(%rax,%rsi), %eax
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x88f9
movzwl %ax, %eax
addl $-0x30, %eax
movw %ax, 0xb2(%rsp)
addq $-0x2, %rsi
leaq 0x60(%rsp), %rdi
xorl %edx, %edx
callq 0x30d0
movq 0x68(%rsp), %rsi
movl 0x88(%rsp), %eax
movl %eax, 0xa8(%rsp)
movq 0x48(%rsp), %rcx
movl %ecx, 0xa0(%rsp)
movl %esi, 0xa4(%rsp)
testl %eax, %eax
setne %al
testl %ecx, %ecx
setne %cl
andb %al, %cl
testl %esi, %esi
setne %al
testb %al, %cl
jne 0x89b8
movl $0x23, %edx
movq 0x66b1(%rip), %rdi      # 0xeff0
leaq 0x34d0(%rip), %rsi      # 0xbe16
callq 0x3310
movq 0x669e(%rip), %rcx      # 0xeff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0x6680(%rip), %rdi      # 0xeff0
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rax, %rdi
callq 0x3310
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq 0x40(%rsp), %rax
movb (%rax), %cl
testb %cl, %cl
leaq 0x298(%rsp), %rdi
je 0x89f0
incq %rax
movzbl %cl, %ecx
addl $-0x41, %ecx
cmpl $0x18, %ecx
ja 0x8d4d
btl %ecx, %r13d
jae 0x8d4d
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x89ce
movq 0x60(%rsp), %rax
movb (%rax), %cl
testb %cl, %cl
je 0x8a20
incq %rax
movzbl %cl, %ecx
addl $-0x41, %ecx
cmpl $0x18, %ecx
ja 0x8cea
btl %ecx, %r13d
jae 0x8cea
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x89fe
movq 0x80(%rsp), %rax
movb (%rax), %cl
testb %cl, %cl
je 0x8a53
incq %rax
movzbl %cl, %ecx
addl $-0x41, %ecx
cmpl $0x13, %ecx
ja 0x8c81
btl %ecx, %r12d
jae 0x8c81
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x8a31
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq $0x0, 0xf8(%rsp)
movb $0x0, 0x100(%rsp)
leaq 0xf0(%rsp), %rbp
movq %rbp, %rsi
movl $0x9, %edx
callq 0x34d0
leaq 0x118(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movl $0x8, %edx
callq 0x3430
movq %r15, %rdi
leaq 0xac(%rsp), %rsi
callq 0x33b0
movq %r15, %rdi
movq 0x6502(%rip), %rsi      # 0xefc0
callq 0x3370
leaq 0x190(%rsp), %rdi
callq 0x30e0
leaq 0x298(%rsp), %rdi
leaq 0xf0(%rsp), %rbp
movq %rbp, %rsi
movl $0x9, %edx
callq 0x34d0
leaq 0x118(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movl $0x8, %edx
callq 0x3430
movq %r15, %rdi
leaq 0xae(%rsp), %rsi
callq 0x33b0
movq %r15, %rdi
movq 0x64a1(%rip), %rsi      # 0xefc0
callq 0x3370
leaq 0x190(%rsp), %rdi
callq 0x30e0
cmpw $0x0, 0xac(%rsp)
je 0x8db0
movq 0xd8(%rsp), %rdi
movq %rsp, %rsi
callq 0x8f98
movq 0xe0(%rsp), %rax
incl (%rax)
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x8b7f
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x298(%rsp), %rdi
movq 0x641a(%rip), %rsi      # 0xefa8
callq 0x31f0
movq 0xe8(%rsp), %rdi
callq 0x30e0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x8bc5
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x8be1
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x8bfd
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x8c19
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x32d0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x8717
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x8717
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x8c5a
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x420(%rsp), %rdi
callq 0x30b0
movq 0xd8(%rsp), %rax
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6368(%rip), %rdi      # 0xeff0
leaq 0x31ab(%rip), %rsi      # 0xbe3a
movl $0x6, %edx
callq 0x3310
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x6347(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x31a5(%rip), %rsi      # 0xbe5d
movl $0x21, %edx
movq %rax, %rdi
callq 0x3310
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %rbx, %rdi
callq 0x3310
movq %rax, %rdi
callq 0x3140
jmp 0x8e50
movq 0x62ff(%rip), %rdi      # 0xeff0
leaq 0x3142(%rip), %rsi      # 0xbe3a
movl $0x6, %edx
callq 0x3310
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x62de(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x3120(%rip), %rsi      # 0xbe41
movl $0x1b, %edx
movq %rax, %rdi
callq 0x3310
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq %rbx, %rdi
callq 0x3310
movq %rax, %rdi
callq 0x3140
jmp 0x8e50
movq 0x629c(%rip), %rdi      # 0xeff0
leaq 0x30df(%rip), %rsi      # 0xbe3a
movl $0x6, %edx
callq 0x3310
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x627b(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x30bd(%rip), %rsi      # 0xbe41
movl $0x1b, %edx
movq %rax, %rdi
callq 0x3310
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x3310
movq %rax, %rdi
callq 0x3140
jmp 0x8e50
movq 0x6239(%rip), %rdi      # 0xeff0
leaq 0x307c(%rip), %rsi      # 0xbe3a
movl $0x6, %edx
callq 0x3310
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x6218(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x3098(%rip), %rsi      # 0xbe7f
movl $0x25, %edx
movq %rax, %rdi
callq 0x3310
movzwl 0xac(%rsp), %esi
movq %rbx, %rdi
callq 0x31b0
movq %rax, %rbx
leaq 0x2445(%rip), %rsi      # 0xb253
movl $0x1, %edx
movq %rax, %rdi
callq 0x3310
movzwl 0xae(%rsp), %esi
movq %rbx, %rdi
callq 0x31b0
movq %rax, %rdi
callq 0x3140
jmp 0x8e50
movq 0x61b4(%rip), %rdi      # 0xeff0
leaq 0x2f97(%rip), %rsi      # 0xbdda
callq 0x32a0
movq %rax, %rdi
callq 0x3140
movl $0x1, %edi
callq 0x3340
movq 0x618f(%rip), %rdi      # 0xeff0
leaq 0x2ecc(%rip), %rsi      # 0xbd34
movl $0xf, %edx
callq 0x3310
movq %rbx, %rdi
callq 0x3130
movq 0x616f(%rip), %rdi      # 0xeff0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3310
movq 0x615d(%rip), %rdi      # 0xeff0
leaq 0x2f6f(%rip), %rsi      # 0xbe09
movl $0xc, %edx
callq 0x3310
movq 0x6145(%rip), %rdi      # 0xeff0
callq 0x3140
jmp 0x8e50
jmp 0x8eb4
movq %rax, %rbx
jmp 0x8f83
jmp 0x8ef7
jmp 0x8ec2
jmp 0x8ef7
movq %rax, %rbx
movq 0x60f4(%rip), %rsi      # 0xefc0
leaq 0x118(%rsp), %rdi
callq 0x3370
leaq 0x190(%rsp), %rdi
callq 0x30e0
jmp 0x8efa
jmp 0x8ef7
movq %rax, %rbx
leaq 0xc8(%rsp), %r14
jmp 0x8f5e
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x8f35
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x8f35
movq %rax, %rbx
leaq 0xc8(%rsp), %r14
jmp 0x8f66
jmp 0x8f32
jmp 0x8f32
movq %rax, %rbx
leaq 0xc8(%rsp), %r14
movq 0x6064(%rip), %rsi      # 0xefa8
leaq 0x298(%rsp), %rdi
callq 0x31f0
movq 0xe8(%rsp), %rdi
callq 0x30e0
movq %rsp, %rdi
callq 0x8fc8
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x8f83
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x420(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x3480