def obfuscate_builtins(module, tokens, name_generator, table=None):
used_builtins = analyze.enumerate_builtins(tokens)<EOL>obfuscated_assignments = remap_name(name_generator, used_builtins, table)<EOL>replacements = []<EOL>for assignment in obfuscated_assignments.split('<STR_LIT:\n>'):<EOL><INDENT>replacements.append(assignment.split('<STR_LIT:=>')[<NUM_LIT:0>])<EOL><DEDENT>replacement_dict = dict(zip(used_builtins, replacements))<EOL>if table:<EOL><INDENT>table[<NUM_LIT:0>].update(replacement_dict)<EOL><DEDENT>iter_replacements = iter(replacements)<EOL>for builtin in used_builtins:<EOL><INDENT>replace_obfuscatables(<EOL>module, tokens, obfuscate_unique, builtin, iter_replacements)<EOL><DEDENT>skip_tokens = <NUM_LIT:0><EOL>matched_shebang = False<EOL>matched_encoding = False<EOL>for tok in tokens[<NUM_LIT:0>:<NUM_LIT:4>]: <EOL><INDENT>line = tok[<NUM_LIT:4>]<EOL>if analyze.shebang.match(line): <EOL><INDENT>if not matched_shebang:<EOL><INDENT>matched_shebang = True<EOL>skip_tokens += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif analyze.encoding.match(line): <EOL><INDENT>if not matched_encoding:<EOL><INDENT>matched_encoding = True<EOL>skip_tokens += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>insert_in_next_line(tokens, skip_tokens, obfuscated_assignments)<EOL>
Inserts an assignment, '<obfuscated identifier> = <builtin function>'  at
the beginning of *tokens* (after the shebang and encoding if present) for
every Python built-in function that is used inside *tokens*.  Also, replaces
all of said builti-in functions in *tokens* with each respective obfuscated
identifer.

Obfuscated identifier names are pulled out of name_generator via next().

If *table* is provided, replacements will be looked up there before
generating a new unique name.