Rating:

The program gave us the first and last part:

image

The middle part is what we had to find.

It was being tested here:

image

Converted each if block to this:

image

And then just checking the flag gave us the middle part.

image

Original writeup (https://github.com/CBC-MIT/CTF-Writeups/tree/main/VishwaCTF2k23/Phi%20Calculator).