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

Module extension.
  Module default_account_state.
    Module processor.
      (*
      fn check_valid_default_state(state: AccountState) -> ProgramResult {
          match state {
              AccountState::Uninitialized => Err(TokenError::InvalidState.into()),
              _ => Ok(()),
          }
      }
      *)
      Definition check_valid_default_state (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ state ] =>
          ltac:(M.monadic
            (let state := M.alloc (| state |) in
            M.read (|
              M.match_operator (|
                state,
                [
                  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::InvalidState"
                                  []
                              ]
                            |)
                          ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (M.alloc (|
                        Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                      |)))
                ]
              |)
            |)))
        | _, _ => M.impossible
        end.
      
      (*
      fn process_initialize_default_account_state(
          accounts: &[AccountInfo],
          state: AccountState,
      ) -> ProgramResult {
          check_valid_default_state(state)?;
          let account_info_iter = &mut accounts.iter();
          let mint_account_info = next_account_info(account_info_iter)?;
          let mut mint_data = mint_account_info.data.borrow_mut();
          let mut mint = PodStateWithExtensionsMut::<PodMint>::unpack_uninitialized(&mut mint_data)?;
          let extension = mint.init_extension::<DefaultAccountState>(true)?;
          extension.state = state.into();
          Ok(())
      }
      *)
      Definition process_initialize_default_account_state (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ accounts; state ] =>
          ltac:(M.monadic
            (let accounts := M.alloc (| accounts |) in
            let state := M.alloc (| state |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let _ :=
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (|
                                "spl_token_2022::extension::default_account_state::processor::check_valid_default_state",
                                []
                              |),
                              [ M.read (| state |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |) in
                  let account_info_iter :=
                    M.alloc (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "slice")
                              [ Ty.path "solana_program::account_info::AccountInfo" ],
                            "iter",
                            []
                          |),
                          [ M.read (| accounts |) ]
                        |)
                      |)
                    |) in
                  let mint_account_info :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&")
                                    [ Ty.path "solana_program::account_info::AccountInfo" ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_function (|
                                  "solana_program::account_info::next_account_info",
                                  [
                                    Ty.apply
                                      (Ty.path "core::slice::iter::Iter")
                                      [ Ty.path "solana_program::account_info::AccountInfo" ]
                                  ]
                                |),
                                [ M.read (| account_info_iter |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let mint_data :=
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::cell::RefCell")
                            [
                              Ty.apply
                                (Ty.path "&mut")
                                [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                            ],
                          "borrow_mut",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::Deref",
                              Ty.apply
                                (Ty.path "alloc::rc::Rc")
                                [
                                  Ty.apply
                                    (Ty.path "core::cell::RefCell")
                                    [
                                      Ty.apply
                                        (Ty.path "&mut")
                                        [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                    ];
                                  Ty.path "alloc::alloc::Global"
                                ],
                              [],
                              "deref",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| mint_account_info |),
                                "solana_program::account_info::AccountInfo",
                                "data"
                              |)
                            ]
                          |)
                        ]
                      |)
                    |) in
                  let mint :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                    [ Ty.path "spl_token_2022::pod::PodMint" ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                    [ Ty.path "spl_token_2022::pod::PodMint" ],
                                  "unpack_uninitialized",
                                  []
                                |),
                                [
                                  M.read (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::deref::DerefMut",
                                        Ty.apply
                                          (Ty.path "core::cell::RefMut")
                                          [
                                            Ty.apply
                                              (Ty.path "&mut")
                                              [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                          ],
                                        [],
                                        "deref_mut",
                                        []
                                      |),
                                      [ mint_data ]
                                    |)
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let extension :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    [
                                      Ty.path
                                        "spl_token_2022::extension::default_account_state::DefaultAccountState"
                                    ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                    [ Ty.path "spl_token_2022::pod::PodMint" ],
                                  [ Ty.path "spl_token_2022::pod::PodMint" ],
                                  "init_extension",
                                  [
                                    Ty.path
                                      "spl_token_2022::extension::default_account_state::DefaultAccountState"
                                  ]
                                |),
                                [ mint; Value.Bool true ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let _ :=
                    M.write (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| extension |),
                        "spl_token_2022::extension::default_account_state::DefaultAccountState",
                        "state"
                      |),
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::convert::Into",
                          Ty.path "spl_token_2022::state::AccountState",
                          [ Ty.path "u8" ],
                          "into",
                          []
                        |),
                        [ M.read (| state |) ]
                      |)
                    |) in
                  M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      (*
      fn process_update_default_account_state(
          program_id: &Pubkey,
          accounts: &[AccountInfo],
          state: AccountState,
      ) -> ProgramResult {
          check_valid_default_state(state)?;
          let account_info_iter = &mut accounts.iter();
          let mint_account_info = next_account_info(account_info_iter)?;
          let freeze_authority_info = next_account_info(account_info_iter)?;
          let freeze_authority_info_data_len = freeze_authority_info.data_len();
      
          let mut mint_data = mint_account_info.data.borrow_mut();
          let mut mint = PodStateWithExtensionsMut::<PodMint>::unpack(&mut mint_data)?;
      
          match &mint.base.freeze_authority {
              PodCOption {
                  option: PodCOption::<Pubkey>::SOME,
                  value: freeze_authority,
              } => Processor::validate_owner(
                  program_id,
                  freeze_authority,
                  freeze_authority_info,
                  freeze_authority_info_data_len,
                  account_info_iter.as_slice(),
              ),
              _ => Err(TokenError::NoAuthorityExists.into()),
          }?;
      
          let extension = mint.get_extension_mut::<DefaultAccountState>()?;
          extension.state = state.into();
          Ok(())
      }
      *)
      Definition process_update_default_account_state (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ program_id; accounts; state ] =>
          ltac:(M.monadic
            (let program_id := M.alloc (| program_id |) in
            let accounts := M.alloc (| accounts |) in
            let state := M.alloc (| state |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let _ :=
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (|
                                "spl_token_2022::extension::default_account_state::processor::check_valid_default_state",
                                []
                              |),
                              [ M.read (| state |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |) in
                  let account_info_iter :=
                    M.alloc (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "slice")
                              [ Ty.path "solana_program::account_info::AccountInfo" ],
                            "iter",
                            []
                          |),
                          [ M.read (| accounts |) ]
                        |)
                      |)
                    |) in
                  let mint_account_info :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&")
                                    [ Ty.path "solana_program::account_info::AccountInfo" ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_function (|
                                  "solana_program::account_info::next_account_info",
                                  [
                                    Ty.apply
                                      (Ty.path "core::slice::iter::Iter")
                                      [ Ty.path "solana_program::account_info::AccountInfo" ]
                                  ]
                                |),
                                [ M.read (| account_info_iter |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let freeze_authority_info :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&")
                                    [ Ty.path "solana_program::account_info::AccountInfo" ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_function (|
                                  "solana_program::account_info::next_account_info",
                                  [
                                    Ty.apply
                                      (Ty.path "core::slice::iter::Iter")
                                      [ Ty.path "solana_program::account_info::AccountInfo" ]
                                  ]
                                |),
                                [ M.read (| account_info_iter |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let freeze_authority_info_data_len :=
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.path "solana_program::account_info::AccountInfo",
                          "data_len",
                          []
                        |),
                        [ M.read (| freeze_authority_info |) ]
                      |)
                    |) in
                  let mint_data :=
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::cell::RefCell")
                            [
                              Ty.apply
                                (Ty.path "&mut")
                                [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                            ],
                          "borrow_mut",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::Deref",
                              Ty.apply
                                (Ty.path "alloc::rc::Rc")
                                [
                                  Ty.apply
                                    (Ty.path "core::cell::RefCell")
                                    [
                                      Ty.apply
                                        (Ty.path "&mut")
                                        [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                    ];
                                  Ty.path "alloc::alloc::Global"
                                ],
                              [],
                              "deref",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| mint_account_info |),
                                "solana_program::account_info::AccountInfo",
                                "data"
                              |)
                            ]
                          |)
                        ]
                      |)
                    |) in
                  let mint :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                    [ Ty.path "spl_token_2022::pod::PodMint" ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                    [ Ty.path "spl_token_2022::pod::PodMint" ],
                                  "unpack",
                                  []
                                |),
                                [
                                  M.read (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::deref::DerefMut",
                                        Ty.apply
                                          (Ty.path "core::cell::RefMut")
                                          [
                                            Ty.apply
                                              (Ty.path "&mut")
                                              [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]
                                          ],
                                        [],
                                        "deref_mut",
                                        []
                                      |),
                                      [ mint_data ]
                                    |)
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let _ :=
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.read (|
                              M.match_operator (|
                                M.alloc (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (|
                                      M.SubPointer.get_struct_record_field (|
                                        mint,
                                        "spl_token_2022::extension::PodStateWithExtensionsMut",
                                        "base"
                                      |)
                                    |),
                                    "spl_token_2022::pod::PodMint",
                                    "freeze_authority"
                                  |)
                                |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ := M.read (| γ |) in
                                      let γ1_0 :=
                                        M.SubPointer.get_struct_record_field (|
                                          γ,
                                          "spl_token_2022::pod::PodCOption",
                                          "option"
                                        |) in
                                      let γ1_1 :=
                                        M.SubPointer.get_struct_record_field (|
                                          γ,
                                          "spl_token_2022::pod::PodCOption",
                                          "value"
                                        |) in
                                      let γ2_0 := M.SubPointer.get_slice_index (| γ1_0, 0 |) in
                                      let γ2_1 := M.SubPointer.get_slice_index (| γ1_0, 1 |) in
                                      let γ2_2 := M.SubPointer.get_slice_index (| γ1_0, 2 |) in
                                      let γ2_3 := M.SubPointer.get_slice_index (| γ1_0, 3 |) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ2_0 |),
                                          Value.Integer 1
                                        |) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ2_1 |),
                                          Value.Integer 0
                                        |) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ2_2 |),
                                          Value.Integer 0
                                        |) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ2_3 |),
                                          Value.Integer 0
                                        |) in
                                      let freeze_authority := M.alloc (| γ1_1 |) in
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "spl_token_2022::processor::Processor",
                                            "validate_owner",
                                            []
                                          |),
                                          [
                                            M.read (| program_id |);
                                            M.read (| freeze_authority |);
                                            M.read (| freeze_authority_info |);
                                            M.read (| freeze_authority_info_data_len |);
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply
                                                  (Ty.path "core::slice::iter::Iter")
                                                  [
                                                    Ty.path
                                                      "solana_program::account_info::AccountInfo"
                                                  ],
                                                "as_slice",
                                                []
                                              |),
                                              [ M.read (| account_info_iter |) ]
                                            |)
                                          ]
                                        |)
                                      |)));
                                  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::NoAuthorityExists"
                                                  []
                                              ]
                                            |)
                                          ]
                                      |)))
                                ]
                              |)
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |) in
                  let extension :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    [
                                      Ty.path
                                        "spl_token_2022::extension::default_account_state::DefaultAccountState"
                                    ];
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "spl_token_2022::extension::BaseStateWithExtensionsMut",
                                  Ty.apply
                                    (Ty.path "spl_token_2022::extension::PodStateWithExtensionsMut")
                                    [ Ty.path "spl_token_2022::pod::PodMint" ],
                                  [ Ty.path "spl_token_2022::pod::PodMint" ],
                                  "get_extension_mut",
                                  [
                                    Ty.path
                                      "spl_token_2022::extension::default_account_state::DefaultAccountState"
                                  ]
                                |),
                                [ mint ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.tuple [];
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let _ :=
                    M.write (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| extension |),
                        "spl_token_2022::extension::default_account_state::DefaultAccountState",
                        "state"
                      |),
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::convert::Into",
                          Ty.path "spl_token_2022::state::AccountState",
                          [ Ty.path "u8" ],
                          "into",
                          []
                        |),
                        [ M.read (| state |) ]
                      |)
                    |) in
                  M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      (*
      pub(crate) fn process_instruction(
          program_id: &Pubkey,
          accounts: &[AccountInfo],
          input: &[u8],
      ) -> ProgramResult {
          check_program_account(program_id)?;
      
          let (instruction, state) = decode_instruction(input)?;
          match instruction {
              DefaultAccountStateInstruction::Initialize => {
                  msg!("DefaultAccountStateInstruction::Initialize");
                  process_initialize_default_account_state(accounts, state)
              }
              DefaultAccountStateInstruction::Update => {
                  msg!("DefaultAccountStateInstruction::Update");
                  process_update_default_account_state(program_id, accounts, state)
              }
          }
      }
      *)
      Definition process_instruction (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ program_id; accounts; input ] =>
          ltac:(M.monadic
            (let program_id := M.alloc (| program_id |) in
            let accounts := M.alloc (| accounts |) in
            let input := M.alloc (| input |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let _ :=
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [ Ty.tuple []; Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (| "spl_token_2022::check_program_account", [] |),
                              [ M.read (| program_id |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |) in
                  M.match_operator (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              [
                                Ty.tuple
                                  [
                                    Ty.path
                                      "spl_token_2022::extension::default_account_state::instruction::DefaultAccountStateInstruction";
                                    Ty.path "spl_token_2022::state::AccountState"
                                  ];
                                Ty.path "solana_program::program_error::ProgramError"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (|
                                "spl_token_2022::extension::default_account_state::instruction::decode_instruction",
                                []
                              |),
                              [ M.read (| input |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Break",
                                0
                              |) in
                            let residual := M.copy (| γ0_0 |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::FromResidual",
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          [
                                            Ty.tuple [];
                                            Ty.path "solana_program::program_error::ProgramError"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ]
                                        ],
                                        "from_residual",
                                        []
                                      |),
                                      [ M.read (| residual |) ]
                                    |)
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::ops::control_flow::ControlFlow::Continue",
                                0
                              |) in
                            let val := M.copy (| γ0_0 |) in
                            val))
                      ]
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                          let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                          let instruction := M.copy (| γ0_0 |) in
                          let state := M.copy (| γ0_1 |) in
                          M.match_operator (|
                            instruction,
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_function (| "solana_program::log::sol_log", [] |),
                                        [
                                          M.read (|
                                            Value.String
                                              "DefaultAccountStateInstruction::Initialize"
                                          |)
                                        ]
                                      |)
                                    |) in
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_function (|
                                        "spl_token_2022::extension::default_account_state::processor::process_initialize_default_account_state",
                                        []
                                      |),
                                      [ M.read (| accounts |); M.read (| state |) ]
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_function (| "solana_program::log::sol_log", [] |),
                                        [
                                          M.read (|
                                            Value.String "DefaultAccountStateInstruction::Update"
                                          |)
                                        ]
                                      |)
                                    |) in
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_function (|
                                        "spl_token_2022::extension::default_account_state::processor::process_update_default_account_state",
                                        []
                                      |),
                                      [
                                        M.read (| program_id |);
                                        M.read (| accounts |);
                                        M.read (| state |)
                                      ]
                                    |)
                                  |)))
                            ]
                          |)))
                    ]
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
    End processor.
  End default_account_state.
End extension.
