To determine whether there is a relationship between two op

For example, I initialize the variable at the very beginning of the code: int split=0. The code is followed by a recursive call with split as an argument input.
Meanwhile, inside MLIR, there is a lot of constant initialization at the beginning, such as
%c-1_i32 = arith.constant -1 : i32
%c0_i32 = arith.constant 0 : i32
%c32_i32 = arith.constant 32 : i32
%c1_i32 = arith.constant 1 : i32
%false = arith.constant false
%true = arith.constant true

Question: How do I extract this custom variable in MLIR, as I need to generate a stack for it, preferably with dynamic detection of a different number of custom variables.
My thinking is to find the variable by starting to go through the op,and I look for the input parameters (getOperands) of the recursive call ( to discern if there is a relationship between them.
I’m not sure if this looks reliable, I hope I’ve described my question clearly and look forward to getting an answer. Thanks !