// File: 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
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq 0x19f77(%rip), %rax     # 0x1efd8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
movl -0xc(%rbp), %ecx
movl -0x10(%rbp), %r8d
leaq 0x13146(%rip), %rsi     # 0x181bc
movb $0x0, %al
callq 0x33c0
leaq 0x13073(%rip), %rax     # 0x180f7
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x1305f(%rip), %rsi     # 0x180fa
callq 0x3320
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x50cd
movq 0x19f27(%rip), %rax     # 0x1efd8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x131c7(%rip), %rsi     # 0x18286
movb $0x0, %al
callq 0x33c0
xorl %edi, %edi
callq 0x3340
movl $0xf4240, -0x34(%rbp)   # imm = 0xF4240
movl -0x34(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x40(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x58(%rbp)
movq %rcx, %rsp
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x5241
movq -0x58(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x3480
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x5149
movq 0x19eaa(%rip), %rax     # 0x1efd8
movq (%rax), %rdi
movl -0x4c(%rbp), %edx
leaq 0x1315a(%rip), %rsi     # 0x18295
movb $0x0, %al
callq 0x33c0
xorl %edi, %edi
callq 0x3340
cmpl $0x0, -0x1c(%rbp)
je 0x5185
movq -0x58(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3470
movq %rax, %rdi
callq 0x3370
movaps %xmm0, %xmm1
movsd 0x12e99(%rip), %xmm0    # 0x18008
subsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
jmp 0x51aa
movq -0x58(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3470
movq %rax, %rdi
callq 0x3370
movq -0x8(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movl $0x1, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x5231
cmpl $0x0, -0x1c(%rbp)
je 0x51fa
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x3470
movq %rax, %rdi
callq 0x3370
movaps %xmm0, %xmm1
movsd 0x12e29(%rip), %xmm0    # 0x18008
subsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x50(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x5224
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x3470
movq %rax, %rdi
callq 0x3370
movq -0x8(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x50(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x5226
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x51b1
jmp 0x5233
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x5101
movq -0x58(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x3480
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x527d
movq 0x19d76(%rip), %rax     # 0x1efd8
movq (%rax), %rdi
movl -0xc(%rbp), %edx
leaq 0x1305d(%rip), %rsi     # 0x182cc
movb $0x0, %al
callq 0x33c0
xorl %edi, %edi
callq 0x3340
movq -0x30(%rbp), %rdi
callq 0x3290
movq -0x40(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)