If it shall appear to the judge, by affidavit, or upon hearing of the matter, or otherwise, or upon the inspection of the process or warrant of commitment, and such other papers in the proceedings as may be shown to the judge, that the party is guilty of a criminal offense, or ought not to be discharged, the judge, although the charge is defectively or unsubstantially set forth in such process or warrant of commitment, shall cause the complainant, or other necessary witnesses, to be subpoenaed to attend at such time as ordered, to testify before the judge; and upon the examination, the judge shall discharge such prisoner, let the prisoner to bail, if the offense be bailable, or recommit the prisoner to custody, as may be just and legal.
NRS 34.520