def METHOD_NAME(evm: Evm) -> None:
    """
    Sign extend operation. In other words, extend a signed number which
    fits in N bytes to 32 bytes.
    Parameters
    ----------
    evm :
        The current EVM frame.
    """
    # STACK
    byte_num = pop(evm.stack)
    value = pop(evm.stack)
    # GAS
    charge_gas(evm, GAS_LOW)
    # OPERATION
    if byte_num > 31:
        # Can't extend any further
        result = value
    else:
        # U256(0).to_be_bytes() gives b'' instead b'\x00'.
        value_bytes = bytes(value.to_be_bytes32())
        # Now among the obtained value bytes, consider only
        # N `least significant bytes`, where N is `byte_num + 1`.
        value_bytes = value_bytes[31 - int(byte_num) :]
        sign_bit = value_bytes[0] >> 7
        if sign_bit == 0:
            result = U256.from_be_bytes(value_bytes)
        else:
            num_bytes_prepend = 32 - (byte_num + 1)
            result = U256.from_be_bytes(
                bytearray([0xFF] * num_bytes_prepend) + value_bytes
            )
    push(evm.stack, result)
    # PROGRAM COUNTER
    evm.pc += 1