// File: /workspace/github_c_makefile_star2_O1/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 0x4f55
cmpl %esi, 0x30(%rdi)
jle 0x4f55
movl %ecx, %ebp
movq %rdx, %rbx
movq 0x58(%rdi), %r14
cmpl $0x0, 0x50(%rdi)
movq 0x60(%rdi), %rax
movl %esi, %ecx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rax
je 0x4dbb
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 0x4e52
cmpb $0x3, %al
jg 0x4e64
movb $0x4, (%rbx,%r15)
movb (%rbx), %al
movq %rbx, %rdx
cmpl $0x1, %ebp
jne 0x4f1f
cmpb $0x4, %al
je 0x4f40
leaq 0x71ea(%rip), %rcx      # 0xbf8a
movq %rbx, %rdx
movsbq %al, %rax
movb (%rax,%rcx), %al
movb %al, (%rdx)
movb 0x1(%rdx), %al
incq %rdx
cmpb $0x4, %al
jne 0x4da3
jmp 0x4f40
movq 0x10(%rax), %r12
movl 0x4(%rax), %r15d
movq %r14, %rdi
callq 0x1080
cmpq %r12, %rax
je 0x4ddd
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1230
leal 0x3(%r15), %eax
sarl $0x2, %eax
testl %eax, %eax
jle 0x4e04
movl %eax, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x4f5a
movl %r15d, %edi
movq %rbx, %rsi
callq 0x3400
cmpl $0x2, %ebp
je 0x4ec0
movb $0x4, %cl
cmpl $0x1, %ebp
jne 0x4f47
movb (%rbx), %al
movq %rbx, %rcx
cmpb $0x4, %al
je 0x4ee6
leaq 0x7153(%rip), %rdx      # 0xbf8a
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
cmpb $0x4, %al
jne 0x4e3a
jmp 0x4ee6
cmpb $0x3, %al
jg 0x4eed
movb $0x4, (%rbx,%r15)
jmp 0x4f1b
xorl %r14d, %r14d
cmpl $0x1, %ebp
sete %bpl
movb $0x0, (%rbx,%r15)
callq 0x12a0
movsbq (%rbx), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
je 0x4f47
movq (%rax), %rax
movzwl (%rax,%rdx,2), %eax
andl $0x200, %eax            # imm = 0x200
movb %bpl, %r14b
cmpw %r14w, %ax
je 0x4f47
leaq 0x1(%rbx), %rax
leaq 0x71f5(%rip), %rcx      # 0xc0a0
movsbq %dl, %rdx
movb (%rdx,%rcx), %dl
movb %dl, -0x1(%rax)
movb (%rax), %dl
incq %rax
testb %dl, %dl
jne 0x4eab
jmp 0x4ee9
movb (%rbx), %al
movq %rbx, %rcx
cmpb $0x4, %al
je 0x4ee6
leaq 0x70be(%rip), %rdx      # 0xbf8e
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
cmpb $0x4, %al
jne 0x4ed3
movb $0x0, (%rcx)
xorl %ecx, %ecx
jmp 0x4f47
movb $0x0, (%rbx,%r15)
movb (%rbx), %al
movq %rbx, %rcx
testb %al, %al
je 0x4f18
leaq 0x709e(%rip), %rdx      # 0xbfa0
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
testb %al, %al
jne 0x4f05
movb $0x4, (%rcx)
movb $0x4, %cl
jmp 0x4f47
cmpb $0x4, %al
je 0x4f40
leaq 0x7064(%rip), %rcx      # 0xbf8e
movq %rbx, %rdx
movsbq %al, %rax
movb (%rax,%rcx), %al
movb %al, (%rdx)
movb 0x1(%rdx), %al
incq %rdx
cmpb $0x4, %al
jne 0x4f2d
xorl %ecx, %ecx
movb %cl, (%rdx)
movb %cl, -0x1(%rbx)
movb %cl, -0x1(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x1646
callq 0x161e