// File: GenisGE[P]evalAdmix/filereader_and_conversions.cpp
// Function: getOptions(char const*, functionPars*)
void getOptions(const char *fileName, functionPars *pars){
  float options[29];		//array of option arguuments
  std::ifstream exsamplefile(fileName);	//opens option file
  //  char *tmpChar;
  if (!exsamplefile.is_open ()){
    printf ("\nError opening options file\n");
    exit(0);
  }
  int tal = 0;			// read option file
  char buffer[256];
  while (!exsamplefile.eof ()) {
    exsamplefile.getline (buffer, 1000);
    char *tokenized=buffer;
    char *buffer_ar = strtok(tokenized,"\t"); //changed from strsep in v. 0.82
    
    if(tal<27){
      //printf("tal:%d\tbuffer:%s\n",tal,buffer_ar);
      options[tal] = atof (buffer_ar);
      tal++;
      continue;
    }
    else{
      // there exist more lines in options file let's check
      if(buffer_ar!=NULL){//The lines are not empty, lets discard them but tell user
	printf("tal:%d\t op:%f \tlen=%d\n",tal,options[tal],(int)strlen(buffer_ar));
	printf("\t-> To many lines in options file, rest will be discarded\n");
	break;
      }
      //lines are empy just keep on going
    }
  }

  exsamplefile.close ();

  pars->doAllPairs = (int) options[0];
  pars->pair->array[0]=(int) options[1];
  pars->pair->array[1]=(int) options[2];
  pars->double_recom=(int) options[3];
  pars->LD = ((int) options[4]==0?1:0 );//ld=1=rsq, ld=0=D
  pars->min=(double) options[5];
  pars->alim->array[0]= options[6];
  pars->alim->array[1]= options[7];
  pars->doPar=(int) options[8];
  pars->par->array[0] = options[9];
  pars->par->array[1] = options[10];
  pars->par->array[2] = options[11];
  pars->ld_adj= (int) options[12];
  pars->epsilon=  options[13];
  pars->back= (int) options[14];
  pars->doPrune = (int) options[15];
  pars->prune_val =  options[16];
  pars->fixA= (int) options[17];
  pars->fixA_val=  options[18];
  pars->fixK= (int) options[19];
  pars->fixK_val= options[20];
  pars->calcA= (int) options[21];
  pars->phi =  options[22];
  pars->convTol = options[23];
  pars->timesToConverge=(int) options[24];
  pars->timesToRun= (int) options[25];
  pars->back2 = (int) options[26];
  
  
}

// Assembly:
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rdi, 0x3e0(%rsp)
movq %rsi, 0x3d8(%rsp)
movq 0x3e0(%rsp), %rsi
leaq 0x158(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movl $0x8, %edx
callq 0x3540
movq 0x20(%rsp), %rdi
callq 0x3490
movb %al, 0x2f(%rsp)
jmp 0xa166
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0xa1ad
jmp 0xa170
leaq 0xedda(%rip), %rdi      # 0x18f51
xorl %eax, %eax
callq 0x3040
jmp 0xa180
xorl %edi, %edi
callq 0x3340
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x3080
jmp 0xa5c0
movl $0x0, 0x148(%rsp)
movq 0x158(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x158(%rsp,%rax), %rdi
callq 0x3550
movb %al, 0x1f(%rsp)
jmp 0xa1d7
movb 0x1f(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xa1e6
jmp 0xa2c6
leaq 0x158(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x30c0
jmp 0xa1ff
leaq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
leaq 0xf017(%rip), %rsi      # 0x1922c
callq 0x3470
movq %rax, 0x30(%rsp)
cmpl $0x1b, 0x148(%rsp)
jge 0xa25e
movq 0x30(%rsp), %rdi
callq 0x3370
cvtsd2ss %xmm0, %xmm0
movslq 0x148(%rsp), %rax
movss %xmm0, 0x360(%rsp,%rax,4)
movl 0x148(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x148(%rsp)
jmp 0xa1b8
cmpq $0x0, 0x30(%rsp)
je 0xa2bf
movslq 0x148(%rsp), %rax
movl %eax, %ecx
movl %ecx, 0xc(%rsp)
movss 0x360(%rsp,%rax,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x30(%rsp), %rdi
callq 0x3110
movl 0xc(%rsp), %esi
movsd 0x10(%rsp), %xmm0
movl %eax, %edx
leaq 0xecca(%rip), %rdi      # 0x18f6e
movb $0x1, %al
callq 0x3040
jmp 0xa2ad
leaq 0xecd1(%rip), %rdi      # 0x18f85
xorl %eax, %eax
callq 0x3040
jmp 0xa2bd
jmp 0xa2c6
jmp 0xa2c1
jmp 0xa1b8
leaq 0x158(%rsp), %rdi
callq 0x3070
jmp 0xa2d5
cvttss2si 0x360(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x70(%rax)
cvttss2si 0x364(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl %ecx, (%rax)
cvttss2si 0x368(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl %ecx, 0x4(%rax)
cvttss2si 0x36c(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x8c(%rax)
cvttss2si 0x370(%rsp), %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovel %eax, %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x90(%rax)
movss 0x374(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movsd %xmm0, 0xb0(%rax)
movss 0x378(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movsd %xmm0, (%rax)
movss 0x37c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movsd %xmm0, 0x8(%rax)
cvttss2si 0x380(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x74(%rax)
movss 0x384(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movsd %xmm0, (%rax)
movss 0x388(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movsd %xmm0, 0x8(%rax)
movss 0x38c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movsd %xmm0, 0x10(%rax)
cvttss2si 0x390(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x94(%rax)
movss 0x394(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movsd %xmm0, 0xb8(%rax)
cvttss2si 0x398(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0xc0(%rax)
cvttss2si 0x39c(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x78(%rax)
movss 0x3a0(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movsd %xmm0, 0xd0(%rax)
cvttss2si 0x3a4(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x80(%rax)
movss 0x3a8(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movsd %xmm0, 0xd8(%rax)
cvttss2si 0x3ac(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x84(%rax)
movss 0x3b0(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movsd %xmm0, 0xe0(%rax)
cvttss2si 0x3b4(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x88(%rax)
movss 0x3b8(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movsd %xmm0, 0xa0(%rax)
movss 0x3bc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x3d8(%rsp), %rax
movsd %xmm0, 0xe8(%rax)
cvttss2si 0x3c0(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0xc8(%rax)
cvttss2si 0x3c4(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0xc4(%rax)
cvttss2si 0x3c8(%rsp), %ecx
movq 0x3d8(%rsp), %rax
movl %ecx, 0x7c(%rax)
leaq 0x158(%rsp), %rdi
callq 0x3080
addq $0x3e8, %rsp            # imm = 0x3E8
retq
movq 0x150(%rsp), %rdi
callq 0x34f0
nopl (%rax)