code: def _classify(self, gadget, classifier, gadget_type, iters):
          
          # Collect REIL instructions of the gadgets.
          instrs = [ir_instr for asm_instr in gadget.instrs for ir_instr in asm_instr.ir_instrs]
  
          # Repeat classification.
          results = []
  
          for _ in range(iters):
              # Reset emulator.
              self._ir_emulator.reset()
  
              # Generate random values for registers.
              regs_initial = self._init_regs_random()
  
              # Emulate gadgets.
              try:
                  regs_final, mem_final = self._ir_emulator.execute_lite(
                      instrs,
                      regs_initial
                  )
              except:
                  # Catch emulator exceptions like ZeroDivisionError, etc.
                  results += [([], [])]
  
                  continue
  
              # Compute values for all registers. For example, in x86, it
              # computes 'al' from 'eax'.
              regs_initial_full = self._compute_full_context(regs_initial)
              regs_final_full = self._compute_full_context(regs_final)
  
              # Get written and read registers.
              regs_written = self._ir_emulator.written_registers
              regs_read = self._ir_emulator.read_registers
  
              # Compute modified registers.
              mod_regs = self._compute_mod_regs(
                  regs_initial_full,
                  regs_final_full
              )
  
              # Classified gadgets based on initial and final context.
              matches = classifier(
                  regs_initial_full,
                  regs_final_full,
                  mem_final,
                  regs_written,
                  regs_read
              )
  
              # Save results.
              results += [(matches, mod_regs)]
  
          # Analyze results and compute candidate gadgets.
          candidates, mod_regs = self._analyze_execution_results(results)
  
          # Create classified gadgets.
          classified = self._create_typed_gadgets(
              gadget,
              candidates,
              mod_regs,
              gadget_type
          )
  
          return classified
docs: Classify gadgets.