'Try to classify an immediate as a pointer.
:param int imm: The immediate to test.
:param int operand_type: Operand type of this operand, can either be IMM or MEM.
:param str mnemonic: Mnemonic of the instruction that this operand belongs to.
:return: A tuple of (is code reference, is data reference, base address, offset)
:rtype: tuple'

def _imm_to_ptr(self, imm, operand_type, mnemonic):

    (is_coderef, is_dataref) = (False, False)
    baseaddr = None
    if ((not is_coderef) and (not is_dataref)):
        if self.binary.main_executable_regions_contain(imm):
            if (imm in self.binary.all_insn_addrs):
                is_coderef = True
                baseaddr = imm
    if ((not is_coderef) and (not is_dataref)):
        if self.binary.main_nonexecutable_regions_contain(imm):
            is_dataref = True
            baseaddr = imm
    if ((not is_coderef) and (not is_dataref)):
        tolerance_before = (1024 if (operand_type == OP_TYPE_MEM) else 64)
        (contains_, baseaddr_) = self.binary.main_nonexecutable_region_limbos_contain(imm, tolerance_before=tolerance_before, tolerance_after=1024)
        if contains_:
            is_dataref = True
            baseaddr = baseaddr_
        if (not contains_):
            (contains_, baseaddr_) = self.binary.main_executable_region_limbos_contain(imm)
            if contains_:
                is_coderef = True
                baseaddr = baseaddr_
    return (is_coderef, is_dataref, baseaddr)
