// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/DB.c
// Function: Load_Read
int Load_Read(DAZZ_DB *db, int i, char *read, int ascii)
{ FILE      *bases  = (FILE *) db->bases;
  int64      off;
  int        len, clen;
  DAZZ_READ *r = db->reads;

  if (i < 0 || i >= db->nreads)
    { EPRINTF(EPLACE,"%s: Index out of bounds (Load_Read)\n",Prog_Name);
      EXIT(1);
    }

  if (db->loaded)
    { len = r[i].rlen;
      strncpy(read,(char *) bases + r[i].boff,len);
      if (ascii == 0)
        { if (*read < 4)
            read[-1] = read[len] = 4;
          else
            { read[len] = '\0';
              Number_Read(read);
              read[-1] = 4;
            }
        }
      else
        { if (*read < 4)
            { read[len] = 4;
              if (ascii == 1)
                Lower_Read(read);
              else
                Upper_Read(read);
              read[-1] = '\0';
            }
          else
            { read[len] = '\0';
              if ((ascii == 1) != islower(*read))
                Change_Read(read);
            }
          read[-1] = '\0';
        }
      return (0);
    }

  off = r[i].boff;
  len = r[i].rlen;

  if (ftello(bases) != off)
    fseeko(bases,off,SEEK_SET);
  clen = COMPRESSED_LEN(len);
  if (clen > 0)
    { if (fread(read,clen,1,bases) != 1)
        { EPRINTF(EPLACE,"%s: Failed read of .bps file (Load_Read)\n",Prog_Name);
          EXIT(1);
        }
    }
  Uncompress_Read(len,read);
  if (ascii == 1)
    { Lower_Read(read);
      read[-1] = '\0';
    }
  else if (ascii == 2)
    { Upper_Read(read);
      read[-1] = '\0';
    }
  else
    read[-1] = 4;
  return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testl %esi, %esi
js 0x3dd7
cmpl %esi, 0x30(%rdi)
jle 0x3dd7
movl %ecx, %ebp
movq %rdx, %rbx
movq 0x58(%rdi), %r14
movl %esi, %eax
imulq $0x28, %rax, %rax
addq 0x60(%rdi), %rax
cmpl $0x0, 0x50(%rdi)
je 0x3d07
movslq 0x4(%rax), %r15
addq 0x10(%rax), %r14
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1060
movb (%rbx), %al
testl %ebp, %ebp
je 0x3d6f
cmpb $0x3, %al
jg 0x3d84
movb $0x4, (%rbx,%r15)
cmpl $0x1, %ebp
je 0x3d65
jmp 0x3d7a
movq 0x10(%rax), %r12
movl 0x4(%rax), %r15d
movq %r14, %rdi
callq 0x1080
cmpq %r12, %rax
je 0x3d29
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1230
leal 0x3(%r15), %eax
sarl $0x2, %eax
testl %eax, %eax
jle 0x3d4e
movl %eax, %esi
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x3dfe
movl %r15d, %edi
movq %rbx, %rsi
callq 0x2337
cmpl $0x2, %ebp
je 0x3d7a
movb $0x4, %al
cmpl $0x1, %ebp
jne 0x3dc9
movq %rbx, %rdi
callq 0x2395
jmp 0x3db6
cmpb $0x3, %al
jg 0x3dba
movb $0x4, (%rbx,%r15)
jmp 0x3dc7
movq %rbx, %rdi
callq 0x23b4
jmp 0x3db6
xorl %r14d, %r14d
cmpl $0x1, %ebp
sete %r14b
movb $0x0, (%rbx,%r15)
callq 0x12a0
movq (%rax), %rax
movsbq (%rbx), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x200, %eax            # imm = 0x200
cmpw %r14w, %ax
je 0x3db6
movq %rbx, %rdi
callq 0x242e
xorl %eax, %eax
jmp 0x3dc9
movb $0x0, (%rbx,%r15)
movq %rbx, %rdi
callq 0x23f2
movb $0x4, %al
movb %al, -0x1(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0xa21a(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xcb00(%rip), %rdx      # 0x108e8
leaq 0x5863(%rip), %rsi      # 0x9652
xorl %eax, %eax
callq 0x11a0
pushq $0x1
popq %rdi
callq 0x1270
movq 0xa1f3(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xcad9(%rip), %rdx      # 0x108e8
leaq 0x5861(%rip), %rsi      # 0x9677
jmp 0x3def