# mediumlevelil module

`binaryninja.mediumlevelil.MediumLevelILBasicBlock`(...) |
`binaryninja.mediumlevelil.MediumLevelILExpr`(index) | `class MediumLevelILExpr` hold the index of IL Expressions.
`binaryninja.mediumlevelil.MediumLevelILFunction`(arch) | `class MediumLevelILFunction` contains the list of MediumLevelILExpr objects that make up a binaryninja.function. MediumLevelILExpr
`binaryninja.mediumlevelil.MediumLevelILInstruction`(...) | `class MediumLevelILInstruction` Medium Level Intermediate Language Instructions are infinite length tree-based
`binaryninja.mediumlevelil.MediumLevelILLabel`([...]) |
`binaryninja.mediumlevelil.MediumLevelILOperationAndSize`(...) |
`binaryninja.mediumlevelil.SSAVariable`(var, ...) |
`binaryninja.mediumlevelil.range`(*args) | A Python2 and Python3 Compatible Range Generator

class `binaryninja.mediumlevelil.``MediumLevelILBasicBlock`(view, handle, owner)

  Bases: `binaryninja.basicblock.BasicBlock`

class `binaryninja.mediumlevelil.``MediumLevelILExpr`(index)

  Bases: `object`

  `class MediumLevelILExpr` hold the index of IL Expressions.

  Note

  This class shouldn’t be instantiated directly. Rather the helper members of MediumLevelILFunction should be used instead.

class `binaryninja.mediumlevelil.``MediumLevelILFunction`(arch, handle=None, source_func=None)

  Bases: `object`

  `class MediumLevelILFunction` contains the list of MediumLevelILExpr objects that make up a binaryninja.function. MediumLevelILExpr objects can be added to the MediumLevelILFunction by calling `append` and passing the result of the various class methods which return MediumLevelILExpr objects.

  `add_label_list`(labels)

    `add_label_list` returns a label list expression for the given list of MediumLevelILLabel objects.

    Parameters: | lables (list(MediumLevelILLabel)) – the list of MediumLevelILLabel to get a label list expression from
    Returns: | the label list expression
    Return type: | MediumLevelILExpr

  `add_operand_list`(operands)

    `add_operand_list` returns an operand list expression for the given list of integer operands.

    Parameters: | operands (list(int)) – list of operand numbers
    Returns: | an operand list expression
    Return type: | MediumLevelILExpr

  `append`(expr)

    `append` adds the MediumLevelILExpr `expr` to the current MediumLevelILFunction.

    Parameters: | expr (MediumLevelILExpr) – the MediumLevelILExpr to add to the current MediumLevelILFunction
    Returns: | number of MediumLevelILExpr in the current function
    Return type: | int

  `basic_blocks`

    list of MediumLevelILBasicBlock objects (read-only)

  `current_address`

    Current IL Address (read/write)

  `expr`(operation, a=0, b=0, c=0, d=0, e=0, size=0)
  `finalize`()

    `finalize` ends the function and computes the list of basic blocks.

    Return type: | None

  `get_instruction_start`(addr, arch=None)
  `get_low_level_il_expr_index`(expr)
  `get_low_level_il_instruction_index`(instr)
  `get_non_ssa_instruction_index`(instr)
  `get_ssa_instruction_index`(instr)
  `get_ssa_memory_definition`(version)
  `get_ssa_memory_uses`(version)
  `get_ssa_var_definition`(ssa_var)
  `get_ssa_var_uses`(ssa_var)
  `get_ssa_var_value`(ssa_var)
  `get_var_definitions`(var)
  `get_var_uses`(var)
  `goto`(label)

    `goto` returns a goto expression which jumps to the provided MediumLevelILLabel.

    Parameters: | label (MediumLevelILLabel) – Label to jump to
    Returns: | the MediumLevelILExpr that jumps to the provided label
    Return type: | MediumLevelILExpr

  `if_expr`(operand, t, f)

    `if_expr` returns the `if` expression which depending on condition `operand` jumps to the MediumLevelILLabel `t` when the condition expression `operand` is non-zero and `f` when it’s zero.

    Parameters:

    - operand (MediumLevelILExpr) – comparison expression to evaluate.
    - t (MediumLevelILLabel) – Label for the true branch
    - f (MediumLevelILLabel) – Label for the false branch

    Returns: | the MediumLevelILExpr for the if expression
    Return type: | MediumLevelILExpr

  `is_ssa_var_live`(ssa_var)

    `is_ssa_var_live` determines if `ssa_var` is live at any point in the function

    Parameters: | ssa_var (SSAVariable) – the SSA variable to query
    Returns: | whether the variable is live at any point in the function
    Return type: | bool

  `low_level_il`

    Low level IL for this function

  `mark_label`(label)

    `mark_label` assigns a MediumLevelILLabel to the current IL address.

    Parameters: | label (MediumLevelILLabel) –
    Return type: | None

  `non_ssa_form`

    Medium level IL in non-SSA (default) form (read-only)

  `operand`(n, expr)

    `operand` sets the operand number of the expression `expr` and passes back `expr` without modification.

    Parameters:

    - n (int) –
    - expr (MediumLevelILExpr) –

    Returns: | returns the expression `expr` unmodified
    Return type: | MediumLevelILExpr

  `set_current_address`(value, arch=None)
  `ssa_form`

    Medium level IL in SSA form (read-only)

