parameters: (asm)
return_statement: return new_contents
docstring: Strip the ASM of unwanted directives and lines
docstring_summary: Strip the ASM of unwanted directives and lines
docstring_tokens: Strip the ASM of unwanted directives and lines
function: def process_asm(asm):
      """
      Strip the ASM of unwanted directives and lines
      """
      new_contents = ''
      asm = transform_labels(asm)
  
      # TODO: Add more things we want to remove
      discard_regexes = [
          re.compile("\s+\..*$"), # directive
          re.compile("\s*#(NO_APP|APP)$"), #inline ASM
          re.compile("\s*#.*$"), # comment line
          re.compile("\s*\.globa?l\s*([.a-zA-Z_][a-zA-Z0-9$_.]*)"), #global directive
          re.compile("\s*\.(string|asciz|ascii|[1248]?byte|short|word|long|quad|value|zero)"),
      ]
      keep_regexes = [
  
      ]
      fn_label_def = re.compile("^[a-zA-Z_][a-zA-Z0-9_.]*:")
      for l in asm.splitlines():
          # Remove Mach-O attribute
          l = l.replace('@GOTPCREL', '')
          add_line = True
          for reg in discard_regexes:
              if reg.match(l) is not None:
                  add_line = False
                  break
          for reg in keep_regexes:
              if reg.match(l) is not None:
                  add_line = True
                  break
          if add_line:
              if fn_label_def.match(l) and len(new_contents) != 0:
                  new_contents += '\n'
              l = process_identifiers(l)
              new_contents += l
              new_contents += '\n'
      return new_contents
function_tokens: def process_asm ( asm ) : new_contents = '' asm = transform_labels ( asm ) # TODO: Add more things we want to remove discard_regexes = [ re . compile ( "\s+\..*$" ) , # directive re . compile ( "\s*#(NO_APP|APP)$" ) , #inline ASM re . compile ( "\s*#.*$" ) , # comment line re . compile ( "\s*\.globa?l\s*([.a-zA-Z_][a-zA-Z0-9$_.]*)" ) , #global directive re . compile ( "\s*\.(string|asciz|ascii|[1248]?byte|short|word|long|quad|value|zero)" ) , ] keep_regexes = [ ] fn_label_def = re . compile ( "^[a-zA-Z_][a-zA-Z0-9_.]*:" ) for l in asm . splitlines ( ) : # Remove Mach-O attribute l = l . replace ( '@GOTPCREL' , '' ) add_line = True for reg in discard_regexes : if reg . match ( l ) is not None : add_line = False break for reg in keep_regexes : if reg . match ( l ) is not None : add_line = True break if add_line : if fn_label_def . match ( l ) and len ( new_contents ) != 0 : new_contents += '\n' l = process_identifiers ( l ) new_contents += l new_contents += '\n' return new_contents