// File: /workspace/github_c_makefile_star2_O3/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 0x4f98
cmpl %esi, 0x30(%rdi)
jle 0x4f98
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 0x4e05
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 0x4e9c
cmpb $0x3, %al
jg 0x4eae
movb $0x4, (%rbx,%r15)
movb (%rbx), %al
movq %rbx, %rcx
cmpl $0x1, %ebp
jne 0x4f64
cmpb $0x4, %al
je 0x4f85
leaq 0x7200(%rip), %rdx      # 0xbfea
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
cmpb $0x4, %al
jne 0x4ded
jmp 0x4f85
movq 0x10(%rax), %r12
movl 0x4(%rax), %r15d
movq %r14, %rdi
callq 0x1080
cmpq %r12, %rax
je 0x4e27
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1230
leal 0x3(%r15), %eax
sarl $0x2, %eax
testl %eax, %eax
jle 0x4e4e
movl %eax, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x4f9d
movl %r15d, %edi
movq %rbx, %rsi
callq 0x330c
cmpl $0x2, %ebp
je 0x4f0a
movb $0x4, %cl
cmpl $0x1, %ebp
jne 0x4f8a
movb (%rbx), %al
movq %rbx, %rcx
cmpb $0x4, %al
je 0x4f85
leaq 0x7169(%rip), %rdx      # 0xbfea
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
cmpb $0x4, %al
jne 0x4e84
jmp 0x4f85
cmpb $0x3, %al
jg 0x4f32
movb $0x4, (%rbx,%r15)
jmp 0x4f60
xorl %r14d, %r14d
cmpl $0x1, %ebp
sete %bpl
movb $0x0, (%rbx,%r15)
callq 0x12a0
movsbq (%rbx), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
je 0x4f8a
movq (%rax), %rax
movzwl (%rax,%rdx,2), %eax
andl $0x200, %eax            # imm = 0x200
movb %bpl, %r14b
cmpw %r14w, %ax
je 0x4f8a
leaq 0x1(%rbx), %rax
leaq 0x720b(%rip), %rcx      # 0xc100
movsbq %dl, %rdx
movb (%rdx,%rcx), %dl
movb %dl, -0x1(%rax)
movb (%rax), %dl
incq %rax
testb %dl, %dl
jne 0x4ef5
jmp 0x4f88
movb (%rbx), %al
movq %rbx, %rcx
cmpb $0x4, %al
je 0x4f85
leaq 0x70d4(%rip), %rdx      # 0xbfee
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
cmpb $0x4, %al
jne 0x4f1d
jmp 0x4f85
movb $0x0, (%rbx,%r15)
movb (%rbx), %al
movq %rbx, %rcx
testb %al, %al
je 0x4f5d
leaq 0x70b9(%rip), %rdx      # 0xc000
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
testb %al, %al
jne 0x4f4a
movb $0x4, (%rcx)
movb $0x4, %cl
jmp 0x4f8a
cmpb $0x4, %al
je 0x4f85
leaq 0x707f(%rip), %rdx      # 0xbfee
movq %rbx, %rcx
movsbq %al, %rax
movb (%rax,%rdx), %al
movb %al, (%rcx)
movb 0x1(%rcx), %al
incq %rcx
cmpb $0x4, %al
jne 0x4f72
movb $0x0, (%rcx)
xorl %ecx, %ecx
movb %cl, -0x1(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x1646
callq 0x161e