# Path: androguard/decompiler/dad/basic_blocks.py
# def build_node_from_block(block, vmap, gen_ret, exception_type=None):
#     ins, lins = None, []
#     idx = block.get_start()
#     for ins in block.get_instructions():
#         opcode = ins.get_op_value()
#         if opcode == -1:  # FIXME? or opcode in (0x0300, 0x0200, 0x0100):
#             idx += ins.get_length()
#             continue
#         try:
#             _ins = INSTRUCTION_SET[opcode]
#         except IndexError:
#             logger.error('Unknown instruction : %s.', ins.get_name().lower())
#             _ins = INSTRUCTION_SET[0]
#         # fill-array-data
#         if opcode == 0x26:
#             fillarray = block.get_special_ins(idx)
#             lins.append(_ins(ins, vmap, fillarray))
#         # invoke-kind[/range]
#         elif 0x6e <= opcode <= 0x72 or 0x74 <= opcode <= 0x78:
#             lins.append(_ins(ins, vmap, gen_ret))
#         # filled-new-array[/range]
#         elif 0x24 <= opcode <= 0x25:
#             lins.append(_ins(ins, vmap, gen_ret.new()))
#         # move-result*
#         elif 0xa <= opcode <= 0xc:
#             lins.append(_ins(ins, vmap, gen_ret.last()))
#         # move-exception
#         elif opcode == 0xd:
#             lins.append(_ins(ins, vmap, exception_type))
#         # monitor-{enter,exit}
#         elif 0x1d <= opcode <= 0x1e:
#             idx += ins.get_length()
#             continue
#         else:
#             lins.append(_ins(ins, vmap))
#         idx += ins.get_length()
#     name = block.get_name()
#     # return*
#     if 0xe <= opcode <= 0x11:
#         node = ReturnBlock(name, lins)
#     # {packed,sparse}-switch
#     elif 0x2b <= opcode <= 0x2c:
#         idx -= ins.get_length()
#         values = block.get_special_ins(idx)
#         node = SwitchBlock(name, values, lins)
#     # if-test[z]
#     elif 0x32 <= opcode <= 0x3d:
#         node = CondBlock(name, lins)
#         node.off_last_ins = ins.get_ref_off()
#     # throw
#     elif opcode == 0x27:
#         node = ThrowBlock(name, lins)
#     else:
#         # goto*
#         if 0x28 <= opcode <= 0x2a:
#             lins.pop()
#         node = StatementBlock(name, lins)
#     return node
# 
# class StatementBlock(BasicBlock):
#     def __init__(self, name, block_ins):
#         super().__init__(name, block_ins)
#         self.type.is_stmt = True
# 
#     def visit(self, visitor):
#         return visitor.visit_statement_node(self)
# 
#     def __str__(self):
#         return '%d-Statement(%s)' % (self.num, self.name)
# 
# class CondBlock(BasicBlock):
#     def __init__(self, name, block_ins):
#         super().__init__(name, block_ins)
#         self.true = None
#         self.false = None
#         self.type.is_cond = True
# 
#     def update_attribute_with(self, n_map):
#         super().update_attribute_with(n_map)
#         self.true = n_map.get(self.true, self.true)
#         self.false = n_map.get(self.false, self.false)
# 
#     def neg(self):
#         if len(self.ins) != 1:
#             raise RuntimeWarning('Condition should have only 1 instruction !')
#         self.ins[-1].neg()
# 
#     def visit(self, visitor):
#         return visitor.visit_cond_node(self)
# 
#     def visit_cond(self, visitor):
#         if len(self.ins) != 1:
#             raise RuntimeWarning('Condition should have only 1 instruction !')
#         return visitor.visit_ins(self.ins[-1])
# 
#     def __str__(self):
#         return '%d-If(%s)' % (self.num, self.name)
# 
# Path: androguard/decompiler/dad/instruction.py
# class Variable(IRForm):
#     def __init__(self, value):
#         self.v = value
#         self.declared = False
#         self.type = None
#         self.name = value
# 
#     def get_used_vars(self):
#         return [self.v]
# 
#     def is_ident(self):
#         return True
# 
#     def value(self):
#         return self.v
# 
#     def visit(self, visitor):
#         return visitor.visit_variable(self)
# 
#     def visit_decl(self, visitor):
#         return visitor.visit_decl(self)
# 
#     def __str__(self):
#         return 'VAR_%s' % self.name


import logging
        import os
from collections import defaultdict
from androguard.decompiler.dad.basic_blocks import (build_node_from_block,
                                                    StatementBlock, CondBlock)
from androguard.decompiler.dad.instruction import Variable
        from pydot import Dot, Edge
                to_visit.append(child)
                visited.add(child)


class GenInvokeRetName:
    def __init__(self):
        self.num = 0
        self.ret = None

    def new(self):
        self.num += 1
        self.ret = Variable('tmp%d' % self.num)
        return self.ret

    def set_to(self, ret):
        self.ret = ret

    def last(self):
        return self.ret


def make_node(graph, block, block_to_node, vmap, gen_ret):
    node = block_to_node.get(block)
    if node is None:
        node = build_node_from_block(block, vmap, gen_ret)
        block_to_node[block] = node
    if block.exception_analysis:
        for _type, _, exception_target in block.exception_analysis.exceptions:
            exception_node = block_to_node.get(exception_target)
            if exception_node is None:

