# Path: sibyl/commons.py
# def objc_is_dereferenceable(target_type):
#     """Return True if target_type may be used as a pointer
#     @target_type: ObjC"""
#     return isinstance(target_type, (ObjCPtr, ObjCArray))
# 
# Path: sibyl/config.py
# class Config(object):
#     def __init__(self, default_config, files):
#     def expandpath(path):
#     def parse_files(self, files):
#     def dump(self):
#     def jit_engine(self):
#     def available_tests(self):
#     def miasm_engine(self):
#     def pin_root(self):
#     def pin_tracer(self):
#     def prune_strategy(self):
#     def prune_keep(self):
#     def prune_keep_max(self):
#     def stubs(self):
#     def idaq64_path(self):
#     def ghidra_headless_path(self):
#     def ghidra_export_function(self):


import struct
import logging
import miasm2.expression.expression as m2_expr
from miasm2.jitter.loader.elf import vm_load_elf
from miasm2.analysis.machine import Machine
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_ACCESS_VIOL, EXCEPT_DIV_BY_ZERO, EXCEPT_PRIV_INSN
from miasm2.core.bin_stream import bin_stream_vm
from miasm2.analysis.dse import ESETrackModif
from miasm2.ir.ir import AssignBlock
from miasm2.core.objc import CHandler
from sibyl.commons import objc_is_dereferenceable
from sibyl.config import config
        self.symb.symbols = self.symbols_init
        for expr in self.memories_read:
            # Eval the expression with the *input* state
            original_expr = expr.replace_expr(self.init_values)
            value = self.symb.eval_expr(original_expr)
            assert isinstance(value, m2_expr.ExprInt)
            memory_in[expr] = value
        self.symb.symbols = saved_symbols

        if self.logger.isEnabledFor(logging.DEBUG):
            print "In:"
            print memory_in
            print "Out:"
            print memory_out
            print "Final value:"
            print output_value

        self.snapshot.memory_in = AssignBlock(memory_in)
        self.snapshot.memory_out = AssignBlock(memory_out)
        self.snapshot.output_value = output_value
        self.snapshot.c_handler = self.c_handler
        self.snapshot.typed_C_ids = self.typed_C_ids
        self.snapshot.arguments_symbols = self.args_symbols
        self.snapshot.init_values = self.init_values

    def run(self):
        '''Main function that is in charge of running the test and return the result:
        true if the snapshot has recognized the function, false else.'''

        # TODO inherit from Replay

# Path: sibyl/commons.py
# def objc_is_dereferenceable(target_type):
#     """Return True if target_type may be used as a pointer
#     @target_type: ObjC"""
#     return isinstance(target_type, (ObjCPtr, ObjCArray))
# 
# Path: sibyl/config.py
# class Config(object):
#     def __init__(self, default_config, files):
#     def expandpath(path):
#     def parse_files(self, files):
#     def dump(self):
#     def jit_engine(self):
#     def available_tests(self):
#     def miasm_engine(self):
#     def pin_root(self):
#     def pin_tracer(self):
#     def prune_strategy(self):
#     def prune_keep(self):
#     def prune_keep_max(self):
#     def stubs(self):
#     def idaq64_path(self):
#     def ghidra_headless_path(self):
#     def ghidra_export_function(self):


# Path: sibyl/learn/findref.py
import struct
import logging
import miasm2.expression.expression as m2_expr
from miasm2.jitter.loader.elf import vm_load_elf
from miasm2.analysis.machine import Machine
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_ACCESS_VIOL, EXCEPT_DIV_BY_ZERO, EXCEPT_PRIV_INSN
from miasm2.core.bin_stream import bin_stream_vm
from miasm2.analysis.dse import ESETrackModif
from miasm2.ir.ir import AssignBlock
from miasm2.core.objc import CHandler
from sibyl.commons import objc_is_dereferenceable
from sibyl.config import config

        self.symb.symbols = self.symbols_init
        for expr in self.memories_read:
            # Eval the expression with the *input* state
            original_expr = expr.replace_expr(self.init_values)
            value = self.symb.eval_expr(original_expr)
            assert isinstance(value, m2_expr.ExprInt)
            memory_in[expr] = value
        self.symb.symbols = saved_symbols

        if self.logger.isEnabledFor(logging.DEBUG):
            print "In:"
            print memory_in
            print "Out:"
            print memory_out
            print "Final value:"
            print output_value

        self.snapshot.memory_in = AssignBlock(memory_in)
        self.snapshot.memory_out = AssignBlock(memory_out)
        self.snapshot.output_value = output_value
        self.snapshot.c_handler = self.c_handler
        self.snapshot.typed_C_ids = self.typed_C_ids
        self.snapshot.arguments_symbols = self.args_symbols
        self.snapshot.init_values = self.init_values

    def run(self):
        '''Main function that is in charge of running the test and return the result:
        true if the snapshot has recognized the function, false else.'''

        # TODO inherit from Replay

        jitter = self.machine.jitter(config.miasm_engine)