#!/usr/bin/perl

sub isSpecial {
    my ($a) = @_;
    if ($a =~ m/x86\\_64/i) {
	return 1;
    }
    return 0;
}

my ($all, $first, $second);
my $third;
while ($ln = <>) {
    chomp $ln;
    $okay = 1;
    while ($okay && $ln =~ m/((\w+)\\_((\w+)(\\_)*)*)/) {
	print STDERR "LN:   $ln\n";
	print STDERR "Got 1: $1 and 2: $2 and 3: $3 and 4: $4 and 5 $5\n";
	if (1 == isSpecial($1)) {
	    print STDERR "SPECIAL $1 in line: $ln\n";
	    $okay = 0;
	} elsif ($ln =~ m/\&/ && ! $ln =~ m/\\\&/) {
	    print STDERR "TABULAR: $ln\n";
	} else {
	    ($all, $first, $second) =  ($1, $2, $3);
	    $all =~ s/\\_/_/g;
	    $all = qq($all);
	    $third = "\\ident{$all}";
	    $ln =~ s/((\w+)\\_((\w+)(\\_)*)*)/$third/;
	    print STDERR "OUT: $ln\n";
	}
    }
    print "$ln\n";
}
