// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x390, %rsp            # imm = 0x390
movq %rsi, %rbx
movq %rdi, %rsi
leaq 0x88(%rsp), %rdi
movl $0x8, %edx
callq 0x2440
leaq 0x100(%rsp), %rdi
callq 0x2060
testb %al, %al
je 0x64fd
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xa8(%rsp,%rax)
jne 0x6382
leaq (%rsp,%rax), %rdi
addq $0x88, %rdi
xorl %ebp, %ebp
leaq 0x88(%rsp), %r14
leaq 0x290(%rsp), %r15
leaq 0x7f41(%rip), %r12      # 0xe21c
movl $0xa, %esi
callq 0x2200
movsbl %al, %ecx
movl $0x3e8, %edx            # imm = 0x3E8
movq %r14, %rdi
movq %r15, %rsi
callq 0x2460
movq %r15, %rdi
movq %r12, %rsi
callq 0x23a0
cmpl $0x1a, %ebp
jg 0x6321
movq %rax, %rdi
callq 0x22b0
cvtsd2ss %xmm0, %xmm0
movslq %ebp, %rax
movss %xmm0, 0x10(%rsp,%rax,4)
incl %ebp
jmp 0x6326
testq %rax, %rax
jne 0x6345
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0x88, %rdi
testb $0x2, 0x20(%rdi)
je 0x62db
jmp 0x6382
movl %ebp, %ecx
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp,%rcx,4), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rax, %rdi
callq 0x20d0
leaq 0x7c34(%rip), %rdi      # 0xdf99
movl %ebp, %esi
movsd 0x8(%rsp), %xmm0
movl %eax, %edx
movb $0x1, %al
callq 0x2040
leaq 0x7fff(%rip), %rdi      # 0xe37c
callq 0x2370
leaq 0x88(%rsp), %rdi
callq 0x2050
cvttss2si 0x10(%rsp), %eax
movl %eax, 0x70(%rbx)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movsd 0x14(%rsp), %xmm0
cvttps2dq %xmm0, %xmm0
movlps %xmm0, (%rax)
cvttss2si 0x1c(%rsp), %eax
movl %eax, 0x8c(%rbx)
cvttss2si 0x20(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, 0x90(%rbx)
xorps %xmm0, %xmm0
cvtss2sd 0x24(%rsp), %xmm0
movsd %xmm0, 0xb0(%rbx)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
cvtps2pd 0x28(%rsp), %xmm0
movups %xmm0, (%rax)
movaps 0x30(%rsp), %xmm0
movq 0x20(%rbx), %rax
movq 0x8(%rax), %rax
cvtps2pd 0x34(%rsp), %xmm1
movups %xmm1, (%rax)
xorps %xmm1, %xmm1
cvtss2sd 0x3c(%rsp), %xmm1
movsd %xmm1, 0x10(%rax)
cvttss2si 0x40(%rsp), %eax
movl %eax, 0x94(%rbx)
xorps %xmm1, %xmm1
cvtss2sd 0x44(%rsp), %xmm1
movsd %xmm1, 0xb8(%rbx)
movups 0x48(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movss 0x58(%rsp), %xmm3
movlhps %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
shufps $0xe2, %xmm2, %xmm3     # xmm3 = xmm3[2,0],xmm2[2,3]
cvtps2pd %xmm3, %xmm4
movss 0x4c(%rsp), %xmm2
movss 0x54(%rsp), %xmm3
movups %xmm4, 0xd0(%rbx)
movups 0x5c(%rsp), %xmm4
movss 0x64(%rsp), %xmm5
movlhps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0]
shufps $0xe2, %xmm4, %xmm5     # xmm5 = xmm5[2,0],xmm4[2,3]
movaps 0x60(%rsp), %xmm4
cvttps2dq %xmm5, %xmm5
movlps %xmm5, 0x84(%rbx)
xorps %xmm5, %xmm5
cvtss2sd 0x68(%rsp), %xmm5
movsd %xmm5, 0xa0(%rbx)
movss 0x6c(%rsp), %xmm5
movlhps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0]
shufps $0xe2, %xmm4, %xmm5     # xmm5 = xmm5[2,0],xmm4[2,3]
cvtps2pd %xmm5, %xmm4
movups %xmm4, 0xe0(%rbx)
cvttss2si 0x70(%rsp), %eax
movlhps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
movl %eax, 0xc8(%rbx)
movss 0x74(%rsp), %xmm0
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
cvttps2dq %xmm0, %xmm0
movlps %xmm0, 0xc0(%rbx)
movss 0x78(%rsp), %xmm0
movlhps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0]
shufps $0x22, %xmm3, %xmm2     # xmm2 = xmm2[2,0],xmm3[2,0]
cvttps2dq %xmm2, %xmm0
movups %xmm0, 0x74(%rbx)
leaq 0x88(%rsp), %rdi
callq 0x2070
addq $0x390, %rsp            # imm = 0x390
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7e5c(%rip), %rdi      # 0xe360
callq 0x2370
xorl %edi, %edi
callq 0x2290
jmp 0x6512
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x2400