code: def linetable_311_writer(first_lineno: int):
      """
      Used to create typing.CodeType.co_linetable
      See https://github.com/python/cpython/blob/3.11/Objects/locations.md
      This is the internal format of the line number table for Python 3.11
      """
      assert sys.version_info >= (3, 11)
      linetable = []
      lineno = first_lineno
  
      def update(positions: "dis.Positions", inst_size):
          nonlocal lineno
          lineno_new = positions.lineno if positions else None
  
          def _update(delta, size):
              assert 0 < size <= 8
              # first byte - use 13 (no column info) is positions is
              # malformed, otherwise use 14 (long form)
              other_varints: Tuple[int, ...] = ()
              if (
                  positions
                  and positions.lineno is not None
                  and positions.end_lineno is not None
                  and positions.col_offset is not None
                  and positions.end_col_offset is not None
              ):
                  linetable.append(0b1_1110_000 + size - 1)
                  # for whatever reason, column offset needs `+ 1`
                  # https://github.com/python/cpython/blob/1931c2a438c50e6250725c84dff94fc760b9b951/Python/compile.c#L7603
                  other_varints = (
                      positions.end_lineno - positions.lineno,
                      positions.col_offset + 1,
                      positions.end_col_offset + 1,
                  )
              else:
                  linetable.append(0b1_1101_000 + size - 1)
              # encode signed int
              if delta < 0:
                  delta = ((-delta) << 1) | 1
              else:
                  delta <<= 1
              # encode unsigned int
              linetable.extend(encode_varint(delta))
              for n in other_varints:
                  linetable.extend(encode_varint(n))
  
          if lineno_new is None:
              lineno_delta = 0
          else:
              lineno_delta = lineno_new - lineno
              lineno = lineno_new
          while inst_size > 8:
              _update(lineno_delta, 8)
              inst_size -= 8
          _update(lineno_delta, inst_size)
  
      return linetable, update
  
imports: import copy
  import dataclasses
  import dis
  import itertools
  import sys
  import types
  from typing import Any, Callable, cast, Dict, Iterator, List, Optional, Tuple
  from .bytecode_analysis import get_indexof, propagate_line_nums, remove_extra_line_nums, stacksize_analysis
label_desc: Use image node_id 12 for calling a global function with example usage: linetable_311_writer(first_lineno) and returns: linetable,  update