(a) Except as otherwise provided in this section, a person who violates a provision of §§ 5–602 through 5–606 of this subtitle with respect to a Schedule I or Schedule II narcotic drug is guilty of a felony and on conviction is subject to imprisonment not exceeding 20 years or a fine not exceeding $15,000 or both.
(b) A person who is convicted under subsection (a) of this section or of conspiracy to commit a crime included in subsection (a) of this section is subject to imprisonment not exceeding 20 years or a fine not exceeding $15,000 or both if the person previously has been convicted once:
(1) under subsection (a) of this section or § 5–609 of this subtitle;
(2) of conspiracy to commit a crime included in subsection (a) of this section or § 5–609 of this subtitle; or
(3) of a crime under the laws of another state or the United States that would be a crime included in subsection (a) of this section or § 5–609 of this subtitle if committed in this State.
(c) (1) A person who is convicted under subsection (a) of this section or of conspiracy to commit a crime included in subsection (a) of this section is subject to imprisonment not exceeding 25 years or a fine not exceeding $25,000 or both if the person previously:
(i) has served at least one term of confinement of at least 180 days in a correctional institution as a result of a conviction:
1. under subsection (a) of this section or § 5–609 or § 5–614 of this subtitle;
2. of conspiracy to commit a crime included in subsection (a) of this section or § 5–609 of this subtitle; or
3. of a crime under the laws of another state or the United States that would be a crime included in subsection (a) of this section or § 5–609 of this subtitle if committed in this State; and
(ii) has been convicted twice, if the convictions arise from separate occasions:
1. under subsection (a) of this section or § 5–609 of this subtitle;
2. of conspiracy to commit a crime included in subsection (a) of this section or § 5–609 of this subtitle;
3. of a crime under the laws of another state or the United States that would be a crime included in subsection (a) of this section or § 5–609 of this subtitle if committed in this State; or
4. of any combination of these crimes.
(2) A separate occasion is one in which the second or succeeding crime is committed after there has been a charging document filed for the preceding crime.
(d) A person who is convicted under subsection (a) of this section or of conspiracy to commit a crime included in subsection (a) of this section is subject to imprisonment not exceeding 40 years or a fine not exceeding $25,000 or both if the person previously has served three or more separate terms of confinement as a result of three or more separate convictions:
(1) under subsection (a) of this section or § 5–609 of this subtitle;
(2) of conspiracy to commit a crime included in subsection (a) of this section or § 5–609 of this subtitle;
(3) of a crime under the laws of another state or the United States that would be a crime included in subsection (a) of this section or § 5–609 of this subtitle if committed in this State; or
(4) of any combination of these crimes.
(e) A person convicted under subsection (a) of this section or of conspiracy to commit a crime included in subsection (a) of this section is not prohibited from participating in a drug treatment program under § 8–507 of the Health – General Article because of the length of the sentence.