<s> import sys <EOL> def bytesToHumanReadable ( n ) : <EOL> kay = <NUM_LIT> <EOL> meg = kay * <NUM_LIT> <EOL> gig = meg * <NUM_LIT> <EOL> if ( ( <NUM_LIT:0> <= n ) and ( n < kay ) ) : <EOL> return "<STR_LIT>" % n <EOL> elif ( ( kay <= n ) and ( n < meg ) ) : <EOL> return "<STR_LIT>" % ( ( n + <NUM_LIT:0.0> ) / kay ) <EOL> elif ( ( meg <= n ) and ( n < gig ) ) : <EOL> return "<STR_LIT>" % ( ( n + <NUM_LIT:0.0> ) / meg ) <EOL> else : <EOL> return "<STR_LIT>" % ( ( n + <NUM_LIT:0.0> ) / gig ) <EOL> def readfile ( filename ) : <EOL> segments = [ ] <EOL> numSegments = <NUM_LIT:0> L <EOL> totalBytes = <NUM_LIT:0> L <EOL> infile = open ( filename , '<STR_LIT:r>' ) <EOL> line = infile . readline ( ) <EOL> while line : <EOL> line = line . rstrip ( ) <EOL> fields = line . split ( None , <NUM_LIT:5> ) <EOL> if <NUM_LIT:6> == len ( fields ) : <EOL> ( memRange , perms , offset , dev , inode , pathname ) = fields <EOL> elif <NUM_LIT:5> == len ( fields ) : <EOL> ( memRange , perms , offset , dev , inode ) = fields <EOL> pathname = '<STR_LIT>' <EOL> else : <EOL> raise Exception ( '<STR_LIT>' % ( line , ) ) <EOL> ( begin , end ) = memRange . split ( '<STR_LIT:->' ) <EOL> t = long ( end , <NUM_LIT:16> ) - long ( begin , <NUM_LIT:16> ) <EOL> totalBytes = totalBytes + t <EOL> numSegments = numSegments + <NUM_LIT:1> <EOL> x = ( t , memRange , pathname ) <EOL> segments . append ( x ) <EOL> line = infile . readline ( ) <EOL> print filename <EOL> print "<STR_LIT>" % ( numSegments , ) <EOL> print "<STR_LIT>" % ( totalBytes , bytesToHumanReadable ( totalBytes ) ) <EOL> for i in sorted ( segments , key = lambda x : x [ <NUM_LIT:0> ] , reverse = True ) : <EOL> print "<STR_LIT>" % ( i [ <NUM_LIT:0> ] , bytesToHumanReadable ( i [ <NUM_LIT:0> ] ) , i [ <NUM_LIT:1> ] , i [ <NUM_LIT:2> ] ) <EOL> readfile ( sys . argv [ <NUM_LIT:1> ] ) </s>