# Path: androguard/decompiler/dad/basic_blocks.py
# def build_node_from_block(block, vmap, gen_ret, exception_type=None):
#     ins, lins = None, []
#     idx = block.get_start()
#     for ins in block.get_instructions():
#         opcode = ins.get_op_value()
#         if opcode == -1:  # FIXME? or opcode in (0x0300, 0x0200, 0x0100):
#             idx += ins.get_length()
#             continue
#         try:
#             _ins = INSTRUCTION_SET[opcode]
#         except IndexError:
#             logger.error('Unknown instruction : %s.', ins.get_name().lower())
#             _ins = INSTRUCTION_SET[0]
#         # fill-array-data
#         if opcode == 0x26:
#             fillarray = block.get_special_ins(idx)
#             lins.append(_ins(ins, vmap, fillarray))
#         # invoke-kind[/range]
#         elif 0x6e <= opcode <= 0x72 or 0x74 <= opcode <= 0x78:
#             lins.append(_ins(ins, vmap, gen_ret))
#         # filled-new-array[/range]
#         elif 0x24 <= opcode <= 0x25:
#             lins.append(_ins(ins, vmap, gen_ret.new()))
#         # move-result*
#         elif 0xa <= opcode <= 0xc:
#             lins.append(_ins(ins, vmap, gen_ret.last()))
#         # move-exception
#         elif opcode == 0xd:
#             lins.append(_ins(ins, vmap, exception_type))
#         # monitor-{enter,exit}
#         elif 0x1d <= opcode <= 0x1e:
#             idx += ins.get_length()
#             continue
#         else:
#             lins.append(_ins(ins, vmap))
#         idx += ins.get_length()
#     name = block.get_name()
#     # return*
#     if 0xe <= opcode <= 0x11:
#         node = ReturnBlock(name, lins)
#     # {packed,sparse}-switch
#     elif 0x2b <= opcode <= 0x2c:
#         idx -= ins.get_length()
#         values = block.get_special_ins(idx)
#         node = SwitchBlock(name, values, lins)
#     # if-test[z]
#     elif 0x32 <= opcode <= 0x3d:
#         node = CondBlock(name, lins)
#         node.off_last_ins = ins.get_ref_off()
#     # throw
#     elif opcode == 0x27:
#         node = ThrowBlock(name, lins)
#     else:
#         # goto*
#         if 0x28 <= opcode <= 0x2a:
#             lins.pop()
#         node = StatementBlock(name, lins)
#     return node
# 
# class StatementBlock(BasicBlock):
#     def __init__(self, name, block_ins):
#         super().__init__(name, block_ins)
#         self.type.is_stmt = True
# 
#     def visit(self, visitor):
#         return visitor.visit_statement_node(self)
# 
#     def __str__(self):
#         return '%d-Statement(%s)' % (self.num, self.name)
# 
# class CondBlock(BasicBlock):
#     def __init__(self, name, block_ins):
#         super().__init__(name, block_ins)
#         self.true = None
#         self.false = None
#         self.type.is_cond = True
# 
#     def update_attribute_with(self, n_map):
#         super().update_attribute_with(n_map)
#         self.true = n_map.get(self.true, self.true)
#         self.false = n_map.get(self.false, self.false)
# 
#     def neg(self):
#         if len(self.ins) != 1:
#             raise RuntimeWarning('Condition should have only 1 instruction !')
#         self.ins[-1].neg()
# 
#     def visit(self, visitor):
#         return visitor.visit_cond_node(self)
# 
#     def visit_cond(self, visitor):
#         if len(self.ins) != 1:
#             raise RuntimeWarning('Condition should have only 1 instruction !')
#         return visitor.visit_ins(self.ins[-1])
# 
#     def __str__(self):
#         return '%d-If(%s)' % (self.num, self.name)
# 
# Path: androguard/decompiler/dad/instruction.py
# class Variable(IRForm):
#     def __init__(self, value):
#         self.v = value
#         self.declared = False
#         self.type = None
#         self.name = value
# 
#     def get_used_vars(self):
#         return [self.v]
# 
#     def is_ident(self):
#         return True
# 
#     def value(self):
#         return self.v
# 
#     def visit(self, visitor):
#         return visitor.visit_variable(self)
# 
#     def visit_decl(self, visitor):
#         return visitor.visit_decl(self)
# 
#     def __str__(self):
#         return 'VAR_%s' % self.name


# Path: androguard/decompiler/dad/graph.py
import logging
        import os
from collections import defaultdict
from androguard.decompiler.dad.basic_blocks import (build_node_from_block,
                                                    StatementBlock, CondBlock)
from androguard.decompiler.dad.instruction import Variable
        from pydot import Dot, Edge

                to_visit.append(child)
                visited.add(child)


class GenInvokeRetName:
    def __init__(self):
        self.num = 0
        self.ret = None

    def new(self):
        self.num += 1
        self.ret = Variable('tmp%d' % self.num)
        return self.ret

    def set_to(self, ret):
        self.ret = ret

    def last(self):
        return self.ret


def make_node(graph, block, block_to_node, vmap, gen_ret):
    node = block_to_node.get(block)
    if node is None:
        node = build_node_from_block(block, vmap, gen_ret)
        block_to_node[block] = node
    if block.exception_analysis:
        for _type, _, exception_target in block.exception_analysis.exceptions:
            exception_node = block_to_node.get(exception_target)
            if exception_node is None:

                exception_node = build_node_from_block(exception_target, vmap,