// File: /workspace/github_cpp_makefile_star2_O2/GenisGE[P]evalAdmix/Cinterface.cpp
// Function: readDoubleGZ(double**, int, int, char const*, int)
void readDoubleGZ(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";
  gzFile fp = NULL;
  if((fp=gzopen(fname,"r"))==NULL){
    fprintf(stderr,"cant open:%s\n",fname);
    exit(0);
  }
  int lens=1000000 ;
  char buf[lens];
  for(int i=0;i<x;i++){
    if(NULL==gzgets(fp,buf,lens)){
      fprintf(stderr,"Error: Only %d sites in frequency file, expected %d sites from plink/beagle file\n",i, x);
	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!=gzgets(fp,buf,lens)){
    fprintf(stderr,"Error: Too many sites in frequency file. Only %d sites in plink/beagle file\n",x);
    exit(0);

  }
  gzclose(fp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r15d
movq %rcx, %rbx
movl %edx, %r8d
movl %esi, %r13d
movq %rdi, %r12
movq 0xdfec(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
leaq 0x81c3(%rip), %rsi      # 0xb1b9
xorl %r14d, %r14d
movq %rcx, %rdx
movl %r13d, %ecx
movl %r8d, -0x30(%rbp)
xorl %eax, %eax
callq 0x2320
leaq 0x80e6(%rip), %rsi      # 0xb0f7
movq %rbx, %rdi
callq 0x2340
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x3135
movq %rsp, %rax
addq $-0xf4240, %rax         # imm = 0xFFF0BDC0
movq %rax, -0x40(%rbp)
movq %rax, %rsp
testl %r13d, %r13d
movl $0x0, %eax
movl %r13d, -0x2c(%rbp)
cmovgl %r13d, %eax
movq %rax, -0x48(%rbp)
movslq -0x30(%rbp), %rbx
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0xf4240, %edx          # imm = 0xF4240
callq 0x23f0
cmpq -0x48(%rbp), %r14
je 0x30f3
testq %rax, %rax
je 0x3110
movq -0x40(%rbp), %rdi
leaq 0x8076(%rip), %rsi      # 0xb0f4
callq 0x23b0
movq %rax, %rdi
callq 0x22a0
testl %r15d, %r15d
je 0x30a0
movsd 0x7f70(%rip), %xmm1     # 0xb008
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq (%r12,%r14,8), %rax
movsd %xmm0, (%rax)
pushq $0x1
popq %r13
cmpq %rbx, %r13
jge 0x30eb
xorl %edi, %edi
leaq 0x803a(%rip), %rsi      # 0xb0f4
callq 0x23b0
movq %rax, %rdi
callq 0x22a0
testl %r15d, %r15d
je 0x30dc
movsd 0x7f34(%rip), %xmm1     # 0xb008
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq (%r12,%r14,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
jmp 0x30ac
incq %r14
jmp 0x304e
testq %rax, %rax
jne 0x3152
movq -0x38(%rbp), %rdi
callq 0x23e0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xdec1(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
leaq 0x80c3(%rip), %rsi      # 0xb1e4
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
xorl %eax, %eax
callq 0x2320
xorl %edi, %edi
callq 0x2280
movq 0xde9c(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
leaq 0x8090(%rip), %rsi      # 0xb1d6
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2320
jmp 0x312e
movq 0xde7f(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
leaq 0x80d3(%rip), %rsi      # 0xb236
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x2320
jmp 0x312e