// File: /workspace/github_cpp_makefile_star2_O1/GenisGE[P]evalAdmix/Cinterface.cpp
// Function: readDouble(double**, int, int, char const*, int)
void readDouble(double **d,int x,int y,const char*fname,int neg){
  fprintf(stderr,"opening : %s with x=%d y=%d\n",fname,x,y);
  const char*delims=" \n";
  FILE *fp = NULL;
  if((fp=fopen(fname,"r"))==NULL){
    fprintf(stderr,"can't open:%s\n",fname);
    exit(0);
  }
  int lens=1000000 ;
  char buf[lens];
  for(int i=0;i<x;i++){
    if(NULL==fgets(buf,lens,fp)){
    	fprintf(stderr,"Error: Only %d individuals in admxiture (-qname) file\n",i);
      exit(0);
    }
    if(neg)
      d[i][0] = 1-atof(strtok(buf,delims));
    else
      d[i][0] = atof(strtok(buf,delims));
    for(int j=1;j<y;j++){
      //      fprintf(stderr,"i=%d j=%d\n",i,j);
      if(neg)
	d[i][j] = 1-atof(strtok(NULL,delims));
      else
	d[i][j] = atof(strtok(NULL,delims));
    }
  }
   if(NULL!=fgets(buf,lens,fp)){
    fprintf(stderr,"Error: Too many individuals in admixture (-qname) file. Only %d individuals in plink file\n",x);
    exit(0);
  }

  fclose(fp); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r14d
movq %rcx, %rbx
movl %edx, %r8d
movl %esi, %r15d
movq %rdi, %r12
movq 0x10951(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xab68(%rip), %rsi      # 0xd1f9
movq %rcx, %rdx
movl %r15d, %ecx
movl %r8d, -0x30(%rbp)
xorl %eax, %eax
callq 0x2310
leaq 0xaa8e(%rip), %rsi      # 0xd137
movq %rbx, %rdi
callq 0x2270
testq %rax, %rax
je 0x27e0
movq %rax, %rdx
movq %rsp, %r13
addq $-0xf4240, %r13         # imm = 0xFFF0BDC0
movq %r13, %rsp
movl %r15d, -0x2c(%rbp)
testl %r15d, %r15d
jle 0x2792
movl -0x2c(%rbp), %eax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %ebx
xorl %r15d, %r15d
movq %rdx, -0x48(%rbp)
movq %r13, -0x40(%rbp)
movq %r13, %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x23b0
testq %rax, %rax
je 0x27be
movq %r13, %rdi
leaq 0xaa28(%rip), %rsi      # 0xd134
callq 0x23a0
movq %rax, %rdi
callq 0x22b0
testl %r14d, %r14d
je 0x272e
movsd 0xa8e2(%rip), %xmm1     # 0xd008
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq (%r12,%r15,8), %rax
movsd %xmm0, (%rax)
cmpl $0x2, -0x30(%rbp)
jl 0x277d
pushq $0x1
popq %r13
xorl %edi, %edi
leaq 0xa9eb(%rip), %rsi      # 0xd134
callq 0x23a0
movq %rax, %rdi
callq 0x22b0
testl %r14d, %r14d
je 0x276b
movsd 0xa8a5(%rip), %xmm1     # 0xd008
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq (%r12,%r15,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
cmpq %r13, %rbx
jne 0x2740
incq %r15
cmpq -0x38(%rbp), %r15
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %r13
jne 0x26ec
movq %r13, %rdi
movl $0xf4240, %esi          # imm = 0xF4240
movq %rdx, %rbx
callq 0x23b0
testq %rax, %rax
jne 0x27fd
movq %rbx, %rdi
callq 0x2210
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10813(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xab03(%rip), %rsi      # 0xd2d2
movl %r15d, %edx
xorl %eax, %eax
callq 0x2310
xorl %edi, %edi
callq 0x2290
movq 0x107f1(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xaad2(%rip), %rsi      # 0xd2c3
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2310
jmp 0x27d9
movq 0x107d4(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xaafb(%rip), %rsi      # 0xd309
movl -0x2c(%rbp), %edx
jmp 0x27d2