///|
fn parse_iterations(args : Array[String]) -> Int {
  if args.length() < 2 {
    return 1
  }
  let mut value = 0
  for ch in args[1] {
    let digit = ch.to_int() - '0'.to_int()
    if digit < 0 || digit > 9 {
      return 1
    }
    value = value * 10 + digit
  }
  if value > 0 {
    value
  } else {
    1
  }
}

///|
fn fixture_score() -> @theory.Score raise Failure {
  let score = @theory.Score::new(480)
  let track = score.add_track("benchmark")
  let roots = ["C4", "F4", "G4", "C4"]
  let types = [
    @theory.ChordType::MajorTriad,
    @theory.ChordType::MajorTriad,
    @theory.ChordType::DominantSeventh,
    @theory.ChordType::MajorTriad,
  ]
  for i in 0.. abort(err.to_string())
    }
    checksum += report.duration_ticks +
      report.note_event_count +
      report.chord_event_count +
      leading.total_semitone_motion +
      decoded.tracks.length() +
      decoded.tracks[0].events.length()
  }
  println(
    "iterations=\{iterations} checksum=\{checksum} fixture=four-chord-report-voice-leading-smf",
  )
}