// File: /workspace/github_cpp_makefile_star2_O1/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 $0x638, %rsp            # imm = 0x638
movq %rdx, (%rsp)
movq %rsi, 0xe8(%rsp)
testq %rdi, %rdi
je 0x8d58
movq %rdi, %r14
leaq 0x2a8(%rsp), %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x34c0
leaq 0x320(%rsp), %rdi
callq 0x30a0
testb %al, %al
je 0x8d7d
movl $0x18, %edi
callq 0x32c0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %ebx, %ebx
movq %rax, 0xe0(%rsp)
movq %rbx, 0x10(%rax)
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rbx, -0x8(%rax)
movb $0x0, (%rax)
movq 0xe8(%rsp), %rax
movl $0x0, (%rax)
movl $0x80, %eax
leaq 0x8(%rsp), %rcx
addq %rax, %rcx
movq %rcx, 0x120(%rsp)
leaq 0x4b0(%rsp), %r13
addq %r13, %rax
movq %rax, 0x118(%rsp)
movq (%rsp), %rax
incq %rax
movq %rax, 0x110(%rsp)
leaq 0x128(%rsp), %rbp
movl $0x80045, %r12d         # imm = 0x80045
movl $0x14e1445, %r15d       # imm = 0x14E1445
movq 0x2a8(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x2a8(%rsp), %r14
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %edx
movq %r14, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x34d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
movq 0xc0(%rsp), %rdi
jne 0x8b5c
cmpb $0x23, (%rdi)
je 0x8625
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movb %bl, 0x18(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movb %bl, 0x38(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq %rbx, 0x50(%rsp)
movb %bl, 0x58(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
movq %rbx, 0x70(%rsp)
movb %bl, 0x78(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %rbx, 0x90(%rsp)
movb %bl, 0x98(%rsp)
movl $0x10001, 0xb8(%rsp) # imm = 0x10001
movq %r13, %rdi
leaq 0xc0(%rsp), %rsi
movl $0x18, %edx
callq 0x3400
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
movq %r13, %rdi
leaq 0x28(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
movq %r13, %rdi
leaq 0x48(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
movq %r13, %rdi
leaq 0x68(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
movq %r13, %rdi
movq 0x120(%rsp), %rsi
movl $0x9, %edx
callq 0x34d0
cmpq $0x0, (%rsp)
je 0x87b0
movq (%rsp), %rax
movb (%rax), %sil
testb %sil, %sil
sete %cl
je 0x87b0
movq 0x28(%rsp), %rax
movq 0x110(%rsp), %rdx
cmpb (%rax), %sil
jne 0x87a3
movb (%rdx), %sil
testb %sil, %sil
sete %cl
je 0x87b0
leaq 0x1(%rax), %rdi
incq %rdx
cmpb 0x1(%rax), %sil
movq %rdi, %rax
je 0x8788
testb %cl, %cl
jne 0x87b0
cmpb $0x0, (%rax)
jne 0x8aa2
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rsi
movzbl -0x1(%rax,%rsi), %eax
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x87e5
movzwl %ax, %eax
addl $-0x30, %eax
movw %ax, 0xb8(%rsp)
addq $-0x2, %rsi
leaq 0x48(%rsp), %rdi
xorl %edx, %edx
callq 0x30d0
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rsi
movzbl -0x1(%rax,%rsi), %eax
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x881a
movzwl %ax, %eax
addl $-0x30, %eax
movw %ax, 0xba(%rsp)
addq $-0x2, %rsi
leaq 0x68(%rsp), %rdi
xorl %edx, %edx
callq 0x30d0
movl 0x90(%rsp), %eax
movl %eax, 0xb0(%rsp)
movq 0x50(%rsp), %rcx
movl %ecx, 0xa8(%rsp)
movl 0x70(%rsp), %edx
movl %edx, 0xac(%rsp)
testl %eax, %eax
setne %al
testl %ecx, %ecx
setne %cl
andb %al, %cl
testl %edx, %edx
setne %al
testb %al, %cl
jne 0x88de
movl $0x23, %edx
movq 0x678c(%rip), %rdi      # 0xeff0
leaq 0x356b(%rip), %rsi      # 0xbdd6
callq 0x3310
movq 0x6779(%rip), %rcx      # 0xeff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0x675b(%rip), %rdi      # 0xeff0
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0x3310
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq 0x48(%rsp), %rax
movb (%rax), %dl
testb %dl, %dl
sete %cl
je 0x890c
incq %rax
movzbl %dl, %edx
addl $-0x41, %edx
cmpl $0x18, %edx
ja 0x890c
btl %edx, %r15d
jae 0x890c
movb (%rax), %dl
incq %rax
testb %dl, %dl
sete %cl
jne 0x88ef
testb $0x1, %cl
je 0x8ba0
movq 0x68(%rsp), %rax
movb (%rax), %dl
testb %dl, %dl
sete %cl
je 0x8943
incq %rax
movzbl %dl, %edx
addl $-0x41, %edx
cmpl $0x18, %edx
ja 0x8943
btl %edx, %r15d
jae 0x8943
movb (%rax), %dl
incq %rax
testb %dl, %dl
sete %cl
jne 0x8926
testb $0x1, %cl
je 0x8c8d
movq 0x88(%rsp), %rax
movb (%rax), %dl
testb %dl, %dl
sete %cl
je 0x897d
incq %rax
movzbl %dl, %edx
addl $-0x41, %edx
cmpl $0x13, %edx
ja 0x897d
btl %edx, %r12d
jae 0x897d
movb (%rax), %dl
incq %rax
testb %dl, %dl
sete %cl
jne 0x8960
testb $0x1, %cl
je 0x8cf1
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq $0x0, 0xf8(%rsp)
movb $0x0, 0x100(%rsp)
movq %r13, %rdi
leaq 0xf0(%rsp), %r14
movq %r14, %rsi
movl $0x9, %edx
callq 0x34d0
movq %rbp, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x3430
movq %rbp, %rdi
leaq 0xb4(%rsp), %rsi
callq 0x33b0
movq %rbp, %rdi
movq 0x65d4(%rip), %rsi      # 0xefc0
callq 0x3370
leaq 0x1a0(%rsp), %rdi
callq 0x30e0
movq %r13, %rdi
leaq 0xf0(%rsp), %r14
movq %r14, %rsi
movl $0x9, %edx
callq 0x34d0
movq %rbp, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x3430
movq %rbp, %rdi
leaq 0xb6(%rsp), %rsi
callq 0x33b0
movq %rbp, %rdi
movq 0x6580(%rip), %rsi      # 0xefc0
callq 0x3370
leaq 0x1a0(%rsp), %rdi
callq 0x30e0
cmpw $0x0, 0xb4(%rsp)
je 0x8c04
movq 0xe0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8ebe
movq 0xe8(%rsp), %rax
incl (%rax)
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x8aa2
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32d0
movq %r13, %rdi
movq 0x64fc(%rip), %rsi      # 0xefa8
callq 0x31f0
movq 0x118(%rsp), %rdi
callq 0x30e0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x8ae3
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x8aff
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x8b1b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x8b37
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x8625
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x8625
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x8b79
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x2a8(%rsp), %rdi
callq 0x30b0
movq 0xe0(%rsp), %rax
addq $0x638, %rsp            # imm = 0x638
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6449(%rip), %rdi      # 0xeff0
leaq 0x324c(%rip), %rsi      # 0xbdfa
movl $0x6, %edx
callq 0x3310
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x6427(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x3229(%rip), %rsi      # 0xbe01
movl $0x1b, %edx
movq %rax, %rdi
callq 0x3310
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x3310
movq %rax, %rdi
callq 0x3140
jmp 0x8d73
movq 0x63e5(%rip), %rdi      # 0xeff0
leaq 0x31e8(%rip), %rsi      # 0xbdfa
movl $0x6, %edx
callq 0x3310
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x63c3(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x3203(%rip), %rsi      # 0xbe3f
movl $0x25, %edx
movq %rax, %rdi
callq 0x3310
movzwl 0xb4(%rsp), %esi
movq %rbx, %rdi
callq 0x31b0
movq %rax, %rbx
leaq 0x25b0(%rip), %rsi      # 0xb213
movl $0x1, %edx
movq %rax, %rdi
callq 0x3310
movzwl 0xb6(%rsp), %esi
movq %rbx, %rdi
callq 0x31b0
movq %rax, %rdi
callq 0x3140
jmp 0x8d73
movq 0x635c(%rip), %rdi      # 0xeff0
leaq 0x315f(%rip), %rsi      # 0xbdfa
movl $0x6, %edx
callq 0x3310
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x633a(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x313c(%rip), %rsi      # 0xbe01
movl $0x1b, %edx
movq %rax, %rdi
callq 0x3310
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rbx, %rdi
callq 0x3310
movq %rax, %rdi
callq 0x3140
jmp 0x8d73
movq 0x62f8(%rip), %rdi      # 0xeff0
leaq 0x30fb(%rip), %rsi      # 0xbdfa
movl $0x6, %edx
callq 0x3310
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x62d6(%rip), %rdi      # 0xeff0
callq 0x3310
movq %rax, %rbx
leaq 0x30f4(%rip), %rsi      # 0xbe1d
movl $0x21, %edx
movq %rax, %rdi
callq 0x3310
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq %rbx, %rdi
callq 0x3310
movq %rax, %rdi
callq 0x3140
jmp 0x8d73
movq 0x6291(%rip), %rdi      # 0xeff0
leaq 0x3034(%rip), %rsi      # 0xbd9a
callq 0x32a0
movq %rax, %rdi
callq 0x3140
movl $0x1, %edi
callq 0x3340
movq 0x626c(%rip), %rdi      # 0xeff0
leaq 0x2f69(%rip), %rsi      # 0xbcf4
movl $0xf, %edx
callq 0x3310
movq %r14, %rdi
callq 0x3130
movq 0x624c(%rip), %rdi      # 0xeff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x3310
movq 0x623a(%rip), %rdi      # 0xeff0
leaq 0x300c(%rip), %rsi      # 0xbdc9
movl $0xc, %edx
callq 0x3310
movq 0x6222(%rip), %rdi      # 0xeff0
callq 0x3140
jmp 0x8d73
jmp 0x8dd7
movq %rax, %rbx
jmp 0x8ea8
jmp 0x8e1c
jmp 0x8e1c
jmp 0x8de5
movq %rax, %rbx
movq 0x61d1(%rip), %rsi      # 0xefc0
leaq 0x128(%rsp), %rdi
callq 0x3370
leaq 0x1a0(%rsp), %rdi
callq 0x30e0
jmp 0x8e1f
jmp 0x8e1c
movq %rax, %rbx
leaq 0xd0(%rsp), %r14
jmp 0x8e81
jmp 0x8e55
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x8e58
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x8e58
movq %rax, %rbx
leaq 0xd0(%rsp), %r14
jmp 0x8e8b
jmp 0x8e55
movq %rax, %rbx
leaq 0xd0(%rsp), %r14
movq 0x6141(%rip), %rsi      # 0xefa8
leaq 0x4b0(%rsp), %rdi
callq 0x31f0
leaq 0x530(%rsp), %rdi
callq 0x30e0
leaq 0x8(%rsp), %rdi
callq 0x8eee
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x8ea8
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x2a8(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x3480
nop