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

  if (i < 0 || i >= db->nreads)
    { EPRINTF(EPLACE,"%s: Index out of bounds (Load_Read)\n",Prog_Name);
      EXIT(NULL);
    }
    
  if (db->loaded)
    { len = end-beg;
      strncpy(read,(char *) bases + r[i].boff + beg,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 (read);
    }

  bbeg = beg/4;
  bend = (end-1)/4+1;

  off = r[i].boff + bbeg;
  len = end - beg;

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

  return (read);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x58(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x59f7
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jl 0x5a20
movq 0xc5fa(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xf080(%rip), %rdx      # 0x14a88
leaq 0x8c46(%rip), %rsi      # 0xe655
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x5b49
movl -0x1c(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x58(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
addq 0x10(%rax), %rsi
movslq -0x18(%rbp), %rax
addq %rax, %rsi
movslq -0x44(%rbp), %rdx
callq 0x1050
cmpl $0x0, -0x2c(%rbp)
jne 0x5aac
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4, %eax
jge 0x5a8a
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movq -0x28(%rbp), %rax
movb $0x4, -0x1(%rax)
jmp 0x5aa7
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x28(%rbp), %rdi
callq 0x3100
movq -0x28(%rbp), %rax
movb $0x4, -0x1(%rax)
jmp 0x5b3c
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4, %eax
jge 0x5ae8
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
cmpl $0x1, -0x2c(%rbp)
jne 0x5ad5
movq -0x28(%rbp), %rdi
callq 0x3010
jmp 0x5ade
movq -0x28(%rbp), %rdi
callq 0x3060
movq -0x28(%rbp), %rax
movb $0x0, -0x1(%rax)
jmp 0x5b34
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x0, (%rax,%rcx)
cmpl $0x1, -0x2c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
callq 0x1290
movq %rax, %rcx
movl -0x5c(%rbp), %eax
movq (%rcx), %rcx
movq -0x28(%rbp), %rdx
movsbl (%rdx), %edx
movslq %edx, %rdx
movzwl (%rcx,%rdx,2), %ecx
andl $0x200, %ecx            # imm = 0x200
cmpl %ecx, %eax
je 0x5b32
movq -0x28(%rbp), %rdi
callq 0x31a0
jmp 0x5b34
movq -0x28(%rbp), %rax
movb $0x0, -0x1(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5c7e
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, -0x4c(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movq -0x58(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x4c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x1c(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rdi
callq 0x1070
cmpq -0x40(%rbp), %rax
je 0x5bb0
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x1220
movl -0x50(%rbp), %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jle 0x5c06
movq -0x28(%rbp), %rdi
movslq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rcx
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x5c04
movq 0xc416(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xee9c(%rip), %rdx      # 0x14a88
leaq 0x8a87(%rip), %rsi      # 0xe67a
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
jmp 0x5c06
movl -0x48(%rbp), %edi
shll $0x2, %edi
movq -0x28(%rbp), %rsi
callq 0x2f20
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x28(%rbp), %rax
movslq %edx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
cmpl $0x1, -0x2c(%rbp)
jne 0x5c53
movq -0x28(%rbp), %rdi
callq 0x3010
movq -0x28(%rbp), %rax
movb $0x0, -0x1(%rax)
jmp 0x5c76
cmpl $0x2, -0x2c(%rbp)
jne 0x5c6c
movq -0x28(%rbp), %rdi
callq 0x3060
movq -0x28(%rbp), %rax
movb $0x0, -0x1(%rax)
jmp 0x5c74
movq -0x28(%rbp), %rax
movb $0x4, -0x1(%rax)
jmp 0x5c76
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)