def random_action(self, b):
action = random.choice([<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:5>, <NUM_LIT:6>, <NUM_LIT:7>, <NUM_LIT:8>, <NUM_LIT:9>, <NUM_LIT:10>])<EOL>if len(b) >= <NUM_LIT:3>:<EOL><INDENT>pos = random.randint(<NUM_LIT:0>, len(b)-<NUM_LIT:2>)<EOL>if action == <NUM_LIT:1>:<EOL><INDENT>rbyte = random.randrange(<NUM_LIT>)<EOL>rn = random.randrange(len(b))<EOL>b[rn] = "<STR_LIT>" % rbyte<EOL><DEDENT>elif action == <NUM_LIT:2>:<EOL><INDENT>howmany = random.randint(<NUM_LIT:1>, <NUM_LIT:100>)<EOL>curpos = pos<EOL>for _ in range(<NUM_LIT:0>, howmany):<EOL><INDENT>b.insert(curpos, b[pos])<EOL>pos += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif action == <NUM_LIT:3>:<EOL><INDENT>n = random.choice([<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:4>])<EOL>for _ in range(<NUM_LIT:0>, n):<EOL><INDENT>if len(b) > pos+<NUM_LIT:1>:<EOL><INDENT>tmp = b[pos]<EOL>b[pos] = b[pos+<NUM_LIT:1>]<EOL>b[pos+<NUM_LIT:1>] = tmp<EOL>pos += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>pos -= <NUM_LIT:2><EOL>tmp = b[pos]<EOL>b[pos] = b[pos+<NUM_LIT:1>]<EOL>b[pos+<NUM_LIT:1>] = tmp<EOL>pos += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>elif action in [<NUM_LIT:4>, <NUM_LIT:5>]:<EOL><INDENT>op = {<EOL><NUM_LIT:4>: lambda x, y: ord(x) << y,<EOL><NUM_LIT:5>: lambda x, y: ord(x) >> y,<EOL>}<EOL>n = random.choice([<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:4>])<EOL>if len(b) < pos+n:<EOL><INDENT>pos = len(b) - (pos+n)<EOL><DEDENT>if n == <NUM_LIT:1>:<EOL><INDENT>f = "<STR_LIT>"<EOL>s = op[action](b[pos], n) % <NUM_LIT><EOL><DEDENT>elif n == <NUM_LIT:2>:<EOL><INDENT>f = "<STR_LIT>"<EOL>s = op[action](b[pos], n) % <NUM_LIT><EOL><DEDENT>elif n == <NUM_LIT:4>:<EOL><INDENT>f = "<STR_LIT>"<EOL>s = op[action](b[pos], n) % <NUM_LIT><EOL><DEDENT>val = struct.pack(f, s)<EOL>for v in val:<EOL><INDENT>if isinstance(v, int):<EOL><INDENT>v = chr(v)<EOL><DEDENT>b[pos] = v<EOL>pos += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif action == <NUM_LIT:6>:<EOL><INDENT>b.insert(random.randint(<NUM_LIT:0>, len(b)-<NUM_LIT:1>), random.choice(["<STR_LIT>", "<STR_LIT:[>", "<STR_LIT:]>", "<STR_LIT:+>", "<STR_LIT:->", "<STR_LIT:}>", "<STR_LIT:{>"]))<EOL><DEDENT>elif action == <NUM_LIT:7>:<EOL><INDENT>del b[random.randint(<NUM_LIT:0>, len(b)-<NUM_LIT:1>)]<EOL><DEDENT>elif action in [<NUM_LIT:8>, <NUM_LIT:9>]:<EOL><INDENT>block = random.choice([<EOL>(r"<STR_LIT>", r"<STR_LIT>"),<EOL>(r"<STR_LIT>", r"<STR_LIT>"),<EOL>(r"<STR_LIT>", r"<STR_LIT>")<EOL>])<EOL>b_str = self.safe_join(b)<EOL>block_re = re.compile(str("<STR_LIT>").format(block[<NUM_LIT:0>], block[<NUM_LIT:1>], block[<NUM_LIT:0>], block[<NUM_LIT:1>]))<EOL>if block_re.search(b_str):<EOL><INDENT>r = random.choice(block_re.findall(b_str))<EOL>random_re = re.compile("<STR_LIT>".format(re.escape(r)))<EOL>if random_re.search(b_str):<EOL><INDENT>if action == <NUM_LIT:8>:<EOL><INDENT>newarr = list(random_re.sub("<STR_LIT>", b_str))<EOL>b[:] = newarr<EOL><DEDENT>else:<EOL><INDENT>newarr = list(random_re.sub("<STR_LIT>" * random.randint(<NUM_LIT:1>, <NUM_LIT:10>), b_str, <NUM_LIT:1>))<EOL>b[:] = newarr<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif action == <NUM_LIT:10>:<EOL><INDENT>b_str = self.safe_join(b)<EOL>limit_choice = random.choice([<EOL><NUM_LIT>,<EOL>-<NUM_LIT>,<EOL><NUM_LIT>,<EOL>-<NUM_LIT>,<EOL>])<EOL>block_re = re.compile("<STR_LIT>")<EOL>if block_re.search(b_str):<EOL><INDENT>block = random.choice([m for m in block_re.finditer(b_str)])<EOL>new = b_str[<NUM_LIT:0>:block.start()] + str(int(block.group())*limit_choice) + b_str[block.start() +<EOL>len(block.group()):]<EOL>b[:] = list(new)<EOL><DEDENT><DEDENT><DEDENT>
Perform the actual fuzzing using random strategies