

def buildComplexComparisonNode(provider, left, rights, comparators, source_ref):
    outline_body = ExpressionOutlineBody(provider=provider, name='comparison_chain', source_ref=source_ref)
    variables = [outline_body.allocateTempVariable(temp_scope=None, name=('operand_%d' % count)) for count in range(2, (len(rights) + 2))]
    tmp_variable = outline_body.allocateTempVariable(temp_scope=None, name='comparison_result')

    def makeTempAssignment(count, value):
        return StatementAssignmentVariable(variable_ref=ExpressionTargetTempVariableRef(variable=variables[count], source_ref=source_ref), source=value, source_ref=source_ref)

    def makeReleaseStatement(count):
        return StatementReleaseVariable(variable=variables[count], source_ref=source_ref)

    def makeValueComparisonReturn(left, right, comparator):
        (yield StatementAssignmentVariable(variable_ref=ExpressionTargetTempVariableRef(variable=tmp_variable, source_ref=source_ref), source=makeComparisonNode(left=left, right=right, comparator=comparator, source_ref=source_ref), source_ref=source_ref))
        (yield StatementConditional(condition=ExpressionOperationNOT(operand=ExpressionTempVariableRef(variable=tmp_variable, source_ref=source_ref), source_ref=source_ref), yes_branch=makeStatementsSequenceFromStatement(statement=StatementReturn(expression=ExpressionTempVariableRef(variable=tmp_variable, source_ref=source_ref), source_ref=source_ref)), no_branch=None, source_ref=source_ref))
    statements = []
    final = []
    for (count, value) in enumerate(rights):
        if (value is not rights[(- 1)]):
            statements.append(makeTempAssignment(count, value))
            final.append(makeReleaseStatement(count))
            right = ExpressionTempVariableRef(variable=variables[count], source_ref=source_ref)
        else:
            right = value
        if (count != 0):
            left = ExpressionTempVariableRef(variable=variables[(count - 1)], source_ref=source_ref)
        comparator = comparators[count]
        if (value is not rights[(- 1)]):
            statements.extend(makeValueComparisonReturn(left, right, comparator))
        else:
            statements.append(StatementReturn(expression=makeComparisonNode(left=left, right=right, comparator=comparator, source_ref=outline_body), source_ref=source_ref))
            final.append(StatementReleaseVariable(variable=tmp_variable, source_ref=source_ref))
    outline_body.setBody(makeStatementsSequenceFromStatement(statement=makeTryFinallyStatement(provider=outline_body, tried=statements, final=final, source_ref=source_ref)))
    return outline_body

dataset/ETHPy150Open kayhayen/Nuitka/nuitka/tree/ReformulationComparisonExpressions.py buildComplexComparisonNode/VarMisuse@457/641 `source_ref`->`outline_body`