my %lines; my %switches; my %jumps; while (<>) { $jumps{hex $1}{hex $2}++ if (/^n([0-9a-f]+)\s+->\s+n([0-9a-f]+)/); if (/^n([0-9a-f]+)\s+->\s+n([0-9a-f]+)\s+\[label=\"([0-9,-]+)\"/) { $switches{hex $1}{$3} = hex $2; } elsif (/^n([0-9a-f]+)\s+\[label=\".*?\\l'(.*)'\\l/) { my ($addr, $str) = ($1, $2); $str =~ s/'\\l'//g; $str =~ s/'\\l.*?\\l'/; /g; $str =~ s/\\\"/\"/g; $str =~ s/\\\\/\\/g; $lines{hex $addr} = $str; } } for my $switch (sort { $a <=> $b } keys %switches) { my %cases = %{$switches{$switch}}; printf "0x%08x:\n", $switch; for my $case (sort { $a <=> $b } keys %cases) { my $tgt = $cases{$case}; my @rtgt = keys %{$jumps{$tgt}||{}}; printf " %10s: 0x%08x %s -> %s\n", $case, $tgt, $lines{$tgt}||'?', join(',',map{sprintf('%08x',$_);}@rtgt); } }