def set_loc(instr, loc):
    """
    Set new location in an instruction
    :param instr: target instruction
    :param loc: location object to be set
    :return: instruction with updated location
    """
    t = type(instr)
    l = len(instr)
    return t(instr[:l-2] + (loc,) + instr[-1:])