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

Module extension.
  Module transfer_fee.
    Definition value_MAX_FEE_BASIS_POINTS : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer 10000 |))).
    
    Definition value_ONE_IN_BASIS_POINTS : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            M.rust_cast
              (M.read (|
                M.get_constant (| "spl_token_2022::extension::transfer_fee::MAX_FEE_BASIS_POINTS" |)
              |))
          |))).
    
    (* StructRecord
      {
        name := "TransferFee";
        ty_params := [];
        fields :=
          [
            ("epoch", Ty.path "spl_pod::primitives::PodU64");
            ("maximum_fee", Ty.path "spl_pod::primitives::PodU64");
            ("transfer_fee_basis_points", Ty.path "spl_pod::primitives::PodU16")
          ];
      } *)
    
    Module Impl_core_clone_Clone_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      (* 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.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_transfer_fee_TransferFee.
    
    Module Impl_core_marker_Copy_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::Copy"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_Copy_for_spl_token_2022_extension_transfer_fee_TransferFee.
    
    Module Impl_core_fmt_Debug_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      (* 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 "TransferFee" |);
                M.read (| Value.String "epoch" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::transfer_fee::TransferFee",
                    "epoch"
                  |));
                M.read (| Value.String "maximum_fee" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::transfer_fee::TransferFee",
                    "maximum_fee"
                  |));
                M.read (| Value.String "transfer_fee_basis_points" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.alloc (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::transfer_fee::TransferFee",
                      "transfer_fee_basis_points"
                    |)
                  |))
              ]
            |)))
        | _, _ => 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_transfer_fee_TransferFee.
    
    Module Impl_core_default_Default_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      (* Default *)
      Definition default (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [] =>
          ltac:(M.monadic
            (Value.StructRecord
              "spl_token_2022::extension::transfer_fee::TransferFee"
              [
                ("epoch",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodU64",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("maximum_fee",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodU64",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("transfer_fee_basis_points",
                  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_transfer_fee_TransferFee.
    
    Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::StructuralPartialEq"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_transfer_fee_TransferFee.
    
    Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      (* 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 (|
              LogicalOp.and (|
                M.call_closure (|
                  M.get_trait_method (|
                    "core::cmp::PartialEq",
                    Ty.path "spl_pod::primitives::PodU64",
                    [ Ty.path "spl_pod::primitives::PodU64" ],
                    "eq",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::transfer_fee::TransferFee",
                      "epoch"
                    |);
                    M.SubPointer.get_struct_record_field (|
                      M.read (| other |),
                      "spl_token_2022::extension::transfer_fee::TransferFee",
                      "epoch"
                    |)
                  ]
                |),
                ltac:(M.monadic
                  (M.call_closure (|
                    M.get_trait_method (|
                      "core::cmp::PartialEq",
                      Ty.path "spl_pod::primitives::PodU64",
                      [ Ty.path "spl_pod::primitives::PodU64" ],
                      "eq",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::transfer_fee::TransferFee",
                        "maximum_fee"
                      |);
                      M.SubPointer.get_struct_record_field (|
                        M.read (| other |),
                        "spl_token_2022::extension::transfer_fee::TransferFee",
                        "maximum_fee"
                      |)
                    ]
                  |)))
              |),
              ltac:(M.monadic
                (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_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::transfer_fee::TransferFee",
                      "transfer_fee_basis_points"
                    |);
                    M.SubPointer.get_struct_record_field (|
                      M.read (| other |),
                      "spl_token_2022::extension::transfer_fee::TransferFee",
                      "transfer_fee_basis_points"
                    |)
                  ]
                |)))
            |)))
        | _, _ => 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_transfer_fee_TransferFee.
    
    Module Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::pod::Pod"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_transfer_fee_TransferFee.
    
    Module Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::zeroable::Zeroable"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_transfer_fee_TransferFee.
    
    Module Impl_spl_token_2022_extension_transfer_fee_TransferFee.
      Definition Self : Ty.t := Ty.path "spl_token_2022::extension::transfer_fee::TransferFee".
      
      (*
          fn ceil_div(numerator: u128, denominator: u128) -> Option<u128> {
              numerator
                  .checked_add(denominator)?
                  .checked_sub(1)?
                  .checked_div(denominator)
          }
      *)
      Definition ceil_div (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ numerator; denominator ] =>
          ltac:(M.monadic
            (let numerator := M.alloc (| numerator |) in
            let denominator := M.alloc (| denominator |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.call_closure (|
                  M.get_associated_function (| Ty.path "u128", "checked_div", [] |),
                  [
                    M.read (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply (Ty.path "core::option::Option") [ Ty.path "u128" ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (| Ty.path "u128", "checked_sub", [] |),
                                [
                                  M.read (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.path "u128" ],
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.path "u128",
                                                "checked_add",
                                                []
                                              |),
                                              [ M.read (| numerator |); M.read (| denominator |) ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        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::option::Option")
                                                          [ Ty.path "u128" ],
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::option::Option")
                                                            [ Ty.path "core::convert::Infallible" ]
                                                        ],
                                                        "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))
                                      ]
                                    |)
                                  |);
                                  Value.Integer 1
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          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::option::Option")
                                            [ Ty.path "u128" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "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 (| denominator |)
                  ]
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_ceil_div : M.IsAssociatedFunction Self "ceil_div" ceil_div.
      
      (*
          pub fn calculate_fee(&self, pre_fee_amount: u64) -> Option<u64> {
              let transfer_fee_basis_points = u16::from(self.transfer_fee_basis_points) as u128;
              if transfer_fee_basis_points == 0 || pre_fee_amount == 0 {
                  Some(0)
              } else {
                  let numerator = (pre_fee_amount as u128).checked_mul(transfer_fee_basis_points)?;
                  let raw_fee = Self::ceil_div(numerator, ONE_IN_BASIS_POINTS)?
                      .try_into() // guaranteed to be okay
                      .ok()?;
      
                  Some(cmp::min(raw_fee, u64::from(self.maximum_fee)))
              }
          }
      *)
      Definition calculate_fee (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; pre_fee_amount ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let pre_fee_amount := M.alloc (| pre_fee_amount |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let transfer_fee_basis_points :=
                    M.alloc (|
                      M.rust_cast
                        (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_record_field (|
                                M.read (| self |),
                                "spl_token_2022::extension::transfer_fee::TransferFee",
                                "transfer_fee_basis_points"
                              |)
                            |)
                          ]
                        |))
                    |) in
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                LogicalOp.or (|
                                  BinOp.Pure.eq
                                    (M.read (| transfer_fee_basis_points |))
                                    (Value.Integer 0),
                                  ltac:(M.monadic
                                    (BinOp.Pure.eq (M.read (| pre_fee_amount |)) (Value.Integer 0)))
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            Value.StructTuple "core::option::Option::Some" [ Value.Integer 0 ]
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let numerator :=
                            M.copy (|
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::Try",
                                      Ty.apply (Ty.path "core::option::Option") [ Ty.path "u128" ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "u128",
                                          "checked_mul",
                                          []
                                        |),
                                        [
                                          M.rust_cast (M.read (| pre_fee_amount |));
                                          M.read (| transfer_fee_basis_points |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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::option::Option")
                                                    [ Ty.path "u64" ],
                                                  [
                                                    Ty.apply
                                                      (Ty.path "core::option::Option")
                                                      [ Ty.path "core::convert::Infallible" ]
                                                  ],
                                                  "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 raw_fee :=
                            M.copy (|
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::Try",
                                      Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "u64";
                                              Ty.path "core::num::error::TryFromIntError"
                                            ],
                                          "ok",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::convert::TryInto",
                                              Ty.path "u128",
                                              [ Ty.path "u64" ],
                                              "try_into",
                                              []
                                            |),
                                            [
                                              M.read (|
                                                M.match_operator (|
                                                  M.alloc (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::Try",
                                                        Ty.apply
                                                          (Ty.path "core::option::Option")
                                                          [ Ty.path "u128" ],
                                                        [],
                                                        "branch",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.path
                                                              "spl_token_2022::extension::transfer_fee::TransferFee",
                                                            "ceil_div",
                                                            []
                                                          |),
                                                          [
                                                            M.read (| numerator |);
                                                            M.read (|
                                                              M.get_constant (|
                                                                "spl_token_2022::extension::transfer_fee::ONE_IN_BASIS_POINTS"
                                                              |)
                                                            |)
                                                          ]
                                                        |)
                                                      ]
                                                    |)
                                                  |),
                                                  [
                                                    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::option::Option")
                                                                      [ Ty.path "u64" ],
                                                                    [
                                                                      Ty.apply
                                                                        (Ty.path
                                                                          "core::option::Option")
                                                                        [
                                                                          Ty.path
                                                                            "core::convert::Infallible"
                                                                        ]
                                                                    ],
                                                                    "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::option::Option")
                                                    [ Ty.path "u64" ],
                                                  [
                                                    Ty.apply
                                                      (Ty.path "core::option::Option")
                                                      [ Ty.path "core::convert::Infallible" ]
                                                  ],
                                                  "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::option::Option::Some"
                              [
                                M.call_closure (|
                                  M.get_function (| "core::cmp::min", [ Ty.path "u64" ] |),
                                  [
                                    M.read (| raw_fee |);
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::convert::From",
                                        Ty.path "u64",
                                        [ Ty.path "spl_pod::primitives::PodU64" ],
                                        "from",
                                        []
                                      |),
                                      [
                                        M.read (|
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "spl_token_2022::extension::transfer_fee::TransferFee",
                                            "maximum_fee"
                                          |)
                                        |)
                                      ]
                                    |)
                                  ]
                                |)
                              ]
                          |)))
                    ]
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_calculate_fee :
        M.IsAssociatedFunction Self "calculate_fee" calculate_fee.
      
      (*
          pub fn calculate_post_fee_amount(&self, pre_fee_amount: u64) -> Option<u64> {
              pre_fee_amount.checked_sub(self.calculate_fee(pre_fee_amount)?)
          }
      *)
      Definition calculate_post_fee_amount (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; pre_fee_amount ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let pre_fee_amount := M.alloc (| pre_fee_amount |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.call_closure (|
                  M.get_associated_function (| Ty.path "u64", "checked_sub", [] |),
                  [
                    M.read (| pre_fee_amount |);
                    M.read (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                                  "calculate_fee",
                                  []
                                |),
                                [ M.read (| self |); M.read (| pre_fee_amount |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          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::option::Option")
                                            [ Ty.path "u64" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "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_calculate_post_fee_amount :
        M.IsAssociatedFunction Self "calculate_post_fee_amount" calculate_post_fee_amount.
      
      (*
          pub fn calculate_pre_fee_amount(&self, post_fee_amount: u64) -> Option<u64> {
              let maximum_fee = u64::from(self.maximum_fee);
              let transfer_fee_basis_points = u16::from(self.transfer_fee_basis_points) as u128;
              if transfer_fee_basis_points == 0 {
                  Some(post_fee_amount)
              } else if transfer_fee_basis_points == ONE_IN_BASIS_POINTS || post_fee_amount == 0 {
                  Some(0)
              } else {
                  let numerator = (post_fee_amount as u128).checked_mul(ONE_IN_BASIS_POINTS)?;
                  let denominator = ONE_IN_BASIS_POINTS.checked_sub(transfer_fee_basis_points)?;
                  let raw_pre_fee_amount = Self::ceil_div(numerator, denominator)?;
      
                  if raw_pre_fee_amount.checked_sub(post_fee_amount as u128)? >= maximum_fee as u128 {
                      post_fee_amount.checked_add(maximum_fee)
                  } else {
                      // should return `None` if `pre_fee_amount` overflows
                      u64::try_from(raw_pre_fee_amount).ok()
                  }
              }
          }
      *)
      Definition calculate_pre_fee_amount (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; post_fee_amount ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let post_fee_amount := M.alloc (| post_fee_amount |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let maximum_fee :=
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::convert::From",
                          Ty.path "u64",
                          [ Ty.path "spl_pod::primitives::PodU64" ],
                          "from",
                          []
                        |),
                        [
                          M.read (|
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "spl_token_2022::extension::transfer_fee::TransferFee",
                              "maximum_fee"
                            |)
                          |)
                        ]
                      |)
                    |) in
                  let transfer_fee_basis_points :=
                    M.alloc (|
                      M.rust_cast
                        (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_record_field (|
                                M.read (| self |),
                                "spl_token_2022::extension::transfer_fee::TransferFee",
                                "transfer_fee_basis_points"
                              |)
                            |)
                          ]
                        |))
                    |) in
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                BinOp.Pure.eq
                                  (M.read (| transfer_fee_basis_points |))
                                  (Value.Integer 0)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            Value.StructTuple
                              "core::option::Option::Some"
                              [ M.read (| post_fee_amount |) ]
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.use
                                      (M.alloc (|
                                        LogicalOp.or (|
                                          BinOp.Pure.eq
                                            (M.read (| transfer_fee_basis_points |))
                                            (M.read (|
                                              M.get_constant (|
                                                "spl_token_2022::extension::transfer_fee::ONE_IN_BASIS_POINTS"
                                              |)
                                            |)),
                                          ltac:(M.monadic
                                            (BinOp.Pure.eq
                                              (M.read (| post_fee_amount |))
                                              (Value.Integer 0)))
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    Value.StructTuple
                                      "core::option::Option::Some"
                                      [ Value.Integer 0 ]
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let numerator :=
                                    M.copy (|
                                      M.match_operator (|
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::Try",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "u128" ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.path "u128",
                                                  "checked_mul",
                                                  []
                                                |),
                                                [
                                                  M.rust_cast (M.read (| post_fee_amount |));
                                                  M.read (|
                                                    M.get_constant (|
                                                      "spl_token_2022::extension::transfer_fee::ONE_IN_BASIS_POINTS"
                                                    |)
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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::option::Option")
                                                            [ Ty.path "u64" ],
                                                          [
                                                            Ty.apply
                                                              (Ty.path "core::option::Option")
                                                              [ Ty.path "core::convert::Infallible"
                                                              ]
                                                          ],
                                                          "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 denominator :=
                                    M.copy (|
                                      M.match_operator (|
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::Try",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "u128" ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.path "u128",
                                                  "checked_sub",
                                                  []
                                                |),
                                                [
                                                  M.read (|
                                                    M.get_constant (|
                                                      "spl_token_2022::extension::transfer_fee::ONE_IN_BASIS_POINTS"
                                                    |)
                                                  |);
                                                  M.read (| transfer_fee_basis_points |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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::option::Option")
                                                            [ Ty.path "u64" ],
                                                          [
                                                            Ty.apply
                                                              (Ty.path "core::option::Option")
                                                              [ Ty.path "core::convert::Infallible"
                                                              ]
                                                          ],
                                                          "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 raw_pre_fee_amount :=
                                    M.copy (|
                                      M.match_operator (|
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::Try",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "u128" ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.path
                                                    "spl_token_2022::extension::transfer_fee::TransferFee",
                                                  "ceil_div",
                                                  []
                                                |),
                                                [ M.read (| numerator |); M.read (| denominator |) ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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::option::Option")
                                                            [ Ty.path "u64" ],
                                                          [
                                                            Ty.apply
                                                              (Ty.path "core::option::Option")
                                                              [ Ty.path "core::convert::Infallible"
                                                              ]
                                                          ],
                                                          "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.ge
                                                  (M.read (|
                                                    M.match_operator (|
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::try_trait::Try",
                                                            Ty.apply
                                                              (Ty.path "core::option::Option")
                                                              [ Ty.path "u128" ],
                                                            [],
                                                            "branch",
                                                            []
                                                          |),
                                                          [
                                                            M.call_closure (|
                                                              M.get_associated_function (|
                                                                Ty.path "u128",
                                                                "checked_sub",
                                                                []
                                                              |),
                                                              [
                                                                M.read (| raw_pre_fee_amount |);
                                                                M.rust_cast
                                                                  (M.read (| post_fee_amount |))
                                                              ]
                                                            |)
                                                          ]
                                                        |)
                                                      |),
                                                      [
                                                        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::option::Option")
                                                                          [ Ty.path "u64" ],
                                                                        [
                                                                          Ty.apply
                                                                            (Ty.path
                                                                              "core::option::Option")
                                                                            [
                                                                              Ty.path
                                                                                "core::convert::Infallible"
                                                                            ]
                                                                        ],
                                                                        "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.rust_cast (M.read (| maximum_fee |)))
                                              |)) 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 "u64",
                                                "checked_add",
                                                []
                                              |),
                                              [
                                                M.read (| post_fee_amount |);
                                                M.read (| maximum_fee |)
                                              ]
                                            |)
                                          |)));
                                      fun γ =>
                                        ltac:(M.monadic
                                          (M.alloc (|
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "u64";
                                                    Ty.path "core::num::error::TryFromIntError"
                                                  ],
                                                "ok",
                                                []
                                              |),
                                              [
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::convert::TryFrom",
                                                    Ty.path "u64",
                                                    [ Ty.path "u128" ],
                                                    "try_from",
                                                    []
                                                  |),
                                                  [ M.read (| raw_pre_fee_amount |) ]
                                                |)
                                              ]
                                            |)
                                          |)))
                                    ]
                                  |)))
                            ]
                          |)))
                    ]
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_calculate_pre_fee_amount :
        M.IsAssociatedFunction Self "calculate_pre_fee_amount" calculate_pre_fee_amount.
      
      (*
          pub fn calculate_inverse_fee(&self, post_fee_amount: u64) -> Option<u64> {
              let pre_fee_amount = self.calculate_pre_fee_amount(post_fee_amount)?;
              self.calculate_fee(pre_fee_amount)
          }
      *)
      Definition calculate_inverse_fee (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; post_fee_amount ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let post_fee_amount := M.alloc (| post_fee_amount |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let pre_fee_amount :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                                  "calculate_pre_fee_amount",
                                  []
                                |),
                                [ M.read (| self |); M.read (| post_fee_amount |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          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::option::Option")
                                            [ Ty.path "u64" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "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_associated_function (|
                        Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                        "calculate_fee",
                        []
                      |),
                      [ M.read (| self |); M.read (| pre_fee_amount |) ]
                    |)
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_calculate_inverse_fee :
        M.IsAssociatedFunction Self "calculate_inverse_fee" calculate_inverse_fee.
    End Impl_spl_token_2022_extension_transfer_fee_TransferFee.
    
    (* StructRecord
      {
        name := "TransferFeeConfig";
        ty_params := [];
        fields :=
          [
            ("transfer_fee_config_authority",
              Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey");
            ("withdraw_withheld_authority",
              Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey");
            ("withheld_amount", Ty.path "spl_pod::primitives::PodU64");
            ("older_transfer_fee", Ty.path "spl_token_2022::extension::transfer_fee::TransferFee");
            ("newer_transfer_fee", Ty.path "spl_token_2022::extension::transfer_fee::TransferFee")
          ];
      } *)
    
    Module Impl_core_clone_Clone_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      (* 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.match_operator (|
                        Value.DeclaredButUndefined,
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (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_transfer_fee_TransferFeeConfig.
    
    Module Impl_core_marker_Copy_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::Copy"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_Copy_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
    
    Module Impl_core_fmt_Debug_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      (* 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_field5_finish",
                []
              |),
              [
                M.read (| f |);
                M.read (| Value.String "TransferFeeConfig" |);
                M.read (| Value.String "transfer_fee_config_authority" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                    "transfer_fee_config_authority"
                  |));
                M.read (| Value.String "withdraw_withheld_authority" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                    "withdraw_withheld_authority"
                  |));
                M.read (| Value.String "withheld_amount" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                    "withheld_amount"
                  |));
                M.read (| Value.String "older_transfer_fee" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                    "older_transfer_fee"
                  |));
                M.read (| Value.String "newer_transfer_fee" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.alloc (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                      "newer_transfer_fee"
                    |)
                  |))
              ]
            |)))
        | _, _ => 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_transfer_fee_TransferFeeConfig.
    
    Module Impl_core_default_Default_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      (* Default *)
      Definition default (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [] =>
          ltac:(M.monadic
            (Value.StructRecord
              "spl_token_2022::extension::transfer_fee::TransferFeeConfig"
              [
                ("transfer_fee_config_authority",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("withdraw_withheld_authority",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("withheld_amount",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodU64",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("older_transfer_fee",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("newer_transfer_fee",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                      [],
                      "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_transfer_fee_TransferFeeConfig.
    
    Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::StructuralPartialEq"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
    
    Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      (* 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 (|
              LogicalOp.and (|
                LogicalOp.and (|
                  LogicalOp.and (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::cmp::PartialEq",
                        Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey",
                        [ Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey" ],
                        "eq",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                          "transfer_fee_config_authority"
                        |);
                        M.SubPointer.get_struct_record_field (|
                          M.read (| other |),
                          "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                          "transfer_fee_config_authority"
                        |)
                      ]
                    |),
                    ltac:(M.monadic
                      (M.call_closure (|
                        M.get_trait_method (|
                          "core::cmp::PartialEq",
                          Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey",
                          [ Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey" ],
                          "eq",
                          []
                        |),
                        [
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                            "withdraw_withheld_authority"
                          |);
                          M.SubPointer.get_struct_record_field (|
                            M.read (| other |),
                            "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                            "withdraw_withheld_authority"
                          |)
                        ]
                      |)))
                  |),
                  ltac:(M.monadic
                    (M.call_closure (|
                      M.get_trait_method (|
                        "core::cmp::PartialEq",
                        Ty.path "spl_pod::primitives::PodU64",
                        [ Ty.path "spl_pod::primitives::PodU64" ],
                        "eq",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                          "withheld_amount"
                        |);
                        M.SubPointer.get_struct_record_field (|
                          M.read (| other |),
                          "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                          "withheld_amount"
                        |)
                      ]
                    |)))
                |),
                ltac:(M.monadic
                  (M.call_closure (|
                    M.get_trait_method (|
                      "core::cmp::PartialEq",
                      Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                      [ Ty.path "spl_token_2022::extension::transfer_fee::TransferFee" ],
                      "eq",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                        "older_transfer_fee"
                      |);
                      M.SubPointer.get_struct_record_field (|
                        M.read (| other |),
                        "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                        "older_transfer_fee"
                      |)
                    ]
                  |)))
              |),
              ltac:(M.monadic
                (M.call_closure (|
                  M.get_trait_method (|
                    "core::cmp::PartialEq",
                    Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                    [ Ty.path "spl_token_2022::extension::transfer_fee::TransferFee" ],
                    "eq",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                      "newer_transfer_fee"
                    |);
                    M.SubPointer.get_struct_record_field (|
                      M.read (| other |),
                      "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                      "newer_transfer_fee"
                    |)
                  ]
                |)))
            |)))
        | _, _ => 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_transfer_fee_TransferFeeConfig.
    
    Module Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::pod::Pod"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
    
    Module Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::zeroable::Zeroable"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
    
    Module Impl_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      (*
          pub fn get_epoch_fee(&self, epoch: Epoch) -> &TransferFee {
              if epoch >= self.newer_transfer_fee.epoch.into() {
                  &self.newer_transfer_fee
              } else {
                  &self.older_transfer_fee
              }
          }
      *)
      Definition get_epoch_fee (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; epoch ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let epoch := M.alloc (| epoch |) in
            M.read (|
              M.match_operator (|
                M.alloc (| Value.Tuple [] |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ :=
                        M.use
                          (M.alloc (|
                            BinOp.Pure.ge
                              (M.read (| epoch |))
                              (M.call_closure (|
                                M.get_trait_method (|
                                  "core::convert::Into",
                                  Ty.path "spl_pod::primitives::PodU64",
                                  [ Ty.path "u64" ],
                                  "into",
                                  []
                                |),
                                [
                                  M.read (|
                                    M.SubPointer.get_struct_record_field (|
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                                        "newer_transfer_fee"
                                      |),
                                      "spl_token_2022::extension::transfer_fee::TransferFee",
                                      "epoch"
                                    |)
                                  |)
                                ]
                              |))
                          |)) in
                      let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                      M.alloc (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                          "newer_transfer_fee"
                        |)
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (M.alloc (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                          "older_transfer_fee"
                        |)
                      |)))
                ]
              |)
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_get_epoch_fee :
        M.IsAssociatedFunction Self "get_epoch_fee" get_epoch_fee.
      
      (*
          pub fn calculate_epoch_fee(&self, epoch: Epoch, pre_fee_amount: u64) -> Option<u64> {
              self.get_epoch_fee(epoch).calculate_fee(pre_fee_amount)
          }
      *)
      Definition calculate_epoch_fee (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; epoch; pre_fee_amount ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let epoch := M.alloc (| epoch |) in
            let pre_fee_amount := M.alloc (| pre_fee_amount |) in
            M.call_closure (|
              M.get_associated_function (|
                Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                "calculate_fee",
                []
              |),
              [
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                    "get_epoch_fee",
                    []
                  |),
                  [ M.read (| self |); M.read (| epoch |) ]
                |);
                M.read (| pre_fee_amount |)
              ]
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_calculate_epoch_fee :
        M.IsAssociatedFunction Self "calculate_epoch_fee" calculate_epoch_fee.
      
      (*
          pub fn calculate_inverse_epoch_fee(&self, epoch: Epoch, post_fee_amount: u64) -> Option<u64> {
              self.get_epoch_fee(epoch)
                  .calculate_inverse_fee(post_fee_amount)
          }
      *)
      Definition calculate_inverse_epoch_fee (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; epoch; post_fee_amount ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let epoch := M.alloc (| epoch |) in
            let post_fee_amount := M.alloc (| post_fee_amount |) in
            M.call_closure (|
              M.get_associated_function (|
                Ty.path "spl_token_2022::extension::transfer_fee::TransferFee",
                "calculate_inverse_fee",
                []
              |),
              [
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig",
                    "get_epoch_fee",
                    []
                  |),
                  [ M.read (| self |); M.read (| epoch |) ]
                |);
                M.read (| post_fee_amount |)
              ]
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_calculate_inverse_epoch_fee :
        M.IsAssociatedFunction Self "calculate_inverse_epoch_fee" calculate_inverse_epoch_fee.
    End Impl_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
    
    Module Impl_spl_token_2022_extension_Extension_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeConfig".
      
      (*     const TYPE: ExtensionType = ExtensionType::TransferFeeConfig; *)
      (* Ty.path "spl_token_2022::extension::ExtensionType" *)
      Definition value_TYPE : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              Value.StructTuple "spl_token_2022::extension::ExtensionType::TransferFeeConfig" []
            |))).
      
      Axiom Implements :
        M.IsTraitInstance
          "spl_token_2022::extension::Extension"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("value_TYPE", InstanceField.Constant value_TYPE) ].
    End Impl_spl_token_2022_extension_Extension_for_spl_token_2022_extension_transfer_fee_TransferFeeConfig.
    
    (* StructRecord
      {
        name := "TransferFeeAmount";
        ty_params := [];
        fields := [ ("withheld_amount", Ty.path "spl_pod::primitives::PodU64") ];
      } *)
    
    Module Impl_core_clone_Clone_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      (* 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_transfer_fee_TransferFeeAmount.
    
    Module Impl_core_marker_Copy_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::Copy"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_Copy_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
    
    Module Impl_core_fmt_Debug_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      (* 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_field1_finish",
                []
              |),
              [
                M.read (| f |);
                M.read (| Value.String "TransferFeeAmount" |);
                M.read (| Value.String "withheld_amount" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.alloc (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::transfer_fee::TransferFeeAmount",
                      "withheld_amount"
                    |)
                  |))
              ]
            |)))
        | _, _ => 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_transfer_fee_TransferFeeAmount.
    
    Module Impl_core_default_Default_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      (* Default *)
      Definition default (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [] =>
          ltac:(M.monadic
            (Value.StructRecord
              "spl_token_2022::extension::transfer_fee::TransferFeeAmount"
              [
                ("withheld_amount",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodU64",
                      [],
                      "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_transfer_fee_TransferFeeAmount.
    
    Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::StructuralPartialEq"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
    
    Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      (* 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::PodU64",
                [ Ty.path "spl_pod::primitives::PodU64" ],
                "eq",
                []
              |),
              [
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "spl_token_2022::extension::transfer_fee::TransferFeeAmount",
                  "withheld_amount"
                |);
                M.SubPointer.get_struct_record_field (|
                  M.read (| other |),
                  "spl_token_2022::extension::transfer_fee::TransferFeeAmount",
                  "withheld_amount"
                |)
              ]
            |)))
        | _, _ => 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_transfer_fee_TransferFeeAmount.
    
    Module Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::pod::Pod"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
    
    Module Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::zeroable::Zeroable"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
    
    Module Impl_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      (*
          pub fn closable(&self) -> ProgramResult {
              if self.withheld_amount == 0.into() {
                  Ok(())
              } else {
                  Err(TokenError::AccountHasWithheldTransferFees.into())
              }
          }
      *)
      Definition closable (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) 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_pod::primitives::PodU64",
                                [ Ty.path "spl_pod::primitives::PodU64" ],
                                "eq",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "spl_token_2022::extension::transfer_fee::TransferFeeAmount",
                                  "withheld_amount"
                                |);
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::convert::Into",
                                      Ty.path "u64",
                                      [ Ty.path "spl_pod::primitives::PodU64" ],
                                      "into",
                                      []
                                    |),
                                    [ Value.Integer 0 ]
                                  |)
                                |)
                              ]
                            |)
                          |)) in
                      let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                      M.alloc (|
                        Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                      |)));
                  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::AccountHasWithheldTransferFees"
                                  []
                              ]
                            |)
                          ]
                      |)))
                ]
              |)
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_closable : M.IsAssociatedFunction Self "closable" closable.
    End Impl_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
    
    Module Impl_spl_token_2022_extension_Extension_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::transfer_fee::TransferFeeAmount".
      
      (*     const TYPE: ExtensionType = ExtensionType::TransferFeeAmount; *)
      (* Ty.path "spl_token_2022::extension::ExtensionType" *)
      Definition value_TYPE : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              Value.StructTuple "spl_token_2022::extension::ExtensionType::TransferFeeAmount" []
            |))).
      
      Axiom Implements :
        M.IsTraitInstance
          "spl_token_2022::extension::Extension"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("value_TYPE", InstanceField.Constant value_TYPE) ].
    End Impl_spl_token_2022_extension_Extension_for_spl_token_2022_extension_transfer_fee_TransferFeeAmount.
  End transfer_fee.
End extension.