class `binaryninja.mediumlevelil.``MediumLevelILInstruction`(func, expr_index, instr_index=None)

  Bases: `object`

  `class MediumLevelILInstruction` Medium Level Intermediate Language Instructions are infinite length tree-based instructions. Tree-based instructions use infix notation with the left hand operand being the destination operand. Infix notation is thus more natural to read than other notations (e.g. x86 `mov eax, 0` vs. MLIL `eax = 0`).

  `ILOperations` = {<MediumLevelILOperation.MLIL_NOP: 0>: [], <MediumLevelILOperation.MLIL_SET_VAR: 1>: [('dest', 'var'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_FIELD: 2>: [('dest', 'var'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SPLIT: 3>: [('high', 'var'), ('low', 'var'), ('src', 'expr')], <MediumLevelILOperation.MLIL_LOAD: 4>: [('src', 'expr')], <MediumLevelILOperation.MLIL_LOAD_STRUCT: 5>: [('src', 'expr'), ('offset', 'int')], <MediumLevelILOperation.MLIL_STORE: 6>: [('dest', 'expr'), ('src', 'expr')], <MediumLevelILOperation.MLIL_STORE_STRUCT: 7>: [('dest', 'expr'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_VAR: 8>: [('src', 'var')], <MediumLevelILOperation.MLIL_VAR_FIELD: 9>: [('src', 'var'), ('offset', 'int')], <MediumLevelILOperation.MLIL_VAR_SPLIT: 10>: [('high', 'var'), ('low', 'var')], <MediumLevelILOperation.MLIL_ADDRESS_OF: 11>: [('src', 'var')], <MediumLevelILOperation.MLIL_ADDRESS_OF_FIELD: 12>: [('src', 'var'), ('offset', 'int')], <MediumLevelILOperation.MLIL_CONST: 13>: [('constant', 'int')], <MediumLevelILOperation.MLIL_CONST_PTR: 14>: [('constant', 'int')], <MediumLevelILOperation.MLIL_FLOAT_CONST: 15>: [('constant', 'float')], <MediumLevelILOperation.MLIL_IMPORT: 16>: [('constant', 'int')], <MediumLevelILOperation.MLIL_ADD: 17>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_ADC: 18>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_SUB: 19>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_SBB: 20>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_AND: 21>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_OR: 22>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_XOR: 23>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_LSL: 24>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_LSR: 25>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_ASR: 26>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_ROL: 27>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_RLC: 28>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_ROR: 29>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_RRC: 30>: [('left', 'expr'), ('right', 'expr'), ('carry', 'expr')], <MediumLevelILOperation.MLIL_MUL: 31>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MULU_DP: 32>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MULS_DP: 33>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVU: 34>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVU_DP: 35>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVS: 36>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_DIVS_DP: 37>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODU: 38>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODU_DP: 39>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODS: 40>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_MODS_DP: 41>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_NEG: 42>: [('src', 'expr')], <MediumLevelILOperation.MLIL_NOT: 43>: [('src', 'expr')], <MediumLevelILOperation.MLIL_SX: 44>: [('src', 'expr')], <MediumLevelILOperation.MLIL_ZX: 45>: [('src', 'expr')], <MediumLevelILOperation.MLIL_LOW_PART: 46>: [('src', 'expr')], <MediumLevelILOperation.MLIL_JUMP: 47>: [('dest', 'expr')], <MediumLevelILOperation.MLIL_JUMP_TO: 48>: [('dest', 'expr'), ('targets', 'int_list')], <MediumLevelILOperation.MLIL_CALL: 49>: [('output', 'var_list'), ('dest', 'expr'), ('params', 'expr_list')], <MediumLevelILOperation.MLIL_CALL_UNTYPED: 50>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_CALL_OUTPUT: 51>: [('dest', 'var_list')], <MediumLevelILOperation.MLIL_CALL_PARAM: 52>: [('src', 'var_list')], <MediumLevelILOperation.MLIL_RET: 53>: [('src', 'expr_list')], <MediumLevelILOperation.MLIL_NORET: 54>: [], <MediumLevelILOperation.MLIL_IF: 55>: [('condition', 'expr'), ('true', 'int'), ('false', 'int')], <MediumLevelILOperation.MLIL_GOTO: 56>: [('dest', 'int')], <MediumLevelILOperation.MLIL_CMP_E: 57>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_NE: 58>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SLT: 59>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_ULT: 60>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SLE: 61>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_ULE: 62>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SGE: 63>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_UGE: 64>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_SGT: 65>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_CMP_UGT: 66>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_TEST_BIT: 67>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_BOOL_TO_INT: 68>: [('src', 'expr')], <MediumLevelILOperation.MLIL_ADD_OVERFLOW: 69>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_SYSCALL: 70>: [('output', 'var_list'), ('params', 'expr_list')], <MediumLevelILOperation.MLIL_SYSCALL_UNTYPED: 71>: [('output', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_TAILCALL: 72>: [('output', 'var_list'), ('dest', 'expr'), ('params', 'expr_list')], <MediumLevelILOperation.MLIL_TAILCALL_UNTYPED: 73>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_INTRINSIC: 74>: [('output', 'var_list'), ('intrinsic', 'intrinsic'), ('params', 'expr_list')], <MediumLevelILOperation.MLIL_FREE_VAR_SLOT: 75>: [('dest', 'var')], <MediumLevelILOperation.MLIL_BP: 76>: [], <MediumLevelILOperation.MLIL_TRAP: 77>: [('vector', 'int')], <MediumLevelILOperation.MLIL_UNDEF: 78>: [], <MediumLevelILOperation.MLIL_UNIMPL: 79>: [], <MediumLevelILOperation.MLIL_UNIMPL_MEM: 80>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FADD: 81>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FSUB: 82>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FMUL: 83>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FDIV: 84>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FSQRT: 85>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FNEG: 86>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FABS: 87>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FLOAT_TO_INT: 88>: [('src', 'expr')], <MediumLevelILOperation.MLIL_INT_TO_FLOAT: 89>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FLOAT_CONV: 90>: [('src', 'expr')], <MediumLevelILOperation.MLIL_ROUND_TO_INT: 91>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FLOOR: 92>: [('src', 'expr')], <MediumLevelILOperation.MLIL_CEIL: 93>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FTRUNC: 94>: [('src', 'expr')], <MediumLevelILOperation.MLIL_FCMP_E: 95>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FCMP_NE: 96>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FCMP_LT: 97>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FCMP_LE: 98>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FCMP_GE: 99>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FCMP_GT: 100>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FCMP_O: 101>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_FCMP_UO: 102>: [('left', 'expr'), ('right', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SSA: 103>: [('dest', 'var_ssa'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SSA_FIELD: 104>: [('prev', 'var_ssa_dest_and_src'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_SPLIT_SSA: 105>: [('high', 'var_ssa'), ('low', 'var_ssa'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_ALIASED: 106>: [('prev', 'var_ssa_dest_and_src'), ('src', 'expr')], <MediumLevelILOperation.MLIL_SET_VAR_ALIASED_FIELD: 107>: [('prev', 'var_ssa_dest_and_src'), ('offset', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_VAR_SSA: 108>: [('src', 'var_ssa')], <MediumLevelILOperation.MLIL_VAR_SSA_FIELD: 109>: [('src', 'var_ssa'), ('offset', 'int')], <MediumLevelILOperation.MLIL_VAR_ALIASED: 110>: [('src', 'var_ssa')], <MediumLevelILOperation.MLIL_VAR_ALIASED_FIELD: 111>: [('src', 'var_ssa'), ('offset', 'int')], <MediumLevelILOperation.MLIL_VAR_SPLIT_SSA: 112>: [('high', 'var_ssa'), ('low', 'var_ssa')], <MediumLevelILOperation.MLIL_CALL_SSA: 113>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr_list'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_CALL_UNTYPED_SSA: 114>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_SYSCALL_SSA: 115>: [('output', 'expr'), ('params', 'expr_list'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_SYSCALL_UNTYPED_SSA: 116>: [('output', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_TAILCALL_SSA: 117>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr_list'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_TAILCALL_UNTYPED_SSA: 118>: [('output', 'expr'), ('dest', 'expr'), ('params', 'expr'), ('stack', 'expr')], <MediumLevelILOperation.MLIL_CALL_PARAM_SSA: 119>: [('src_memory', 'int'), ('src', 'var_ssa_list')], <MediumLevelILOperation.MLIL_CALL_OUTPUT_SSA: 120>: [('dest_memory', 'int'), ('dest', 'var_ssa_list')], <MediumLevelILOperation.MLIL_LOAD_SSA: 121>: [('src', 'expr'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_LOAD_STRUCT_SSA: 122>: [('src', 'expr'), ('offset', 'int'), ('src_memory', 'int')], <MediumLevelILOperation.MLIL_STORE_SSA: 123>: [('dest', 'expr'), ('dest_memory', 'int'), ('src_memory', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_STORE_STRUCT_SSA: 124>: [('dest', 'expr'), ('offset', 'int'), ('dest_memory', 'int'), ('src_memory', 'int'), ('src', 'expr')], <MediumLevelILOperation.MLIL_INTRINSIC_SSA: 125>: [('output', 'var_ssa_list'), ('intrinsic', 'intrinsic'), ('params', 'expr_list')], <MediumLevelILOperation.MLIL_FREE_VAR_SLOT_SSA: 126>: [('prev', 'var_ssa_dest_and_src')], <MediumLevelILOperation.MLIL_VAR_PHI: 127>: [('dest', 'var_ssa'), ('src', 'var_ssa_list')], <MediumLevelILOperation.MLIL_MEM_PHI: 128>: [('dest_memory', 'int'), ('src_memory', 'int_list')]}
  `branch_dependence`

    Set of branching instructions that must take the true or false path to reach this instruction

  `expr_type`

    Type of expression

  `get_branch_dependence`(branch_instr)
  `get_flag_value`(flag)
  `get_flag_value_after`(flag)
  `get_possible_flag_values`(flag)
  `get_possible_flag_values_after`(flag)
  `get_possible_reg_values`(reg)
  `get_possible_reg_values_after`(reg)
  `get_possible_stack_contents`(offset, size)
  `get_possible_stack_contents_after`(offset, size)
  `get_reg_value`(reg)
  `get_reg_value_after`(reg)
  `get_ssa_var_possible_values`(ssa_var)
  `get_ssa_var_version`(var)
  `get_stack_contents`(offset, size)
  `get_stack_contents_after`(offset, size)
  `get_var_for_flag`(flag)
  `get_var_for_reg`(reg)
  `get_var_for_stack_location`(offset)
  `low_level_il`

    Low level IL form of this expression

  `non_ssa_form`

    Non-SSA form of expression (read-only)

  `possible_values`

    Possible values of expression using path-sensitive static data flow analysis (read-only)

  `postfix_operands`

    All operands in the expression tree in postfix order

  `prefix_operands`

    All operands in the expression tree in prefix order

  `ssa_form`

    SSA form of expression (read-only)

  `ssa_memory_version`

    Version of active memory contents in SSA form for this instruction

  `tokens`

    MLIL tokens (read-only)

  `value`

    Value of expression if constant or a known value (read-only)

  `vars_read`

    List of variables read by instruction

  `vars_written`

    List of variables written by instruction

class `binaryninja.mediumlevelil.``MediumLevelILLabel`(handle=None)

  Bases: `object`

class `binaryninja.mediumlevelil.``MediumLevelILOperationAndSize`(operation, size)

  Bases: `object`

class `binaryninja.mediumlevelil.``SSAVariable`(var, version)

  Bases: `object`