// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/DB.c
// Function: Open_Arrow
int Open_Arrow(DAZZ_DB *db)
{ int64      *avector;
  DAZZ_ARROW *atrack;
  FILE       *afile;
  DAZZ_READ  *reads;
  int         i, nreads;

  if (db->tracks != NULL && db->tracks->name == atrack_name)
    return (0);
 
  if ((db->allarr & DB_ARROW) == 0)
    { EPRINTF(EPLACE,"%s: The DB is not an Arrow database (Open_Arrow)\n",Prog_Name);
      EXIT(1);
    }
  if (db->loaded)
    { EPRINTF(EPLACE,"%s: Cannot open Arrow vectors after loading all reads (Open_Arrow)\n",
                        Prog_Name);
      EXIT(1);
    }

  afile = Fopen(MyCatenate(db->path,"","",".arw"),"r");
  if (afile == NULL)
    return (-1);

  nreads  = db->nreads;
  avector = (int64 *) Malloc(sizeof(int64)*nreads,"Allocating Arrow index");
  atrack  = (DAZZ_ARROW *) Malloc(sizeof(DAZZ_ARROW),"Allocating Arrow track");
  if (avector == NULL || atrack == NULL)
    { fclose(afile);
      if (avector != NULL)
        free(avector);
      EXIT(1);
    }
  db->tracks     = (DAZZ_TRACK *) atrack;
  atrack->next   = NULL;
  atrack->name   = atrack_name;
  atrack->aoff   = avector;
  atrack->arrow  = (void *) afile;
  atrack->loaded = 0;


  reads = db->reads;
  for (i = 0; i < nreads; i++)
    avector[i] = reads[i].boff;
  return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0x5ee8
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq 0x8(%rax), %rax
cmpq 0xc466(%rip), %rax      # 0x12340
jne 0x5ee8
movl $0x0, -0x4(%rbp)
jmp 0x6094
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x5f20
movq 0xc0fa(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xeb80(%rip), %rdx      # 0x14a88
leaq 0x87e6(%rip), %rsi      # 0xe6f5
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x5f53
movq 0xc0c7(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xeb4d(%rip), %rdx      # 0x14a88
leaq 0x87e5(%rip), %rsi      # 0xe727
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
leaq 0x89fb(%rip), %rdx      # 0xe95d
leaq 0x8802(%rip), %rcx      # 0xe76b
movq %rdx, %rsi
callq 0x4550
movq %rax, %rdi
leaq 0x8dd9(%rip), %rsi      # 0xed54
callq 0x2480
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5f97
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6094
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x38(%rbp)
movslq -0x38(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x87c0(%rip), %rsi      # 0xe770
callq 0x22c0
movq %rax, -0x18(%rbp)
movl $0x28, %edi
leaq 0x87c2(%rip), %rsi      # 0xe787
callq 0x22c0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5fdc
cmpq $0x0, -0x20(%rbp)
jne 0x5fff
movq -0x28(%rbp), %rdi
callq 0x10b0
cmpq $0x0, -0x18(%rbp)
je 0x5ff5
movq -0x18(%rbp), %rdi
callq 0x1030
movl $0x1, %edi
callq 0x1260
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq 0xc323(%rip), %rcx      # 0x12340
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x608d
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x605b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)