// File: /workspace/github_cpp_makefile_star2_O1/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, %r14d
movq %rcx, %rbx
movl %edx, %r8d
movl %esi, %r15d
movq %rdi, %r12
movq 0x10b11(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xad28(%rip), %rsi      # 0xd1f9
movq %rcx, %rdx
movl %r15d, %ecx
movl %r8d, -0x30(%rbp)
xorl %eax, %eax
callq 0x2310
leaq 0xac4e(%rip), %rsi      # 0xd137
movq %rbx, %rdi
callq 0x2330
testq %rax, %rax
je 0x2626
movq %rax, %r13
movq %rsp, %rax
addq $-0xf4240, %rax         # imm = 0xFFF0BDC0
movq %rax, -0x38(%rbp)
movq %rax, %rsp
movl %r15d, -0x2c(%rbp)
testl %r15d, %r15d
jle 0x25d4
movl -0x2c(%rbp), %eax
movq %rax, -0x40(%rbp)
movl -0x30(%rbp), %ebx
xorl %r15d, %r15d
movq %r13, -0x48(%rbp)
movq %r13, %rdi
movq -0x38(%rbp), %r13
movq %r13, %rsi
movl $0xf4240, %edx          # imm = 0xF4240
callq 0x23e0
testq %rax, %rax
je 0x2601
movq %r13, %rdi
leaq 0xabe2(%rip), %rsi      # 0xd134
callq 0x23a0
movq %rax, %rdi
callq 0x22b0
testl %r14d, %r14d
je 0x2574
movsd 0xaa9c(%rip), %xmm1     # 0xd008
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq (%r12,%r15,8), %rax
movsd %xmm0, (%rax)
cmpl $0x2, -0x30(%rbp)
jl 0x25c3
pushq $0x1
popq %r13
xorl %edi, %edi
leaq 0xaba5(%rip), %rsi      # 0xd134
callq 0x23a0
movq %rax, %rdi
callq 0x22b0
testl %r14d, %r14d
je 0x25b1
movsd 0xaa5f(%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 0x2586
incq %r15
cmpq -0x40(%rbp), %r15
movq -0x48(%rbp), %r13
jne 0x252b
movq %r13, %rdi
movq -0x38(%rbp), %rsi
movl $0xf4240, %edx          # imm = 0xF4240
callq 0x23e0
testq %rax, %rax
jne 0x2643
movq %r13, %rdi
callq 0x23d0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x109d0(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xac12(%rip), %rsi      # 0xd224
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
xorl %eax, %eax
callq 0x2310
xorl %edi, %edi
callq 0x2290
movq 0x109ab(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xabdf(%rip), %rsi      # 0xd216
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2310
jmp 0x261f
movq 0x1098e(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xac22(%rip), %rsi      # 0xd276
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x2310
jmp 0x261f