You are given a text file containing a small straight-line program in three-address code.
In plain English, this is just a short list of assignments such as:
a = var1 + var2
b = a * 3
res = b
You are not building a real compiler. Instead, you are analyzing this assignment list to answer two questions:
- how much runtime work the remaining arithmetic operations would cost,
- and what is the largest number of computed temporary values that need to exist at the same time.
Your task is to compute the optimized runtime cost and peak temporary-memory cost of the program.
Each test case file also includes an operator cost model, so the cost of +, -, *, and / may vary across test cases. You must read those costs from the file instead of hardcoding them.
The final program output is always the variable res.
Assumptions:
- each line is an assignment,
- variables are assigned at most once,
/ uses integer division for constant folding,
- input variables such as
var1 already exist and do not count toward temporary memory,
- literals do not count toward temporary memory.
In plain English, each test case file is just a short list of assignments like `a = var1 + var2`, `b = a * 3`, `res = b`.
You are not building a real compiler. You are reading that assignment list to measure how much arithmetic work it does and how many computed temporary values need to stay alive at once.
The test case files are the `instruction*.txt` files under `tests/data/`. Each one stores both the operator cost model and the expected optimized totals directly inside the file.
The helper in `optimizer_utils.py` is currently wrong, which makes later tests misleading.
Fix the metadata loader so that it correctly reads:
- per-operator runtime costs,
- the expected optimized `(time, memory)` totals,
- and the actual program lines.
Keep the public function signature unchanged.
test_reads_per_file_operator_costs
test_reads_multi_digit_metadata_values
test_ignores_comments_and_blank_lines_in_program_body