(* Generated by coq-of-rust *)
Require Import CoqOfRust.CoqOfRust.

Module extension.
  (* StructTuple
    {
      name := "Length";
      ty_params := [];
      fields := [ Ty.path "spl_pod::primitives::PodU16" ];
    } *)
  
  Module Impl_core_clone_Clone_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    (* Clone *)
    Definition clone (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.match_operator (|
              Value.DeclaredButUndefined,
              [ fun γ => ltac:(M.monadic (M.read (| self |))) ]
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::clone::Clone"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("clone", InstanceField.Method clone) ].
  End Impl_core_clone_Clone_for_spl_token_2022_extension_Length.
  
  Module Impl_core_marker_Copy_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::Copy"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_Copy_for_spl_token_2022_extension_Length.
  
  Module Impl_core_fmt_Debug_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    (* Debug *)
    Definition fmt (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_tuple_field1_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "Length" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_tuple_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::Length",
                    0
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::fmt::Debug"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
  End Impl_core_fmt_Debug_for_spl_token_2022_extension_Length.
  
  Module Impl_core_default_Default_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    (* Default *)
    Definition default (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [] =>
        ltac:(M.monadic
          (Value.StructTuple
            "spl_token_2022::extension::Length"
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::default::Default",
                  Ty.path "spl_pod::primitives::PodU16",
                  [],
                  "default",
                  []
                |),
                []
              |)
            ]))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::default::Default"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("default", InstanceField.Method default) ].
  End Impl_core_default_Default_for_spl_token_2022_extension_Length.
  
  Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_Length.
  
  Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    (* PartialEq *)
    Definition eq (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::cmp::PartialEq",
              Ty.path "spl_pod::primitives::PodU16",
              [ Ty.path "spl_pod::primitives::PodU16" ],
              "eq",
              []
            |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "spl_token_2022::extension::Length",
                0
              |);
              M.SubPointer.get_struct_tuple_field (|
                M.read (| other |),
                "spl_token_2022::extension::Length",
                0
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::PartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method eq) ].
  End Impl_core_cmp_PartialEq_for_spl_token_2022_extension_Length.
  
  Module Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    Axiom Implements :
      M.IsTraitInstance
        "bytemuck::pod::Pod"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_Length.
  
  Module Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    Axiom Implements :
      M.IsTraitInstance
        "bytemuck::zeroable::Zeroable"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_Length.
  
  Module Impl_core_convert_From_spl_token_2022_extension_Length_for_usize.
    Definition Self : Ty.t := Ty.path "usize".
    
    (*
        fn from(n: Length) -> Self {
            Self::from(u16::from(n.0))
        }
    *)
    Definition from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::convert::From",
              Ty.path "usize",
              [ Ty.path "u16" ],
              "from",
              []
            |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::convert::From",
                  Ty.path "u16",
                  [ Ty.path "spl_pod::primitives::PodU16" ],
                  "from",
                  []
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_tuple_field (|
                      n,
                      "spl_token_2022::extension::Length",
                      0
                    |)
                  |)
                ]
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::From"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "spl_token_2022::extension::Length" ]
        (* Instance *) [ ("from", InstanceField.Method from) ].
  End Impl_core_convert_From_spl_token_2022_extension_Length_for_usize.
  
  Module Impl_core_convert_TryFrom_usize_for_spl_token_2022_extension_Length.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::Length".
    
    (*     type Error = ProgramError; *)
    Definition _Error : Ty.t := Ty.path "solana_program::program_error::ProgramError".
    
    (*
        fn try_from(n: usize) -> Result<Self, Self::Error> {
            u16::try_from(n)
                .map(|v| Self(PodU16::from(v)))
                .map_err(|_| ProgramError::AccountDataTooSmall)
        }
    *)
    Definition try_from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.apply
                (Ty.path "core::result::Result")
                [
                  Ty.path "spl_token_2022::extension::Length";
                  Ty.path "core::num::error::TryFromIntError"
                ],
              "map_err",
              [
                Ty.path "solana_program::program_error::ProgramError";
                Ty.function
                  [ Ty.tuple [ Ty.path "core::num::error::TryFromIntError" ] ]
                  (Ty.path "solana_program::program_error::ProgramError")
              ]
            |),
            [
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::result::Result")
                    [ Ty.path "u16"; Ty.path "core::num::error::TryFromIntError" ],
                  "map",
                  [
                    Ty.path "spl_token_2022::extension::Length";
                    Ty.function
                      [ Ty.tuple [ Ty.path "u16" ] ]
                      (Ty.path "spl_token_2022::extension::Length")
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::convert::TryFrom",
                      Ty.path "u16",
                      [ Ty.path "usize" ],
                      "try_from",
                      []
                    |),
                    [ M.read (| n |) ]
                  |);
                  M.closure
                    (fun γ =>
                      ltac:(M.monadic
                        match γ with
                        | [ α0 ] =>
                          M.match_operator (|
                            M.alloc (| α0 |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let v := M.copy (| γ |) in
                                  Value.StructTuple
                                    "spl_token_2022::extension::Length"
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::convert::From",
                                          Ty.path "spl_pod::primitives::PodU16",
                                          [ Ty.path "u16" ],
                                          "from",
                                          []
                                        |),
                                        [ M.read (| v |) ]
                                      |)
                                    ]))
                            ]
                          |)
                        | _ => M.impossible (||)
                        end))
                ]
              |);
              M.closure
                (fun γ =>
                  ltac:(M.monadic
                    match γ with
                    | [ α0 ] =>
                      M.match_operator (|
                        M.alloc (| α0 |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (Value.StructTuple
                                "solana_program::program_error::ProgramError::AccountDataTooSmall"
                                []))
                        ]
                      |)
                    | _ => M.impossible (||)
                    end))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::TryFrom"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "usize" ]
        (* Instance *)
        [ ("Error", InstanceField.Ty _Error); ("try_from", InstanceField.Method try_from) ].
  End Impl_core_convert_TryFrom_usize_for_spl_token_2022_extension_Length.
  
  (*
  fn get_tlv_indices(type_start: usize) -> TlvIndices {
      let length_start = type_start.saturating_add(size_of::<ExtensionType>());
      let value_start = length_start.saturating_add(pod_get_packed_len::<Length>());
      TlvIndices {
          type_start,
          length_start,
          value_start,
      }
  }
  *)
  Definition get_tlv_indices (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [], [ type_start ] =>
      ltac:(M.monadic
        (let type_start := M.alloc (| type_start |) in
        M.read (|
          let length_start :=
            M.alloc (|
              M.call_closure (|
                M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                [
                  M.read (| type_start |);
                  M.call_closure (|
                    M.get_function (|
                      "core::mem::size_of",
                      [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                    |),
                    []
                  |)
                ]
              |)
            |) in
          let value_start :=
            M.alloc (|
              M.call_closure (|
                M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                [
                  M.read (| length_start |);
                  M.call_closure (|
                    M.get_function (|
                      "spl_pod::bytemuck::pod_get_packed_len",
                      [ Ty.path "spl_token_2022::extension::Length" ]
                    |),
                    []
                  |)
                ]
              |)
            |) in
          M.alloc (|
            Value.StructRecord
              "spl_token_2022::extension::TlvIndices"
              [
                ("type_start", M.read (| type_start |));
                ("length_start", M.read (| length_start |));
                ("value_start", M.read (| value_start |))
              ]
          |)
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  const fn adjust_len_for_multisig(account_len: usize) -> usize {
      if account_len == Multisig::LEN {
          account_len.saturating_add(size_of::<ExtensionType>())
      } else {
          account_len
      }
  }
  *)
  Definition adjust_len_for_multisig (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [], [ account_len ] =>
      ltac:(M.monadic
        (let account_len := M.alloc (| account_len |) in
        M.read (|
          M.match_operator (|
            M.alloc (| Value.Tuple [] |),
            [
              fun γ =>
                ltac:(M.monadic
                  (let γ :=
                    M.use
                      (M.alloc (|
                        BinOp.Pure.eq
                          (M.read (| account_len |))
                          (M.read (|
                            M.get_constant (| "solana_program::program_pack::Pack::LEN" |)
                          |))
                      |)) in
                  let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                      [
                        M.read (| account_len |);
                        M.call_closure (|
                          M.get_function (|
                            "core::mem::size_of",
                            [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                          |),
                          []
                        |)
                      ]
                    |)
                  |)));
              fun γ => ltac:(M.monadic account_len)
            ]
          |)
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  const fn add_type_and_length_to_len(value_len: usize) -> usize {
      value_len
          .saturating_add(size_of::<ExtensionType>())
          .saturating_add(pod_get_packed_len::<Length>())
  }
  *)
  Definition add_type_and_length_to_len (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [], [ value_len ] =>
      ltac:(M.monadic
        (let value_len := M.alloc (| value_len |) in
        M.call_closure (|
          M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
          [
            M.call_closure (|
              M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
              [
                M.read (| value_len |);
                M.call_closure (|
                  M.get_function (|
                    "core::mem::size_of",
                    [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                  |),
                  []
                |)
              ]
            |);
            M.call_closure (|
              M.get_function (|
                "spl_pod::bytemuck::pod_get_packed_len",
                [ Ty.path "spl_token_2022::extension::Length" ]
              |),
              []
            |)
          ]
        |)))
    | _, _ => M.impossible
    end.
  
  (* StructRecord
    {
      name := "TlvIndices";
      ty_params := [];
      fields :=
        [
          ("type_start", Ty.path "usize");
          ("length_start", Ty.path "usize");
          ("value_start", Ty.path "usize")
        ];
    } *)
  
  Module Impl_core_fmt_Debug_for_spl_token_2022_extension_TlvIndices.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::TlvIndices".
    
    (* Debug *)
    Definition fmt (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_struct_field3_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "TlvIndices" |);
              M.read (| Value.String "type_start" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::TlvIndices",
                  "type_start"
                |));
              M.read (| Value.String "length_start" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::TlvIndices",
                  "length_start"
                |));
              M.read (| Value.String "value_start" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::TlvIndices",
                    "value_start"
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::fmt::Debug"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
  End Impl_core_fmt_Debug_for_spl_token_2022_extension_TlvIndices.
  
  (*
  fn get_extension_indices<V: Extension>(
      tlv_data: &[u8],
      init: bool,
  ) -> Result<TlvIndices, ProgramError> {
      let mut start_index = 0;
      let v_account_type = V::TYPE.get_account_type();
      while start_index < tlv_data.len() {
          let tlv_indices = get_tlv_indices(start_index);
          if tlv_data.len() < tlv_indices.value_start {
              return Err(ProgramError::InvalidAccountData);
          }
          let extension_type =
              ExtensionType::try_from(&tlv_data[tlv_indices.type_start..tlv_indices.length_start])?;
          let account_type = extension_type.get_account_type();
          if extension_type == V::TYPE {
              // found an instance of the extension that we're initializing, return!
              return Ok(tlv_indices);
          // got to an empty spot, init here, or error if we're searching, since
          // nothing is written after an Uninitialized spot
          } else if extension_type == ExtensionType::Uninitialized {
              if init {
                  return Ok(tlv_indices);
              } else {
                  return Err(TokenError::ExtensionNotFound.into());
              }
          } else if v_account_type != account_type {
              return Err(TokenError::ExtensionTypeMismatch.into());
          } else {
              let length = pod_from_bytes::<Length>(
                  &tlv_data[tlv_indices.length_start..tlv_indices.value_start],
              )?;
              let value_end_index = tlv_indices.value_start.saturating_add(usize::from( *length));
              start_index = value_end_index;
          }
      }
      Err(ProgramError::InvalidAccountData)
  }
  *)
  Definition get_extension_indices (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ V ], [ tlv_data; init ] =>
      ltac:(M.monadic
        (let tlv_data := M.alloc (| tlv_data |) in
        let init := M.alloc (| init |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let start_index := M.alloc (| Value.Integer 0 |) in
              let v_account_type :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "spl_token_2022::extension::ExtensionType",
                      "get_account_type",
                      []
                    |),
                    [ M.get_constant (| "spl_token_2022::extension::Extension::TYPE" |) ]
                  |)
                |) in
              let _ :=
                M.loop (|
                  ltac:(M.monadic
                    (M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.Pure.lt
                                    (M.read (| start_index |))
                                    (M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                        "len",
                                        []
                                      |),
                                      [ M.read (| tlv_data |) ]
                                    |))
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            let tlv_indices :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "spl_token_2022::extension::get_tlv_indices",
                                    []
                                  |),
                                  [ M.read (| start_index |) ]
                                |)
                              |) in
                            let _ :=
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            BinOp.Pure.lt
                                              (M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                  "len",
                                                  []
                                                |),
                                                [ M.read (| tlv_data |) ]
                                              |))
                                              (M.read (|
                                                M.SubPointer.get_struct_record_field (|
                                                  tlv_indices,
                                                  "spl_token_2022::extension::TlvIndices",
                                                  "value_start"
                                                |)
                                              |))
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              Value.StructTuple
                                                "core::result::Result::Err"
                                                [
                                                  Value.StructTuple
                                                    "solana_program::program_error::ProgramError::InvalidAccountData"
                                                    []
                                                ]
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            let extension_type :=
                              M.copy (|
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::Try",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "spl_token_2022::extension::ExtensionType";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [],
                                        "branch",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::convert::TryFrom",
                                            Ty.path "spl_token_2022::extension::ExtensionType",
                                            [
                                              Ty.apply
                                                (Ty.path "&")
                                                [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                            ],
                                            "try_from",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::index::Index",
                                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::ops::range::Range")
                                                    [ Ty.path "usize" ]
                                                ],
                                                "index",
                                                []
                                              |),
                                              [
                                                M.read (| tlv_data |);
                                                Value.StructRecord
                                                  "core::ops::range::Range"
                                                  [
                                                    ("start",
                                                      M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          tlv_indices,
                                                          "spl_token_2022::extension::TlvIndices",
                                                          "type_start"
                                                        |)
                                                      |));
                                                    ("end_",
                                                      M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          tlv_indices,
                                                          "spl_token_2022::extension::TlvIndices",
                                                          "length_start"
                                                        |)
                                                      |))
                                                  ]
                                              ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Break",
                                            0
                                          |) in
                                        let residual := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.read (|
                                              M.return_ (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::FromResidual",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.path
                                                          "spl_token_2022::extension::TlvIndices";
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.path "core::convert::Infallible";
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ]
                                                    ],
                                                    "from_residual",
                                                    []
                                                  |),
                                                  [ M.read (| residual |) ]
                                                |)
                                              |)
                                            |)
                                          |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Continue",
                                            0
                                          |) in
                                        let val := M.copy (| γ0_0 |) in
                                        val))
                                  ]
                                |)
                              |) in
                            let account_type :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "spl_token_2022::extension::ExtensionType",
                                    "get_account_type",
                                    []
                                  |),
                                  [ extension_type ]
                                |)
                              |) in
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.use
                                        (M.alloc (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::cmp::PartialEq",
                                              Ty.path "spl_token_2022::extension::ExtensionType",
                                              [ Ty.path "spl_token_2022::extension::ExtensionType"
                                              ],
                                              "eq",
                                              []
                                            |),
                                            [
                                              extension_type;
                                              M.get_constant (|
                                                "spl_token_2022::extension::Extension::TYPE"
                                              |)
                                            ]
                                          |)
                                        |)) in
                                    let _ :=
                                      M.is_constant_or_break_match (|
                                        M.read (| γ |),
                                        Value.Bool true
                                      |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            Value.StructTuple
                                              "core::result::Result::Ok"
                                              [ M.read (| tlv_indices |) ]
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (M.match_operator (|
                                      M.alloc (| Value.Tuple [] |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ :=
                                              M.use
                                                (M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::cmp::PartialEq",
                                                      Ty.path
                                                        "spl_token_2022::extension::ExtensionType",
                                                      [
                                                        Ty.path
                                                          "spl_token_2022::extension::ExtensionType"
                                                      ],
                                                      "eq",
                                                      []
                                                    |),
                                                    [
                                                      extension_type;
                                                      M.alloc (|
                                                        Value.StructTuple
                                                          "spl_token_2022::extension::ExtensionType::Uninitialized"
                                                          []
                                                      |)
                                                    ]
                                                  |)
                                                |)) in
                                            let _ :=
                                              M.is_constant_or_break_match (|
                                                M.read (| γ |),
                                                Value.Bool true
                                              |) in
                                            M.match_operator (|
                                              M.alloc (| Value.Tuple [] |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ := M.use init in
                                                    let _ :=
                                                      M.is_constant_or_break_match (|
                                                        M.read (| γ |),
                                                        Value.Bool true
                                                      |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            Value.StructTuple
                                                              "core::result::Result::Ok"
                                                              [ M.read (| tlv_indices |) ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            Value.StructTuple
                                                              "core::result::Result::Err"
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::convert::Into",
                                                                    Ty.path
                                                                      "spl_token_2022::error::TokenError",
                                                                    [
                                                                      Ty.path
                                                                        "solana_program::program_error::ProgramError"
                                                                    ],
                                                                    "into",
                                                                    []
                                                                  |),
                                                                  [
                                                                    Value.StructTuple
                                                                      "spl_token_2022::error::TokenError::ExtensionNotFound"
                                                                      []
                                                                  ]
                                                                |)
                                                              ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)))
                                              ]
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (M.match_operator (|
                                              M.alloc (| Value.Tuple [] |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ :=
                                                      M.use
                                                        (M.alloc (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::cmp::PartialEq",
                                                              Ty.path
                                                                "spl_token_2022::extension::AccountType",
                                                              [
                                                                Ty.path
                                                                  "spl_token_2022::extension::AccountType"
                                                              ],
                                                              "ne",
                                                              []
                                                            |),
                                                            [ v_account_type; account_type ]
                                                          |)
                                                        |)) in
                                                    let _ :=
                                                      M.is_constant_or_break_match (|
                                                        M.read (| γ |),
                                                        Value.Bool true
                                                      |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            Value.StructTuple
                                                              "core::result::Result::Err"
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::convert::Into",
                                                                    Ty.path
                                                                      "spl_token_2022::error::TokenError",
                                                                    [
                                                                      Ty.path
                                                                        "solana_program::program_error::ProgramError"
                                                                    ],
                                                                    "into",
                                                                    []
                                                                  |),
                                                                  [
                                                                    Value.StructTuple
                                                                      "spl_token_2022::error::TokenError::ExtensionTypeMismatch"
                                                                      []
                                                                  ]
                                                                |)
                                                              ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let length :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.apply
                                                                      (Ty.path "&")
                                                                      [
                                                                        Ty.path
                                                                          "spl_token_2022::extension::Length"
                                                                      ];
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_function (|
                                                                    "spl_pod::bytemuck::pod_from_bytes",
                                                                    [
                                                                      Ty.path
                                                                        "spl_token_2022::extension::Length"
                                                                    ]
                                                                  |),
                                                                  [
                                                                    M.call_closure (|
                                                                      M.get_trait_method (|
                                                                        "core::ops::index::Index",
                                                                        Ty.apply
                                                                          (Ty.path "slice")
                                                                          [ Ty.path "u8" ],
                                                                        [
                                                                          Ty.apply
                                                                            (Ty.path
                                                                              "core::ops::range::Range")
                                                                            [ Ty.path "usize" ]
                                                                        ],
                                                                        "index",
                                                                        []
                                                                      |),
                                                                      [
                                                                        M.read (| tlv_data |);
                                                                        Value.StructRecord
                                                                          "core::ops::range::Range"
                                                                          [
                                                                            ("start",
                                                                              M.read (|
                                                                                M.SubPointer.get_struct_record_field (|
                                                                                  tlv_indices,
                                                                                  "spl_token_2022::extension::TlvIndices",
                                                                                  "length_start"
                                                                                |)
                                                                              |));
                                                                            ("end_",
                                                                              M.read (|
                                                                                M.SubPointer.get_struct_record_field (|
                                                                                  tlv_indices,
                                                                                  "spl_token_2022::extension::TlvIndices",
                                                                                  "value_start"
                                                                                |)
                                                                              |))
                                                                          ]
                                                                      ]
                                                                    |)
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Break",
                                                                    0
                                                                  |) in
                                                                let residual := M.copy (| γ0_0 |) in
                                                                M.alloc (|
                                                                  M.never_to_any (|
                                                                    M.read (|
                                                                      M.return_ (|
                                                                        M.call_closure (|
                                                                          M.get_trait_method (|
                                                                            "core::ops::try_trait::FromResidual",
                                                                            Ty.apply
                                                                              (Ty.path
                                                                                "core::result::Result")
                                                                              [
                                                                                Ty.path
                                                                                  "spl_token_2022::extension::TlvIndices";
                                                                                Ty.path
                                                                                  "solana_program::program_error::ProgramError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "solana_program::program_error::ProgramError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let value_end_index :=
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.path "usize",
                                                            "saturating_add",
                                                            []
                                                          |),
                                                          [
                                                            M.read (|
                                                              M.SubPointer.get_struct_record_field (|
                                                                tlv_indices,
                                                                "spl_token_2022::extension::TlvIndices",
                                                                "value_start"
                                                              |)
                                                            |);
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::convert::From",
                                                                Ty.path "usize",
                                                                [
                                                                  Ty.path
                                                                    "spl_token_2022::extension::Length"
                                                                ],
                                                                "from",
                                                                []
                                                              |),
                                                              [ M.read (| M.read (| length |) |) ]
                                                            |)
                                                          ]
                                                        |)
                                                      |) in
                                                    let _ :=
                                                      M.write (|
                                                        start_index,
                                                        M.read (| value_end_index |)
                                                      |) in
                                                    M.alloc (| Value.Tuple [] |)))
                                              ]
                                            |)))
                                      ]
                                    |)))
                              ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  let _ :=
                                    M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in
                                  M.alloc (| Value.Tuple [] |)
                                |)
                              |)
                            |)))
                      ]
                    |)))
                |) in
              M.alloc (|
                Value.StructTuple
                  "core::result::Result::Err"
                  [
                    Value.StructTuple
                      "solana_program::program_error::ProgramError::InvalidAccountData"
                      []
                  ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (* StructRecord
    {
      name := "TlvDataInfo";
      ty_params := [];
      fields :=
        [
          ("extension_types",
            Ty.apply
              (Ty.path "alloc::vec::Vec")
              [ Ty.path "spl_token_2022::extension::ExtensionType"; Ty.path "alloc::alloc::Global"
              ]);
          ("used_len", Ty.path "usize")
        ];
    } *)
  
  Module Impl_core_fmt_Debug_for_spl_token_2022_extension_TlvDataInfo.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::TlvDataInfo".
    
    (* Debug *)
    Definition fmt (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_struct_field2_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "TlvDataInfo" |);
              M.read (| Value.String "extension_types" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::TlvDataInfo",
                  "extension_types"
                |));
              M.read (| Value.String "used_len" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::TlvDataInfo",
                    "used_len"
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::fmt::Debug"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
  End Impl_core_fmt_Debug_for_spl_token_2022_extension_TlvDataInfo.
  
  Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_TlvDataInfo.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::TlvDataInfo".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_TlvDataInfo.
  
  Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_TlvDataInfo.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::TlvDataInfo".
    
    (* PartialEq *)
    Definition eq (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          LogicalOp.and (|
            M.call_closure (|
              M.get_trait_method (|
                "core::cmp::PartialEq",
                Ty.apply
                  (Ty.path "alloc::vec::Vec")
                  [
                    Ty.path "spl_token_2022::extension::ExtensionType";
                    Ty.path "alloc::alloc::Global"
                  ],
                [
                  Ty.apply
                    (Ty.path "alloc::vec::Vec")
                    [
                      Ty.path "spl_token_2022::extension::ExtensionType";
                      Ty.path "alloc::alloc::Global"
                    ]
                ],
                "eq",
                []
              |),
              [
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::TlvDataInfo",
                  "extension_types"
                |);
                M.SubPointer.get_struct_record_field (|
                  M.read (| other |),
                  "spl_token_2022::extension::TlvDataInfo",
                  "extension_types"
                |)
              ]
            |),
            ltac:(M.monadic
              (BinOp.Pure.eq
                (M.read (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::TlvDataInfo",
                    "used_len"
                  |)
                |))
                (M.read (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| other |),
                    "spl_token_2022::extension::TlvDataInfo",
                    "used_len"
                  |)
                |))))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::PartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method eq) ].
  End Impl_core_cmp_PartialEq_for_spl_token_2022_extension_TlvDataInfo.
  
  (*
  fn get_tlv_data_info(tlv_data: &[u8]) -> Result<TlvDataInfo, ProgramError> {
      let mut extension_types = vec![];
      let mut start_index = 0;
      while start_index < tlv_data.len() {
          let tlv_indices = get_tlv_indices(start_index);
          if tlv_data.len() < tlv_indices.length_start {
              // There aren't enough bytes to store the next type, which means we
              // got to the end. The last byte could be used during a realloc!
              return Ok(TlvDataInfo {
                  extension_types,
                  used_len: tlv_indices.type_start,
              });
          }
          let extension_type =
              ExtensionType::try_from(&tlv_data[tlv_indices.type_start..tlv_indices.length_start])?;
          if extension_type == ExtensionType::Uninitialized {
              return Ok(TlvDataInfo {
                  extension_types,
                  used_len: tlv_indices.type_start,
              });
          } else {
              if tlv_data.len() < tlv_indices.value_start {
                  // not enough bytes to store the length, malformed
                  return Err(ProgramError::InvalidAccountData);
              }
              extension_types.push(extension_type);
              let length = pod_from_bytes::<Length>(
                  &tlv_data[tlv_indices.length_start..tlv_indices.value_start],
              )?;
  
              let value_end_index = tlv_indices.value_start.saturating_add(usize::from( *length));
              if value_end_index > tlv_data.len() {
                  // value blows past the size of the slice, malformed
                  return Err(ProgramError::InvalidAccountData);
              }
              start_index = value_end_index;
          }
      }
      Ok(TlvDataInfo {
          extension_types,
          used_len: start_index,
      })
  }
  *)
  Definition get_tlv_data_info (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [], [ tlv_data ] =>
      ltac:(M.monadic
        (let tlv_data := M.alloc (| tlv_data |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let extension_types :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply
                        (Ty.path "alloc::vec::Vec")
                        [
                          Ty.path "spl_token_2022::extension::ExtensionType";
                          Ty.path "alloc::alloc::Global"
                        ],
                      "new",
                      []
                    |),
                    []
                  |)
                |) in
              let start_index := M.alloc (| Value.Integer 0 |) in
              let _ :=
                M.loop (|
                  ltac:(M.monadic
                    (M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.Pure.lt
                                    (M.read (| start_index |))
                                    (M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                        "len",
                                        []
                                      |),
                                      [ M.read (| tlv_data |) ]
                                    |))
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            let tlv_indices :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "spl_token_2022::extension::get_tlv_indices",
                                    []
                                  |),
                                  [ M.read (| start_index |) ]
                                |)
                              |) in
                            let _ :=
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            BinOp.Pure.lt
                                              (M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                  "len",
                                                  []
                                                |),
                                                [ M.read (| tlv_data |) ]
                                              |))
                                              (M.read (|
                                                M.SubPointer.get_struct_record_field (|
                                                  tlv_indices,
                                                  "spl_token_2022::extension::TlvIndices",
                                                  "length_start"
                                                |)
                                              |))
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              Value.StructTuple
                                                "core::result::Result::Ok"
                                                [
                                                  Value.StructRecord
                                                    "spl_token_2022::extension::TlvDataInfo"
                                                    [
                                                      ("extension_types",
                                                        M.read (| extension_types |));
                                                      ("used_len",
                                                        M.read (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            tlv_indices,
                                                            "spl_token_2022::extension::TlvIndices",
                                                            "type_start"
                                                          |)
                                                        |))
                                                    ]
                                                ]
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            let extension_type :=
                              M.copy (|
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::Try",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "spl_token_2022::extension::ExtensionType";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [],
                                        "branch",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::convert::TryFrom",
                                            Ty.path "spl_token_2022::extension::ExtensionType",
                                            [
                                              Ty.apply
                                                (Ty.path "&")
                                                [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                            ],
                                            "try_from",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::index::Index",
                                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::ops::range::Range")
                                                    [ Ty.path "usize" ]
                                                ],
                                                "index",
                                                []
                                              |),
                                              [
                                                M.read (| tlv_data |);
                                                Value.StructRecord
                                                  "core::ops::range::Range"
                                                  [
                                                    ("start",
                                                      M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          tlv_indices,
                                                          "spl_token_2022::extension::TlvIndices",
                                                          "type_start"
                                                        |)
                                                      |));
                                                    ("end_",
                                                      M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          tlv_indices,
                                                          "spl_token_2022::extension::TlvIndices",
                                                          "length_start"
                                                        |)
                                                      |))
                                                  ]
                                              ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Break",
                                            0
                                          |) in
                                        let residual := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.read (|
                                              M.return_ (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::FromResidual",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.path
                                                          "spl_token_2022::extension::TlvDataInfo";
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.path "core::convert::Infallible";
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ]
                                                    ],
                                                    "from_residual",
                                                    []
                                                  |),
                                                  [ M.read (| residual |) ]
                                                |)
                                              |)
                                            |)
                                          |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Continue",
                                            0
                                          |) in
                                        let val := M.copy (| γ0_0 |) in
                                        val))
                                  ]
                                |)
                              |) in
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.use
                                        (M.alloc (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::cmp::PartialEq",
                                              Ty.path "spl_token_2022::extension::ExtensionType",
                                              [ Ty.path "spl_token_2022::extension::ExtensionType"
                                              ],
                                              "eq",
                                              []
                                            |),
                                            [
                                              extension_type;
                                              M.alloc (|
                                                Value.StructTuple
                                                  "spl_token_2022::extension::ExtensionType::Uninitialized"
                                                  []
                                              |)
                                            ]
                                          |)
                                        |)) in
                                    let _ :=
                                      M.is_constant_or_break_match (|
                                        M.read (| γ |),
                                        Value.Bool true
                                      |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            Value.StructTuple
                                              "core::result::Result::Ok"
                                              [
                                                Value.StructRecord
                                                  "spl_token_2022::extension::TlvDataInfo"
                                                  [
                                                    ("extension_types",
                                                      M.read (| extension_types |));
                                                    ("used_len",
                                                      M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          tlv_indices,
                                                          "spl_token_2022::extension::TlvIndices",
                                                          "type_start"
                                                        |)
                                                      |))
                                                  ]
                                              ]
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let _ :=
                                      M.match_operator (|
                                        M.alloc (| Value.Tuple [] |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ :=
                                                M.use
                                                  (M.alloc (|
                                                    BinOp.Pure.lt
                                                      (M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            [ Ty.path "u8" ],
                                                          "len",
                                                          []
                                                        |),
                                                        [ M.read (| tlv_data |) ]
                                                      |))
                                                      (M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          tlv_indices,
                                                          "spl_token_2022::extension::TlvIndices",
                                                          "value_start"
                                                        |)
                                                      |))
                                                  |)) in
                                              let _ :=
                                                M.is_constant_or_break_match (|
                                                  M.read (| γ |),
                                                  Value.Bool true
                                                |) in
                                              M.alloc (|
                                                M.never_to_any (|
                                                  M.read (|
                                                    M.return_ (|
                                                      Value.StructTuple
                                                        "core::result::Result::Err"
                                                        [
                                                          Value.StructTuple
                                                            "solana_program::program_error::ProgramError::InvalidAccountData"
                                                            []
                                                        ]
                                                    |)
                                                  |)
                                                |)
                                              |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |) in
                                    let _ :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::vec::Vec")
                                              [
                                                Ty.path "spl_token_2022::extension::ExtensionType";
                                                Ty.path "alloc::alloc::Global"
                                              ],
                                            "push",
                                            []
                                          |),
                                          [ extension_types; M.read (| extension_type |) ]
                                        |)
                                      |) in
                                    let length :=
                                      M.copy (|
                                        M.match_operator (|
                                          M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::Try",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&")
                                                      [ Ty.path "spl_token_2022::extension::Length"
                                                      ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [],
                                                "branch",
                                                []
                                              |),
                                              [
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "spl_pod::bytemuck::pod_from_bytes",
                                                    [ Ty.path "spl_token_2022::extension::Length" ]
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::index::Index",
                                                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::ops::range::Range")
                                                            [ Ty.path "usize" ]
                                                        ],
                                                        "index",
                                                        []
                                                      |),
                                                      [
                                                        M.read (| tlv_data |);
                                                        Value.StructRecord
                                                          "core::ops::range::Range"
                                                          [
                                                            ("start",
                                                              M.read (|
                                                                M.SubPointer.get_struct_record_field (|
                                                                  tlv_indices,
                                                                  "spl_token_2022::extension::TlvIndices",
                                                                  "length_start"
                                                                |)
                                                              |));
                                                            ("end_",
                                                              M.read (|
                                                                M.SubPointer.get_struct_record_field (|
                                                                  tlv_indices,
                                                                  "spl_token_2022::extension::TlvIndices",
                                                                  "value_start"
                                                                |)
                                                              |))
                                                          ]
                                                      ]
                                                    |)
                                                  ]
                                                |)
                                              ]
                                            |)
                                          |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let γ0_0 :=
                                                  M.SubPointer.get_struct_tuple_field (|
                                                    γ,
                                                    "core::ops::control_flow::ControlFlow::Break",
                                                    0
                                                  |) in
                                                let residual := M.copy (| γ0_0 |) in
                                                M.alloc (|
                                                  M.never_to_any (|
                                                    M.read (|
                                                      M.return_ (|
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::try_trait::FromResidual",
                                                            Ty.apply
                                                              (Ty.path "core::result::Result")
                                                              [
                                                                Ty.path
                                                                  "spl_token_2022::extension::TlvDataInfo";
                                                                Ty.path
                                                                  "solana_program::program_error::ProgramError"
                                                              ],
                                                            [
                                                              Ty.apply
                                                                (Ty.path "core::result::Result")
                                                                [
                                                                  Ty.path
                                                                    "core::convert::Infallible";
                                                                  Ty.path
                                                                    "solana_program::program_error::ProgramError"
                                                                ]
                                                            ],
                                                            "from_residual",
                                                            []
                                                          |),
                                                          [ M.read (| residual |) ]
                                                        |)
                                                      |)
                                                    |)
                                                  |)
                                                |)));
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let γ0_0 :=
                                                  M.SubPointer.get_struct_tuple_field (|
                                                    γ,
                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                    0
                                                  |) in
                                                let val := M.copy (| γ0_0 |) in
                                                val))
                                          ]
                                        |)
                                      |) in
                                    let value_end_index :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "usize",
                                            "saturating_add",
                                            []
                                          |),
                                          [
                                            M.read (|
                                              M.SubPointer.get_struct_record_field (|
                                                tlv_indices,
                                                "spl_token_2022::extension::TlvIndices",
                                                "value_start"
                                              |)
                                            |);
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::convert::From",
                                                Ty.path "usize",
                                                [ Ty.path "spl_token_2022::extension::Length" ],
                                                "from",
                                                []
                                              |),
                                              [ M.read (| M.read (| length |) |) ]
                                            |)
                                          ]
                                        |)
                                      |) in
                                    let _ :=
                                      M.match_operator (|
                                        M.alloc (| Value.Tuple [] |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ :=
                                                M.use
                                                  (M.alloc (|
                                                    BinOp.Pure.gt
                                                      (M.read (| value_end_index |))
                                                      (M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            [ Ty.path "u8" ],
                                                          "len",
                                                          []
                                                        |),
                                                        [ M.read (| tlv_data |) ]
                                                      |))
                                                  |)) in
                                              let _ :=
                                                M.is_constant_or_break_match (|
                                                  M.read (| γ |),
                                                  Value.Bool true
                                                |) in
                                              M.alloc (|
                                                M.never_to_any (|
                                                  M.read (|
                                                    M.return_ (|
                                                      Value.StructTuple
                                                        "core::result::Result::Err"
                                                        [
                                                          Value.StructTuple
                                                            "solana_program::program_error::ProgramError::InvalidAccountData"
                                                            []
                                                        ]
                                                    |)
                                                  |)
                                                |)
                                              |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |) in
                                    let _ :=
                                      M.write (| start_index, M.read (| value_end_index |) |) in
                                    M.alloc (| Value.Tuple [] |)))
                              ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  let _ :=
                                    M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in
                                  M.alloc (| Value.Tuple [] |)
                                |)
                              |)
                            |)))
                      ]
                    |)))
                |) in
              M.alloc (|
                Value.StructTuple
                  "core::result::Result::Ok"
                  [
                    Value.StructRecord
                      "spl_token_2022::extension::TlvDataInfo"
                      [
                        ("extension_types", M.read (| extension_types |));
                        ("used_len", M.read (| start_index |))
                      ]
                  ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn get_first_extension_type(tlv_data: &[u8]) -> Result<Option<ExtensionType>, ProgramError> {
      if tlv_data.is_empty() {
          Ok(None)
      } else {
          let tlv_indices = get_tlv_indices(0);
          if tlv_data.len() <= tlv_indices.length_start {
              return Ok(None);
          }
          let extension_type =
              ExtensionType::try_from(&tlv_data[tlv_indices.type_start..tlv_indices.length_start])?;
          if extension_type == ExtensionType::Uninitialized {
              Ok(None)
          } else {
              Ok(Some(extension_type))
          }
      }
  }
  *)
  Definition get_first_extension_type (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [], [ tlv_data ] =>
      ltac:(M.monadic
        (let tlv_data := M.alloc (| tlv_data |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              M.match_operator (|
                M.alloc (| Value.Tuple [] |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ :=
                        M.use
                          (M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                "is_empty",
                                []
                              |),
                              [ M.read (| tlv_data |) ]
                            |)
                          |)) in
                      let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                      M.alloc (|
                        Value.StructTuple
                          "core::result::Result::Ok"
                          [ Value.StructTuple "core::option::Option::None" [] ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (let tlv_indices :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_function (| "spl_token_2022::extension::get_tlv_indices", [] |),
                            [ Value.Integer 0 ]
                          |)
                        |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      BinOp.Pure.le
                                        (M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            "len",
                                            []
                                          |),
                                          [ M.read (| tlv_data |) ]
                                        |))
                                        (M.read (|
                                          M.SubPointer.get_struct_record_field (|
                                            tlv_indices,
                                            "spl_token_2022::extension::TlvIndices",
                                            "length_start"
                                          |)
                                        |))
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructTuple
                                          "core::result::Result::Ok"
                                          [ Value.StructTuple "core::option::Option::None" [] ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      let extension_type :=
                        M.copy (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.path "spl_token_2022::extension::ExtensionType";
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::convert::TryFrom",
                                      Ty.path "spl_token_2022::extension::ExtensionType",
                                      [
                                        Ty.apply
                                          (Ty.path "&")
                                          [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                      ],
                                      "try_from",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::index::Index",
                                          Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::ops::range::Range")
                                              [ Ty.path "usize" ]
                                          ],
                                          "index",
                                          []
                                        |),
                                        [
                                          M.read (| tlv_data |);
                                          Value.StructRecord
                                            "core::ops::range::Range"
                                            [
                                              ("start",
                                                M.read (|
                                                  M.SubPointer.get_struct_record_field (|
                                                    tlv_indices,
                                                    "spl_token_2022::extension::TlvIndices",
                                                    "type_start"
                                                  |)
                                                |));
                                              ("end_",
                                                M.read (|
                                                  M.SubPointer.get_struct_record_field (|
                                                    tlv_indices,
                                                    "spl_token_2022::extension::TlvIndices",
                                                    "length_start"
                                                  |)
                                                |))
                                            ]
                                        ]
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    [
                                                      Ty.path
                                                        "spl_token_2022::extension::ExtensionType"
                                                    ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |) in
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::cmp::PartialEq",
                                        Ty.path "spl_token_2022::extension::ExtensionType",
                                        [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                                        "eq",
                                        []
                                      |),
                                      [
                                        extension_type;
                                        M.alloc (|
                                          Value.StructTuple
                                            "spl_token_2022::extension::ExtensionType::Uninitialized"
                                            []
                                        |)
                                      ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                Value.StructTuple
                                  "core::result::Result::Ok"
                                  [ Value.StructTuple "core::option::Option::None" [] ]
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (M.alloc (|
                                Value.StructTuple
                                  "core::result::Result::Ok"
                                  [
                                    Value.StructTuple
                                      "core::option::Option::Some"
                                      [ M.read (| extension_type |) ]
                                  ]
                              |)))
                        ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn check_min_len_and_not_multisig(input: &[u8], minimum_len: usize) -> Result<(), ProgramError> {
      if input.len() == Multisig::LEN || input.len() < minimum_len {
          Err(ProgramError::InvalidAccountData)
      } else {
          Ok(())
      }
  }
  *)
  Definition check_min_len_and_not_multisig (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [], [ input; minimum_len ] =>
      ltac:(M.monadic
        (let input := M.alloc (| input |) in
        let minimum_len := M.alloc (| minimum_len |) in
        M.read (|
          M.match_operator (|
            M.alloc (| Value.Tuple [] |),
            [
              fun γ =>
                ltac:(M.monadic
                  (let γ :=
                    M.use
                      (M.alloc (|
                        LogicalOp.or (|
                          BinOp.Pure.eq
                            (M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                "len",
                                []
                              |),
                              [ M.read (| input |) ]
                            |))
                            (M.read (|
                              M.get_constant (| "solana_program::program_pack::Pack::LEN" |)
                            |)),
                          ltac:(M.monadic
                            (BinOp.Pure.lt
                              (M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                  "len",
                                  []
                                |),
                                [ M.read (| input |) ]
                              |))
                              (M.read (| minimum_len |))))
                        |)
                      |)) in
                  let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::result::Result::Err"
                      [
                        Value.StructTuple
                          "solana_program::program_error::ProgramError::InvalidAccountData"
                          []
                      ]
                  |)));
              fun γ =>
                ltac:(M.monadic
                  (M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)))
            ]
          |)
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn check_account_type<S: BaseState>(account_type: AccountType) -> Result<(), ProgramError> {
      if account_type != S::ACCOUNT_TYPE {
          Err(ProgramError::InvalidAccountData)
      } else {
          Ok(())
      }
  }
  *)
  Definition check_account_type (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S ], [ account_type ] =>
      ltac:(M.monadic
        (let account_type := M.alloc (| account_type |) in
        M.read (|
          M.match_operator (|
            M.alloc (| Value.Tuple [] |),
            [
              fun γ =>
                ltac:(M.monadic
                  (let γ :=
                    M.use
                      (M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::cmp::PartialEq",
                            Ty.path "spl_token_2022::extension::AccountType",
                            [ Ty.path "spl_token_2022::extension::AccountType" ],
                            "ne",
                            []
                          |),
                          [
                            account_type;
                            M.get_constant (|
                              "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                            |)
                          ]
                        |)
                      |)) in
                  let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::result::Result::Err"
                      [
                        Value.StructTuple
                          "solana_program::program_error::ProgramError::InvalidAccountData"
                          []
                      ]
                  |)));
              fun γ =>
                ltac:(M.monadic
                  (M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)))
            ]
          |)
        |)))
    | _, _ => M.impossible
    end.
  
  Definition value_BASE_ACCOUNT_LENGTH : Value.t :=
    M.run ltac:(M.monadic (M.get_constant (| "solana_program::program_pack::Pack::LEN" |))).
  
  Definition value_BASE_ACCOUNT_AND_TYPE_LENGTH : Value.t :=
    M.run
      ltac:(M.monadic
        (M.alloc (|
          BinOp.Panic.add (|
            Integer.Usize,
            M.read (| M.get_constant (| "spl_token_2022::extension::BASE_ACCOUNT_LENGTH" |) |),
            M.call_closure (|
              M.get_function (|
                "core::mem::size_of",
                [ Ty.path "spl_token_2022::extension::AccountType" ]
              |),
              []
            |)
          |)
        |))).
  
  (*
  fn type_and_tlv_indices<S: BaseState>(
      rest_input: &[u8],
  ) -> Result<Option<(usize, usize)>, ProgramError> {
      if rest_input.is_empty() {
          Ok(None)
      } else {
          let account_type_index = BASE_ACCOUNT_LENGTH.saturating_sub(S::SIZE_OF);
          // check padding is all zeroes
          let tlv_start_index = account_type_index.saturating_add(size_of::<AccountType>());
          if rest_input.len() <= tlv_start_index {
              return Err(ProgramError::InvalidAccountData);
          }
          if rest_input[..account_type_index] != vec![0; account_type_index] {
              Err(ProgramError::InvalidAccountData)
          } else {
              Ok(Some((account_type_index, tlv_start_index)))
          }
      }
  }
  *)
  Definition type_and_tlv_indices (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S ], [ rest_input ] =>
      ltac:(M.monadic
        (let rest_input := M.alloc (| rest_input |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              M.match_operator (|
                M.alloc (| Value.Tuple [] |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ :=
                        M.use
                          (M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                "is_empty",
                                []
                              |),
                              [ M.read (| rest_input |) ]
                            |)
                          |)) in
                      let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                      M.alloc (|
                        Value.StructTuple
                          "core::result::Result::Ok"
                          [ Value.StructTuple "core::option::Option::None" [] ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (let account_type_index :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "usize", "saturating_sub", [] |),
                            [
                              M.read (|
                                M.get_constant (|
                                  "spl_token_2022::extension::BASE_ACCOUNT_LENGTH"
                                |)
                              |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        |) in
                      let tlv_start_index :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                            [
                              M.read (| account_type_index |);
                              M.call_closure (|
                                M.get_function (|
                                  "core::mem::size_of",
                                  [ Ty.path "spl_token_2022::extension::AccountType" ]
                                |),
                                []
                              |)
                            ]
                          |)
                        |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      BinOp.Pure.le
                                        (M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            "len",
                                            []
                                          |),
                                          [ M.read (| rest_input |) ]
                                        |))
                                        (M.read (| tlv_start_index |))
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructTuple
                                          "core::result::Result::Err"
                                          [
                                            Value.StructTuple
                                              "solana_program::program_error::ProgramError::InvalidAccountData"
                                              []
                                          ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::cmp::PartialEq",
                                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                        [
                                          Ty.apply
                                            (Ty.path "alloc::vec::Vec")
                                            [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ]
                                        ],
                                        "ne",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::index::Index",
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::ops::range::RangeTo")
                                                [ Ty.path "usize" ]
                                            ],
                                            "index",
                                            []
                                          |),
                                          [
                                            M.read (| rest_input |);
                                            Value.StructRecord
                                              "core::ops::range::RangeTo"
                                              [ ("end_", M.read (| account_type_index |)) ]
                                          ]
                                        |);
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_function (|
                                              "alloc::vec::from_elem",
                                              [ Ty.path "u8" ]
                                            |),
                                            [ Value.Integer 0; M.read (| account_type_index |) ]
                                          |)
                                        |)
                                      ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                Value.StructTuple
                                  "core::result::Result::Err"
                                  [
                                    Value.StructTuple
                                      "solana_program::program_error::ProgramError::InvalidAccountData"
                                      []
                                  ]
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (M.alloc (|
                                Value.StructTuple
                                  "core::result::Result::Ok"
                                  [
                                    Value.StructTuple
                                      "core::option::Option::Some"
                                      [
                                        Value.Tuple
                                          [
                                            M.read (| account_type_index |);
                                            M.read (| tlv_start_index |)
                                          ]
                                      ]
                                  ]
                              |)))
                        ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn is_initialized_account(input: &[u8]) -> Result<bool, ProgramError> {
      const ACCOUNT_INITIALIZED_INDEX: usize = 108; // See state.rs#L99
  
      if input.len() != BASE_ACCOUNT_LENGTH {
          return Err(ProgramError::InvalidAccountData);
      }
      Ok(input[ACCOUNT_INITIALIZED_INDEX] != 0)
  }
  *)
  Definition is_initialized_account (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [], [ input ] =>
      ltac:(M.monadic
        (let input := M.alloc (| input |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.Pure.ne
                                (M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                    "len",
                                    []
                                  |),
                                  [ M.read (| input |) ]
                                |))
                                (M.read (|
                                  M.get_constant (|
                                    "spl_token_2022::extension::BASE_ACCOUNT_LENGTH"
                                  |)
                                |))
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                Value.StructTuple
                                  "core::result::Result::Err"
                                  [
                                    Value.StructTuple
                                      "solana_program::program_error::ProgramError::InvalidAccountData"
                                      []
                                  ]
                              |)
                            |)
                          |)
                        |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              M.alloc (|
                Value.StructTuple
                  "core::result::Result::Ok"
                  [
                    BinOp.Pure.ne
                      (M.read (|
                        M.SubPointer.get_array_field (|
                          M.read (| input |),
                          M.get_constant (|
                            "spl_token_2022::extension::is_initialized_account::ACCOUNT_INITIALIZED_INDEX"
                          |)
                        |)
                      |))
                      (Value.Integer 0)
                  ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  Module is_initialized_account.
    Definition value_ACCOUNT_INITIALIZED_INDEX : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer 108 |))).
  End is_initialized_account.
  
  (*
  fn get_extension_bytes<S: BaseState, V: Extension>(tlv_data: &[u8]) -> Result<&[u8], ProgramError> {
      if V::TYPE.get_account_type() != S::ACCOUNT_TYPE {
          return Err(ProgramError::InvalidAccountData);
      }
      let TlvIndices {
          type_start: _,
          length_start,
          value_start,
      } = get_extension_indices::<V>(tlv_data, false)?;
      // get_extension_indices has checked that tlv_data is long enough to include
      // these indices
      let length = pod_from_bytes::<Length>(&tlv_data[length_start..value_start])?;
      let value_end = value_start.saturating_add(usize::from( *length));
      if tlv_data.len() < value_end {
          return Err(ProgramError::InvalidAccountData);
      }
      Ok(&tlv_data[value_start..value_end])
  }
  *)
  Definition get_extension_bytes (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S; V ], [ tlv_data ] =>
      ltac:(M.monadic
        (let tlv_data := M.alloc (| tlv_data |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::cmp::PartialEq",
                                  Ty.path "spl_token_2022::extension::AccountType",
                                  [ Ty.path "spl_token_2022::extension::AccountType" ],
                                  "ne",
                                  []
                                |),
                                [
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.path "spl_token_2022::extension::ExtensionType",
                                        "get_account_type",
                                        []
                                      |),
                                      [
                                        M.get_constant (|
                                          "spl_token_2022::extension::Extension::TYPE"
                                        |)
                                      ]
                                    |)
                                  |);
                                  M.get_constant (|
                                    "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                  |)
                                ]
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                Value.StructTuple
                                  "core::result::Result::Err"
                                  [
                                    Value.StructTuple
                                      "solana_program::program_error::ProgramError::InvalidAccountData"
                                      []
                                  ]
                              |)
                            |)
                          |)
                        |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              M.match_operator (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::try_trait::Try",
                        Ty.apply
                          (Ty.path "core::result::Result")
                          [
                            Ty.path "spl_token_2022::extension::TlvIndices";
                            Ty.path "solana_program::program_error::ProgramError"
                          ],
                        [],
                        "branch",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_function (|
                            "spl_token_2022::extension::get_extension_indices",
                            [ V ]
                          |),
                          [ M.read (| tlv_data |); Value.Bool false ]
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Break",
                            0
                          |) in
                        let residual := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::FromResidual",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply
                                          (Ty.path "&")
                                          [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.path "core::convert::Infallible";
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ]
                                    ],
                                    "from_residual",
                                    []
                                  |),
                                  [ M.read (| residual |) ]
                                |)
                              |)
                            |)
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Continue",
                            0
                          |) in
                        let val := M.copy (| γ0_0 |) in
                        val))
                  ]
                |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ0_0 :=
                        M.SubPointer.get_struct_record_field (|
                          γ,
                          "spl_token_2022::extension::TlvIndices",
                          "type_start"
                        |) in
                      let γ0_1 :=
                        M.SubPointer.get_struct_record_field (|
                          γ,
                          "spl_token_2022::extension::TlvIndices",
                          "length_start"
                        |) in
                      let γ0_2 :=
                        M.SubPointer.get_struct_record_field (|
                          γ,
                          "spl_token_2022::extension::TlvIndices",
                          "value_start"
                        |) in
                      let length_start := M.copy (| γ0_1 |) in
                      let value_start := M.copy (| γ0_2 |) in
                      let length :=
                        M.copy (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.apply
                                        (Ty.path "&")
                                        [ Ty.path "spl_token_2022::extension::Length" ];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_from_bytes",
                                      [ Ty.path "spl_token_2022::extension::Length" ]
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::index::Index",
                                          Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::ops::range::Range")
                                              [ Ty.path "usize" ]
                                          ],
                                          "index",
                                          []
                                        |),
                                        [
                                          M.read (| tlv_data |);
                                          Value.StructRecord
                                            "core::ops::range::Range"
                                            [
                                              ("start", M.read (| length_start |));
                                              ("end_", M.read (| value_start |))
                                            ]
                                        ]
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path "&")
                                                    [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |) in
                      let value_end :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                            [
                              M.read (| value_start |);
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::convert::From",
                                  Ty.path "usize",
                                  [ Ty.path "spl_token_2022::extension::Length" ],
                                  "from",
                                  []
                                |),
                                [ M.read (| M.read (| length |) |) ]
                              |)
                            ]
                          |)
                        |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      BinOp.Pure.lt
                                        (M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            "len",
                                            []
                                          |),
                                          [ M.read (| tlv_data |) ]
                                        |))
                                        (M.read (| value_end |))
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructTuple
                                          "core::result::Result::Err"
                                          [
                                            Value.StructTuple
                                              "solana_program::program_error::ProgramError::InvalidAccountData"
                                              []
                                          ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.alloc (|
                        Value.StructTuple
                          "core::result::Result::Ok"
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::index::Index",
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]
                                ],
                                "index",
                                []
                              |),
                              [
                                M.read (| tlv_data |);
                                Value.StructRecord
                                  "core::ops::range::Range"
                                  [
                                    ("start", M.read (| value_start |));
                                    ("end_", M.read (| value_end |))
                                  ]
                              ]
                            |)
                          ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn get_extension_bytes_mut<S: BaseState, V: Extension>(
      tlv_data: &mut [u8],
  ) -> Result<&mut [u8], ProgramError> {
      if V::TYPE.get_account_type() != S::ACCOUNT_TYPE {
          return Err(ProgramError::InvalidAccountData);
      }
      let TlvIndices {
          type_start: _,
          length_start,
          value_start,
      } = get_extension_indices::<V>(tlv_data, false)?;
      // get_extension_indices has checked that tlv_data is long enough to include
      // these indices
      let length = pod_from_bytes::<Length>(&tlv_data[length_start..value_start])?;
      let value_end = value_start.saturating_add(usize::from( *length));
      if tlv_data.len() < value_end {
          return Err(ProgramError::InvalidAccountData);
      }
      Ok(&mut tlv_data[value_start..value_end])
  }
  *)
  Definition get_extension_bytes_mut (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S; V ], [ tlv_data ] =>
      ltac:(M.monadic
        (let tlv_data := M.alloc (| tlv_data |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::cmp::PartialEq",
                                  Ty.path "spl_token_2022::extension::AccountType",
                                  [ Ty.path "spl_token_2022::extension::AccountType" ],
                                  "ne",
                                  []
                                |),
                                [
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.path "spl_token_2022::extension::ExtensionType",
                                        "get_account_type",
                                        []
                                      |),
                                      [
                                        M.get_constant (|
                                          "spl_token_2022::extension::Extension::TYPE"
                                        |)
                                      ]
                                    |)
                                  |);
                                  M.get_constant (|
                                    "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                  |)
                                ]
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                Value.StructTuple
                                  "core::result::Result::Err"
                                  [
                                    Value.StructTuple
                                      "solana_program::program_error::ProgramError::InvalidAccountData"
                                      []
                                  ]
                              |)
                            |)
                          |)
                        |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              M.match_operator (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::try_trait::Try",
                        Ty.apply
                          (Ty.path "core::result::Result")
                          [
                            Ty.path "spl_token_2022::extension::TlvIndices";
                            Ty.path "solana_program::program_error::ProgramError"
                          ],
                        [],
                        "branch",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_function (|
                            "spl_token_2022::extension::get_extension_indices",
                            [ V ]
                          |),
                          [ M.read (| tlv_data |); Value.Bool false ]
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Break",
                            0
                          |) in
                        let residual := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::FromResidual",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply
                                          (Ty.path "&mut")
                                          [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.path "core::convert::Infallible";
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ]
                                    ],
                                    "from_residual",
                                    []
                                  |),
                                  [ M.read (| residual |) ]
                                |)
                              |)
                            |)
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Continue",
                            0
                          |) in
                        let val := M.copy (| γ0_0 |) in
                        val))
                  ]
                |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ0_0 :=
                        M.SubPointer.get_struct_record_field (|
                          γ,
                          "spl_token_2022::extension::TlvIndices",
                          "type_start"
                        |) in
                      let γ0_1 :=
                        M.SubPointer.get_struct_record_field (|
                          γ,
                          "spl_token_2022::extension::TlvIndices",
                          "length_start"
                        |) in
                      let γ0_2 :=
                        M.SubPointer.get_struct_record_field (|
                          γ,
                          "spl_token_2022::extension::TlvIndices",
                          "value_start"
                        |) in
                      let length_start := M.copy (| γ0_1 |) in
                      let value_start := M.copy (| γ0_2 |) in
                      let length :=
                        M.copy (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.apply
                                        (Ty.path "&")
                                        [ Ty.path "spl_token_2022::extension::Length" ];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_from_bytes",
                                      [ Ty.path "spl_token_2022::extension::Length" ]
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::index::Index",
                                          Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::ops::range::Range")
                                              [ Ty.path "usize" ]
                                          ],
                                          "index",
                                          []
                                        |),
                                        [
                                          M.read (| tlv_data |);
                                          Value.StructRecord
                                            "core::ops::range::Range"
                                            [
                                              ("start", M.read (| length_start |));
                                              ("end_", M.read (| value_start |))
                                            ]
                                        ]
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path "&mut")
                                                    [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |) in
                      let value_end :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                            [
                              M.read (| value_start |);
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::convert::From",
                                  Ty.path "usize",
                                  [ Ty.path "spl_token_2022::extension::Length" ],
                                  "from",
                                  []
                                |),
                                [ M.read (| M.read (| length |) |) ]
                              |)
                            ]
                          |)
                        |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      BinOp.Pure.lt
                                        (M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            "len",
                                            []
                                          |),
                                          [ M.read (| tlv_data |) ]
                                        |))
                                        (M.read (| value_end |))
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructTuple
                                          "core::result::Result::Err"
                                          [
                                            Value.StructTuple
                                              "solana_program::program_error::ProgramError::InvalidAccountData"
                                              []
                                          ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.alloc (|
                        Value.StructTuple
                          "core::result::Result::Ok"
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::index::IndexMut",
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]
                                ],
                                "index_mut",
                                []
                              |),
                              [
                                M.read (| tlv_data |);
                                Value.StructRecord
                                  "core::ops::range::Range"
                                  [
                                    ("start", M.read (| value_start |));
                                    ("end_", M.read (| value_end |))
                                  ]
                              ]
                            |)
                          ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn try_get_new_account_len_for_extension_len<S: BaseState, V: Extension>(
      tlv_data: &[u8],
      new_extension_len: usize,
  ) -> Result<usize, ProgramError> {
      // get the new length used by the extension
      let new_extension_tlv_len = add_type_and_length_to_len(new_extension_len);
      let tlv_info = get_tlv_data_info(tlv_data)?;
      // If we're adding an extension, then we must have at least BASE_ACCOUNT_LENGTH
      // and account type
      let current_len = tlv_info
          .used_len
          .saturating_add(BASE_ACCOUNT_AND_TYPE_LENGTH);
      // get the current length used by the extension
      let current_extension_len = get_extension_bytes::<S, V>(tlv_data)
          .map(|x| add_type_and_length_to_len(x.len()))
          .unwrap_or(0);
      let new_len = current_len
          .saturating_sub(current_extension_len)
          .saturating_add(new_extension_tlv_len);
      Ok(adjust_len_for_multisig(new_len))
  }
  *)
  Definition try_get_new_account_len_for_extension_len (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S; V ], [ tlv_data; new_extension_len ] =>
      ltac:(M.monadic
        (let tlv_data := M.alloc (| tlv_data |) in
        let new_extension_len := M.alloc (| new_extension_len |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let new_extension_tlv_len :=
                M.alloc (|
                  M.call_closure (|
                    M.get_function (|
                      "spl_token_2022::extension::add_type_and_length_to_len",
                      []
                    |),
                    [ M.read (| new_extension_len |) ]
                  |)
                |) in
              let tlv_info :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [
                              Ty.path "spl_token_2022::extension::TlvDataInfo";
                              Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (| "spl_token_2022::extension::get_tlv_data_info", [] |),
                            [ M.read (| tlv_data |) ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.path "usize";
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let current_len :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                    [
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          tlv_info,
                          "spl_token_2022::extension::TlvDataInfo",
                          "used_len"
                        |)
                      |);
                      M.read (|
                        M.get_constant (|
                          "spl_token_2022::extension::BASE_ACCOUNT_AND_TYPE_LENGTH"
                        |)
                      |)
                    ]
                  |)
                |) in
              let current_extension_len :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply
                        (Ty.path "core::result::Result")
                        [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError" ],
                      "unwrap_or",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [
                              Ty.apply
                                (Ty.path "&")
                                [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                              Ty.path "solana_program::program_error::ProgramError"
                            ],
                          "map",
                          [
                            Ty.path "usize";
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.apply
                                      (Ty.path "&")
                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                  ]
                              ]
                              (Ty.path "usize")
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::get_extension_bytes",
                              [ S; V ]
                            |),
                            [ M.read (| tlv_data |) ]
                          |);
                          M.closure
                            (fun γ =>
                              ltac:(M.monadic
                                match γ with
                                | [ α0 ] =>
                                  M.match_operator (|
                                    M.alloc (| α0 |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let x := M.copy (| γ |) in
                                          M.call_closure (|
                                            M.get_function (|
                                              "spl_token_2022::extension::add_type_and_length_to_len",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                  "len",
                                                  []
                                                |),
                                                [ M.read (| x |) ]
                                              |)
                                            ]
                                          |)))
                                    ]
                                  |)
                                | _ => M.impossible (||)
                                end))
                        ]
                      |);
                      Value.Integer 0
                    ]
                  |)
                |) in
              let new_len :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                    [
                      M.call_closure (|
                        M.get_associated_function (| Ty.path "usize", "saturating_sub", [] |),
                        [ M.read (| current_len |); M.read (| current_extension_len |) ]
                      |);
                      M.read (| new_extension_tlv_len |)
                    ]
                  |)
                |) in
              M.alloc (|
                Value.StructTuple
                  "core::result::Result::Ok"
                  [
                    M.call_closure (|
                      M.get_function (| "spl_token_2022::extension::adjust_len_for_multisig", [] |),
                      [ M.read (| new_len |) ]
                    |)
                  ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (* Trait *)
  Module BaseStateWithExtensions.
    Definition get_extension_bytes (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_function (| "spl_token_2022::extension::get_extension_bytes", [ S; V ] |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "spl_token_2022::extension::BaseStateWithExtensions",
                  Self,
                  [ S ],
                  "get_tlv_data",
                  []
                |),
                [ M.read (| self |) ]
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_get_extension_bytes :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "get_extension_bytes"
        (get_extension_bytes S).
    Definition get_extension (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.call_closure (|
                M.get_function (| "spl_pod::bytemuck::pod_from_bytes", [ V ] |),
                [
                  M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "&")
                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensions",
                                Self,
                                [ S ],
                                "get_extension_bytes",
                                [ V ]
                              |),
                              [ M.read (| self |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.apply (Ty.path "&") [ V ];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            M.alloc (| M.read (| val |) |)))
                      ]
                    |)
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_get_extension :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "get_extension"
        (get_extension S).
    Definition get_variable_len_extension (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let data :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "&")
                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (|
                                "spl_token_2022::extension::get_extension_bytes",
                                [ S; V ]
                              |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "spl_token_2022::extension::BaseStateWithExtensions",
                                    Self,
                                    [ S ],
                                    "get_tlv_data",
                                    []
                                  |),
                                  [ M.read (| self |) ]
                                |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [ V; Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "spl_type_length_value::variable_len_pack::VariableLenPack",
                      V,
                      [],
                      "unpack_from_slice",
                      []
                    |),
                    [ M.read (| data |) ]
                  |)
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_get_variable_len_extension :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "get_variable_len_extension"
        (get_variable_len_extension S).
    Definition get_extension_types (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.apply
                (Ty.path "core::result::Result")
                [
                  Ty.path "spl_token_2022::extension::TlvDataInfo";
                  Ty.path "solana_program::program_error::ProgramError"
                ],
              "map",
              [
                Ty.apply
                  (Ty.path "alloc::vec::Vec")
                  [
                    Ty.path "spl_token_2022::extension::ExtensionType";
                    Ty.path "alloc::alloc::Global"
                  ];
                Ty.function
                  [ Ty.tuple [ Ty.path "spl_token_2022::extension::TlvDataInfo" ] ]
                  (Ty.apply
                    (Ty.path "alloc::vec::Vec")
                    [
                      Ty.path "spl_token_2022::extension::ExtensionType";
                      Ty.path "alloc::alloc::Global"
                    ])
              ]
            |),
            [
              M.call_closure (|
                M.get_function (| "spl_token_2022::extension::get_tlv_data_info", [] |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "spl_token_2022::extension::BaseStateWithExtensions",
                      Self,
                      [ S ],
                      "get_tlv_data",
                      []
                    |),
                    [ M.read (| self |) ]
                  |)
                ]
              |);
              M.closure
                (fun γ =>
                  ltac:(M.monadic
                    match γ with
                    | [ α0 ] =>
                      M.match_operator (|
                        M.alloc (| α0 |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let x := M.copy (| γ |) in
                              M.read (|
                                M.SubPointer.get_struct_record_field (|
                                  x,
                                  "spl_token_2022::extension::TlvDataInfo",
                                  "extension_types"
                                |)
                              |)))
                        ]
                      |)
                    | _ => M.impossible (||)
                    end))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_get_extension_types :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "get_extension_types"
        (get_extension_types S).
    Definition get_first_extension_type (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_function (| "spl_token_2022::extension::get_first_extension_type", [] |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "spl_token_2022::extension::BaseStateWithExtensions",
                  Self,
                  [ S ],
                  "get_tlv_data",
                  []
                |),
                [ M.read (| self |) ]
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_get_first_extension_type :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "get_first_extension_type"
        (get_first_extension_type S).
    Definition try_get_account_len (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let tlv_info :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.path "spl_token_2022::extension::TlvDataInfo";
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (|
                                "spl_token_2022::extension::get_tlv_data_info",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "spl_token_2022::extension::BaseStateWithExtensions",
                                    Self,
                                    [ S ],
                                    "get_tlv_data",
                                    []
                                  |),
                                  [ M.read (| self |) ]
                                |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "usize";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::vec::Vec")
                                    [
                                      Ty.path "spl_token_2022::extension::ExtensionType";
                                      Ty.path "alloc::alloc::Global"
                                    ],
                                  "is_empty",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    tlv_info,
                                    "spl_token_2022::extension::TlvDataInfo",
                                    "extension_types"
                                  |)
                                ]
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let total_len :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                              [
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    tlv_info,
                                    "spl_token_2022::extension::TlvDataInfo",
                                    "used_len"
                                  |)
                                |);
                                M.read (|
                                  M.get_constant (|
                                    "spl_token_2022::extension::BASE_ACCOUNT_AND_TYPE_LENGTH"
                                  |)
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              M.call_closure (|
                                M.get_function (|
                                  "spl_token_2022::extension::adjust_len_for_multisig",
                                  []
                                |),
                                [ M.read (| total_len |) ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_try_get_account_len :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "try_get_account_len"
        (try_get_account_len S).
    Definition try_get_new_account_len (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_function (|
              "spl_token_2022::extension::try_get_new_account_len_for_extension_len",
              [ S; V ]
            |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "spl_token_2022::extension::BaseStateWithExtensions",
                  Self,
                  [ S ],
                  "get_tlv_data",
                  []
                |),
                [ M.read (| self |) ]
              |);
              M.call_closure (|
                M.get_function (| "spl_pod::bytemuck::pod_get_packed_len", [ V ] |),
                []
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_try_get_new_account_len :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "try_get_new_account_len"
        (try_get_new_account_len S).
    Definition try_get_new_account_len_for_variable_len_extension
        (S Self : Ty.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      match τ, α with
      | [ V ], [ self; new_extension ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let new_extension := M.alloc (| new_extension |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.call_closure (|
                M.get_function (|
                  "spl_token_2022::extension::try_get_new_account_len_for_extension_len",
                  [ S; V ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "spl_token_2022::extension::BaseStateWithExtensions",
                      Self,
                      [ S ],
                      "get_tlv_data",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.path "usize";
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_type_length_value::variable_len_pack::VariableLenPack",
                                V,
                                [],
                                "get_packed_len",
                                []
                              |),
                              [ M.read (| new_extension |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "usize";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_try_get_new_account_len_for_variable_len_extension :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensions"
        "try_get_new_account_len_for_variable_len_extension"
        (try_get_new_account_len_for_variable_len_extension S).
  End BaseStateWithExtensions.
  
  (* StructRecord
    {
      name := "StateWithExtensionsOwned";
      ty_params := [ "S" ];
      fields :=
        [
          ("base", S);
          ("tlv_data",
            Ty.apply (Ty.path "alloc::vec::Vec") [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ])
        ];
    } *)
  
  Module Impl_core_clone_Clone_where_core_clone_Clone_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsOwned") [ S ].
    
    (* Clone *)
    Definition clone (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          Value.StructRecord
            "spl_token_2022::extension::StateWithExtensionsOwned"
            [
              ("base",
                M.call_closure (|
                  M.get_trait_method (| "core::clone::Clone", S, [], "clone", [] |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::StateWithExtensionsOwned",
                      "base"
                    |)
                  ]
                |));
              ("tlv_data",
                M.call_closure (|
                  M.get_trait_method (|
                    "core::clone::Clone",
                    Ty.apply
                      (Ty.path "alloc::vec::Vec")
                      [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                    [],
                    "clone",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::StateWithExtensionsOwned",
                      "tlv_data"
                    |)
                  ]
                |))
            ]))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::clone::Clone"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("clone", InstanceField.Method (clone S)) ].
  End Impl_core_clone_Clone_where_core_clone_Clone_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
  
  Module Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsOwned") [ S ].
    
    (* Debug *)
    Definition fmt (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_struct_field2_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "StateWithExtensionsOwned" |);
              M.read (| Value.String "base" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::StateWithExtensionsOwned",
                  "base"
                |));
              M.read (| Value.String "tlv_data" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::StateWithExtensionsOwned",
                    "tlv_data"
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::fmt::Debug"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method (fmt S)) ].
  End Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
  
  Module Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsOwned") [ S ].
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
  
  Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsOwned") [ S ].
    
    (* PartialEq *)
    Definition eq (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          LogicalOp.and (|
            M.call_closure (|
              M.get_trait_method (| "core::cmp::PartialEq", S, [ S ], "eq", [] |),
              [
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::StateWithExtensionsOwned",
                  "base"
                |);
                M.SubPointer.get_struct_record_field (|
                  M.read (| other |),
                  "spl_token_2022::extension::StateWithExtensionsOwned",
                  "base"
                |)
              ]
            |),
            ltac:(M.monadic
              (M.call_closure (|
                M.get_trait_method (|
                  "core::cmp::PartialEq",
                  Ty.apply
                    (Ty.path "alloc::vec::Vec")
                    [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                  [
                    Ty.apply
                      (Ty.path "alloc::vec::Vec")
                      [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ]
                  ],
                  "eq",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::StateWithExtensionsOwned",
                    "tlv_data"
                  |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| other |),
                    "spl_token_2022::extension::StateWithExtensionsOwned",
                    "tlv_data"
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::cmp::PartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method (eq S)) ].
  End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
  
  Module Impl_spl_token_2022_extension_StateWithExtensionsOwned_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsOwned") [ S ].
    
    (*
        pub fn unpack(mut input: Vec<u8>) -> Result<Self, ProgramError> {
            check_min_len_and_not_multisig(&input, S::SIZE_OF)?;
            let mut rest = input.split_off(S::SIZE_OF);
            let base = S::unpack(&input)?;
            if let Some((account_type_index, tlv_start_index)) = type_and_tlv_indices::<S>(&rest)? {
                // type_and_tlv_indices() checks that returned indexes are within range
                let account_type = AccountType::try_from(rest[account_type_index])
                    .map_err(|_| ProgramError::InvalidAccountData)?;
                check_account_type::<S>(account_type)?;
                let tlv_data = rest.split_off(tlv_start_index);
                Ok(Self { base, tlv_data })
            } else {
                Ok(Self {
                    base,
                    tlv_data: vec![],
                })
            }
        }
    *)
    Definition unpack (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ input ] =>
        ltac:(M.monadic
          (let input := M.alloc (| input |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::check_min_len_and_not_multisig",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::deref::Deref",
                                  Ty.apply
                                    (Ty.path "alloc::vec::Vec")
                                    [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                                  [],
                                  "deref",
                                  []
                                |),
                                [ input ]
                              |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "spl_token_2022::extension::StateWithExtensionsOwned")
                                            [ S ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |) in
                let rest :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::vec::Vec")
                          [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                        "split_off",
                        []
                      |),
                      [
                        input;
                        M.read (|
                          M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                        |)
                      ]
                    |)
                  |) in
                let base :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [ S; Ty.path "solana_program::program_error::ProgramError" ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "solana_program::program_pack::Pack",
                                S,
                                [],
                                "unpack",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::deref::Deref",
                                    Ty.apply
                                      (Ty.path "alloc::vec::Vec")
                                      [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                                    [],
                                    "deref",
                                    []
                                  |),
                                  [ input ]
                                |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.apply
                                              (Ty.path
                                                "spl_token_2022::extension::StateWithExtensionsOwned")
                                              [ S ];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.apply
                                        (Ty.path "core::option::Option")
                                        [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_token_2022::extension::type_and_tlv_indices",
                                      [ S ]
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::deref::Deref",
                                          Ty.apply
                                            (Ty.path "alloc::vec::Vec")
                                            [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                                          [],
                                          "deref",
                                          []
                                        |),
                                        [ rest ]
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "spl_token_2022::extension::StateWithExtensionsOwned")
                                                    [ S ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                        let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                        let account_type_index := M.copy (| γ1_0 |) in
                        let tlv_start_index := M.copy (| γ1_1 |) in
                        let account_type :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.path "spl_token_2022::extension::AccountType";
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "spl_token_2022::extension::AccountType";
                                            Ty.apply
                                              (Ty.path "num_enum::TryFromPrimitiveError")
                                              [ Ty.path "spl_token_2022::extension::AccountType" ]
                                          ],
                                        "map_err",
                                        [
                                          Ty.path "solana_program::program_error::ProgramError";
                                          Ty.function
                                            [
                                              Ty.tuple
                                                [
                                                  Ty.apply
                                                    (Ty.path "num_enum::TryFromPrimitiveError")
                                                    [
                                                      Ty.path
                                                        "spl_token_2022::extension::AccountType"
                                                    ]
                                                ]
                                            ]
                                            (Ty.path "solana_program::program_error::ProgramError")
                                        ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::convert::TryFrom",
                                            Ty.path "spl_token_2022::extension::AccountType",
                                            [ Ty.path "u8" ],
                                            "try_from",
                                            []
                                          |),
                                          [
                                            M.read (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::index::Index",
                                                  Ty.apply
                                                    (Ty.path "alloc::vec::Vec")
                                                    [ Ty.path "u8"; Ty.path "alloc::alloc::Global"
                                                    ],
                                                  [ Ty.path "usize" ],
                                                  "index",
                                                  []
                                                |),
                                                [ rest; M.read (| account_type_index |) ]
                                              |)
                                            |)
                                          ]
                                        |);
                                        M.closure
                                          (fun γ =>
                                            ltac:(M.monadic
                                              match γ with
                                              | [ α0 ] =>
                                                M.match_operator (|
                                                  M.alloc (| α0 |),
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (Value.StructTuple
                                                          "solana_program::program_error::ProgramError::InvalidAccountData"
                                                          []))
                                                  ]
                                                |)
                                              | _ => M.impossible (||)
                                              end))
                                      ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::StateWithExtensionsOwned")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.tuple [];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_token_2022::extension::check_account_type",
                                      [ S ]
                                    |),
                                    [ M.read (| account_type |) ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "spl_token_2022::extension::StateWithExtensionsOwned")
                                                    [ S ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |) in
                        let tlv_data :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::vec::Vec")
                                  [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                                "split_off",
                                []
                              |),
                              [ rest; M.read (| tlv_start_index |) ]
                            |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              Value.StructRecord
                                "spl_token_2022::extension::StateWithExtensionsOwned"
                                [ ("base", M.read (| base |)); ("tlv_data", M.read (| tlv_data |)) ]
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              Value.StructRecord
                                "spl_token_2022::extension::StateWithExtensionsOwned"
                                [
                                  ("base", M.read (| base |));
                                  ("tlv_data",
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::vec::Vec")
                                          [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                                        "new",
                                        []
                                      |),
                                      []
                                    |))
                                ]
                            ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_unpack :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "unpack" (unpack S).
  End Impl_spl_token_2022_extension_StateWithExtensionsOwned_S.
  
  Module Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsOwned") [ S ].
    
    (*
        fn get_tlv_data(&self) -> &[u8] {
            &self.tlv_data
        }
    *)
    Definition get_tlv_data (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::ops::deref::Deref",
              Ty.apply (Ty.path "alloc::vec::Vec") [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
              [],
              "deref",
              []
            |),
            [
              M.SubPointer.get_struct_record_field (|
                M.read (| self |),
                "spl_token_2022::extension::StateWithExtensionsOwned",
                "tlv_data"
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "spl_token_2022::extension::BaseStateWithExtensions"
        (Self S)
        (* Trait polymorphic types *) [ (* S *) S ]
        (* Instance *) [ ("get_tlv_data", InstanceField.Method (get_tlv_data S)) ].
  End Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_StateWithExtensionsOwned_S.
  
  (* StructRecord
    {
      name := "StateWithExtensions";
      ty_params := [ "S" ];
      fields :=
        [
          ("base", S);
          ("tlv_data", Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ])
        ];
    } *)
  
  Module Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_for_spl_token_2022_extension_StateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensions") [ S ].
    
    (* Debug *)
    Definition fmt (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_struct_field2_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "StateWithExtensions" |);
              M.read (| Value.String "base" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::StateWithExtensions",
                  "base"
                |));
              M.read (| Value.String "tlv_data" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::StateWithExtensions",
                    "tlv_data"
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::fmt::Debug"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method (fmt S)) ].
  End Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_for_spl_token_2022_extension_StateWithExtensions_S.
  
  Module Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_for_spl_token_2022_extension_StateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensions") [ S ].
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_for_spl_token_2022_extension_StateWithExtensions_S.
  
  Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_for_spl_token_2022_extension_StateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensions") [ S ].
    
    (* PartialEq *)
    Definition eq (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          LogicalOp.and (|
            M.call_closure (|
              M.get_trait_method (| "core::cmp::PartialEq", S, [ S ], "eq", [] |),
              [
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::StateWithExtensions",
                  "base"
                |);
                M.SubPointer.get_struct_record_field (|
                  M.read (| other |),
                  "spl_token_2022::extension::StateWithExtensions",
                  "base"
                |)
              ]
            |),
            ltac:(M.monadic
              (M.call_closure (|
                M.get_trait_method (|
                  "core::cmp::PartialEq",
                  Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                  [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ],
                  "eq",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::StateWithExtensions",
                    "tlv_data"
                  |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| other |),
                    "spl_token_2022::extension::StateWithExtensions",
                    "tlv_data"
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::cmp::PartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method (eq S)) ].
  End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_for_spl_token_2022_extension_StateWithExtensions_S.
  
  Module Impl_spl_token_2022_extension_StateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensions") [ S ].
    
    (*
        pub fn unpack(input: &'data [u8]) -> Result<Self, ProgramError> {
            check_min_len_and_not_multisig(input, S::SIZE_OF)?;
            let (base_data, rest) = input.split_at(S::SIZE_OF);
            let base = S::unpack(base_data)?;
            let tlv_data = unpack_tlv_data::<S>(rest)?;
            Ok(Self { base, tlv_data })
        }
    *)
    Definition unpack (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ input ] =>
        ltac:(M.monadic
          (let input := M.alloc (| input |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::check_min_len_and_not_multisig",
                              []
                            |),
                            [
                              M.read (| input |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "spl_token_2022::extension::StateWithExtensions")
                                            [ S ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |) in
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                        "split_at",
                        []
                      |),
                      [
                        M.read (| input |);
                        M.read (|
                          M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                        let base_data := M.copy (| γ0_0 |) in
                        let rest := M.copy (| γ0_1 |) in
                        let base :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [ S; Ty.path "solana_program::program_error::ProgramError" ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "solana_program::program_pack::Pack",
                                        S,
                                        [],
                                        "unpack",
                                        []
                                      |),
                                      [ M.read (| base_data |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::StateWithExtensions")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        let tlv_data :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply
                                          (Ty.path "&")
                                          [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_function (|
                                        "spl_token_2022::extension::unpack_tlv_data",
                                        [ S ]
                                      |),
                                      [ M.read (| rest |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::StateWithExtensions")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              Value.StructRecord
                                "spl_token_2022::extension::StateWithExtensions"
                                [ ("base", M.read (| base |)); ("tlv_data", M.read (| tlv_data |)) ]
                            ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_unpack :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "unpack" (unpack S).
  End Impl_spl_token_2022_extension_StateWithExtensions_S.
  
  Module Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_S_for_spl_token_2022_extension_StateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensions") [ S ].
    
    (*
        fn get_tlv_data(&self) -> &[u8] {
            self.tlv_data
        }
    *)
    Definition get_tlv_data (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::StateWithExtensions",
              "tlv_data"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "spl_token_2022::extension::BaseStateWithExtensions"
        (Self S)
        (* Trait polymorphic types *) [ (* S *) S ]
        (* Instance *) [ ("get_tlv_data", InstanceField.Method (get_tlv_data S)) ].
  End Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_where_solana_program_program_pack_Pack_S_S_for_spl_token_2022_extension_StateWithExtensions_S.
  
  (* StructRecord
    {
      name := "PodStateWithExtensions";
      ty_params := [ "S" ];
      fields :=
        [
          ("base", Ty.apply (Ty.path "&") [ S ]);
          ("tlv_data", Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ])
        ];
    } *)
  
  Module Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensions") [ S ].
    
    (* Debug *)
    Definition fmt (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_struct_field2_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "PodStateWithExtensions" |);
              M.read (| Value.String "base" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::PodStateWithExtensions",
                  "base"
                |));
              M.read (| Value.String "tlv_data" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::PodStateWithExtensions",
                    "tlv_data"
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::fmt::Debug"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method (fmt S)) ].
  End Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
  
  Module Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensions") [ S ].
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
  
  Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensions") [ S ].
    
    (* PartialEq *)
    Definition eq (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          LogicalOp.and (|
            M.call_closure (|
              M.get_trait_method (|
                "core::cmp::PartialEq",
                Ty.apply (Ty.path "&") [ S ],
                [ Ty.apply (Ty.path "&") [ S ] ],
                "eq",
                []
              |),
              [
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::PodStateWithExtensions",
                  "base"
                |);
                M.SubPointer.get_struct_record_field (|
                  M.read (| other |),
                  "spl_token_2022::extension::PodStateWithExtensions",
                  "base"
                |)
              ]
            |),
            ltac:(M.monadic
              (M.call_closure (|
                M.get_trait_method (|
                  "core::cmp::PartialEq",
                  Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                  [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ],
                  "eq",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::PodStateWithExtensions",
                    "tlv_data"
                  |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| other |),
                    "spl_token_2022::extension::PodStateWithExtensions",
                    "tlv_data"
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::cmp::PartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method (eq S)) ].
  End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
  
  Module Impl_spl_token_2022_extension_PodStateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensions") [ S ].
    
    (*
        pub fn unpack(input: &'data [u8]) -> Result<Self, ProgramError> {
            check_min_len_and_not_multisig(input, S::SIZE_OF)?;
            let (base_data, rest) = input.split_at(S::SIZE_OF);
            let base = pod_from_bytes::<S>(base_data)?;
            if !base.is_initialized() {
                Err(ProgramError::UninitializedAccount)
            } else {
                let tlv_data = unpack_tlv_data::<S>(rest)?;
                Ok(Self { base, tlv_data })
            }
        }
    *)
    Definition unpack (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ input ] =>
        ltac:(M.monadic
          (let input := M.alloc (| input |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::check_min_len_and_not_multisig",
                              []
                            |),
                            [
                              M.read (| input |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "spl_token_2022::extension::PodStateWithExtensions")
                                            [ S ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |) in
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                        "split_at",
                        []
                      |),
                      [
                        M.read (| input |);
                        M.read (|
                          M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                        let base_data := M.copy (| γ0_0 |) in
                        let rest := M.copy (| γ0_1 |) in
                        let base :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply (Ty.path "&") [ S ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_function (|
                                        "spl_pod::bytemuck::pod_from_bytes",
                                        [ S ]
                                      |),
                                      [ M.read (| base_data |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::PodStateWithExtensions")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      UnOp.Pure.not
                                        (M.call_closure (|
                                          M.get_trait_method (|
                                            "solana_program::program_pack::IsInitialized",
                                            S,
                                            [],
                                            "is_initialized",
                                            []
                                          |),
                                          [ M.read (| base |) ]
                                        |))
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Err"
                                    [
                                      Value.StructTuple
                                        "solana_program::program_error::ProgramError::UninitializedAccount"
                                        []
                                    ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let tlv_data :=
                                  M.copy (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.apply
                                                  (Ty.path "&")
                                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_function (|
                                                "spl_token_2022::extension::unpack_tlv_data",
                                                [ S ]
                                              |),
                                              [ M.read (| rest |) ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.apply
                                                              (Ty.path
                                                                "spl_token_2022::extension::PodStateWithExtensions")
                                                              [ S ];
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            [
                                                              Ty.path "core::convert::Infallible";
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ]
                                                        ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Ok"
                                    [
                                      Value.StructRecord
                                        "spl_token_2022::extension::PodStateWithExtensions"
                                        [
                                          ("base", M.read (| base |));
                                          ("tlv_data", M.read (| tlv_data |))
                                        ]
                                    ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_unpack :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "unpack" (unpack S).
  End Impl_spl_token_2022_extension_PodStateWithExtensions_S.
  
  Module Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensions") [ S ].
    
    (*
        fn get_tlv_data(&self) -> &[u8] {
            self.tlv_data
        }
    *)
    Definition get_tlv_data (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::PodStateWithExtensions",
              "tlv_data"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "spl_token_2022::extension::BaseStateWithExtensions"
        (Self S)
        (* Trait polymorphic types *) [ (* S *) S ]
        (* Instance *) [ ("get_tlv_data", InstanceField.Method (get_tlv_data S)) ].
  End Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_where_bytemuck_pod_Pod_S_S_for_spl_token_2022_extension_PodStateWithExtensions_S.
  
  (* Trait *)
  Module BaseStateWithExtensionsMut.
    Definition get_extension_bytes_mut (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_function (| "spl_token_2022::extension::get_extension_bytes_mut", [ S; V ] |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "spl_token_2022::extension::BaseStateWithExtensionsMut",
                  Self,
                  [ S ],
                  "get_tlv_data_mut",
                  []
                |),
                [ M.read (| self |) ]
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_get_extension_bytes_mut :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "get_extension_bytes_mut"
        (get_extension_bytes_mut S).
    Definition get_extension_mut (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.call_closure (|
                M.get_function (| "spl_pod::bytemuck::pod_from_bytes_mut", [ V ] |),
                [
                  M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "&mut")
                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                Self,
                                [ S ],
                                "get_extension_bytes_mut",
                                [ V ]
                              |),
                              [ M.read (| self |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.apply (Ty.path "&mut") [ V ];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            M.alloc (| M.read (| val |) |)))
                      ]
                    |)
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_get_extension_mut :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "get_extension_mut"
        (get_extension_mut S).
    Definition pack_variable_len_extension (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self; extension ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let extension := M.alloc (| extension |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let data :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "&mut")
                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                Self,
                                [ S ],
                                "get_extension_bytes_mut",
                                [ V ]
                              |),
                              [ M.read (| self |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "spl_type_length_value::variable_len_pack::VariableLenPack",
                      V,
                      [],
                      "pack_into_slice",
                      []
                    |),
                    [ M.read (| extension |); M.read (| data |) ]
                  |)
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_pack_variable_len_extension :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "pack_variable_len_extension"
        (pack_variable_len_extension S).
    Definition init_extension (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self; overwrite ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let overwrite := M.alloc (| overwrite |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let length :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_function (| "spl_pod::bytemuck::pod_get_packed_len", [ V ] |),
                      []
                    |)
                  |) in
                let buffer :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "&mut")
                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                Self,
                                [ S ],
                                "alloc",
                                [ V ]
                              |),
                              [ M.read (| self |); M.read (| length |); M.read (| overwrite |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.apply (Ty.path "&mut") [ V ];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                let extension_ref :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply (Ty.path "&mut") [ V ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (| "spl_pod::bytemuck::pod_from_bytes_mut", [ V ] |),
                              [ M.read (| buffer |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.apply (Ty.path "&mut") [ V ];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                let _ :=
                  M.write (|
                    M.read (| extension_ref |),
                    M.call_closure (|
                      M.get_trait_method (| "core::default::Default", V, [], "default", [] |),
                      []
                    |)
                  |) in
                M.alloc (|
                  Value.StructTuple "core::result::Result::Ok" [ M.read (| extension_ref |) ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_init_extension :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "init_extension"
        (init_extension S).
    Definition realloc_variable_len_extension
        (S Self : Ty.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      match τ, α with
      | [ V ], [ self; new_extension ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let new_extension := M.alloc (| new_extension |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let data :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "&mut")
                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                Self,
                                [ S ],
                                "realloc",
                                [ V ]
                              |),
                              [
                                M.read (| self |);
                                M.read (|
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::Try",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "usize";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [],
                                          "branch",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "spl_type_length_value::variable_len_pack::VariableLenPack",
                                              V,
                                              [],
                                              "get_packed_len",
                                              []
                                            |),
                                            [ M.read (| new_extension |) ]
                                          |)
                                        ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Break",
                                              0
                                            |) in
                                          let residual := M.copy (| γ0_0 |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::FromResidual",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.tuple [];
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.path "core::convert::Infallible";
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ]
                                                      ],
                                                      "from_residual",
                                                      []
                                                    |),
                                                    [ M.read (| residual |) ]
                                                  |)
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Continue",
                                              0
                                            |) in
                                          let val := M.copy (| γ0_0 |) in
                                          val))
                                    ]
                                  |)
                                |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "spl_type_length_value::variable_len_pack::VariableLenPack",
                      V,
                      [],
                      "pack_into_slice",
                      []
                    |),
                    [ M.read (| new_extension |); M.read (| data |) ]
                  |)
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_realloc_variable_len_extension :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "realloc_variable_len_extension"
        (realloc_variable_len_extension S).
    Definition realloc (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self; length ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let length := M.alloc (| length |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let tlv_data :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "spl_token_2022::extension::BaseStateWithExtensionsMut",
                        Self,
                        [ S ],
                        "get_tlv_data_mut",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |) in
                M.match_operator (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [
                              Ty.path "spl_token_2022::extension::TlvIndices";
                              Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::get_extension_indices",
                              [ V ]
                            |),
                            [ M.read (| tlv_data |); Value.Bool false ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "spl_token_2022::extension::TlvIndices",
                            "type_start"
                          |) in
                        let γ0_1 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "spl_token_2022::extension::TlvIndices",
                            "length_start"
                          |) in
                        let γ0_2 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "spl_token_2022::extension::TlvIndices",
                            "value_start"
                          |) in
                        let length_start := M.copy (| γ0_1 |) in
                        let value_start := M.copy (| γ0_2 |) in
                        let tlv_len :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.path "usize";
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "spl_token_2022::extension::TlvDataInfo";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        "map",
                                        [
                                          Ty.path "usize";
                                          Ty.function
                                            [
                                              Ty.tuple
                                                [ Ty.path "spl_token_2022::extension::TlvDataInfo" ]
                                            ]
                                            (Ty.path "usize")
                                        ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_function (|
                                            "spl_token_2022::extension::get_tlv_data_info",
                                            []
                                          |),
                                          [ M.read (| tlv_data |) ]
                                        |);
                                        M.closure
                                          (fun γ =>
                                            ltac:(M.monadic
                                              match γ with
                                              | [ α0 ] =>
                                                M.match_operator (|
                                                  M.alloc (| α0 |),
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let x := M.copy (| γ |) in
                                                        M.read (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            x,
                                                            "spl_token_2022::extension::TlvDataInfo",
                                                            "used_len"
                                                          |)
                                                        |)))
                                                  ]
                                                |)
                                              | _ => M.impossible (||)
                                              end))
                                      ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        let data_len :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                "len",
                                []
                              |),
                              [ M.read (| tlv_data |) ]
                            |)
                          |) in
                        let length_ref :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply
                                          (Ty.path "&mut")
                                          [ Ty.path "spl_token_2022::extension::Length" ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_function (|
                                        "spl_pod::bytemuck::pod_from_bytes_mut",
                                        [ Ty.path "spl_token_2022::extension::Length" ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::index::IndexMut",
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::ops::range::Range")
                                                [ Ty.path "usize" ]
                                            ],
                                            "index_mut",
                                            []
                                          |),
                                          [
                                            M.read (| tlv_data |);
                                            Value.StructRecord
                                              "core::ops::range::Range"
                                              [
                                                ("start", M.read (| length_start |));
                                                ("end_", M.read (| value_start |))
                                              ]
                                          ]
                                        |)
                                      ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        let old_length :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::convert::From",
                                Ty.path "usize",
                                [ Ty.path "spl_token_2022::extension::Length" ],
                                "from",
                                []
                              |),
                              [ M.read (| M.read (| length_ref |) |) ]
                            |)
                          |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.use
                                      (M.alloc (|
                                        BinOp.Pure.lt
                                          (M.read (| old_length |))
                                          (M.read (| length |))
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  let new_tlv_len :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "usize",
                                          "saturating_add",
                                          []
                                        |),
                                        [
                                          M.read (| tlv_len |);
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "usize",
                                              "saturating_sub",
                                              []
                                            |),
                                            [ M.read (| length |); M.read (| old_length |) ]
                                          |)
                                        ]
                                      |)
                                    |) in
                                  M.match_operator (|
                                    M.alloc (| Value.Tuple [] |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ :=
                                            M.use
                                              (M.alloc (|
                                                BinOp.Pure.gt
                                                  (M.read (| new_tlv_len |))
                                                  (M.read (| data_len |))
                                              |)) in
                                          let _ :=
                                            M.is_constant_or_break_match (|
                                              M.read (| γ |),
                                              Value.Bool true
                                            |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  Value.StructTuple
                                                    "core::result::Result::Err"
                                                    [
                                                      Value.StructTuple
                                                        "solana_program::program_error::ProgramError::InvalidAccountData"
                                                        []
                                                    ]
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        let _ :=
                          M.write (|
                            M.read (| length_ref |),
                            M.read (|
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::Try",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.path "spl_token_2022::extension::Length";
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::convert::TryFrom",
                                          Ty.path "spl_token_2022::extension::Length",
                                          [ Ty.path "usize" ],
                                          "try_from",
                                          []
                                        |),
                                        [ M.read (| length |) ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::ops::control_flow::ControlFlow::Break",
                                          0
                                        |) in
                                      let residual := M.copy (| γ0_0 |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::FromResidual",
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.apply
                                                        (Ty.path "&mut")
                                                        [
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            [ Ty.path "u8" ]
                                                        ];
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ],
                                                  [
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.path "core::convert::Infallible";
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ]
                                                  ],
                                                  "from_residual",
                                                  []
                                                |),
                                                [ M.read (| residual |) ]
                                              |)
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::ops::control_flow::ControlFlow::Continue",
                                          0
                                        |) in
                                      let val := M.copy (| γ0_0 |) in
                                      val))
                                ]
                              |)
                            |)
                          |) in
                        let old_value_end :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                              [ M.read (| value_start |); M.read (| old_length |) ]
                            |)
                          |) in
                        let new_value_end :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                              [ M.read (| value_start |); M.read (| length |) ]
                            |)
                          |) in
                        let _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                "copy_within",
                                [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ]
                              |),
                              [
                                M.read (| tlv_data |);
                                Value.StructRecord
                                  "core::ops::range::Range"
                                  [
                                    ("start", M.read (| old_value_end |));
                                    ("end_", M.read (| tlv_len |))
                                  ];
                                M.read (| new_value_end |)
                              ]
                            |)
                          |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::cmp::Ord",
                                  Ty.path "usize",
                                  [],
                                  "cmp",
                                  []
                                |),
                                [ old_length; length ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let new_tlv_len :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "usize",
                                          "saturating_sub",
                                          []
                                        |),
                                        [
                                          M.read (| tlv_len |);
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "usize",
                                              "saturating_sub",
                                              []
                                            |),
                                            [ M.read (| old_length |); M.read (| length |) ]
                                          |)
                                        ]
                                      |)
                                    |) in
                                  let _ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                          "fill",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::index::IndexMut",
                                              Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::ops::range::Range")
                                                  [ Ty.path "usize" ]
                                              ],
                                              "index_mut",
                                              []
                                            |),
                                            [
                                              M.read (| tlv_data |);
                                              Value.StructRecord
                                                "core::ops::range::Range"
                                                [
                                                  ("start", M.read (| new_tlv_len |));
                                                  ("end_", M.read (| tlv_len |))
                                                ]
                                            ]
                                          |);
                                          Value.Integer 0
                                        ]
                                      |)
                                    |) in
                                  M.alloc (| Value.Tuple [] |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                          "fill",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::index::IndexMut",
                                              Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::ops::range::Range")
                                                  [ Ty.path "usize" ]
                                              ],
                                              "index_mut",
                                              []
                                            |),
                                            [
                                              M.read (| tlv_data |);
                                              Value.StructRecord
                                                "core::ops::range::Range"
                                                [
                                                  ("start", M.read (| old_value_end |));
                                                  ("end_", M.read (| new_value_end |))
                                                ]
                                            ]
                                          |);
                                          Value.Integer 0
                                        ]
                                      |)
                                    |) in
                                  M.alloc (| Value.Tuple [] |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::index::IndexMut",
                                  Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                  [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]
                                  ],
                                  "index_mut",
                                  []
                                |),
                                [
                                  M.read (| tlv_data |);
                                  Value.StructRecord
                                    "core::ops::range::Range"
                                    [
                                      ("start", M.read (| value_start |));
                                      ("end_", M.read (| new_value_end |))
                                    ]
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_realloc :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "realloc"
        (realloc S).
    Definition init_variable_len_extension (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self; extension; overwrite ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let extension := M.alloc (| extension |) in
          let overwrite := M.alloc (| overwrite |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let data :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "&mut")
                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                Self,
                                [ S ],
                                "alloc",
                                [ V ]
                              |),
                              [
                                M.read (| self |);
                                M.read (|
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::Try",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "usize";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [],
                                          "branch",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "spl_type_length_value::variable_len_pack::VariableLenPack",
                                              V,
                                              [],
                                              "get_packed_len",
                                              []
                                            |),
                                            [ M.read (| extension |) ]
                                          |)
                                        ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Break",
                                              0
                                            |) in
                                          let residual := M.copy (| γ0_0 |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::FromResidual",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.tuple [];
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.path "core::convert::Infallible";
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ]
                                                      ],
                                                      "from_residual",
                                                      []
                                                    |),
                                                    [ M.read (| residual |) ]
                                                  |)
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Continue",
                                              0
                                            |) in
                                          let val := M.copy (| γ0_0 |) in
                                          val))
                                    ]
                                  |)
                                |);
                                M.read (| overwrite |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "spl_type_length_value::variable_len_pack::VariableLenPack",
                      V,
                      [],
                      "pack_into_slice",
                      []
                    |),
                    [ M.read (| extension |); M.read (| data |) ]
                  |)
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_init_variable_len_extension :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "init_variable_len_extension"
        (init_variable_len_extension S).
    Definition alloc (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ V ], [ self; length; overwrite ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let length := M.alloc (| length |) in
          let overwrite := M.alloc (| overwrite |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::cmp::PartialEq",
                                    Ty.path "spl_token_2022::extension::AccountType",
                                    [ Ty.path "spl_token_2022::extension::AccountType" ],
                                    "ne",
                                    []
                                  |),
                                  [
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "spl_token_2022::extension::ExtensionType",
                                          "get_account_type",
                                          []
                                        |),
                                        [
                                          M.get_constant (|
                                            "spl_token_2022::extension::Extension::TYPE"
                                          |)
                                        ]
                                      |)
                                    |);
                                    M.get_constant (|
                                      "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                    |)
                                  ]
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  Value.StructTuple
                                    "core::result::Result::Err"
                                    [
                                      Value.StructTuple
                                        "solana_program::program_error::ProgramError::InvalidAccountData"
                                        []
                                    ]
                                |)
                              |)
                            |)
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                let tlv_data :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "spl_token_2022::extension::BaseStateWithExtensionsMut",
                        Self,
                        [ S ],
                        "get_tlv_data_mut",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |) in
                M.match_operator (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [
                              Ty.path "spl_token_2022::extension::TlvIndices";
                              Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::get_extension_indices",
                              [ V ]
                            |),
                            [ M.read (| tlv_data |); Value.Bool true ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "spl_token_2022::extension::TlvIndices",
                            "type_start"
                          |) in
                        let γ0_1 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "spl_token_2022::extension::TlvIndices",
                            "length_start"
                          |) in
                        let γ0_2 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "spl_token_2022::extension::TlvIndices",
                            "value_start"
                          |) in
                        let type_start := M.copy (| γ0_0 |) in
                        let length_start := M.copy (| γ0_1 |) in
                        let value_start := M.copy (| γ0_2 |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.use
                                      (M.alloc (|
                                        BinOp.Pure.lt
                                          (M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                              "len",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::index::Index",
                                                  Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                  [
                                                    Ty.apply
                                                      (Ty.path "core::ops::range::RangeFrom")
                                                      [ Ty.path "usize" ]
                                                  ],
                                                  "index",
                                                  []
                                                |),
                                                [
                                                  M.read (| tlv_data |);
                                                  Value.StructRecord
                                                    "core::ops::range::RangeFrom"
                                                    [ ("start", M.read (| type_start |)) ]
                                                ]
                                              |)
                                            ]
                                          |))
                                          (M.call_closure (|
                                            M.get_function (|
                                              "spl_token_2022::extension::add_type_and_length_to_len",
                                              []
                                            |),
                                            [ M.read (| length |) ]
                                          |))
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          Value.StructTuple
                                            "core::result::Result::Err"
                                            [
                                              Value.StructTuple
                                                "solana_program::program_error::ProgramError::InvalidAccountData"
                                                []
                                            ]
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        let extension_type :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.path "spl_token_2022::extension::ExtensionType";
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::convert::TryFrom",
                                        Ty.path "spl_token_2022::extension::ExtensionType",
                                        [
                                          Ty.apply
                                            (Ty.path "&")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                        ],
                                        "try_from",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::index::Index",
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::ops::range::Range")
                                                [ Ty.path "usize" ]
                                            ],
                                            "index",
                                            []
                                          |),
                                          [
                                            M.read (| tlv_data |);
                                            Value.StructRecord
                                              "core::ops::range::Range"
                                              [
                                                ("start", M.read (| type_start |));
                                                ("end_", M.read (| length_start |))
                                              ]
                                          ]
                                        |)
                                      ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      LogicalOp.or (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::cmp::PartialEq",
                                            Ty.path "spl_token_2022::extension::ExtensionType",
                                            [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                                            "eq",
                                            []
                                          |),
                                          [
                                            extension_type;
                                            M.alloc (|
                                              Value.StructTuple
                                                "spl_token_2022::extension::ExtensionType::Uninitialized"
                                                []
                                            |)
                                          ]
                                        |),
                                        ltac:(M.monadic (M.read (| overwrite |)))
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                let extension_type_array :=
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::convert::Into",
                                        Ty.path "spl_token_2022::extension::ExtensionType",
                                        [ Ty.apply (Ty.path "array") [ Ty.path "u8" ] ],
                                        "into",
                                        []
                                      |),
                                      [
                                        M.read (|
                                          M.get_constant (|
                                            "spl_token_2022::extension::Extension::TYPE"
                                          |)
                                        |)
                                      ]
                                    |)
                                  |) in
                                let extension_type_ref :=
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::index::IndexMut",
                                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::ops::range::Range")
                                            [ Ty.path "usize" ]
                                        ],
                                        "index_mut",
                                        []
                                      |),
                                      [
                                        M.read (| tlv_data |);
                                        Value.StructRecord
                                          "core::ops::range::Range"
                                          [
                                            ("start", M.read (| type_start |));
                                            ("end_", M.read (| length_start |))
                                          ]
                                      ]
                                    |)
                                  |) in
                                let _ :=
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                        "copy_from_slice",
                                        []
                                      |),
                                      [
                                        M.read (| extension_type_ref |);
                                        (* Unsize *) M.pointer_coercion extension_type_array
                                      ]
                                    |)
                                  |) in
                                let length_ref :=
                                  M.copy (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.apply
                                                  (Ty.path "&mut")
                                                  [ Ty.path "spl_token_2022::extension::Length" ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_function (|
                                                "spl_pod::bytemuck::pod_from_bytes_mut",
                                                [ Ty.path "spl_token_2022::extension::Length" ]
                                              |),
                                              [
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::index::IndexMut",
                                                    Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                                    [
                                                      Ty.apply
                                                        (Ty.path "core::ops::range::Range")
                                                        [ Ty.path "usize" ]
                                                    ],
                                                    "index_mut",
                                                    []
                                                  |),
                                                  [
                                                    M.read (| tlv_data |);
                                                    Value.StructRecord
                                                      "core::ops::range::Range"
                                                      [
                                                        ("start", M.read (| length_start |));
                                                        ("end_", M.read (| value_start |))
                                                      ]
                                                  ]
                                                |)
                                              ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.apply
                                                              (Ty.path "&mut")
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "slice")
                                                                  [ Ty.path "u8" ]
                                                              ];
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            [
                                                              Ty.path "core::convert::Infallible";
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ]
                                                        ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |) in
                                let _ :=
                                  M.match_operator (|
                                    M.alloc (| Value.Tuple [] |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ :=
                                            M.use
                                              (M.alloc (|
                                                LogicalOp.and (|
                                                  LogicalOp.and (|
                                                    M.read (| overwrite |),
                                                    ltac:(M.monadic
                                                      (M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::cmp::PartialEq",
                                                          Ty.path
                                                            "spl_token_2022::extension::ExtensionType",
                                                          [
                                                            Ty.path
                                                              "spl_token_2022::extension::ExtensionType"
                                                          ],
                                                          "eq",
                                                          []
                                                        |),
                                                        [
                                                          extension_type;
                                                          M.get_constant (|
                                                            "spl_token_2022::extension::Extension::TYPE"
                                                          |)
                                                        ]
                                                      |)))
                                                  |),
                                                  ltac:(M.monadic
                                                    (BinOp.Pure.ne
                                                      (M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::convert::From",
                                                          Ty.path "usize",
                                                          [
                                                            Ty.path
                                                              "spl_token_2022::extension::Length"
                                                          ],
                                                          "from",
                                                          []
                                                        |),
                                                        [ M.read (| M.read (| length_ref |) |) ]
                                                      |))
                                                      (M.read (| length |))))
                                                |)
                                              |)) in
                                          let _ :=
                                            M.is_constant_or_break_match (|
                                              M.read (| γ |),
                                              Value.Bool true
                                            |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  Value.StructTuple
                                                    "core::result::Result::Err"
                                                    [
                                                      M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::convert::Into",
                                                          Ty.path
                                                            "spl_token_2022::error::TokenError",
                                                          [
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ],
                                                          "into",
                                                          []
                                                        |),
                                                        [
                                                          Value.StructTuple
                                                            "spl_token_2022::error::TokenError::InvalidLengthForAlloc"
                                                            []
                                                        ]
                                                      |)
                                                    ]
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |) in
                                let _ :=
                                  M.write (|
                                    M.read (| length_ref |),
                                    M.read (|
                                      M.match_operator (|
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::Try",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "spl_token_2022::extension::Length";
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::convert::TryFrom",
                                                  Ty.path "spl_token_2022::extension::Length",
                                                  [ Ty.path "usize" ],
                                                  "try_from",
                                                  []
                                                |),
                                                [ M.read (| length |) ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ0_0 :=
                                                M.SubPointer.get_struct_tuple_field (|
                                                  γ,
                                                  "core::ops::control_flow::ControlFlow::Break",
                                                  0
                                                |) in
                                              let residual := M.copy (| γ0_0 |) in
                                              M.alloc (|
                                                M.never_to_any (|
                                                  M.read (|
                                                    M.return_ (|
                                                      M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::ops::try_trait::FromResidual",
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            [
                                                              Ty.apply
                                                                (Ty.path "&mut")
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "slice")
                                                                    [ Ty.path "u8" ]
                                                                ];
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ],
                                                          [
                                                            Ty.apply
                                                              (Ty.path "core::result::Result")
                                                              [
                                                                Ty.path "core::convert::Infallible";
                                                                Ty.path
                                                                  "solana_program::program_error::ProgramError"
                                                              ]
                                                          ],
                                                          "from_residual",
                                                          []
                                                        |),
                                                        [ M.read (| residual |) ]
                                                      |)
                                                    |)
                                                  |)
                                                |)
                                              |)));
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ0_0 :=
                                                M.SubPointer.get_struct_tuple_field (|
                                                  γ,
                                                  "core::ops::control_flow::ControlFlow::Continue",
                                                  0
                                                |) in
                                              let val := M.copy (| γ0_0 |) in
                                              val))
                                        ]
                                      |)
                                    |)
                                  |) in
                                let value_end :=
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.path "usize",
                                        "saturating_add",
                                        []
                                      |),
                                      [ M.read (| value_start |); M.read (| length |) ]
                                    |)
                                  |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Ok"
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::index::IndexMut",
                                          Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::ops::range::Range")
                                              [ Ty.path "usize" ]
                                          ],
                                          "index_mut",
                                          []
                                        |),
                                        [
                                          M.read (| tlv_data |);
                                          Value.StructRecord
                                            "core::ops::range::Range"
                                            [
                                              ("start", M.read (| value_start |));
                                              ("end_", M.read (| value_end |))
                                            ]
                                        ]
                                      |)
                                    ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Err"
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::convert::Into",
                                          Ty.path "spl_token_2022::error::TokenError",
                                          [ Ty.path "solana_program::program_error::ProgramError" ],
                                          "into",
                                          []
                                        |),
                                        [
                                          Value.StructTuple
                                            "spl_token_2022::error::TokenError::ExtensionAlreadyInitialized"
                                            []
                                        ]
                                      |)
                                    ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_alloc :
      forall (S : Ty.t),
      M.IsProvidedMethod "spl_token_2022::extension::BaseStateWithExtensionsMut" "alloc" (alloc S).
    Definition init_account_extension_from_type
        (S Self : Ty.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      match τ, α with
      | [], [ self; extension_type ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let extension_type := M.alloc (| extension_type |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::cmp::PartialEq",
                                    Ty.path "spl_token_2022::extension::AccountType",
                                    [ Ty.path "spl_token_2022::extension::AccountType" ],
                                    "ne",
                                    []
                                  |),
                                  [
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "spl_token_2022::extension::ExtensionType",
                                          "get_account_type",
                                          []
                                        |),
                                        [ extension_type ]
                                      |)
                                    |);
                                    M.alloc (|
                                      Value.StructTuple
                                        "spl_token_2022::extension::AccountType::Account"
                                        []
                                    |)
                                  ]
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                                |)
                              |)
                            |)
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                M.match_operator (|
                  extension_type,
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    [
                                      Ty.path
                                        "spl_token_2022::extension::transfer_fee::TransferFeeAmount"
                                    ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              "map",
                              [
                                Ty.tuple [];
                                Ty.function
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply
                                          (Ty.path "&mut")
                                          [
                                            Ty.path
                                              "spl_token_2022::extension::transfer_fee::TransferFeeAmount"
                                          ]
                                      ]
                                  ]
                                  (Ty.tuple [])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                  Self,
                                  [ S ],
                                  "init_extension",
                                  [
                                    Ty.path
                                      "spl_token_2022::extension::transfer_fee::TransferFeeAmount"
                                  ]
                                |),
                                [ M.read (| self |); Value.Bool true ]
                              |);
                              M.closure
                                (fun γ =>
                                  ltac:(M.monadic
                                    match γ with
                                    | [ α0 ] =>
                                      M.match_operator (|
                                        M.alloc (| α0 |),
                                        [ fun γ => ltac:(M.monadic (Value.Tuple [])) ]
                                      |)
                                    | _ => M.impossible (||)
                                    end))
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    [
                                      Ty.path
                                        "spl_token_2022::extension::immutable_owner::ImmutableOwner"
                                    ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              "map",
                              [
                                Ty.tuple [];
                                Ty.function
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply
                                          (Ty.path "&mut")
                                          [
                                            Ty.path
                                              "spl_token_2022::extension::immutable_owner::ImmutableOwner"
                                          ]
                                      ]
                                  ]
                                  (Ty.tuple [])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                  Self,
                                  [ S ],
                                  "init_extension",
                                  [
                                    Ty.path
                                      "spl_token_2022::extension::immutable_owner::ImmutableOwner"
                                  ]
                                |),
                                [ M.read (| self |); Value.Bool true ]
                              |);
                              M.closure
                                (fun γ =>
                                  ltac:(M.monadic
                                    match γ with
                                    | [ α0 ] =>
                                      M.match_operator (|
                                        M.alloc (| α0 |),
                                        [ fun γ => ltac:(M.monadic (Value.Tuple [])) ]
                                      |)
                                    | _ => M.impossible (||)
                                    end))
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    [
                                      Ty.path
                                        "spl_token_2022::extension::non_transferable::NonTransferableAccount"
                                    ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              "map",
                              [
                                Ty.tuple [];
                                Ty.function
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply
                                          (Ty.path "&mut")
                                          [
                                            Ty.path
                                              "spl_token_2022::extension::non_transferable::NonTransferableAccount"
                                          ]
                                      ]
                                  ]
                                  (Ty.tuple [])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                  Self,
                                  [ S ],
                                  "init_extension",
                                  [
                                    Ty.path
                                      "spl_token_2022::extension::non_transferable::NonTransferableAccount"
                                  ]
                                |),
                                [ M.read (| self |); Value.Bool true ]
                              |);
                              M.closure
                                (fun γ =>
                                  ltac:(M.monadic
                                    match γ with
                                    | [ α0 ] =>
                                      M.match_operator (|
                                        M.alloc (| α0 |),
                                        [ fun γ => ltac:(M.monadic (Value.Tuple [])) ]
                                      |)
                                    | _ => M.impossible (||)
                                    end))
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    [
                                      Ty.path
                                        "spl_token_2022::extension::transfer_hook::TransferHookAccount"
                                    ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              "map",
                              [
                                Ty.tuple [];
                                Ty.function
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply
                                          (Ty.path "&mut")
                                          [
                                            Ty.path
                                              "spl_token_2022::extension::transfer_hook::TransferHookAccount"
                                          ]
                                      ]
                                  ]
                                  (Ty.tuple [])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                  Self,
                                  [ S ],
                                  "init_extension",
                                  [
                                    Ty.path
                                      "spl_token_2022::extension::transfer_hook::TransferHookAccount"
                                  ]
                                |),
                                [ M.read (| self |); Value.Bool true ]
                              |);
                              M.closure
                                (fun γ =>
                                  ltac:(M.monadic
                                    match γ with
                                    | [ α0 ] =>
                                      M.match_operator (|
                                        M.alloc (| α0 |),
                                        [ fun γ => ltac:(M.monadic (Value.Tuple [])) ]
                                      |)
                                    | _ => M.impossible (||)
                                    end))
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.never_to_any (|
                            M.call_closure (|
                              M.get_function (| "core::panicking::panic", [] |),
                              [ M.read (| Value.String "internal error: entered unreachable code" |)
                              ]
                            |)
                          |)
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_init_account_extension_from_type :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "init_account_extension_from_type"
        (init_account_extension_from_type S).
    Definition init_account_type (S Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let first_extension_type :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  [ Ty.path "spl_token_2022::extension::ExtensionType" ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensions",
                                Self,
                                [ S ],
                                "get_first_extension_type",
                                []
                              |),
                              [ M.read (| self |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                let account_type :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "spl_token_2022::extension::BaseStateWithExtensionsMut",
                        Self,
                        [ S ],
                        "get_account_type_mut",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |) in
                let _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                UnOp.Pure.not
                                  (M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                      "is_empty",
                                      []
                                    |),
                                    [ M.read (| account_type |) ]
                                  |))
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          let _ :=
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ := first_extension_type in
                                    let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::option::Option::Some",
                                        0
                                      |) in
                                    let extension_type := M.copy (| γ0_0 |) in
                                    let account_type :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "spl_token_2022::extension::ExtensionType",
                                            "get_account_type",
                                            []
                                          |),
                                          [ extension_type ]
                                        |)
                                      |) in
                                    M.match_operator (|
                                      M.alloc (| Value.Tuple [] |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ :=
                                              M.use
                                                (M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::cmp::PartialEq",
                                                      Ty.path
                                                        "spl_token_2022::extension::AccountType",
                                                      [
                                                        Ty.path
                                                          "spl_token_2022::extension::AccountType"
                                                      ],
                                                      "ne",
                                                      []
                                                    |),
                                                    [
                                                      account_type;
                                                      M.get_constant (|
                                                        "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                                      |)
                                                    ]
                                                  |)
                                                |)) in
                                            let _ :=
                                              M.is_constant_or_break_match (|
                                                M.read (| γ |),
                                                Value.Bool true
                                              |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    Value.StructTuple
                                                      "core::result::Result::Err"
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::convert::Into",
                                                            Ty.path
                                                              "spl_token_2022::error::TokenError",
                                                            [
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ],
                                                            "into",
                                                            []
                                                          |),
                                                          [
                                                            Value.StructTuple
                                                              "spl_token_2022::error::TokenError::ExtensionBaseMismatch"
                                                              []
                                                          ]
                                                        |)
                                                      ]
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                      ]
                                    |)));
                                fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                              ]
                            |) in
                          let _ :=
                            M.write (|
                              M.SubPointer.get_array_field (|
                                M.read (| account_type |),
                                M.alloc (| Value.Integer 0 |)
                              |),
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::convert::Into",
                                  Ty.path "spl_token_2022::extension::AccountType",
                                  [ Ty.path "u8" ],
                                  "into",
                                  []
                                |),
                                [
                                  M.read (|
                                    M.get_constant (|
                                      "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                    |)
                                  |)
                                ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_init_account_type :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "init_account_type"
        (init_account_type S).
    Definition check_account_type_matches_extension_type
        (S Self : Ty.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply
                                          (Ty.path "core::option::Option")
                                          [ Ty.path "spl_token_2022::extension::ExtensionType" ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "spl_token_2022::extension::BaseStateWithExtensions",
                                        Self,
                                        [ S ],
                                        "get_first_extension_type",
                                        []
                                      |),
                                      [ M.read (| self |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.tuple [];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |) in
                          let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let extension_type := M.copy (| γ0_0 |) in
                          let account_type :=
                            M.alloc (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.path "spl_token_2022::extension::ExtensionType",
                                  "get_account_type",
                                  []
                                |),
                                [ extension_type ]
                              |)
                            |) in
                          M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.use
                                      (M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::cmp::PartialEq",
                                            Ty.path "spl_token_2022::extension::AccountType",
                                            [ Ty.path "spl_token_2022::extension::AccountType" ],
                                            "ne",
                                            []
                                          |),
                                          [
                                            account_type;
                                            M.get_constant (|
                                              "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                            |)
                                          ]
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          Value.StructTuple
                                            "core::result::Result::Err"
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::convert::Into",
                                                  Ty.path "spl_token_2022::error::TokenError",
                                                  [
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                  "into",
                                                  []
                                                |),
                                                [
                                                  Value.StructTuple
                                                    "spl_token_2022::error::TokenError::ExtensionBaseMismatch"
                                                    []
                                                ]
                                              |)
                                            ]
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom ProvidedMethod_check_account_type_matches_extension_type :
      forall (S : Ty.t),
      M.IsProvidedMethod
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        "check_account_type_matches_extension_type"
        (check_account_type_matches_extension_type S).
  End BaseStateWithExtensionsMut.
  
  (* StructRecord
    {
      name := "StateWithExtensionsMut";
      ty_params := [ "S" ];
      fields :=
        [
          ("base", S);
          ("base_data", Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]);
          ("account_type",
            Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]);
          ("tlv_data", Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ])
        ];
    } *)
  
  Module Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsMut") [ S ].
    
    (* Debug *)
    Definition fmt (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_struct_field4_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "StateWithExtensionsMut" |);
              M.read (| Value.String "base" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::StateWithExtensionsMut",
                  "base"
                |));
              M.read (| Value.String "base_data" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::StateWithExtensionsMut",
                  "base_data"
                |));
              M.read (| Value.String "account_type" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::StateWithExtensionsMut",
                  "account_type"
                |));
              M.read (| Value.String "tlv_data" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::StateWithExtensionsMut",
                    "tlv_data"
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::fmt::Debug"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method (fmt S)) ].
  End Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
  
  Module Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsMut") [ S ].
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
  
  Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsMut") [ S ].
    
    (* PartialEq *)
    Definition eq (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          LogicalOp.and (|
            LogicalOp.and (|
              LogicalOp.and (|
                M.call_closure (|
                  M.get_trait_method (| "core::cmp::PartialEq", S, [ S ], "eq", [] |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::StateWithExtensionsMut",
                      "base"
                    |);
                    M.SubPointer.get_struct_record_field (|
                      M.read (| other |),
                      "spl_token_2022::extension::StateWithExtensionsMut",
                      "base"
                    |)
                  ]
                |),
                ltac:(M.monadic
                  (M.call_closure (|
                    M.get_trait_method (|
                      "core::cmp::PartialEq",
                      Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                      [ Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ],
                      "eq",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::StateWithExtensionsMut",
                        "base_data"
                      |);
                      M.SubPointer.get_struct_record_field (|
                        M.read (| other |),
                        "spl_token_2022::extension::StateWithExtensionsMut",
                        "base_data"
                      |)
                    ]
                  |)))
              |),
              ltac:(M.monadic
                (M.call_closure (|
                  M.get_trait_method (|
                    "core::cmp::PartialEq",
                    Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                    [ Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ],
                    "eq",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::StateWithExtensionsMut",
                      "account_type"
                    |);
                    M.SubPointer.get_struct_record_field (|
                      M.read (| other |),
                      "spl_token_2022::extension::StateWithExtensionsMut",
                      "account_type"
                    |)
                  ]
                |)))
            |),
            ltac:(M.monadic
              (M.call_closure (|
                M.get_trait_method (|
                  "core::cmp::PartialEq",
                  Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                  [ Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ],
                  "eq",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::StateWithExtensionsMut",
                    "tlv_data"
                  |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| other |),
                    "spl_token_2022::extension::StateWithExtensionsMut",
                    "tlv_data"
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::cmp::PartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method (eq S)) ].
  End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
  
  Module Impl_spl_token_2022_extension_StateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsMut") [ S ].
    
    (*
        pub fn unpack(input: &'data mut [u8]) -> Result<Self, ProgramError> {
            check_min_len_and_not_multisig(input, S::SIZE_OF)?;
            let (base_data, rest) = input.split_at_mut(S::SIZE_OF);
            let base = S::unpack(base_data)?;
            let (account_type, tlv_data) = unpack_type_and_tlv_data_mut::<S>(rest)?;
            Ok(Self {
                base,
                base_data,
                account_type,
                tlv_data,
            })
        }
    *)
    Definition unpack (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ input ] =>
        ltac:(M.monadic
          (let input := M.alloc (| input |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::check_min_len_and_not_multisig",
                              []
                            |),
                            [
                              M.read (| input |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "spl_token_2022::extension::StateWithExtensionsMut")
                                            [ S ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |) in
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                        "split_at_mut",
                        []
                      |),
                      [
                        M.read (| input |);
                        M.read (|
                          M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                        let base_data := M.copy (| γ0_0 |) in
                        let rest := M.copy (| γ0_1 |) in
                        let base :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [ S; Ty.path "solana_program::program_error::ProgramError" ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "solana_program::program_pack::Pack",
                                        S,
                                        [],
                                        "unpack",
                                        []
                                      |),
                                      [ M.read (| base_data |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::StateWithExtensionsMut")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        M.match_operator (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.tuple
                                        [
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                        ];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_token_2022::extension::unpack_type_and_tlv_data_mut",
                                      [ S ]
                                    |),
                                    [ M.read (| rest |) ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "spl_token_2022::extension::StateWithExtensionsMut")
                                                    [ S ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                let account_type := M.copy (| γ0_0 |) in
                                let tlv_data := M.copy (| γ0_1 |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Ok"
                                    [
                                      Value.StructRecord
                                        "spl_token_2022::extension::StateWithExtensionsMut"
                                        [
                                          ("base", M.read (| base |));
                                          ("base_data", M.read (| base_data |));
                                          ("account_type", M.read (| account_type |));
                                          ("tlv_data", M.read (| tlv_data |))
                                        ]
                                    ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_unpack :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "unpack" (unpack S).
    
    (*
        pub fn unpack_uninitialized(input: &'data mut [u8]) -> Result<Self, ProgramError> {
            check_min_len_and_not_multisig(input, S::SIZE_OF)?;
            let (base_data, rest) = input.split_at_mut(S::SIZE_OF);
            let base = S::unpack_unchecked(base_data)?;
            if base.is_initialized() {
                return Err(TokenError::AlreadyInUse.into());
            }
            let (account_type, tlv_data) = unpack_uninitialized_type_and_tlv_data_mut::<S>(rest)?;
            let state = Self {
                base,
                base_data,
                account_type,
                tlv_data,
            };
            state.check_account_type_matches_extension_type()?;
            Ok(state)
        }
    *)
    Definition unpack_uninitialized (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ input ] =>
        ltac:(M.monadic
          (let input := M.alloc (| input |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::check_min_len_and_not_multisig",
                              []
                            |),
                            [
                              M.read (| input |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "spl_token_2022::extension::StateWithExtensionsMut")
                                            [ S ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |) in
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                        "split_at_mut",
                        []
                      |),
                      [
                        M.read (| input |);
                        M.read (|
                          M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                        let base_data := M.copy (| γ0_0 |) in
                        let rest := M.copy (| γ0_1 |) in
                        let base :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [ S; Ty.path "solana_program::program_error::ProgramError" ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "solana_program::program_pack::Pack",
                                        S,
                                        [],
                                        "unpack_unchecked",
                                        []
                                      |),
                                      [ M.read (| base_data |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::StateWithExtensionsMut")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.use
                                      (M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "solana_program::program_pack::IsInitialized",
                                            S,
                                            [],
                                            "is_initialized",
                                            []
                                          |),
                                          [ base ]
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          Value.StructTuple
                                            "core::result::Result::Err"
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::convert::Into",
                                                  Ty.path "spl_token_2022::error::TokenError",
                                                  [
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                  "into",
                                                  []
                                                |),
                                                [
                                                  Value.StructTuple
                                                    "spl_token_2022::error::TokenError::AlreadyInUse"
                                                    []
                                                ]
                                              |)
                                            ]
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        M.match_operator (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.tuple
                                        [
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                        ];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_token_2022::extension::unpack_uninitialized_type_and_tlv_data_mut",
                                      [ S ]
                                    |),
                                    [ M.read (| rest |) ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "spl_token_2022::extension::StateWithExtensionsMut")
                                                    [ S ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                let account_type := M.copy (| γ0_0 |) in
                                let tlv_data := M.copy (| γ0_1 |) in
                                let state :=
                                  M.alloc (|
                                    Value.StructRecord
                                      "spl_token_2022::extension::StateWithExtensionsMut"
                                      [
                                        ("base", M.read (| base |));
                                        ("base_data", M.read (| base_data |));
                                        ("account_type", M.read (| account_type |));
                                        ("tlv_data", M.read (| tlv_data |))
                                      ]
                                  |) in
                                let _ :=
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::Try",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [],
                                          "branch",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                              Ty.apply
                                                (Ty.path
                                                  "spl_token_2022::extension::StateWithExtensionsMut")
                                                [ S ],
                                              [ S ],
                                              "check_account_type_matches_extension_type",
                                              []
                                            |),
                                            [ state ]
                                          |)
                                        ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Break",
                                              0
                                            |) in
                                          let residual := M.copy (| γ0_0 |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::FromResidual",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.apply
                                                            (Ty.path
                                                              "spl_token_2022::extension::StateWithExtensionsMut")
                                                            [ S ];
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.path "core::convert::Infallible";
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ]
                                                      ],
                                                      "from_residual",
                                                      []
                                                    |),
                                                    [ M.read (| residual |) ]
                                                  |)
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Continue",
                                              0
                                            |) in
                                          let val := M.copy (| γ0_0 |) in
                                          val))
                                    ]
                                  |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Ok"
                                    [ M.read (| state |) ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_unpack_uninitialized :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "unpack_uninitialized" (unpack_uninitialized S).
    
    (*
        pub fn pack_base(&mut self) {
            S::pack_into_slice(&self.base, self.base_data);
        }
    *)
    Definition pack_base (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            let _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_trait_method (|
                    "solana_program::program_pack::Pack",
                    S,
                    [],
                    "pack_into_slice",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::StateWithExtensionsMut",
                      "base"
                    |);
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::StateWithExtensionsMut",
                        "base_data"
                      |)
                    |)
                  ]
                |)
              |) in
            M.alloc (| Value.Tuple [] |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_pack_base :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "pack_base" (pack_base S).
  End Impl_spl_token_2022_extension_StateWithExtensionsMut_S.
  
  Module Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsMut") [ S ].
    
    (*
        fn get_tlv_data(&self) -> &[u8] {
            self.tlv_data
        }
    *)
    Definition get_tlv_data (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::StateWithExtensionsMut",
              "tlv_data"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "spl_token_2022::extension::BaseStateWithExtensions"
        (Self S)
        (* Trait polymorphic types *) [ (* S *) S ]
        (* Instance *) [ ("get_tlv_data", InstanceField.Method (get_tlv_data S)) ].
  End Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
  
  Module Impl_spl_token_2022_extension_BaseStateWithExtensionsMut_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::StateWithExtensionsMut") [ S ].
    
    (*
        fn get_tlv_data_mut(&mut self) -> &mut [u8] {
            self.tlv_data
        }
    *)
    Definition get_tlv_data_mut (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::StateWithExtensionsMut",
              "tlv_data"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    (*
        fn get_account_type_mut(&mut self) -> &mut [u8] {
            self.account_type
        }
    *)
    Definition get_account_type_mut (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::StateWithExtensionsMut",
              "account_type"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        (Self S)
        (* Trait polymorphic types *) [ (* S *) S ]
        (* Instance *)
        [
          ("get_tlv_data_mut", InstanceField.Method (get_tlv_data_mut S));
          ("get_account_type_mut", InstanceField.Method (get_account_type_mut S))
        ].
  End Impl_spl_token_2022_extension_BaseStateWithExtensionsMut_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_StateWithExtensionsMut_S.
  
  (* StructRecord
    {
      name := "PodStateWithExtensionsMut";
      ty_params := [ "S" ];
      fields :=
        [
          ("base", Ty.apply (Ty.path "&mut") [ S ]);
          ("account_type",
            Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]);
          ("tlv_data", Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ])
        ];
    } *)
  
  Module Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut") [ S ].
    
    (* Debug *)
    Definition fmt (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "core::fmt::Formatter",
              "debug_struct_field3_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "PodStateWithExtensionsMut" |);
              M.read (| Value.String "base" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::PodStateWithExtensionsMut",
                  "base"
                |));
              M.read (| Value.String "account_type" |);
              (* Unsize *)
              M.pointer_coercion
                (M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::PodStateWithExtensionsMut",
                  "account_type"
                |));
              M.read (| Value.String "tlv_data" |);
              (* Unsize *)
              M.pointer_coercion
                (M.alloc (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::PodStateWithExtensionsMut",
                    "tlv_data"
                  |)
                |))
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::fmt::Debug"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method (fmt S)) ].
  End Impl_core_fmt_Debug_where_core_fmt_Debug_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
  
  Module Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut") [ S ].
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
  
  Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut") [ S ].
    
    (* PartialEq *)
    Definition eq (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          LogicalOp.and (|
            LogicalOp.and (|
              M.call_closure (|
                M.get_trait_method (|
                  "core::cmp::PartialEq",
                  Ty.apply (Ty.path "&mut") [ S ],
                  [ Ty.apply (Ty.path "&mut") [ S ] ],
                  "eq",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::PodStateWithExtensionsMut",
                    "base"
                  |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| other |),
                    "spl_token_2022::extension::PodStateWithExtensionsMut",
                    "base"
                  |)
                ]
              |),
              ltac:(M.monadic
                (M.call_closure (|
                  M.get_trait_method (|
                    "core::cmp::PartialEq",
                    Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                    [ Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ],
                    "eq",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::PodStateWithExtensionsMut",
                      "account_type"
                    |);
                    M.SubPointer.get_struct_record_field (|
                      M.read (| other |),
                      "spl_token_2022::extension::PodStateWithExtensionsMut",
                      "account_type"
                    |)
                  ]
                |)))
            |),
            ltac:(M.monadic
              (M.call_closure (|
                M.get_trait_method (|
                  "core::cmp::PartialEq",
                  Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                  [ Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ],
                  "eq",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::PodStateWithExtensionsMut",
                    "tlv_data"
                  |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| other |),
                    "spl_token_2022::extension::PodStateWithExtensionsMut",
                    "tlv_data"
                  |)
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "core::cmp::PartialEq"
        (Self S)
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method (eq S)) ].
  End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_S_where_spl_token_2022_extension_BaseState_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
  
  Module Impl_spl_token_2022_extension_PodStateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut") [ S ].
    
    (*
        pub fn unpack(input: &'data mut [u8]) -> Result<Self, ProgramError> {
            check_min_len_and_not_multisig(input, S::SIZE_OF)?;
            let (base_data, rest) = input.split_at_mut(S::SIZE_OF);
            let base = pod_from_bytes_mut::<S>(base_data)?;
            if !base.is_initialized() {
                Err(ProgramError::UninitializedAccount)
            } else {
                let (account_type, tlv_data) = unpack_type_and_tlv_data_mut::<S>(rest)?;
                Ok(Self {
                    base,
                    account_type,
                    tlv_data,
                })
            }
        }
    *)
    Definition unpack (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ input ] =>
        ltac:(M.monadic
          (let input := M.alloc (| input |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::check_min_len_and_not_multisig",
                              []
                            |),
                            [
                              M.read (| input |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "spl_token_2022::extension::PodStateWithExtensionsMut")
                                            [ S ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |) in
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                        "split_at_mut",
                        []
                      |),
                      [
                        M.read (| input |);
                        M.read (|
                          M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                        let base_data := M.copy (| γ0_0 |) in
                        let rest := M.copy (| γ0_1 |) in
                        let base :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply (Ty.path "&mut") [ S ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_function (|
                                        "spl_pod::bytemuck::pod_from_bytes_mut",
                                        [ S ]
                                      |),
                                      [ M.read (| base_data |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      UnOp.Pure.not
                                        (M.call_closure (|
                                          M.get_trait_method (|
                                            "solana_program::program_pack::IsInitialized",
                                            S,
                                            [],
                                            "is_initialized",
                                            []
                                          |),
                                          [ M.read (| base |) ]
                                        |))
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Err"
                                    [
                                      Value.StructTuple
                                        "solana_program::program_error::ProgramError::UninitializedAccount"
                                        []
                                    ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::Try",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple
                                                [
                                                  Ty.apply
                                                    (Ty.path "&mut")
                                                    [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                                  Ty.apply
                                                    (Ty.path "&mut")
                                                    [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                                ];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [],
                                          "branch",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_function (|
                                              "spl_token_2022::extension::unpack_type_and_tlv_data_mut",
                                              [ S ]
                                            |),
                                            [ M.read (| rest |) ]
                                          |)
                                        ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Break",
                                              0
                                            |) in
                                          let residual := M.copy (| γ0_0 |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::FromResidual",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.apply
                                                            (Ty.path
                                                              "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                            [ S ];
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.path "core::convert::Infallible";
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ]
                                                      ],
                                                      "from_residual",
                                                      []
                                                    |),
                                                    [ M.read (| residual |) ]
                                                  |)
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Continue",
                                              0
                                            |) in
                                          let val := M.copy (| γ0_0 |) in
                                          val))
                                    ]
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                        let account_type := M.copy (| γ0_0 |) in
                                        let tlv_data := M.copy (| γ0_1 |) in
                                        M.alloc (|
                                          Value.StructTuple
                                            "core::result::Result::Ok"
                                            [
                                              Value.StructRecord
                                                "spl_token_2022::extension::PodStateWithExtensionsMut"
                                                [
                                                  ("base", M.read (| base |));
                                                  ("account_type", M.read (| account_type |));
                                                  ("tlv_data", M.read (| tlv_data |))
                                                ]
                                            ]
                                        |)))
                                  ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_unpack :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "unpack" (unpack S).
    
    (*
        pub fn unpack_uninitialized(input: &'data mut [u8]) -> Result<Self, ProgramError> {
            check_min_len_and_not_multisig(input, S::SIZE_OF)?;
            let (base_data, rest) = input.split_at_mut(S::SIZE_OF);
            let base = pod_from_bytes_mut::<S>(base_data)?;
            if base.is_initialized() {
                return Err(TokenError::AlreadyInUse.into());
            }
            let (account_type, tlv_data) = unpack_uninitialized_type_and_tlv_data_mut::<S>(rest)?;
            let state = Self {
                base,
                account_type,
                tlv_data,
            };
            state.check_account_type_matches_extension_type()?;
            Ok(state)
        }
    *)
    Definition unpack_uninitialized (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ input ] =>
        ltac:(M.monadic
          (let input := M.alloc (| input |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (|
                              "spl_token_2022::extension::check_min_len_and_not_multisig",
                              []
                            |),
                            [
                              M.read (| input |);
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "spl_token_2022::extension::PodStateWithExtensionsMut")
                                            [ S ];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |) in
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                        "split_at_mut",
                        []
                      |),
                      [
                        M.read (| input |);
                        M.read (|
                          M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                        let base_data := M.copy (| γ0_0 |) in
                        let rest := M.copy (| γ0_1 |) in
                        let base :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply (Ty.path "&mut") [ S ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_function (|
                                        "spl_pod::bytemuck::pod_from_bytes_mut",
                                        [ S ]
                                      |),
                                      [ M.read (| base_data |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                      [ S ];
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.use
                                      (M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "solana_program::program_pack::IsInitialized",
                                            S,
                                            [],
                                            "is_initialized",
                                            []
                                          |),
                                          [ M.read (| base |) ]
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          Value.StructTuple
                                            "core::result::Result::Err"
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::convert::Into",
                                                  Ty.path "spl_token_2022::error::TokenError",
                                                  [
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                  "into",
                                                  []
                                                |),
                                                [
                                                  Value.StructTuple
                                                    "spl_token_2022::error::TokenError::AlreadyInUse"
                                                    []
                                                ]
                                              |)
                                            ]
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        M.match_operator (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.tuple
                                        [
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                        ];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_token_2022::extension::unpack_uninitialized_type_and_tlv_data_mut",
                                      [ S ]
                                    |),
                                    [ M.read (| rest |) ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                    [ S ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                let account_type := M.copy (| γ0_0 |) in
                                let tlv_data := M.copy (| γ0_1 |) in
                                let state :=
                                  M.alloc (|
                                    Value.StructRecord
                                      "spl_token_2022::extension::PodStateWithExtensionsMut"
                                      [
                                        ("base", M.read (| base |));
                                        ("account_type", M.read (| account_type |));
                                        ("tlv_data", M.read (| tlv_data |))
                                      ]
                                  |) in
                                let _ :=
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::Try",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [],
                                          "branch",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                              Ty.apply
                                                (Ty.path
                                                  "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                [ S ],
                                              [ S ],
                                              "check_account_type_matches_extension_type",
                                              []
                                            |),
                                            [ state ]
                                          |)
                                        ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Break",
                                              0
                                            |) in
                                          let residual := M.copy (| γ0_0 |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::FromResidual",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.apply
                                                            (Ty.path
                                                              "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                            [ S ];
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.path "core::convert::Infallible";
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ]
                                                      ],
                                                      "from_residual",
                                                      []
                                                    |),
                                                    [ M.read (| residual |) ]
                                                  |)
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Continue",
                                              0
                                            |) in
                                          let val := M.copy (| γ0_0 |) in
                                          val))
                                    ]
                                  |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::result::Result::Ok"
                                    [ M.read (| state |) ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_unpack_uninitialized :
      forall (S : Ty.t),
      M.IsAssociatedFunction (Self S) "unpack_uninitialized" (unpack_uninitialized S).
  End Impl_spl_token_2022_extension_PodStateWithExtensionsMut_S.
  
  Module Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut") [ S ].
    
    (*
        fn get_tlv_data(&self) -> &[u8] {
            self.tlv_data
        }
    *)
    Definition get_tlv_data (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::PodStateWithExtensionsMut",
              "tlv_data"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "spl_token_2022::extension::BaseStateWithExtensions"
        (Self S)
        (* Trait polymorphic types *) [ (* S *) S ]
        (* Instance *) [ ("get_tlv_data", InstanceField.Method (get_tlv_data S)) ].
  End Impl_spl_token_2022_extension_BaseStateWithExtensions_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
  
  Module Impl_spl_token_2022_extension_BaseStateWithExtensionsMut_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
    Definition Self (S : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut") [ S ].
    
    (*
        fn get_tlv_data_mut(&mut self) -> &mut [u8] {
            self.tlv_data
        }
    *)
    Definition get_tlv_data_mut (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::PodStateWithExtensionsMut",
              "tlv_data"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    (*
        fn get_account_type_mut(&mut self) -> &mut [u8] {
            self.account_type
        }
    *)
    Definition get_account_type_mut (S : Ty.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self S in
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "spl_token_2022::extension::PodStateWithExtensionsMut",
              "account_type"
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      forall (S : Ty.t),
      M.IsTraitInstance
        "spl_token_2022::extension::BaseStateWithExtensionsMut"
        (Self S)
        (* Trait polymorphic types *) [ (* S *) S ]
        (* Instance *)
        [
          ("get_tlv_data_mut", InstanceField.Method (get_tlv_data_mut S));
          ("get_account_type_mut", InstanceField.Method (get_account_type_mut S))
        ].
  End Impl_spl_token_2022_extension_BaseStateWithExtensionsMut_where_spl_token_2022_extension_BaseState_S_S_for_spl_token_2022_extension_PodStateWithExtensionsMut_S.
  
  (*
  fn unpack_tlv_data<S: BaseState>(rest: &[u8]) -> Result<&[u8], ProgramError> {
      if let Some((account_type_index, tlv_start_index)) = type_and_tlv_indices::<S>(rest)? {
          // type_and_tlv_indices() checks that returned indexes are within range
          let account_type = AccountType::try_from(rest[account_type_index])
              .map_err(|_| ProgramError::InvalidAccountData)?;
          check_account_type::<S>(account_type)?;
          Ok(&rest[tlv_start_index..])
      } else {
          Ok(&[])
      }
  }
  *)
  Definition unpack_tlv_data (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S ], [ rest ] =>
      ltac:(M.monadic
        (let rest := M.alloc (| rest |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              M.match_operator (|
                M.alloc (| Value.Tuple [] |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ :=
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::try_trait::Try",
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  [
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ];
                                    Ty.path "solana_program::program_error::ProgramError"
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_function (|
                                    "spl_token_2022::extension::type_and_tlv_indices",
                                    [ S ]
                                  |),
                                  [ M.read (| rest |) ]
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Break",
                                    0
                                  |) in
                                let residual := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::FromResidual",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.apply
                                                  (Ty.path "&")
                                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "core::convert::Infallible";
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ]
                                            ],
                                            "from_residual",
                                            []
                                          |),
                                          [ M.read (| residual |) ]
                                        |)
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Continue",
                                    0
                                  |) in
                                let val := M.copy (| γ0_0 |) in
                                val))
                          ]
                        |) in
                      let γ0_0 :=
                        M.SubPointer.get_struct_tuple_field (|
                          γ,
                          "core::option::Option::Some",
                          0
                        |) in
                      let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                      let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                      let account_type_index := M.copy (| γ1_0 |) in
                      let tlv_start_index := M.copy (| γ1_1 |) in
                      let account_type :=
                        M.copy (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.path "spl_token_2022::extension::AccountType";
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.path "spl_token_2022::extension::AccountType";
                                          Ty.apply
                                            (Ty.path "num_enum::TryFromPrimitiveError")
                                            [ Ty.path "spl_token_2022::extension::AccountType" ]
                                        ],
                                      "map_err",
                                      [
                                        Ty.path "solana_program::program_error::ProgramError";
                                        Ty.function
                                          [
                                            Ty.tuple
                                              [
                                                Ty.apply
                                                  (Ty.path "num_enum::TryFromPrimitiveError")
                                                  [ Ty.path "spl_token_2022::extension::AccountType"
                                                  ]
                                              ]
                                          ]
                                          (Ty.path "solana_program::program_error::ProgramError")
                                      ]
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::convert::TryFrom",
                                          Ty.path "spl_token_2022::extension::AccountType",
                                          [ Ty.path "u8" ],
                                          "try_from",
                                          []
                                        |),
                                        [
                                          M.read (|
                                            M.SubPointer.get_array_field (|
                                              M.read (| rest |),
                                              account_type_index
                                            |)
                                          |)
                                        ]
                                      |);
                                      M.closure
                                        (fun γ =>
                                          ltac:(M.monadic
                                            match γ with
                                            | [ α0 ] =>
                                              M.match_operator (|
                                                M.alloc (| α0 |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (Value.StructTuple
                                                        "solana_program::program_error::ProgramError::InvalidAccountData"
                                                        []))
                                                ]
                                              |)
                                            | _ => M.impossible (||)
                                            end))
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.apply
                                                    (Ty.path "&")
                                                    [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::try_trait::Try",
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  [
                                    Ty.tuple [];
                                    Ty.path "solana_program::program_error::ProgramError"
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_function (|
                                    "spl_token_2022::extension::check_account_type",
                                    [ S ]
                                  |),
                                  [ M.read (| account_type |) ]
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Break",
                                    0
                                  |) in
                                let residual := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::FromResidual",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.apply
                                                  (Ty.path "&")
                                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "core::convert::Infallible";
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ]
                                            ],
                                            "from_residual",
                                            []
                                          |),
                                          [ M.read (| residual |) ]
                                        |)
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Continue",
                                    0
                                  |) in
                                let val := M.copy (| γ0_0 |) in
                                val))
                          ]
                        |) in
                      M.alloc (|
                        Value.StructTuple
                          "core::result::Result::Ok"
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::index::Index",
                                Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                [
                                  Ty.apply
                                    (Ty.path "core::ops::range::RangeFrom")
                                    [ Ty.path "usize" ]
                                ],
                                "index",
                                []
                              |),
                              [
                                M.read (| rest |);
                                Value.StructRecord
                                  "core::ops::range::RangeFrom"
                                  [ ("start", M.read (| tlv_start_index |)) ]
                              ]
                            |)
                          ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (M.alloc (|
                        Value.StructTuple
                          "core::result::Result::Ok"
                          [ (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |)) ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn unpack_type_and_tlv_data_with_check_mut<
      S: BaseState,
      F: Fn(AccountType) -> Result<(), ProgramError>,
  >(
      rest: &mut [u8],
      check_fn: F,
  ) -> Result<(&mut [u8], &mut [u8]), ProgramError> {
      if let Some((account_type_index, tlv_start_index)) = type_and_tlv_indices::<S>(rest)? {
          // type_and_tlv_indices() checks that returned indexes are within range
          let account_type = AccountType::try_from(rest[account_type_index])
              .map_err(|_| ProgramError::InvalidAccountData)?;
          check_fn(account_type)?;
          let (account_type, tlv_data) = rest.split_at_mut(tlv_start_index);
          Ok((
              &mut account_type[account_type_index..tlv_start_index],
              tlv_data,
          ))
      } else {
          Ok((&mut [], &mut []))
      }
  }
  *)
  Definition unpack_type_and_tlv_data_with_check_mut (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S; F ], [ rest; check_fn ] =>
      ltac:(M.monadic
        (let rest := M.alloc (| rest |) in
        let check_fn := M.alloc (| check_fn |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              M.match_operator (|
                M.alloc (| Value.Tuple [] |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ :=
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::try_trait::Try",
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  [
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ];
                                    Ty.path "solana_program::program_error::ProgramError"
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_function (|
                                    "spl_token_2022::extension::type_and_tlv_indices",
                                    [ S ]
                                  |),
                                  [ M.read (| rest |) ]
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Break",
                                    0
                                  |) in
                                let residual := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::FromResidual",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.tuple
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ];
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ]
                                                  ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "core::convert::Infallible";
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ]
                                            ],
                                            "from_residual",
                                            []
                                          |),
                                          [ M.read (| residual |) ]
                                        |)
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Continue",
                                    0
                                  |) in
                                let val := M.copy (| γ0_0 |) in
                                val))
                          ]
                        |) in
                      let γ0_0 :=
                        M.SubPointer.get_struct_tuple_field (|
                          γ,
                          "core::option::Option::Some",
                          0
                        |) in
                      let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                      let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                      let account_type_index := M.copy (| γ1_0 |) in
                      let tlv_start_index := M.copy (| γ1_1 |) in
                      let account_type :=
                        M.copy (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.path "spl_token_2022::extension::AccountType";
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.path "spl_token_2022::extension::AccountType";
                                          Ty.apply
                                            (Ty.path "num_enum::TryFromPrimitiveError")
                                            [ Ty.path "spl_token_2022::extension::AccountType" ]
                                        ],
                                      "map_err",
                                      [
                                        Ty.path "solana_program::program_error::ProgramError";
                                        Ty.function
                                          [
                                            Ty.tuple
                                              [
                                                Ty.apply
                                                  (Ty.path "num_enum::TryFromPrimitiveError")
                                                  [ Ty.path "spl_token_2022::extension::AccountType"
                                                  ]
                                              ]
                                          ]
                                          (Ty.path "solana_program::program_error::ProgramError")
                                      ]
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::convert::TryFrom",
                                          Ty.path "spl_token_2022::extension::AccountType",
                                          [ Ty.path "u8" ],
                                          "try_from",
                                          []
                                        |),
                                        [
                                          M.read (|
                                            M.SubPointer.get_array_field (|
                                              M.read (| rest |),
                                              account_type_index
                                            |)
                                          |)
                                        ]
                                      |);
                                      M.closure
                                        (fun γ =>
                                          ltac:(M.monadic
                                            match γ with
                                            | [ α0 ] =>
                                              M.match_operator (|
                                                M.alloc (| α0 |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (Value.StructTuple
                                                        "solana_program::program_error::ProgramError::InvalidAccountData"
                                                        []))
                                                ]
                                              |)
                                            | _ => M.impossible (||)
                                            end))
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.tuple
                                                    [
                                                      Ty.apply
                                                        (Ty.path "&mut")
                                                        [
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            [ Ty.path "u8" ]
                                                        ];
                                                      Ty.apply
                                                        (Ty.path "&mut")
                                                        [
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            [ Ty.path "u8" ]
                                                        ]
                                                    ];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::try_trait::Try",
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  [
                                    Ty.tuple [];
                                    Ty.path "solana_program::program_error::ProgramError"
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::function::Fn",
                                    F,
                                    [ Ty.tuple [ Ty.path "spl_token_2022::extension::AccountType" ]
                                    ],
                                    "call",
                                    []
                                  |),
                                  [ check_fn; Value.Tuple [ M.read (| account_type |) ] ]
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Break",
                                    0
                                  |) in
                                let residual := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::FromResidual",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.tuple
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ];
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ]
                                                  ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "core::convert::Infallible";
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ]
                                            ],
                                            "from_residual",
                                            []
                                          |),
                                          [ M.read (| residual |) ]
                                        |)
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Continue",
                                    0
                                  |) in
                                let val := M.copy (| γ0_0 |) in
                                val))
                          ]
                        |) in
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                              "split_at_mut",
                              []
                            |),
                            [ M.read (| rest |); M.read (| tlv_start_index |) ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                              let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                              let account_type := M.copy (| γ0_0 |) in
                              let tlv_data := M.copy (| γ0_1 |) in
                              M.alloc (|
                                Value.StructTuple
                                  "core::result::Result::Ok"
                                  [
                                    Value.Tuple
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::index::IndexMut",
                                            Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::ops::range::Range")
                                                [ Ty.path "usize" ]
                                            ],
                                            "index_mut",
                                            []
                                          |),
                                          [
                                            M.read (| account_type |);
                                            Value.StructRecord
                                              "core::ops::range::Range"
                                              [
                                                ("start", M.read (| account_type_index |));
                                                ("end_", M.read (| tlv_start_index |))
                                              ]
                                          ]
                                        |);
                                        M.read (| tlv_data |)
                                      ]
                                  ]
                              |)))
                        ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (M.alloc (|
                        Value.StructTuple
                          "core::result::Result::Ok"
                          [
                            Value.Tuple
                              [
                                (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |));
                                (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |))
                              ]
                          ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn unpack_type_and_tlv_data_mut<S: BaseState>(
      rest: &mut [u8],
  ) -> Result<(&mut [u8], &mut [u8]), ProgramError> {
      unpack_type_and_tlv_data_with_check_mut::<S, _>(rest, check_account_type::<S>)
  }
  *)
  Definition unpack_type_and_tlv_data_mut (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S ], [ rest ] =>
      ltac:(M.monadic
        (let rest := M.alloc (| rest |) in
        M.call_closure (|
          M.get_function (|
            "spl_token_2022::extension::unpack_type_and_tlv_data_with_check_mut",
            [
              S;
              Ty.function
                [ Ty.path "spl_token_2022::extension::AccountType" ]
                (Ty.apply
                  (Ty.path "core::result::Result")
                  [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ])
            ]
          |),
          [
            M.read (| rest |);
            M.get_function (| "spl_token_2022::extension::check_account_type", [ S ] |)
          ]
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  fn unpack_uninitialized_type_and_tlv_data_mut<S: BaseState>(
      rest: &mut [u8],
  ) -> Result<(&mut [u8], &mut [u8]), ProgramError> {
      unpack_type_and_tlv_data_with_check_mut::<S, _>(rest, |account_type| {
          if account_type != AccountType::Uninitialized {
              Err(ProgramError::InvalidAccountData)
          } else {
              Ok(())
          }
      })
  }
  *)
  Definition unpack_uninitialized_type_and_tlv_data_mut (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S ], [ rest ] =>
      ltac:(M.monadic
        (let rest := M.alloc (| rest |) in
        M.call_closure (|
          M.get_function (|
            "spl_token_2022::extension::unpack_type_and_tlv_data_with_check_mut",
            [
              S;
              Ty.function
                [ Ty.tuple [ Ty.path "spl_token_2022::extension::AccountType" ] ]
                (Ty.apply
                  (Ty.path "core::result::Result")
                  [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ])
            ]
          |),
          [
            M.read (| rest |);
            M.closure
              (fun γ =>
                ltac:(M.monadic
                  match γ with
                  | [ α0 ] =>
                    M.match_operator (|
                      M.alloc (| α0 |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let account_type := M.copy (| γ |) in
                            M.read (|
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::cmp::PartialEq",
                                                Ty.path "spl_token_2022::extension::AccountType",
                                                [ Ty.path "spl_token_2022::extension::AccountType"
                                                ],
                                                "ne",
                                                []
                                              |),
                                              [
                                                account_type;
                                                M.alloc (|
                                                  Value.StructTuple
                                                    "spl_token_2022::extension::AccountType::Uninitialized"
                                                    []
                                                |)
                                              ]
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        Value.StructTuple
                                          "core::result::Result::Err"
                                          [
                                            Value.StructTuple
                                              "solana_program::program_error::ProgramError::InvalidAccountData"
                                              []
                                          ]
                                      |)));
                                  fun γ =>
                                    ltac:(M.monadic
                                      (M.alloc (|
                                        Value.StructTuple
                                          "core::result::Result::Ok"
                                          [ Value.Tuple [] ]
                                      |)))
                                ]
                              |)
                            |)))
                      ]
                    |)
                  | _ => M.impossible (||)
                  end))
          ]
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  pub fn set_account_type<S: BaseState>(input: &mut [u8]) -> Result<(), ProgramError> {
      check_min_len_and_not_multisig(input, S::SIZE_OF)?;
      let (base_data, rest) = input.split_at_mut(S::SIZE_OF);
      if S::ACCOUNT_TYPE == AccountType::Account && !is_initialized_account(base_data)? {
          return Err(ProgramError::InvalidAccountData);
      }
      if let Some((account_type_index, _tlv_start_index)) = type_and_tlv_indices::<S>(rest)? {
          let mut account_type = AccountType::try_from(rest[account_type_index])
              .map_err(|_| ProgramError::InvalidAccountData)?;
          if account_type == AccountType::Uninitialized {
              rest[account_type_index] = S::ACCOUNT_TYPE.into();
              account_type = S::ACCOUNT_TYPE;
          }
          check_account_type::<S>(account_type)?;
          Ok(())
      } else {
          Err(ProgramError::InvalidAccountData)
      }
  }
  *)
  Definition set_account_type (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S ], [ input ] =>
      ltac:(M.monadic
        (let input := M.alloc (| input |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let _ :=
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::try_trait::Try",
                        Ty.apply
                          (Ty.path "core::result::Result")
                          [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError" ],
                        [],
                        "branch",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_function (|
                            "spl_token_2022::extension::check_min_len_and_not_multisig",
                            []
                          |),
                          [
                            M.read (| input |);
                            M.read (|
                              M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                            |)
                          ]
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Break",
                            0
                          |) in
                        let residual := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::FromResidual",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.tuple [];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.path "core::convert::Infallible";
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ]
                                    ],
                                    "from_residual",
                                    []
                                  |),
                                  [ M.read (| residual |) ]
                                |)
                              |)
                            |)
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Continue",
                            0
                          |) in
                        let val := M.copy (| γ0_0 |) in
                        val))
                  ]
                |) in
              M.match_operator (|
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "slice") [ Ty.path "u8" ],
                      "split_at_mut",
                      []
                    |),
                    [
                      M.read (| input |);
                      M.read (|
                        M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                      |)
                    ]
                  |)
                |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                      let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                      let base_data := M.copy (| γ0_0 |) in
                      let rest := M.copy (| γ0_1 |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      LogicalOp.and (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::cmp::PartialEq",
                                            Ty.path "spl_token_2022::extension::AccountType",
                                            [ Ty.path "spl_token_2022::extension::AccountType" ],
                                            "eq",
                                            []
                                          |),
                                          [
                                            M.get_constant (|
                                              "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                            |);
                                            M.alloc (|
                                              Value.StructTuple
                                                "spl_token_2022::extension::AccountType::Account"
                                                []
                                            |)
                                          ]
                                        |),
                                        ltac:(M.monadic
                                          (UnOp.Pure.not
                                            (M.read (|
                                              M.match_operator (|
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::Try",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.path "bool";
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [],
                                                      "branch",
                                                      []
                                                    |),
                                                    [
                                                      M.call_closure (|
                                                        M.get_function (|
                                                          "spl_token_2022::extension::is_initialized_account",
                                                          []
                                                        |),
                                                        [ M.read (| base_data |) ]
                                                      |)
                                                    ]
                                                  |)
                                                |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let γ0_0 :=
                                                        M.SubPointer.get_struct_tuple_field (|
                                                          γ,
                                                          "core::ops::control_flow::ControlFlow::Break",
                                                          0
                                                        |) in
                                                      let residual := M.copy (| γ0_0 |) in
                                                      M.alloc (|
                                                        M.never_to_any (|
                                                          M.read (|
                                                            M.return_ (|
                                                              M.call_closure (|
                                                                M.get_trait_method (|
                                                                  "core::ops::try_trait::FromResidual",
                                                                  Ty.apply
                                                                    (Ty.path "core::result::Result")
                                                                    [
                                                                      Ty.tuple [];
                                                                      Ty.path
                                                                        "solana_program::program_error::ProgramError"
                                                                    ],
                                                                  [
                                                                    Ty.apply
                                                                      (Ty.path
                                                                        "core::result::Result")
                                                                      [
                                                                        Ty.path
                                                                          "core::convert::Infallible";
                                                                        Ty.path
                                                                          "solana_program::program_error::ProgramError"
                                                                      ]
                                                                  ],
                                                                  "from_residual",
                                                                  []
                                                                |),
                                                                [ M.read (| residual |) ]
                                                              |)
                                                            |)
                                                          |)
                                                        |)
                                                      |)));
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let γ0_0 :=
                                                        M.SubPointer.get_struct_tuple_field (|
                                                          γ,
                                                          "core::ops::control_flow::ControlFlow::Continue",
                                                          0
                                                        |) in
                                                      let val := M.copy (| γ0_0 |) in
                                                      val))
                                                ]
                                              |)
                                            |))))
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructTuple
                                          "core::result::Result::Err"
                                          [
                                            Value.StructTuple
                                              "solana_program::program_error::ProgramError::InvalidAccountData"
                                              []
                                          ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::Try",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [],
                                        "branch",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_function (|
                                            "spl_token_2022::extension::type_and_tlv_indices",
                                            [ S ]
                                          |),
                                          [ M.read (| rest |) ]
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Break",
                                            0
                                          |) in
                                        let residual := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.read (|
                                              M.return_ (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::FromResidual",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.tuple [];
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.path "core::convert::Infallible";
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ]
                                                    ],
                                                    "from_residual",
                                                    []
                                                  |),
                                                  [ M.read (| residual |) ]
                                                |)
                                              |)
                                            |)
                                          |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Continue",
                                            0
                                          |) in
                                        let val := M.copy (| γ0_0 |) in
                                        val))
                                  ]
                                |) in
                              let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                              let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                              let account_type_index := M.copy (| γ1_0 |) in
                              let _tlv_start_index := M.copy (| γ1_1 |) in
                              let account_type :=
                                M.copy (|
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::Try",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "spl_token_2022::extension::AccountType";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [],
                                          "branch",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "spl_token_2022::extension::AccountType";
                                                  Ty.apply
                                                    (Ty.path "num_enum::TryFromPrimitiveError")
                                                    [
                                                      Ty.path
                                                        "spl_token_2022::extension::AccountType"
                                                    ]
                                                ],
                                              "map_err",
                                              [
                                                Ty.path
                                                  "solana_program::program_error::ProgramError";
                                                Ty.function
                                                  [
                                                    Ty.tuple
                                                      [
                                                        Ty.apply
                                                          (Ty.path
                                                            "num_enum::TryFromPrimitiveError")
                                                          [
                                                            Ty.path
                                                              "spl_token_2022::extension::AccountType"
                                                          ]
                                                      ]
                                                  ]
                                                  (Ty.path
                                                    "solana_program::program_error::ProgramError")
                                              ]
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::convert::TryFrom",
                                                  Ty.path "spl_token_2022::extension::AccountType",
                                                  [ Ty.path "u8" ],
                                                  "try_from",
                                                  []
                                                |),
                                                [
                                                  M.read (|
                                                    M.SubPointer.get_array_field (|
                                                      M.read (| rest |),
                                                      account_type_index
                                                    |)
                                                  |)
                                                ]
                                              |);
                                              M.closure
                                                (fun γ =>
                                                  ltac:(M.monadic
                                                    match γ with
                                                    | [ α0 ] =>
                                                      M.match_operator (|
                                                        M.alloc (| α0 |),
                                                        [
                                                          fun γ =>
                                                            ltac:(M.monadic
                                                              (Value.StructTuple
                                                                "solana_program::program_error::ProgramError::InvalidAccountData"
                                                                []))
                                                        ]
                                                      |)
                                                    | _ => M.impossible (||)
                                                    end))
                                            ]
                                          |)
                                        ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Break",
                                              0
                                            |) in
                                          let residual := M.copy (| γ0_0 |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::FromResidual",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.tuple [];
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.path "core::convert::Infallible";
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ]
                                                      ],
                                                      "from_residual",
                                                      []
                                                    |),
                                                    [ M.read (| residual |) ]
                                                  |)
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Continue",
                                              0
                                            |) in
                                          let val := M.copy (| γ0_0 |) in
                                          val))
                                    ]
                                  |)
                                |) in
                              let _ :=
                                M.match_operator (|
                                  M.alloc (| Value.Tuple [] |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ :=
                                          M.use
                                            (M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::cmp::PartialEq",
                                                  Ty.path "spl_token_2022::extension::AccountType",
                                                  [ Ty.path "spl_token_2022::extension::AccountType"
                                                  ],
                                                  "eq",
                                                  []
                                                |),
                                                [
                                                  account_type;
                                                  M.alloc (|
                                                    Value.StructTuple
                                                      "spl_token_2022::extension::AccountType::Uninitialized"
                                                      []
                                                  |)
                                                ]
                                              |)
                                            |)) in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        let _ :=
                                          M.write (|
                                            M.SubPointer.get_array_field (|
                                              M.read (| rest |),
                                              account_type_index
                                            |),
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::convert::Into",
                                                Ty.path "spl_token_2022::extension::AccountType",
                                                [ Ty.path "u8" ],
                                                "into",
                                                []
                                              |),
                                              [
                                                M.read (|
                                                  M.get_constant (|
                                                    "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                                  |)
                                                |)
                                              ]
                                            |)
                                          |) in
                                        let _ :=
                                          M.write (|
                                            account_type,
                                            M.read (|
                                              M.get_constant (|
                                                "spl_token_2022::extension::BaseState::ACCOUNT_TYPE"
                                              |)
                                            |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              let _ :=
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::Try",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [],
                                        "branch",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_function (|
                                            "spl_token_2022::extension::check_account_type",
                                            [ S ]
                                          |),
                                          [ M.read (| account_type |) ]
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Break",
                                            0
                                          |) in
                                        let residual := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.read (|
                                              M.return_ (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::FromResidual",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.tuple [];
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.path "core::convert::Infallible";
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ]
                                                    ],
                                                    "from_residual",
                                                    []
                                                  |),
                                                  [ M.read (| residual |) ]
                                                |)
                                              |)
                                            |)
                                          |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::ops::control_flow::ControlFlow::Continue",
                                            0
                                          |) in
                                        let val := M.copy (| γ0_0 |) in
                                        val))
                                  ]
                                |) in
                              M.alloc (|
                                Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (M.alloc (|
                                Value.StructTuple
                                  "core::result::Result::Err"
                                  [
                                    Value.StructTuple
                                      "solana_program::program_error::ProgramError::InvalidAccountData"
                                      []
                                  ]
                              |)))
                        ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  Enum AccountType
  {
    ty_params := [];
    variants :=
      [
        {
          name := "Uninitialized";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "Mint";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "Account";
          item := StructTuple [];
          discriminant := None;
        }
      ];
  }
  *)
  
  Module Impl_core_clone_Clone_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    (* Clone *)
    Definition clone (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (| M.read (| self |) |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::clone::Clone"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("clone", InstanceField.Method clone) ].
  End Impl_core_clone_Clone_for_spl_token_2022_extension_AccountType.
  
  Module Impl_core_marker_Copy_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::Copy"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_Copy_for_spl_token_2022_extension_AccountType.
  
  Module Impl_core_fmt_Debug_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    (* Debug *)
    Definition fmt (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |),
            [
              M.read (| f |);
              M.read (|
                M.match_operator (|
                  self,
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "Uninitialized" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "Mint" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "Account" |) |)))
                  ]
                |)
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::fmt::Debug"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
  End Impl_core_fmt_Debug_for_spl_token_2022_extension_AccountType.
  
  Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_AccountType.
  
  Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    (* PartialEq *)
    Definition eq (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          M.read (|
            let __self_tag :=
              M.alloc (|
                M.call_closure (|
                  M.get_function (|
                    "core::intrinsics::discriminant_value",
                    [ Ty.path "spl_token_2022::extension::AccountType" ]
                  |),
                  [ M.read (| self |) ]
                |)
              |) in
            let __arg1_tag :=
              M.alloc (|
                M.call_closure (|
                  M.get_function (|
                    "core::intrinsics::discriminant_value",
                    [ Ty.path "spl_token_2022::extension::AccountType" ]
                  |),
                  [ M.read (| other |) ]
                |)
              |) in
            M.alloc (| BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)) |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::PartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method eq) ].
  End Impl_core_cmp_PartialEq_for_spl_token_2022_extension_AccountType.
  
  Module Impl_num_enum_TryFromPrimitive_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    (* TryFromPrimitive *)
    Definition _Primitive : Ty.t := Ty.path "u8".
    
    (* TryFromPrimitive *)
    Definition _Error : Ty.t :=
      Ty.apply
        (Ty.path "num_enum::TryFromPrimitiveError")
        [ Ty.path "spl_token_2022::extension::AccountType" ].
    
    (* TryFromPrimitive *)
    (* Ty.apply (Ty.path "&") [ Ty.path "str" ] *)
    Definition value_NAME : Value.t := M.run ltac:(M.monadic (Value.String "AccountType")).
    
    (* TryFromPrimitive *)
    Definition try_from_primitive (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ number ] =>
        ltac:(M.monadic
          (let number := M.alloc (| number |) in
          M.read (|
            M.match_operator (|
              number,
              [
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 0 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::AccountType::Uninitialized"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 1 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [ Value.StructTuple "spl_token_2022::extension::AccountType::Mint" [] ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 2 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [ Value.StructTuple "spl_token_2022::extension::AccountType::Account" [] ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Err"
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "num_enum::TryFromPrimitiveError")
                                [ Ty.path "spl_token_2022::extension::AccountType" ],
                              "new",
                              []
                            |),
                            [ M.read (| number |) ]
                          |)
                        ]
                    |)))
              ]
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "num_enum::TryFromPrimitive"
        Self
        (* Trait polymorphic types *) []
        (* Instance *)
        [
          ("Primitive", InstanceField.Ty _Primitive);
          ("Error", InstanceField.Ty _Error);
          ("value_NAME", InstanceField.Constant value_NAME);
          ("try_from_primitive", InstanceField.Method try_from_primitive)
        ].
  End Impl_num_enum_TryFromPrimitive_for_spl_token_2022_extension_AccountType.
  
  Module Impl_core_convert_TryFrom_u8_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    (* TryFromPrimitive *)
    Definition _Error : Ty.t :=
      Ty.apply
        (Ty.path "num_enum::TryFromPrimitiveError")
        [ Ty.path "spl_token_2022::extension::AccountType" ].
    
    (* TryFromPrimitive *)
    Definition try_from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ number ] =>
        ltac:(M.monadic
          (let number := M.alloc (| number |) in
          M.call_closure (|
            M.get_trait_method (|
              "num_enum::TryFromPrimitive",
              Ty.path "spl_token_2022::extension::AccountType",
              [],
              "try_from_primitive",
              []
            |),
            [ M.read (| number |) ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::TryFrom"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "u8" ]
        (* Instance *)
        [ ("Error", InstanceField.Ty _Error); ("try_from", InstanceField.Method try_from) ].
  End Impl_core_convert_TryFrom_u8_for_spl_token_2022_extension_AccountType.
  
  Module Impl_num_enum_CannotDeriveBothFromPrimitiveAndTryFromPrimitive_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    Axiom Implements :
      M.IsTraitInstance
        "num_enum::CannotDeriveBothFromPrimitiveAndTryFromPrimitive"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_num_enum_CannotDeriveBothFromPrimitiveAndTryFromPrimitive_for_spl_token_2022_extension_AccountType.
  
  Module Impl_core_convert_From_spl_token_2022_extension_AccountType_for_u8.
    Definition Self : Ty.t := Ty.path "u8".
    
    (* IntoPrimitive *)
    Definition from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ enum_value ] =>
        ltac:(M.monadic
          (let enum_value := M.alloc (| enum_value |) in
          M.rust_cast (M.read (| enum_value |))))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::From"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "spl_token_2022::extension::AccountType" ]
        (* Instance *) [ ("from", InstanceField.Method from) ].
  End Impl_core_convert_From_spl_token_2022_extension_AccountType_for_u8.
  
  Module Impl_core_default_Default_for_spl_token_2022_extension_AccountType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::AccountType".
    
    (*
        fn default() -> Self {
            Self::Uninitialized
        }
    *)
    Definition default (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [] =>
        ltac:(M.monadic
          (Value.StructTuple "spl_token_2022::extension::AccountType::Uninitialized" []))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::default::Default"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("default", InstanceField.Method default) ].
  End Impl_core_default_Default_for_spl_token_2022_extension_AccountType.
  
  (*
  Enum ExtensionType
  {
    ty_params := [];
    variants :=
      [
        {
          name := "Uninitialized";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "TransferFeeConfig";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "TransferFeeAmount";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "MintCloseAuthority";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "ConfidentialTransferMint";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "ConfidentialTransferAccount";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "DefaultAccountState";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "ImmutableOwner";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "MemoTransfer";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "NonTransferable";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "InterestBearingConfig";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "CpiGuard";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "PermanentDelegate";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "NonTransferableAccount";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "TransferHook";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "TransferHookAccount";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "ConfidentialTransferFeeConfig";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "ConfidentialTransferFeeAmount";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "MetadataPointer";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "TokenMetadata";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "GroupPointer";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "TokenGroup";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "GroupMemberPointer";
          item := StructTuple [];
          discriminant := None;
        };
        {
          name := "TokenGroupMember";
          item := StructTuple [];
          discriminant := None;
        }
      ];
  }
  *)
  
  Module Impl_core_clone_Clone_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    (* Clone *)
    Definition clone (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (| M.read (| self |) |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::clone::Clone"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("clone", InstanceField.Method clone) ].
  End Impl_core_clone_Clone_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_core_marker_Copy_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::Copy"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_Copy_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_core_fmt_Debug_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    (* Debug *)
    Definition fmt (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.call_closure (|
            M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |),
            [
              M.read (| f |);
              M.read (|
                M.match_operator (|
                  self,
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "Uninitialized" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "TransferFeeConfig" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "TransferFeeAmount" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "MintCloseAuthority" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "ConfidentialTransferMint" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "ConfidentialTransferAccount" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "DefaultAccountState" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "ImmutableOwner" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "MemoTransfer" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "NonTransferable" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "InterestBearingConfig" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "CpiGuard" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "PermanentDelegate" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "NonTransferableAccount" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "TransferHook" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "TransferHookAccount" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "ConfidentialTransferFeeConfig" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "ConfidentialTransferFeeAmount" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "MetadataPointer" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "TokenMetadata" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "GroupPointer" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "TokenGroup" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "GroupMemberPointer" |) |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        M.alloc (| M.read (| Value.String "TokenGroupMember" |) |)))
                  ]
                |)
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::fmt::Debug"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
  End Impl_core_fmt_Debug_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    (* PartialEq *)
    Definition eq (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self; other ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let other := M.alloc (| other |) in
          M.read (|
            let __self_tag :=
              M.alloc (|
                M.call_closure (|
                  M.get_function (|
                    "core::intrinsics::discriminant_value",
                    [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                  |),
                  [ M.read (| self |) ]
                |)
              |) in
            let __arg1_tag :=
              M.alloc (|
                M.call_closure (|
                  M.get_function (|
                    "core::intrinsics::discriminant_value",
                    [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                  |),
                  [ M.read (| other |) ]
                |)
              |) in
            M.alloc (| BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)) |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::PartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("eq", InstanceField.Method eq) ].
  End Impl_core_cmp_PartialEq_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_num_enum_TryFromPrimitive_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    (* TryFromPrimitive *)
    Definition _Primitive : Ty.t := Ty.path "u16".
    
    (* TryFromPrimitive *)
    Definition _Error : Ty.t :=
      Ty.apply
        (Ty.path "num_enum::TryFromPrimitiveError")
        [ Ty.path "spl_token_2022::extension::ExtensionType" ].
    
    (* TryFromPrimitive *)
    (* Ty.apply (Ty.path "&") [ Ty.path "str" ] *)
    Definition value_NAME : Value.t := M.run ltac:(M.monadic (Value.String "ExtensionType")).
    
    (* TryFromPrimitive *)
    Definition try_from_primitive (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ number ] =>
        ltac:(M.monadic
          (let number := M.alloc (| number |) in
          M.read (|
            M.match_operator (|
              number,
              [
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 0 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::Uninitialized"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 1 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::TransferFeeConfig"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 2 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::TransferFeeAmount"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 3 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::MintCloseAuthority"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 4 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::ConfidentialTransferMint"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 5 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::ConfidentialTransferAccount"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 6 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::DefaultAccountState"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 7 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::ImmutableOwner"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 8 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::MemoTransfer"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 9 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::NonTransferable"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 10 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::InterestBearingConfig"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 11 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [ Value.StructTuple "spl_token_2022::extension::ExtensionType::CpiGuard" []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 12 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::PermanentDelegate"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 13 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::NonTransferableAccount"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 14 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::TransferHook"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 15 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::TransferHookAccount"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 16 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::ConfidentialTransferFeeConfig"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 17 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::ConfidentialTransferFeeAmount"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 18 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::MetadataPointer"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 19 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::TokenMetadata"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 20 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::GroupPointer"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 21 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::TokenGroup"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 22 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::GroupMemberPointer"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Integer 23 |) in
                    M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Ok"
                        [
                          Value.StructTuple
                            "spl_token_2022::extension::ExtensionType::TokenGroupMember"
                            []
                        ]
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (M.alloc (|
                      Value.StructTuple
                        "core::result::Result::Err"
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "num_enum::TryFromPrimitiveError")
                                [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                              "new",
                              []
                            |),
                            [ M.read (| number |) ]
                          |)
                        ]
                    |)))
              ]
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "num_enum::TryFromPrimitive"
        Self
        (* Trait polymorphic types *) []
        (* Instance *)
        [
          ("Primitive", InstanceField.Ty _Primitive);
          ("Error", InstanceField.Ty _Error);
          ("value_NAME", InstanceField.Constant value_NAME);
          ("try_from_primitive", InstanceField.Method try_from_primitive)
        ].
  End Impl_num_enum_TryFromPrimitive_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_core_convert_TryFrom_u16_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    (* TryFromPrimitive *)
    Definition _Error : Ty.t :=
      Ty.apply
        (Ty.path "num_enum::TryFromPrimitiveError")
        [ Ty.path "spl_token_2022::extension::ExtensionType" ].
    
    (* TryFromPrimitive *)
    Definition try_from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ number ] =>
        ltac:(M.monadic
          (let number := M.alloc (| number |) in
          M.call_closure (|
            M.get_trait_method (|
              "num_enum::TryFromPrimitive",
              Ty.path "spl_token_2022::extension::ExtensionType",
              [],
              "try_from_primitive",
              []
            |),
            [ M.read (| number |) ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::TryFrom"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "u16" ]
        (* Instance *)
        [ ("Error", InstanceField.Ty _Error); ("try_from", InstanceField.Method try_from) ].
  End Impl_core_convert_TryFrom_u16_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_num_enum_CannotDeriveBothFromPrimitiveAndTryFromPrimitive_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    Axiom Implements :
      M.IsTraitInstance
        "num_enum::CannotDeriveBothFromPrimitiveAndTryFromPrimitive"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_num_enum_CannotDeriveBothFromPrimitiveAndTryFromPrimitive_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_core_convert_From_spl_token_2022_extension_ExtensionType_for_u16.
    Definition Self : Ty.t := Ty.path "u16".
    
    (* IntoPrimitive *)
    Definition from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ enum_value ] =>
        ltac:(M.monadic
          (let enum_value := M.alloc (| enum_value |) in
          M.rust_cast (M.read (| enum_value |))))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::From"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "spl_token_2022::extension::ExtensionType" ]
        (* Instance *) [ ("from", InstanceField.Method from) ].
  End Impl_core_convert_From_spl_token_2022_extension_ExtensionType_for_u16.
  
  Module Impl_core_convert_TryFrom_ref__slice_u8_for_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    (*     type Error = ProgramError; *)
    Definition _Error : Ty.t := Ty.path "solana_program::program_error::ProgramError".
    
    (*
        fn try_from(a: &[u8]) -> Result<Self, Self::Error> {
            Self::try_from(u16::from_le_bytes(
                a.try_into().map_err(|_| ProgramError::InvalidAccountData)?,
            ))
            .map_err(|_| ProgramError::InvalidAccountData)
        }
    *)
    Definition try_from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ a ] =>
        ltac:(M.monadic
          (let a := M.alloc (| a |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::result::Result")
                    [
                      Ty.path "spl_token_2022::extension::ExtensionType";
                      Ty.apply
                        (Ty.path "num_enum::TryFromPrimitiveError")
                        [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                    ],
                  "map_err",
                  [
                    Ty.path "solana_program::program_error::ProgramError";
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.apply
                              (Ty.path "num_enum::TryFromPrimitiveError")
                              [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                          ]
                      ]
                      (Ty.path "solana_program::program_error::ProgramError")
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::convert::TryFrom",
                      Ty.path "spl_token_2022::extension::ExtensionType",
                      [ Ty.path "u16" ],
                      "try_from",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (| Ty.path "u16", "from_le_bytes", [] |),
                        [
                          M.read (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.apply (Ty.path "array") [ Ty.path "u8" ];
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.apply (Ty.path "array") [ Ty.path "u8" ];
                                            Ty.path "core::array::TryFromSliceError"
                                          ],
                                        "map_err",
                                        [
                                          Ty.path "solana_program::program_error::ProgramError";
                                          Ty.function
                                            [ Ty.tuple [ Ty.path "core::array::TryFromSliceError" ]
                                            ]
                                            (Ty.path "solana_program::program_error::ProgramError")
                                        ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::convert::TryInto",
                                            Ty.apply
                                              (Ty.path "&")
                                              [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ],
                                            [ Ty.apply (Ty.path "array") [ Ty.path "u8" ] ],
                                            "try_into",
                                            []
                                          |),
                                          [ M.read (| a |) ]
                                        |);
                                        M.closure
                                          (fun γ =>
                                            ltac:(M.monadic
                                              match γ with
                                              | [ α0 ] =>
                                                M.match_operator (|
                                                  M.alloc (| α0 |),
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (Value.StructTuple
                                                          "solana_program::program_error::ProgramError::InvalidAccountData"
                                                          []))
                                                  ]
                                                |)
                                              | _ => M.impossible (||)
                                              end))
                                      ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path
                                                      "spl_token_2022::extension::ExtensionType";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |)
                        ]
                      |)
                    ]
                  |);
                  M.closure
                    (fun γ =>
                      ltac:(M.monadic
                        match γ with
                        | [ α0 ] =>
                          M.match_operator (|
                            M.alloc (| α0 |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (Value.StructTuple
                                    "solana_program::program_error::ProgramError::InvalidAccountData"
                                    []))
                            ]
                          |)
                        | _ => M.impossible (||)
                        end))
                ]
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::TryFrom"
        Self
        (* Trait polymorphic types *)
        [ (* T *) Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ]
        (* Instance *)
        [ ("Error", InstanceField.Ty _Error); ("try_from", InstanceField.Method try_from) ].
  End Impl_core_convert_TryFrom_ref__slice_u8_for_spl_token_2022_extension_ExtensionType.
  
  Module Impl_core_convert_From_spl_token_2022_extension_ExtensionType_for_array_u8.
    Definition Self : Ty.t := Ty.apply (Ty.path "array") [ Ty.path "u8" ].
    
    (*
        fn from(a: ExtensionType) -> Self {
            u16::from(a).to_le_bytes()
        }
    *)
    Definition from (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ a ] =>
        ltac:(M.monadic
          (let a := M.alloc (| a |) in
          M.call_closure (|
            M.get_associated_function (| Ty.path "u16", "to_le_bytes", [] |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::convert::From",
                  Ty.path "u16",
                  [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                  "from",
                  []
                |),
                [ M.read (| a |) ]
              |)
            ]
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::From"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "spl_token_2022::extension::ExtensionType" ]
        (* Instance *) [ ("from", InstanceField.Method from) ].
  End Impl_core_convert_From_spl_token_2022_extension_ExtensionType_for_array_u8.
  
  Module Impl_spl_token_2022_extension_ExtensionType.
    Definition Self : Ty.t := Ty.path "spl_token_2022::extension::ExtensionType".
    
    (*
        const fn sized(&self) -> bool {
            match self {
                ExtensionType::TokenMetadata => false,
                #[cfg(test)]
                ExtensionType::VariableLenMintTest => false,
                _ => true,
            }
        }
    *)
    Definition sized (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.match_operator (|
              self,
              [
                fun γ =>
                  ltac:(M.monadic
                    (let γ := M.read (| γ |) in
                    M.alloc (| Value.Bool false |)));
                fun γ => ltac:(M.monadic (M.alloc (| Value.Bool true |)))
              ]
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_sized : M.IsAssociatedFunction Self "sized" sized.
    
    (*
        fn try_get_type_len(&self) -> Result<usize, ProgramError> {
            if !self.sized() {
                return Err(ProgramError::InvalidArgument);
            }
            Ok(match self {
                ExtensionType::Uninitialized => 0,
                ExtensionType::TransferFeeConfig => pod_get_packed_len::<TransferFeeConfig>(),
                ExtensionType::TransferFeeAmount => pod_get_packed_len::<TransferFeeAmount>(),
                ExtensionType::MintCloseAuthority => pod_get_packed_len::<MintCloseAuthority>(),
                ExtensionType::ImmutableOwner => pod_get_packed_len::<ImmutableOwner>(),
                ExtensionType::ConfidentialTransferMint => {
                    pod_get_packed_len::<ConfidentialTransferMint>()
                }
                ExtensionType::ConfidentialTransferAccount => {
                    pod_get_packed_len::<ConfidentialTransferAccount>()
                }
                ExtensionType::DefaultAccountState => pod_get_packed_len::<DefaultAccountState>(),
                ExtensionType::MemoTransfer => pod_get_packed_len::<MemoTransfer>(),
                ExtensionType::NonTransferable => pod_get_packed_len::<NonTransferable>(),
                ExtensionType::InterestBearingConfig => pod_get_packed_len::<InterestBearingConfig>(),
                ExtensionType::CpiGuard => pod_get_packed_len::<CpiGuard>(),
                ExtensionType::PermanentDelegate => pod_get_packed_len::<PermanentDelegate>(),
                ExtensionType::NonTransferableAccount => pod_get_packed_len::<NonTransferableAccount>(),
                ExtensionType::TransferHook => pod_get_packed_len::<TransferHook>(),
                ExtensionType::TransferHookAccount => pod_get_packed_len::<TransferHookAccount>(),
                ExtensionType::ConfidentialTransferFeeConfig => {
                    pod_get_packed_len::<ConfidentialTransferFeeConfig>()
                }
                ExtensionType::ConfidentialTransferFeeAmount => {
                    pod_get_packed_len::<ConfidentialTransferFeeAmount>()
                }
                ExtensionType::MetadataPointer => pod_get_packed_len::<MetadataPointer>(),
                ExtensionType::TokenMetadata => unreachable!(),
                ExtensionType::GroupPointer => pod_get_packed_len::<GroupPointer>(),
                ExtensionType::TokenGroup => pod_get_packed_len::<TokenGroup>(),
                ExtensionType::GroupMemberPointer => pod_get_packed_len::<GroupMemberPointer>(),
                ExtensionType::TokenGroupMember => pod_get_packed_len::<TokenGroupMember>(),
                #[cfg(test)]
                ExtensionType::AccountPaddingTest => pod_get_packed_len::<AccountPaddingTest>(),
                #[cfg(test)]
                ExtensionType::MintPaddingTest => pod_get_packed_len::<MintPaddingTest>(),
                #[cfg(test)]
                ExtensionType::VariableLenMintTest => unreachable!(),
            })
        }
    *)
    Definition try_get_type_len (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                UnOp.Pure.not
                                  (M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "spl_token_2022::extension::ExtensionType",
                                      "sized",
                                      []
                                    |),
                                    [ M.read (| self |) ]
                                  |))
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  Value.StructTuple
                                    "core::result::Result::Err"
                                    [
                                      Value.StructTuple
                                        "solana_program::program_error::ProgramError::InvalidArgument"
                                        []
                                    ]
                                |)
                              |)
                            |)
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                M.alloc (|
                  Value.StructTuple
                    "core::result::Result::Ok"
                    [
                      M.read (|
                        M.match_operator (|
                          self,
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (| Value.Integer 0 |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::transfer_fee::TransferFeeConfig"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::transfer_fee::TransferFeeAmount"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::mint_close_authority::MintCloseAuthority"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::immutable_owner::ImmutableOwner"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::confidential_transfer::ConfidentialTransferMint"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::confidential_transfer::ConfidentialTransferAccount"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::default_account_state::DefaultAccountState"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::memo_transfer::MemoTransfer"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::non_transferable::NonTransferable"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [ Ty.path "spl_token_2022::extension::cpi_guard::CpiGuard" ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::permanent_delegate::PermanentDelegate"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::non_transferable::NonTransferableAccount"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::transfer_hook::TransferHook"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::transfer_hook::TransferHookAccount"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::confidential_transfer_fee::ConfidentialTransferFeeConfig"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::confidential_transfer_fee::ConfidentialTransferFeeAmount"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::metadata_pointer::MetadataPointer"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.call_closure (|
                                      M.get_function (| "core::panicking::panic", [] |),
                                      [
                                        M.read (|
                                          Value.String "internal error: entered unreachable code"
                                        |)
                                      ]
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::group_pointer::GroupPointer"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [ Ty.path "spl_token_group_interface::state::TokenGroup" ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [
                                        Ty.path
                                          "spl_token_2022::extension::group_member_pointer::GroupMemberPointer"
                                      ]
                                    |),
                                    []
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ := M.read (| γ |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_pod::bytemuck::pod_get_packed_len",
                                      [ Ty.path "spl_token_group_interface::state::TokenGroupMember"
                                      ]
                                    |),
                                    []
                                  |)
                                |)))
                          ]
                        |)
                      |)
                    ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_try_get_type_len :
      M.IsAssociatedFunction Self "try_get_type_len" try_get_type_len.
    
    (*
        fn try_get_tlv_len(&self) -> Result<usize, ProgramError> {
            Ok(add_type_and_length_to_len(self.try_get_type_len()?))
        }
    *)
    Definition try_get_tlv_len (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.catch_return (|
            ltac:(M.monadic
              (Value.StructTuple
                "core::result::Result::Ok"
                [
                  M.call_closure (|
                    M.get_function (|
                      "spl_token_2022::extension::add_type_and_length_to_len",
                      []
                    |),
                    [
                      M.read (|
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::try_trait::Try",
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  [
                                    Ty.path "usize";
                                    Ty.path "solana_program::program_error::ProgramError"
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "spl_token_2022::extension::ExtensionType",
                                    "try_get_type_len",
                                    []
                                  |),
                                  [ M.read (| self |) ]
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Break",
                                    0
                                  |) in
                                let residual := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::FromResidual",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "usize";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "core::convert::Infallible";
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ]
                                            ],
                                            "from_residual",
                                            []
                                          |),
                                          [ M.read (| residual |) ]
                                        |)
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Continue",
                                    0
                                  |) in
                                let val := M.copy (| γ0_0 |) in
                                val))
                          ]
                        |)
                      |)
                    ]
                  |)
                ]))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_try_get_tlv_len :
      M.IsAssociatedFunction Self "try_get_tlv_len" try_get_tlv_len.
    
    (*
        fn try_get_total_tlv_len(extension_types: &[Self]) -> Result<usize, ProgramError> {
            // dedupe extensions
            let mut extensions = vec![];
            for extension_type in extension_types {
                if !extensions.contains(&extension_type) {
                    extensions.push(extension_type);
                }
            }
            extensions.iter().map(|e| e.try_get_tlv_len()).sum()
        }
    *)
    Definition try_get_total_tlv_len (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ extension_types ] =>
        ltac:(M.monadic
          (let extension_types := M.alloc (| extension_types |) in
          M.read (|
            let extensions :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "alloc::vec::Vec")
                      [
                        Ty.apply
                          (Ty.path "&")
                          [ Ty.path "spl_token_2022::extension::ExtensionType" ];
                        Ty.path "alloc::alloc::Global"
                      ],
                    "new",
                    []
                  |),
                  []
                |)
              |) in
            let _ :=
              M.use
                (M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::collect::IntoIterator",
                        Ty.apply
                          (Ty.path "&")
                          [
                            Ty.apply
                              (Ty.path "slice")
                              [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                          ],
                        [],
                        "into_iter",
                        []
                      |),
                      [ M.read (| extension_types |) ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let iter := M.copy (| γ |) in
                        M.loop (|
                          ltac:(M.monadic
                            (let _ :=
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::iter::traits::iterator::Iterator",
                                      Ty.apply
                                        (Ty.path "core::slice::iter::Iter")
                                        [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                                      [],
                                      "next",
                                      []
                                    |),
                                    [ iter ]
                                  |)
                                |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (M.alloc (|
                                        M.never_to_any (| M.read (| M.break (||) |) |)
                                      |)));
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::option::Option::Some",
                                          0
                                        |) in
                                      let extension_type := M.copy (| γ0_0 |) in
                                      M.match_operator (|
                                        M.alloc (| Value.Tuple [] |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ :=
                                                M.use
                                                  (M.alloc (|
                                                    UnOp.Pure.not
                                                      (M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            [
                                                              Ty.apply
                                                                (Ty.path "&")
                                                                [
                                                                  Ty.path
                                                                    "spl_token_2022::extension::ExtensionType"
                                                                ]
                                                            ],
                                                          "contains",
                                                          []
                                                        |),
                                                        [
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::deref::Deref",
                                                              Ty.apply
                                                                (Ty.path "alloc::vec::Vec")
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "&")
                                                                    [
                                                                      Ty.path
                                                                        "spl_token_2022::extension::ExtensionType"
                                                                    ];
                                                                  Ty.path "alloc::alloc::Global"
                                                                ],
                                                              [],
                                                              "deref",
                                                              []
                                                            |),
                                                            [ extensions ]
                                                          |);
                                                          extension_type
                                                        ]
                                                      |))
                                                  |)) in
                                              let _ :=
                                                M.is_constant_or_break_match (|
                                                  M.read (| γ |),
                                                  Value.Bool true
                                                |) in
                                              let _ :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path "alloc::vec::Vec")
                                                        [
                                                          Ty.apply
                                                            (Ty.path "&")
                                                            [
                                                              Ty.path
                                                                "spl_token_2022::extension::ExtensionType"
                                                            ];
                                                          Ty.path "alloc::alloc::Global"
                                                        ],
                                                      "push",
                                                      []
                                                    |),
                                                    [ extensions; M.read (| extension_type |) ]
                                                  |)
                                                |) in
                                              M.alloc (| Value.Tuple [] |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |)))
                                ]
                              |) in
                            M.alloc (| Value.Tuple [] |)))
                        |)))
                  ]
                |)) in
            M.alloc (|
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::map::Map")
                    [
                      Ty.apply
                        (Ty.path "core::slice::iter::Iter")
                        [
                          Ty.apply
                            (Ty.path "&")
                            [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                        ];
                      Ty.function
                        [
                          Ty.tuple
                            [
                              Ty.apply
                                (Ty.path "&")
                                [
                                  Ty.apply
                                    (Ty.path "&")
                                    [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                                ]
                            ]
                        ]
                        (Ty.apply
                          (Ty.path "core::result::Result")
                          [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError"
                          ])
                    ],
                  [],
                  "sum",
                  [
                    Ty.apply
                      (Ty.path "core::result::Result")
                      [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError" ]
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply
                        (Ty.path "core::slice::iter::Iter")
                        [
                          Ty.apply
                            (Ty.path "&")
                            [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                        ],
                      [],
                      "map",
                      [
                        Ty.apply
                          (Ty.path "core::result::Result")
                          [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError"
                          ];
                        Ty.function
                          [
                            Ty.tuple
                              [
                                Ty.apply
                                  (Ty.path "&")
                                  [
                                    Ty.apply
                                      (Ty.path "&")
                                      [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                                  ]
                              ]
                          ]
                          (Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError"
                            ])
                      ]
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "slice")
                            [
                              Ty.apply
                                (Ty.path "&")
                                [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                            ],
                          "iter",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::Deref",
                              Ty.apply
                                (Ty.path "alloc::vec::Vec")
                                [
                                  Ty.apply
                                    (Ty.path "&")
                                    [ Ty.path "spl_token_2022::extension::ExtensionType" ];
                                  Ty.path "alloc::alloc::Global"
                                ],
                              [],
                              "deref",
                              []
                            |),
                            [ extensions ]
                          |)
                        ]
                      |);
                      M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0 ] =>
                              M.match_operator (|
                                M.alloc (| α0 |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let e := M.copy (| γ |) in
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "spl_token_2022::extension::ExtensionType",
                                          "try_get_tlv_len",
                                          []
                                        |),
                                        [ M.read (| M.read (| e |) |) ]
                                      |)))
                                ]
                              |)
                            | _ => M.impossible (||)
                            end))
                    ]
                  |)
                ]
              |)
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_try_get_total_tlv_len :
      M.IsAssociatedFunction Self "try_get_total_tlv_len" try_get_total_tlv_len.
    
    (*
        pub fn try_calculate_account_len<S: BaseState>(
            extension_types: &[Self],
        ) -> Result<usize, ProgramError> {
            if extension_types.is_empty() {
                Ok(S::SIZE_OF)
            } else {
                let extension_size = Self::try_get_total_tlv_len(extension_types)?;
                let total_len = extension_size.saturating_add(BASE_ACCOUNT_AND_TYPE_LENGTH);
                Ok(adjust_len_for_multisig(total_len))
            }
        }
    *)
    Definition try_calculate_account_len (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [ _ as S ], [ extension_types ] =>
        ltac:(M.monadic
          (let extension_types := M.alloc (| extension_types |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "slice")
                                    [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                                  "is_empty",
                                  []
                                |),
                                [ M.read (| extension_types |) ]
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              M.read (|
                                M.get_constant (| "spl_token_2022::state::PackedSizeOf::SIZE_OF" |)
                              |)
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let extension_size :=
                          M.copy (|
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::Try",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      [
                                        Ty.path "usize";
                                        Ty.path "solana_program::program_error::ProgramError"
                                      ],
                                    [],
                                    "branch",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.path "spl_token_2022::extension::ExtensionType",
                                        "try_get_total_tlv_len",
                                        []
                                      |),
                                      [ M.read (| extension_types |) ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Break",
                                        0
                                      |) in
                                    let residual := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::try_trait::FromResidual",
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "usize";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ],
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.path "core::convert::Infallible";
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ]
                                                ],
                                                "from_residual",
                                                []
                                              |),
                                              [ M.read (| residual |) ]
                                            |)
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::ops::control_flow::ControlFlow::Continue",
                                        0
                                      |) in
                                    let val := M.copy (| γ0_0 |) in
                                    val))
                              ]
                            |)
                          |) in
                        let total_len :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (| Ty.path "usize", "saturating_add", [] |),
                              [
                                M.read (| extension_size |);
                                M.read (|
                                  M.get_constant (|
                                    "spl_token_2022::extension::BASE_ACCOUNT_AND_TYPE_LENGTH"
                                  |)
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              M.call_closure (|
                                M.get_function (|
                                  "spl_token_2022::extension::adjust_len_for_multisig",
                                  []
                                |),
                                [ M.read (| total_len |) ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_try_calculate_account_len :
      M.IsAssociatedFunction Self "try_calculate_account_len" try_calculate_account_len.
    
    (*
        pub fn get_account_type(&self) -> AccountType {
            match self {
                ExtensionType::Uninitialized => AccountType::Uninitialized,
                ExtensionType::TransferFeeConfig
                | ExtensionType::MintCloseAuthority
                | ExtensionType::ConfidentialTransferMint
                | ExtensionType::DefaultAccountState
                | ExtensionType::NonTransferable
                | ExtensionType::InterestBearingConfig
                | ExtensionType::PermanentDelegate
                | ExtensionType::TransferHook
                | ExtensionType::ConfidentialTransferFeeConfig
                | ExtensionType::MetadataPointer
                | ExtensionType::TokenMetadata
                | ExtensionType::GroupPointer
                | ExtensionType::TokenGroup
                | ExtensionType::GroupMemberPointer
                | ExtensionType::TokenGroupMember => AccountType::Mint,
                ExtensionType::ImmutableOwner
                | ExtensionType::TransferFeeAmount
                | ExtensionType::ConfidentialTransferAccount
                | ExtensionType::MemoTransfer
                | ExtensionType::NonTransferableAccount
                | ExtensionType::TransferHookAccount
                | ExtensionType::CpiGuard
                | ExtensionType::ConfidentialTransferFeeAmount => AccountType::Account,
                #[cfg(test)]
                ExtensionType::VariableLenMintTest => AccountType::Mint,
                #[cfg(test)]
                ExtensionType::AccountPaddingTest => AccountType::Account,
                #[cfg(test)]
                ExtensionType::MintPaddingTest => AccountType::Mint,
            }
        }
    *)
    Definition get_account_type (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.match_operator (|
              self,
              [
                fun γ =>
                  ltac:(M.monadic
                    (let γ := M.read (| γ |) in
                    M.alloc (|
                      Value.StructTuple "spl_token_2022::extension::AccountType::Uninitialized" []
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (M.find_or_pattern (|
                      γ,
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []))
                      ],
                      M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [] =>
                              M.alloc (|
                                Value.StructTuple "spl_token_2022::extension::AccountType::Mint" []
                              |)
                            | _ => M.impossible (||)
                            end))
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (M.find_or_pattern (|
                      γ,
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.read (| γ |) in
                            Value.Tuple []))
                      ],
                      M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [] =>
                              M.alloc (|
                                Value.StructTuple
                                  "spl_token_2022::extension::AccountType::Account"
                                  []
                              |)
                            | _ => M.impossible (||)
                            end))
                    |)))
              ]
            |)
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_get_account_type :
      M.IsAssociatedFunction Self "get_account_type" get_account_type.
    
    (*
        pub fn get_required_init_account_extensions(mint_extension_types: &[Self]) -> Vec<Self> {
            let mut account_extension_types = vec![];
            for extension_type in mint_extension_types {
                match extension_type {
                    ExtensionType::TransferFeeConfig => {
                        account_extension_types.push(ExtensionType::TransferFeeAmount);
                    }
                    ExtensionType::NonTransferable => {
                        account_extension_types.push(ExtensionType::NonTransferableAccount);
                        account_extension_types.push(ExtensionType::ImmutableOwner);
                    }
                    ExtensionType::TransferHook => {
                        account_extension_types.push(ExtensionType::TransferHookAccount);
                    }
                    #[cfg(test)]
                    ExtensionType::MintPaddingTest => {
                        account_extension_types.push(ExtensionType::AccountPaddingTest);
                    }
                    _ => {}
                }
            }
            account_extension_types
        }
    *)
    Definition get_required_init_account_extensions (τ : list Ty.t) (α : list Value.t) : M :=
      match τ, α with
      | [], [ mint_extension_types ] =>
        ltac:(M.monadic
          (let mint_extension_types := M.alloc (| mint_extension_types |) in
          M.read (|
            let account_extension_types :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "alloc::vec::Vec")
                      [
                        Ty.path "spl_token_2022::extension::ExtensionType";
                        Ty.path "alloc::alloc::Global"
                      ],
                    "new",
                    []
                  |),
                  []
                |)
              |) in
            let _ :=
              M.use
                (M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::collect::IntoIterator",
                        Ty.apply
                          (Ty.path "&")
                          [
                            Ty.apply
                              (Ty.path "slice")
                              [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                          ],
                        [],
                        "into_iter",
                        []
                      |),
                      [ M.read (| mint_extension_types |) ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let iter := M.copy (| γ |) in
                        M.loop (|
                          ltac:(M.monadic
                            (let _ :=
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::iter::traits::iterator::Iterator",
                                      Ty.apply
                                        (Ty.path "core::slice::iter::Iter")
                                        [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                                      [],
                                      "next",
                                      []
                                    |),
                                    [ iter ]
                                  |)
                                |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (M.alloc (|
                                        M.never_to_any (| M.read (| M.break (||) |) |)
                                      |)));
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::option::Option::Some",
                                          0
                                        |) in
                                      let extension_type := M.copy (| γ0_0 |) in
                                      M.match_operator (|
                                        extension_type,
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ := M.read (| γ |) in
                                              let _ :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path "alloc::vec::Vec")
                                                        [
                                                          Ty.path
                                                            "spl_token_2022::extension::ExtensionType";
                                                          Ty.path "alloc::alloc::Global"
                                                        ],
                                                      "push",
                                                      []
                                                    |),
                                                    [
                                                      account_extension_types;
                                                      Value.StructTuple
                                                        "spl_token_2022::extension::ExtensionType::TransferFeeAmount"
                                                        []
                                                    ]
                                                  |)
                                                |) in
                                              M.alloc (| Value.Tuple [] |)));
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ := M.read (| γ |) in
                                              let _ :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path "alloc::vec::Vec")
                                                        [
                                                          Ty.path
                                                            "spl_token_2022::extension::ExtensionType";
                                                          Ty.path "alloc::alloc::Global"
                                                        ],
                                                      "push",
                                                      []
                                                    |),
                                                    [
                                                      account_extension_types;
                                                      Value.StructTuple
                                                        "spl_token_2022::extension::ExtensionType::NonTransferableAccount"
                                                        []
                                                    ]
                                                  |)
                                                |) in
                                              let _ :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path "alloc::vec::Vec")
                                                        [
                                                          Ty.path
                                                            "spl_token_2022::extension::ExtensionType";
                                                          Ty.path "alloc::alloc::Global"
                                                        ],
                                                      "push",
                                                      []
                                                    |),
                                                    [
                                                      account_extension_types;
                                                      Value.StructTuple
                                                        "spl_token_2022::extension::ExtensionType::ImmutableOwner"
                                                        []
                                                    ]
                                                  |)
                                                |) in
                                              M.alloc (| Value.Tuple [] |)));
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ := M.read (| γ |) in
                                              let _ :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path "alloc::vec::Vec")
                                                        [
                                                          Ty.path
                                                            "spl_token_2022::extension::ExtensionType";
                                                          Ty.path "alloc::alloc::Global"
                                                        ],
                                                      "push",
                                                      []
                                                    |),
                                                    [
                                                      account_extension_types;
                                                      Value.StructTuple
                                                        "spl_token_2022::extension::ExtensionType::TransferHookAccount"
                                                        []
                                                    ]
                                                  |)
                                                |) in
                                              M.alloc (| Value.Tuple [] |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |)))
                                ]
                              |) in
                            M.alloc (| Value.Tuple [] |)))
                        |)))
                  ]
                |)) in
            account_extension_types
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_get_required_init_account_extensions :
      M.IsAssociatedFunction
        Self
        "get_required_init_account_extensions"
        get_required_init_account_extensions.
    
    (*
        pub fn check_for_invalid_mint_extension_combinations(
            mint_extension_types: &[Self],
        ) -> Result<(), TokenError> {
            let mut transfer_fee_config = false;
            let mut confidential_transfer_mint = false;
            let mut confidential_transfer_fee_config = false;
    
            for extension_type in mint_extension_types {
                match extension_type {
                    ExtensionType::TransferFeeConfig => transfer_fee_config = true,
                    ExtensionType::ConfidentialTransferMint => confidential_transfer_mint = true,
                    ExtensionType::ConfidentialTransferFeeConfig => {
                        confidential_transfer_fee_config = true
                    }
                    _ => (),
                }
            }
    
            if confidential_transfer_fee_config && !(transfer_fee_config && confidential_transfer_mint)
            {
                return Err(TokenError::InvalidExtensionCombination);
            }
    
            if transfer_fee_config && confidential_transfer_mint && !confidential_transfer_fee_config {
                return Err(TokenError::InvalidExtensionCombination);
            }
    
            Ok(())
        }
    *)
    Definition check_for_invalid_mint_extension_combinations
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      match τ, α with
      | [], [ mint_extension_types ] =>
        ltac:(M.monadic
          (let mint_extension_types := M.alloc (| mint_extension_types |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let transfer_fee_config := M.alloc (| Value.Bool false |) in
                let confidential_transfer_mint := M.alloc (| Value.Bool false |) in
                let confidential_transfer_fee_config := M.alloc (| Value.Bool false |) in
                let _ :=
                  M.use
                    (M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::collect::IntoIterator",
                            Ty.apply
                              (Ty.path "&")
                              [
                                Ty.apply
                                  (Ty.path "slice")
                                  [ Ty.path "spl_token_2022::extension::ExtensionType" ]
                              ],
                            [],
                            "into_iter",
                            []
                          |),
                          [ M.read (| mint_extension_types |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let iter := M.copy (| γ |) in
                            M.loop (|
                              ltac:(M.monadic
                                (let _ :=
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::iter::traits::iterator::Iterator",
                                          Ty.apply
                                            (Ty.path "core::slice::iter::Iter")
                                            [ Ty.path "spl_token_2022::extension::ExtensionType" ],
                                          [],
                                          "next",
                                          []
                                        |),
                                        [ iter ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (M.alloc (|
                                            M.never_to_any (| M.read (| M.break (||) |) |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::option::Option::Some",
                                              0
                                            |) in
                                          let extension_type := M.copy (| γ0_0 |) in
                                          M.match_operator (|
                                            extension_type,
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ := M.read (| γ |) in
                                                  M.write (|
                                                    transfer_fee_config,
                                                    Value.Bool true
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ := M.read (| γ |) in
                                                  M.write (|
                                                    confidential_transfer_mint,
                                                    Value.Bool true
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ := M.read (| γ |) in
                                                  M.write (|
                                                    confidential_transfer_fee_config,
                                                    Value.Bool true
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                            ]
                                          |)))
                                    ]
                                  |) in
                                M.alloc (| Value.Tuple [] |)))
                            |)))
                      ]
                    |)) in
                let _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                LogicalOp.and (|
                                  M.read (| confidential_transfer_fee_config |),
                                  ltac:(M.monadic
                                    (UnOp.Pure.not
                                      (LogicalOp.and (|
                                        M.read (| transfer_fee_config |),
                                        ltac:(M.monadic (M.read (| confidential_transfer_mint |)))
                                      |))))
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  Value.StructTuple
                                    "core::result::Result::Err"
                                    [
                                      Value.StructTuple
                                        "spl_token_2022::error::TokenError::InvalidExtensionCombination"
                                        []
                                    ]
                                |)
                              |)
                            |)
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                let _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                LogicalOp.and (|
                                  LogicalOp.and (|
                                    M.read (| transfer_fee_config |),
                                    ltac:(M.monadic (M.read (| confidential_transfer_mint |)))
                                  |),
                                  ltac:(M.monadic
                                    (UnOp.Pure.not (M.read (| confidential_transfer_fee_config |))))
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  Value.StructTuple
                                    "core::result::Result::Err"
                                    [
                                      Value.StructTuple
                                        "spl_token_2022::error::TokenError::InvalidExtensionCombination"
                                        []
                                    ]
                                |)
                              |)
                            |)
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
              |)))
          |)))
      | _, _ => M.impossible
      end.
    
    Axiom AssociatedFunction_check_for_invalid_mint_extension_combinations :
      M.IsAssociatedFunction
        Self
        "check_for_invalid_mint_extension_combinations"
        check_for_invalid_mint_extension_combinations.
  End Impl_spl_token_2022_extension_ExtensionType.
  
  (* Trait *)
  (* Empty module 'BaseState' *)
  
  Module Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_state_Account.
    Definition Self : Ty.t := Ty.path "spl_token_2022::state::Account".
    
    (*     const ACCOUNT_TYPE: AccountType = AccountType::Account; *)
    (* Ty.path "spl_token_2022::extension::AccountType" *)
    Definition value_ACCOUNT_TYPE : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (| Value.StructTuple "spl_token_2022::extension::AccountType::Account" [] |))).
    
    Axiom Implements :
      M.IsTraitInstance
        "spl_token_2022::extension::BaseState"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("value_ACCOUNT_TYPE", InstanceField.Constant value_ACCOUNT_TYPE) ].
  End Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_state_Account.
  
  Module Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_state_Mint.
    Definition Self : Ty.t := Ty.path "spl_token_2022::state::Mint".
    
    (*     const ACCOUNT_TYPE: AccountType = AccountType::Mint; *)
    (* Ty.path "spl_token_2022::extension::AccountType" *)
    Definition value_ACCOUNT_TYPE : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (| Value.StructTuple "spl_token_2022::extension::AccountType::Mint" [] |))).
    
    Axiom Implements :
      M.IsTraitInstance
        "spl_token_2022::extension::BaseState"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("value_ACCOUNT_TYPE", InstanceField.Constant value_ACCOUNT_TYPE) ].
  End Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_state_Mint.
  
  Module Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_pod_PodAccount.
    Definition Self : Ty.t := Ty.path "spl_token_2022::pod::PodAccount".
    
    (*     const ACCOUNT_TYPE: AccountType = AccountType::Account; *)
    (* Ty.path "spl_token_2022::extension::AccountType" *)
    Definition value_ACCOUNT_TYPE : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (| Value.StructTuple "spl_token_2022::extension::AccountType::Account" [] |))).
    
    Axiom Implements :
      M.IsTraitInstance
        "spl_token_2022::extension::BaseState"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("value_ACCOUNT_TYPE", InstanceField.Constant value_ACCOUNT_TYPE) ].
  End Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_pod_PodAccount.
  
  Module Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_pod_PodMint.
    Definition Self : Ty.t := Ty.path "spl_token_2022::pod::PodMint".
    
    (*     const ACCOUNT_TYPE: AccountType = AccountType::Mint; *)
    (* Ty.path "spl_token_2022::extension::AccountType" *)
    Definition value_ACCOUNT_TYPE : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (| Value.StructTuple "spl_token_2022::extension::AccountType::Mint" [] |))).
    
    Axiom Implements :
      M.IsTraitInstance
        "spl_token_2022::extension::BaseState"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("value_ACCOUNT_TYPE", InstanceField.Constant value_ACCOUNT_TYPE) ].
  End Impl_spl_token_2022_extension_BaseState_for_spl_token_2022_pod_PodMint.
  
  (* Trait *)
  (* Empty module 'Extension' *)
  
  (*
  pub(crate) fn alloc_and_serialize<S: BaseState + Pod, V: Default + Extension + Pod>(
      account_info: &AccountInfo,
      new_extension: &V,
      overwrite: bool,
  ) -> Result<(), ProgramError> {
      let previous_account_len = account_info.try_data_len()?;
      let new_account_len = {
          let data = account_info.try_borrow_data()?;
          let state = PodStateWithExtensions::<S>::unpack(&data)?;
          state.try_get_new_account_len::<V>()?
      };
  
      // Realloc the account first, if needed
      if new_account_len > previous_account_len {
          account_info.realloc(new_account_len, false)?;
      }
      let mut buffer = account_info.try_borrow_mut_data()?;
      if previous_account_len <= BASE_ACCOUNT_LENGTH {
          set_account_type::<S>( *buffer)?;
      }
      let mut state = PodStateWithExtensionsMut::<S>::unpack(&mut buffer)?;
  
      // Write the extension
      let extension = state.init_extension::<V>(overwrite)?;
      *extension = *new_extension;
  
      Ok(())
  }
  *)
  Definition alloc_and_serialize (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S; V ], [ account_info; new_extension; overwrite ] =>
      ltac:(M.monadic
        (let account_info := M.alloc (| account_info |) in
        let new_extension := M.alloc (| new_extension |) in
        let overwrite := M.alloc (| overwrite |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let previous_account_len :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.path "solana_program::account_info::AccountInfo",
                              "try_data_len",
                              []
                            |),
                            [ M.read (| account_info |) ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.tuple [];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let new_account_len :=
                M.copy (|
                  let data :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "core::cell::Ref")
                                    [
                                      Ty.apply
                                        (Ty.path "&mut")
                                        [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                    ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.path "solana_program::account_info::AccountInfo",
                                  "try_borrow_data",
                                  []
                                |),
                                [ M.read (| account_info |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let state :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensions")
                                    [ S ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensions")
                                    [ S ],
                                  "unpack",
                                  []
                                |),
                                [
                                  M.read (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::deref::Deref",
                                        Ty.apply
                                          (Ty.path "core::cell::Ref")
                                          [
                                            Ty.apply
                                              (Ty.path "&mut")
                                              [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                          ],
                                        [],
                                        "deref",
                                        []
                                      |),
                                      [ data ]
                                    |)
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "spl_token_2022::extension::BaseStateWithExtensions",
                              Ty.apply
                                (Ty.path "spl_token_2022::extension::PodStateWithExtensions")
                                [ S ],
                              [ S ],
                              "try_get_new_account_len",
                              [ V ]
                            |),
                            [ state ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.tuple [];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.Pure.gt
                                (M.read (| new_account_len |))
                                (M.read (| previous_account_len |))
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.tuple [];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "solana_program::account_info::AccountInfo",
                                      "realloc",
                                      []
                                    |),
                                    [
                                      M.read (| account_info |);
                                      M.read (| new_account_len |);
                                      Value.Bool false
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.tuple [];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let buffer :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [
                              Ty.apply
                                (Ty.path "core::cell::RefMut")
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                ];
                              Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.path "solana_program::account_info::AccountInfo",
                              "try_borrow_mut_data",
                              []
                            |),
                            [ M.read (| account_info |) ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.tuple [];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.Pure.le
                                (M.read (| previous_account_len |))
                                (M.read (|
                                  M.get_constant (|
                                    "spl_token_2022::extension::BASE_ACCOUNT_LENGTH"
                                  |)
                                |))
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        let _ :=
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.tuple [];
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_function (|
                                      "spl_token_2022::extension::set_account_type",
                                      [ S ]
                                    |),
                                    [
                                      M.read (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::deref::DerefMut",
                                            Ty.apply
                                              (Ty.path "core::cell::RefMut")
                                              [
                                                Ty.apply
                                                  (Ty.path "&mut")
                                                  [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                              ],
                                            [],
                                            "deref_mut",
                                            []
                                          |),
                                          [ buffer ]
                                        |)
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.tuple [];
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let state :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [
                              Ty.apply
                                (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                [ S ];
                              Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                [ S ],
                              "unpack",
                              []
                            |),
                            [
                              M.read (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::deref::DerefMut",
                                    Ty.apply
                                      (Ty.path "core::cell::RefMut")
                                      [
                                        Ty.apply
                                          (Ty.path "&mut")
                                          [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                      ],
                                    [],
                                    "deref_mut",
                                    []
                                  |),
                                  [ buffer ]
                                |)
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.tuple [];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let extension :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [
                              Ty.apply (Ty.path "&mut") [ V ];
                              Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "spl_token_2022::extension::BaseStateWithExtensionsMut",
                              Ty.apply
                                (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                [ S ],
                              [ S ],
                              "init_extension",
                              [ V ]
                            |),
                            [ state; M.read (| overwrite |) ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.tuple [];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let _ :=
                M.write (| M.read (| extension |), M.read (| M.read (| new_extension |) |) |) in
              M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
  
  (*
  pub(crate) fn alloc_and_serialize_variable_len_extension<
      S: BaseState + Pod,
      V: Extension + VariableLenPack,
  >(
      account_info: &AccountInfo,
      new_extension: &V,
      overwrite: bool,
  ) -> Result<(), ProgramError> {
      let previous_account_len = account_info.try_data_len()?;
      let (new_account_len, extension_already_exists) = {
          let data = account_info.try_borrow_data()?;
          let state = PodStateWithExtensions::<S>::unpack(&data)?;
          let new_account_len =
              state.try_get_new_account_len_for_variable_len_extension(new_extension)?;
          let extension_already_exists = state.get_extension_bytes::<V>().is_ok();
          (new_account_len, extension_already_exists)
      };
  
      if extension_already_exists && !overwrite {
          return Err(TokenError::ExtensionAlreadyInitialized.into());
      }
  
      if previous_account_len < new_account_len {
          // account size increased, so realloc the account, then the TLV entry, then
          // write data
          account_info.realloc(new_account_len, false)?;
          let mut buffer = account_info.try_borrow_mut_data()?;
          if extension_already_exists {
              let mut state = PodStateWithExtensionsMut::<S>::unpack(&mut buffer)?;
              state.realloc_variable_len_extension(new_extension)?;
          } else {
              if previous_account_len <= BASE_ACCOUNT_LENGTH {
                  set_account_type::<S>( *buffer)?;
              }
              // now alloc in the TLV buffer and write the data
              let mut state = PodStateWithExtensionsMut::<S>::unpack(&mut buffer)?;
              state.init_variable_len_extension(new_extension, false)?;
          }
      } else {
          // do it backwards otherwise, write the state, realloc TLV, then the account
          let mut buffer = account_info.try_borrow_mut_data()?;
          let mut state = PodStateWithExtensionsMut::<S>::unpack(&mut buffer)?;
          if extension_already_exists {
              state.realloc_variable_len_extension(new_extension)?;
          } else {
              // this situation can happen if we have an overallocated buffer
              state.init_variable_len_extension(new_extension, false)?;
          }
  
          let removed_bytes = previous_account_len
              .checked_sub(new_account_len)
              .ok_or(ProgramError::AccountDataTooSmall)?;
          if removed_bytes > 0 {
              // this is probably fine, but be safe and avoid invalidating references
              drop(buffer);
              account_info.realloc(new_account_len, false)?;
          }
      }
      Ok(())
  }
  *)
  Definition alloc_and_serialize_variable_len_extension (τ : list Ty.t) (α : list Value.t) : M :=
    match τ, α with
    | [ _ as S; V ], [ account_info; new_extension; overwrite ] =>
      ltac:(M.monadic
        (let account_info := M.alloc (| account_info |) in
        let new_extension := M.alloc (| new_extension |) in
        let overwrite := M.alloc (| overwrite |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let previous_account_len :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            [ Ty.path "usize"; Ty.path "solana_program::program_error::ProgramError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.path "solana_program::account_info::AccountInfo",
                              "try_data_len",
                              []
                            |),
                            [ M.read (| account_info |) ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        [
                                          Ty.tuple [];
                                          Ty.path "solana_program::program_error::ProgramError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              M.match_operator (|
                let data :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "core::cell::Ref")
                                  [
                                    Ty.apply
                                      (Ty.path "&mut")
                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                  ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "solana_program::account_info::AccountInfo",
                                "try_borrow_data",
                                []
                              |),
                              [ M.read (| account_info |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                let state :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.apply
                                  (Ty.path "spl_token_2022::extension::PodStateWithExtensions")
                                  [ S ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "spl_token_2022::extension::PodStateWithExtensions")
                                  [ S ],
                                "unpack",
                                []
                              |),
                              [
                                M.read (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::Deref",
                                      Ty.apply
                                        (Ty.path "core::cell::Ref")
                                        [
                                          Ty.apply
                                            (Ty.path "&mut")
                                            [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                        ],
                                      [],
                                      "deref",
                                      []
                                    |),
                                    [ data ]
                                  |)
                                |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                let new_account_len :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.path "usize";
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "spl_token_2022::extension::BaseStateWithExtensions",
                                Ty.apply
                                  (Ty.path "spl_token_2022::extension::PodStateWithExtensions")
                                  [ S ],
                                [ S ],
                                "try_get_new_account_len_for_variable_len_extension",
                                [ V ]
                              |),
                              [ state; M.read (| new_extension |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |)
                  |) in
                let extension_already_exists :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::result::Result")
                          [
                            Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ];
                            Ty.path "solana_program::program_error::ProgramError"
                          ],
                        "is_ok",
                        []
                      |),
                      [
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "spl_token_2022::extension::BaseStateWithExtensions",
                              Ty.apply
                                (Ty.path "spl_token_2022::extension::PodStateWithExtensions")
                                [ S ],
                              [ S ],
                              "get_extension_bytes",
                              [ V ]
                            |),
                            [ state ]
                          |)
                        |)
                      ]
                    |)
                  |) in
                M.alloc (|
                  Value.Tuple
                    [ M.read (| new_account_len |); M.read (| extension_already_exists |) ]
                |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                      let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                      let new_account_len := M.copy (| γ0_0 |) in
                      let extension_already_exists := M.copy (| γ0_1 |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      LogicalOp.and (|
                                        M.read (| extension_already_exists |),
                                        ltac:(M.monadic (UnOp.Pure.not (M.read (| overwrite |))))
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructTuple
                                          "core::result::Result::Err"
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::convert::Into",
                                                Ty.path "spl_token_2022::error::TokenError",
                                                [
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                                "into",
                                                []
                                              |),
                                              [
                                                Value.StructTuple
                                                  "spl_token_2022::error::TokenError::ExtensionAlreadyInitialized"
                                                  []
                                              ]
                                            |)
                                          ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      let _ :=
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      BinOp.Pure.lt
                                        (M.read (| previous_account_len |))
                                        (M.read (| new_account_len |))
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                let _ :=
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::Try",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [],
                                          "branch",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "solana_program::account_info::AccountInfo",
                                              "realloc",
                                              []
                                            |),
                                            [
                                              M.read (| account_info |);
                                              M.read (| new_account_len |);
                                              Value.Bool false
                                            ]
                                          |)
                                        ]
                                      |)
                                    |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Break",
                                              0
                                            |) in
                                          let residual := M.copy (| γ0_0 |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (|
                                                M.return_ (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::FromResidual",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        [
                                                          Ty.tuple [];
                                                          Ty.path
                                                            "solana_program::program_error::ProgramError"
                                                        ],
                                                      [
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.path "core::convert::Infallible";
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ]
                                                      ],
                                                      "from_residual",
                                                      []
                                                    |),
                                                    [ M.read (| residual |) ]
                                                  |)
                                                |)
                                              |)
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ0_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::ops::control_flow::ControlFlow::Continue",
                                              0
                                            |) in
                                          let val := M.copy (| γ0_0 |) in
                                          val))
                                    ]
                                  |) in
                                let buffer :=
                                  M.copy (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.apply
                                                  (Ty.path "core::cell::RefMut")
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ]
                                                  ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.path "solana_program::account_info::AccountInfo",
                                                "try_borrow_mut_data",
                                                []
                                              |),
                                              [ M.read (| account_info |) ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.tuple [];
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            [
                                                              Ty.path "core::convert::Infallible";
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ]
                                                        ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |) in
                                M.match_operator (|
                                  M.alloc (| Value.Tuple [] |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ := M.use extension_already_exists in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        let state :=
                                          M.copy (|
                                            M.match_operator (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::Try",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.apply
                                                          (Ty.path
                                                            "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                          [ S ];
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [],
                                                    "branch",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.apply
                                                          (Ty.path
                                                            "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                          [ S ],
                                                        "unpack",
                                                        []
                                                      |),
                                                      [
                                                        M.read (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::deref::DerefMut",
                                                              Ty.apply
                                                                (Ty.path "core::cell::RefMut")
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "&mut")
                                                                    [
                                                                      Ty.apply
                                                                        (Ty.path "slice")
                                                                        [ Ty.path "u8" ]
                                                                    ]
                                                                ],
                                                              [],
                                                              "deref_mut",
                                                              []
                                                            |),
                                                            [ buffer ]
                                                          |)
                                                        |)
                                                      ]
                                                    |)
                                                  ]
                                                |)
                                              |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Break",
                                                        0
                                                      |) in
                                                    let residual := M.copy (| γ0_0 |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::FromResidual",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.tuple [];
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ],
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "core::result::Result")
                                                                    [
                                                                      Ty.path
                                                                        "core::convert::Infallible";
                                                                      Ty.path
                                                                        "solana_program::program_error::ProgramError"
                                                                    ]
                                                                ],
                                                                "from_residual",
                                                                []
                                                              |),
                                                              [ M.read (| residual |) ]
                                                            |)
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Continue",
                                                        0
                                                      |) in
                                                    let val := M.copy (| γ0_0 |) in
                                                    val))
                                              ]
                                            |)
                                          |) in
                                        let _ :=
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::Try",
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.tuple [];
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ],
                                                  [],
                                                  "branch",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                                      Ty.apply
                                                        (Ty.path
                                                          "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                        [ S ],
                                                      [ S ],
                                                      "realloc_variable_len_extension",
                                                      [ V ]
                                                    |),
                                                    [ state; M.read (| new_extension |) ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Break",
                                                      0
                                                    |) in
                                                  let residual := M.copy (| γ0_0 |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.read (|
                                                        M.return_ (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::try_trait::FromResidual",
                                                              Ty.apply
                                                                (Ty.path "core::result::Result")
                                                                [
                                                                  Ty.tuple [];
                                                                  Ty.path
                                                                    "solana_program::program_error::ProgramError"
                                                                ],
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.path
                                                                      "core::convert::Infallible";
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ]
                                                              ],
                                                              "from_residual",
                                                              []
                                                            |),
                                                            [ M.read (| residual |) ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Continue",
                                                      0
                                                    |) in
                                                  let val := M.copy (| γ0_0 |) in
                                                  val))
                                            ]
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let _ :=
                                          M.match_operator (|
                                            M.alloc (| Value.Tuple [] |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ :=
                                                    M.use
                                                      (M.alloc (|
                                                        BinOp.Pure.le
                                                          (M.read (| previous_account_len |))
                                                          (M.read (|
                                                            M.get_constant (|
                                                              "spl_token_2022::extension::BASE_ACCOUNT_LENGTH"
                                                            |)
                                                          |))
                                                      |)) in
                                                  let _ :=
                                                    M.is_constant_or_break_match (|
                                                      M.read (| γ |),
                                                      Value.Bool true
                                                    |) in
                                                  let _ :=
                                                    M.match_operator (|
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::try_trait::Try",
                                                            Ty.apply
                                                              (Ty.path "core::result::Result")
                                                              [
                                                                Ty.tuple [];
                                                                Ty.path
                                                                  "solana_program::program_error::ProgramError"
                                                              ],
                                                            [],
                                                            "branch",
                                                            []
                                                          |),
                                                          [
                                                            M.call_closure (|
                                                              M.get_function (|
                                                                "spl_token_2022::extension::set_account_type",
                                                                [ S ]
                                                              |),
                                                              [
                                                                M.read (|
                                                                  M.call_closure (|
                                                                    M.get_trait_method (|
                                                                      "core::ops::deref::DerefMut",
                                                                      Ty.apply
                                                                        (Ty.path
                                                                          "core::cell::RefMut")
                                                                        [
                                                                          Ty.apply
                                                                            (Ty.path "&mut")
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path "slice")
                                                                                [ Ty.path "u8" ]
                                                                            ]
                                                                        ],
                                                                      [],
                                                                      "deref_mut",
                                                                      []
                                                                    |),
                                                                    [ buffer ]
                                                                  |)
                                                                |)
                                                              ]
                                                            |)
                                                          ]
                                                        |)
                                                      |),
                                                      [
                                                        fun γ =>
                                                          ltac:(M.monadic
                                                            (let γ0_0 :=
                                                              M.SubPointer.get_struct_tuple_field (|
                                                                γ,
                                                                "core::ops::control_flow::ControlFlow::Break",
                                                                0
                                                              |) in
                                                            let residual := M.copy (| γ0_0 |) in
                                                            M.alloc (|
                                                              M.never_to_any (|
                                                                M.read (|
                                                                  M.return_ (|
                                                                    M.call_closure (|
                                                                      M.get_trait_method (|
                                                                        "core::ops::try_trait::FromResidual",
                                                                        Ty.apply
                                                                          (Ty.path
                                                                            "core::result::Result")
                                                                          [
                                                                            Ty.tuple [];
                                                                            Ty.path
                                                                              "solana_program::program_error::ProgramError"
                                                                          ],
                                                                        [
                                                                          Ty.apply
                                                                            (Ty.path
                                                                              "core::result::Result")
                                                                            [
                                                                              Ty.path
                                                                                "core::convert::Infallible";
                                                                              Ty.path
                                                                                "solana_program::program_error::ProgramError"
                                                                            ]
                                                                        ],
                                                                        "from_residual",
                                                                        []
                                                                      |),
                                                                      [ M.read (| residual |) ]
                                                                    |)
                                                                  |)
                                                                |)
                                                              |)
                                                            |)));
                                                        fun γ =>
                                                          ltac:(M.monadic
                                                            (let γ0_0 :=
                                                              M.SubPointer.get_struct_tuple_field (|
                                                                γ,
                                                                "core::ops::control_flow::ControlFlow::Continue",
                                                                0
                                                              |) in
                                                            let val := M.copy (| γ0_0 |) in
                                                            val))
                                                      ]
                                                    |) in
                                                  M.alloc (| Value.Tuple [] |)));
                                              fun γ =>
                                                ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                            ]
                                          |) in
                                        let state :=
                                          M.copy (|
                                            M.match_operator (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::Try",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.apply
                                                          (Ty.path
                                                            "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                          [ S ];
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [],
                                                    "branch",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.apply
                                                          (Ty.path
                                                            "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                          [ S ],
                                                        "unpack",
                                                        []
                                                      |),
                                                      [
                                                        M.read (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::deref::DerefMut",
                                                              Ty.apply
                                                                (Ty.path "core::cell::RefMut")
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "&mut")
                                                                    [
                                                                      Ty.apply
                                                                        (Ty.path "slice")
                                                                        [ Ty.path "u8" ]
                                                                    ]
                                                                ],
                                                              [],
                                                              "deref_mut",
                                                              []
                                                            |),
                                                            [ buffer ]
                                                          |)
                                                        |)
                                                      ]
                                                    |)
                                                  ]
                                                |)
                                              |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Break",
                                                        0
                                                      |) in
                                                    let residual := M.copy (| γ0_0 |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::FromResidual",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.tuple [];
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ],
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "core::result::Result")
                                                                    [
                                                                      Ty.path
                                                                        "core::convert::Infallible";
                                                                      Ty.path
                                                                        "solana_program::program_error::ProgramError"
                                                                    ]
                                                                ],
                                                                "from_residual",
                                                                []
                                                              |),
                                                              [ M.read (| residual |) ]
                                                            |)
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Continue",
                                                        0
                                                      |) in
                                                    let val := M.copy (| γ0_0 |) in
                                                    val))
                                              ]
                                            |)
                                          |) in
                                        let _ :=
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::Try",
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.tuple [];
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ],
                                                  [],
                                                  "branch",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                                      Ty.apply
                                                        (Ty.path
                                                          "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                        [ S ],
                                                      [ S ],
                                                      "init_variable_len_extension",
                                                      [ V ]
                                                    |),
                                                    [
                                                      state;
                                                      M.read (| new_extension |);
                                                      Value.Bool false
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Break",
                                                      0
                                                    |) in
                                                  let residual := M.copy (| γ0_0 |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.read (|
                                                        M.return_ (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::try_trait::FromResidual",
                                                              Ty.apply
                                                                (Ty.path "core::result::Result")
                                                                [
                                                                  Ty.tuple [];
                                                                  Ty.path
                                                                    "solana_program::program_error::ProgramError"
                                                                ],
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.path
                                                                      "core::convert::Infallible";
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ]
                                                              ],
                                                              "from_residual",
                                                              []
                                                            |),
                                                            [ M.read (| residual |) ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Continue",
                                                      0
                                                    |) in
                                                  let val := M.copy (| γ0_0 |) in
                                                  val))
                                            ]
                                          |) in
                                        M.alloc (| Value.Tuple [] |)))
                                  ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let buffer :=
                                  M.copy (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.apply
                                                  (Ty.path "core::cell::RefMut")
                                                  [
                                                    Ty.apply
                                                      (Ty.path "&mut")
                                                      [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ]
                                                      ]
                                                  ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.path "solana_program::account_info::AccountInfo",
                                                "try_borrow_mut_data",
                                                []
                                              |),
                                              [ M.read (| account_info |) ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.tuple [];
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            [
                                                              Ty.path "core::convert::Infallible";
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ]
                                                        ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |) in
                                let state :=
                                  M.copy (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                  [ S ];
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply
                                                  (Ty.path
                                                    "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                  [ S ],
                                                "unpack",
                                                []
                                              |),
                                              [
                                                M.read (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::deref::DerefMut",
                                                      Ty.apply
                                                        (Ty.path "core::cell::RefMut")
                                                        [
                                                          Ty.apply
                                                            (Ty.path "&mut")
                                                            [
                                                              Ty.apply
                                                                (Ty.path "slice")
                                                                [ Ty.path "u8" ]
                                                            ]
                                                        ],
                                                      [],
                                                      "deref_mut",
                                                      []
                                                    |),
                                                    [ buffer ]
                                                  |)
                                                |)
                                              ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.tuple [];
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            [
                                                              Ty.path "core::convert::Infallible";
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ]
                                                        ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |) in
                                let _ :=
                                  M.match_operator (|
                                    M.alloc (| Value.Tuple [] |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ := M.use extension_already_exists in
                                          let _ :=
                                            M.is_constant_or_break_match (|
                                              M.read (| γ |),
                                              Value.Bool true
                                            |) in
                                          let _ :=
                                            M.match_operator (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::Try",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.tuple [];
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [],
                                                    "branch",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                                        Ty.apply
                                                          (Ty.path
                                                            "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                          [ S ],
                                                        [ S ],
                                                        "realloc_variable_len_extension",
                                                        [ V ]
                                                      |),
                                                      [ state; M.read (| new_extension |) ]
                                                    |)
                                                  ]
                                                |)
                                              |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Break",
                                                        0
                                                      |) in
                                                    let residual := M.copy (| γ0_0 |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::FromResidual",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.tuple [];
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ],
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "core::result::Result")
                                                                    [
                                                                      Ty.path
                                                                        "core::convert::Infallible";
                                                                      Ty.path
                                                                        "solana_program::program_error::ProgramError"
                                                                    ]
                                                                ],
                                                                "from_residual",
                                                                []
                                                              |),
                                                              [ M.read (| residual |) ]
                                                            |)
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Continue",
                                                        0
                                                      |) in
                                                    let val := M.copy (| γ0_0 |) in
                                                    val))
                                              ]
                                            |) in
                                          M.alloc (| Value.Tuple [] |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let _ :=
                                            M.match_operator (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::Try",
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      [
                                                        Ty.tuple [];
                                                        Ty.path
                                                          "solana_program::program_error::ProgramError"
                                                      ],
                                                    [],
                                                    "branch",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                                        Ty.apply
                                                          (Ty.path
                                                            "spl_token_2022::extension::PodStateWithExtensionsMut")
                                                          [ S ],
                                                        [ S ],
                                                        "init_variable_len_extension",
                                                        [ V ]
                                                      |),
                                                      [
                                                        state;
                                                        M.read (| new_extension |);
                                                        Value.Bool false
                                                      ]
                                                    |)
                                                  ]
                                                |)
                                              |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Break",
                                                        0
                                                      |) in
                                                    let residual := M.copy (| γ0_0 |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::FromResidual",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.tuple [];
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ],
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "core::result::Result")
                                                                    [
                                                                      Ty.path
                                                                        "core::convert::Infallible";
                                                                      Ty.path
                                                                        "solana_program::program_error::ProgramError"
                                                                    ]
                                                                ],
                                                                "from_residual",
                                                                []
                                                              |),
                                                              [ M.read (| residual |) ]
                                                            |)
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Continue",
                                                        0
                                                      |) in
                                                    let val := M.copy (| γ0_0 |) in
                                                    val))
                                              ]
                                            |) in
                                          M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |) in
                                let removed_bytes :=
                                  M.copy (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "usize";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ],
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  [ Ty.path "usize" ],
                                                "ok_or",
                                                [
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ]
                                              |),
                                              [
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.path "usize",
                                                    "checked_sub",
                                                    []
                                                  |),
                                                  [
                                                    M.read (| previous_account_len |);
                                                    M.read (| new_account_len |)
                                                  ]
                                                |);
                                                Value.StructTuple
                                                  "solana_program::program_error::ProgramError::AccountDataTooSmall"
                                                  []
                                              ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        Ty.apply
                                                          (Ty.path "core::result::Result")
                                                          [
                                                            Ty.tuple [];
                                                            Ty.path
                                                              "solana_program::program_error::ProgramError"
                                                          ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            [
                                                              Ty.path "core::convert::Infallible";
                                                              Ty.path
                                                                "solana_program::program_error::ProgramError"
                                                            ]
                                                        ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |) in
                                M.match_operator (|
                                  M.alloc (| Value.Tuple [] |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ :=
                                          M.use
                                            (M.alloc (|
                                              BinOp.Pure.gt
                                                (M.read (| removed_bytes |))
                                                (Value.Integer 0)
                                            |)) in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        let _ :=
                                          M.alloc (|
                                            M.call_closure (|
                                              M.get_function (|
                                                "core::mem::drop",
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::cell::RefMut")
                                                    [
                                                      Ty.apply
                                                        (Ty.path "&mut")
                                                        [
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            [ Ty.path "u8" ]
                                                        ]
                                                    ]
                                                ]
                                              |),
                                              [ M.read (| buffer |) ]
                                            |)
                                          |) in
                                        let _ :=
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::Try",
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    [
                                                      Ty.tuple [];
                                                      Ty.path
                                                        "solana_program::program_error::ProgramError"
                                                    ],
                                                  [],
                                                  "branch",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path
                                                        "solana_program::account_info::AccountInfo",
                                                      "realloc",
                                                      []
                                                    |),
                                                    [
                                                      M.read (| account_info |);
                                                      M.read (| new_account_len |);
                                                      Value.Bool false
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Break",
                                                      0
                                                    |) in
                                                  let residual := M.copy (| γ0_0 |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.read (|
                                                        M.return_ (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::try_trait::FromResidual",
                                                              Ty.apply
                                                                (Ty.path "core::result::Result")
                                                                [
                                                                  Ty.tuple [];
                                                                  Ty.path
                                                                    "solana_program::program_error::ProgramError"
                                                                ],
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  [
                                                                    Ty.path
                                                                      "core::convert::Infallible";
                                                                    Ty.path
                                                                      "solana_program::program_error::ProgramError"
                                                                  ]
                                                              ],
                                                              "from_residual",
                                                              []
                                                            |),
                                                            [ M.read (| residual |) ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Continue",
                                                      0
                                                    |) in
                                                  let val := M.copy (| γ0_0 |) in
                                                  val))
                                            ]
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |)))
                          ]
                        |) in
                      M.alloc (|
                        Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                      |)))
                ]
              |)
            |)))
        |)))
    | _, _ => M.impossible
    end.
End extension.
