docs: def scan_code_for_ctypes(co, instrs, i):
      """Detects ctypes dependencies, using reasonable heuristics that should
      cover most common ctypes usages; returns a tuple of two lists, one
      containing names of binaries detected as dependencies, the other containing
      warnings.
      """
  
      def _libFromConst(i):
          """Extracts library name from an expected LOAD_CONST instruction and
          appends it to local binaries list.
          """
          op, oparg, conditional, curline = instrs[i]
          if op == LOAD_CONST:
              soname = co.co_consts[oparg]
              b.append(soname)
  
      b = []
  
      op, oparg, conditional, curline = instrs[i]
  
      if op in (LOAD_GLOBAL, LOAD_NAME):
          name = co.co_names[oparg]
  
          if name in ("CDLL", "WinDLL"):
              # Guesses ctypes imports of this type: CDLL("library.so")
  
              # LOAD_GLOBAL 0 (CDLL) <--- we "are" here right now
              # LOAD_CONST 1 ('library.so')
  
              _libFromConst(i+1)
  
          elif name == "ctypes":
              # Guesses ctypes imports of this type: ctypes.DLL("library.so")
  
              # LOAD_GLOBAL 0 (ctypes) <--- we "are" here right now
              # LOAD_ATTR 1 (CDLL)
              # LOAD_CONST 1 ('library.so')
  
              op2, oparg2, conditional2, curline2 = instrs[i+1]
              if op2 == LOAD_ATTR:
                  if co.co_names[oparg2] in ("CDLL", "WinDLL"):
                      # Fetch next, and finally get the library name
                      _libFromConst(i+2)
  
          elif name in ("cdll", "windll"):
              # Guesses ctypes imports of these types:
  
              #  * cdll.library (only valid on Windows)
  
              #     LOAD_GLOBAL 0 (cdll) <--- we "are" here right now
              #     LOAD_ATTR 1 (library)
  
              #  * cdll.LoadLibrary("library.so")
  
              #     LOAD_GLOBAL              0 (cdll) <--- we "are" here right now
              #     LOAD_ATTR                1 (LoadLibrary)
              #     LOAD_CONST               1 ('library.so')
  
              op2, oparg2, conditional2, curline2 = instrs[i+1]
              if op2 == LOAD_ATTR:
                  if co.co_names[oparg2] != "LoadLibrary":
                      # First type
                      soname = co.co_names[oparg2] + ".dll"
                      b.append(soname)
                  else:
                      # Second type, needs to fetch one more instruction
                      _libFromConst(i+2)
  
      # If any of the libraries has been requested with anything different from
      # the bare filename, drop that entry and warn the user - pyinstaller would
      # need to patch the compiled pyc file to make it work correctly!
  
      w = []
      for bin in list(b):
          if bin != os.path.basename(bin):
              b.remove(bin)
              w.append("W: ignoring %s - ctypes imports only supported using bare filenames" % (bin,))
  
      return b, w