def METHOD_NAME(code, result_symbols, rng_name):
    for r in result_symbols:
        statement = f" {r.name};"
        assert statement in code, f"no declaration for variable '{r.name}' in '{code}'"
        code = code.replace(statement, f" {r.name}{{}};", 1)
    statement = f"{rng_name}("
    assert code.count(statement) == 1, f"need 1 '{rng_name}' call in '{code}'"
    lines = code.rstrip().split("\n")
    assert lines[-1].startswith(rng_name), f"'{rng_name}' not in '{lines[-1]}'"
    lines[-1] = f"if (kT > 0.) {{  \n{lines[-1]}\n}}"
    return "\n".join(lines)