#!/usr/bin/perl -w

# runs disasm-solution and strips the 
# unused labels from the output

# (leaves a single space at the start of
# lines whose labels are removed)

$_=`disasm-solution`;

s/(L[0-9a-fA-F]{8}):/ finduse($1) && "$1:" /gme;

sub finduse {
  my($l)=@_;
  return /:.*$l/; # return whether the label is used on a line after the :
}

print;
