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

Module builder.
  (* StructRecord
    {
      name := "EvmBuilder";
      const_params := [];
      ty_params := [ "BuilderStage"; "EXT"; "DB" ];
      fields :=
        [
          ("context", Ty.apply (Ty.path "revm::context::Context") [] [ EXT; DB ]);
          ("handler",
            Ty.apply
              (Ty.path "revm::handler::Handler")
              []
              [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ]);
          ("phantom", Ty.apply (Ty.path "core::marker::PhantomData") [] [ BuilderStage ])
        ];
    } *)
  
  (* StructTuple
    {
      name := "SetGenericStage";
      const_params := [];
      ty_params := [];
      fields := [];
    } *)
  
  (* StructTuple
    {
      name := "HandlerStage";
      const_params := [];
      ty_params := [];
      fields := [];
    } *)
  
  Module Impl_core_default_Default_for_revm_builder_EvmBuilder_revm_builder_SetGenericStage_Tuple__revm_db_emptydb_EmptyDBTyped_core_convert_Infallible.
    Definition Self : Ty.t :=
      Ty.apply
        (Ty.path "revm::builder::EvmBuilder")
        []
        [
          Ty.path "revm::builder::SetGenericStage";
          Ty.tuple [];
          Ty.apply
            (Ty.path "revm::db::emptydb::EmptyDBTyped")
            []
            [ Ty.path "core::convert::Infallible" ]
        ].
    
    (*
        fn default() -> Self {
            cfg_if::cfg_if! {
                if #[cfg(all(feature = "optimism-default-handler",
                    not(feature = "negate-optimism-default-handler")))] {
                        let mut handler_cfg = HandlerCfg::new(SpecId::LATEST);
                        // set is_optimism to true by default.
                        handler_cfg.is_optimism = true;
    
                } else {
                    let handler_cfg = HandlerCfg::new(SpecId::LATEST);
                }
            }
    
            Self {
                context: Context::default(),
                handler: EvmBuilder::<'a, SetGenericStage, (), EmptyDB>::handler(handler_cfg),
                phantom: PhantomData,
            }
        }
    *)
    Definition default (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [] =>
        ltac:(M.monadic
          (M.read (|
            let~ handler_cfg :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.path "revm_primitives::env::handler_cfg::HandlerCfg",
                    "new",
                    []
                  |),
                  [ Value.StructTuple "revm_primitives::specification::SpecId::LATEST" [] ]
                |)
              |) in
            M.alloc (|
              Value.StructRecord
                "revm::builder::EvmBuilder"
                [
                  ("context",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "revm::context::Context")
                          []
                          [
                            Ty.tuple [];
                            Ty.apply
                              (Ty.path "revm::db::emptydb::EmptyDBTyped")
                              []
                              [ Ty.path "core::convert::Infallible" ]
                          ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |));
                  ("handler",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::builder::EvmBuilder")
                          []
                          [
                            Ty.path "revm::builder::SetGenericStage";
                            Ty.tuple [];
                            Ty.apply
                              (Ty.path "revm::db::emptydb::EmptyDBTyped")
                              []
                              [ Ty.path "core::convert::Infallible" ]
                          ],
                        "handler",
                        []
                      |),
                      [ M.read (| handler_cfg |) ]
                    |));
                  ("phantom", Value.StructTuple "core::marker::PhantomData" [])
                ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::default::Default"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("default", InstanceField.Method default) ].
  End Impl_core_default_Default_for_revm_builder_EvmBuilder_revm_builder_SetGenericStage_Tuple__revm_db_emptydb_EmptyDBTyped_core_convert_Infallible.
  
  Module Impl_revm_builder_EvmBuilder_revm_builder_SetGenericStage_EXT_DB.
    Definition Self (EXT DB : Ty.t) : Ty.t :=
      Ty.apply
        (Ty.path "revm::builder::EvmBuilder")
        []
        [ Ty.path "revm::builder::SetGenericStage"; EXT; DB ].
    
    (*
        pub fn with_empty_db(self) -> EvmBuilder<'a, SetGenericStage, EXT, EmptyDB> {
            EvmBuilder {
                context: Context::new(
                    self.context.evm.with_db(EmptyDB::default()),
                    self.context.external,
                ),
                handler: EvmBuilder::<'a, SetGenericStage, EXT, EmptyDB>::handler(self.handler.cfg()),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_empty_db
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::context::Context")
                      []
                      [
                        EXT;
                        Ty.apply
                          (Ty.path "revm::db::emptydb::EmptyDBTyped")
                          []
                          [ Ty.path "core::convert::Infallible" ]
                      ],
                    "new",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                        "with_db",
                        [
                          Ty.apply
                            (Ty.path "revm::db::emptydb::EmptyDBTyped")
                            []
                            [ Ty.path "core::convert::Infallible" ]
                        ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        |);
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::default::Default",
                            Ty.apply
                              (Ty.path "revm::db::emptydb::EmptyDBTyped")
                              []
                              [ Ty.path "core::convert::Infallible" ],
                            [],
                            "default",
                            []
                          |),
                          []
                        |)
                      ]
                    |);
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "external"
                      |)
                    |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [
                        Ty.path "revm::builder::SetGenericStage";
                        EXT;
                        Ty.apply
                          (Ty.path "revm::db::emptydb::EmptyDBTyped")
                          []
                          [ Ty.path "core::convert::Infallible" ]
                      ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_empty_db :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction (Self EXT DB) "with_empty_db" (with_empty_db EXT DB).
    
    (*
        pub fn with_db<ODB: Database>(self, db: ODB) -> EvmBuilder<'a, SetGenericStage, EXT, ODB> {
            EvmBuilder {
                context: Context::new(self.context.evm.with_db(db), self.context.external),
                handler: EvmBuilder::<'a, SetGenericStage, EXT, ODB>::handler(self.handler.cfg()),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_db (EXT DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [ ODB ], [ self; db ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let db := M.alloc (| db |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "revm::context::Context") [] [ EXT; ODB ],
                    "new",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                        "with_db",
                        [ ODB ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        |);
                        M.read (| db |)
                      ]
                    |);
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "external"
                      |)
                    |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [ Ty.path "revm::builder::SetGenericStage"; EXT; ODB ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_db :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction (Self EXT DB) "with_db" (with_db EXT DB).
    
    (*
        pub fn with_ref_db<ODB: DatabaseRef>(
            self,
            db: ODB,
        ) -> EvmBuilder<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>> {
            EvmBuilder {
                context: Context::new(
                    self.context.evm.with_db(WrapDatabaseRef(db)),
                    self.context.external,
                ),
                handler: EvmBuilder::<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>>::handler(
                    self.handler.cfg(),
                ),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_ref_db
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [ ODB ], [ self; db ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let db := M.alloc (| db |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::context::Context")
                      []
                      [ EXT; Ty.apply (Ty.path "revm_primitives::db::WrapDatabaseRef") [] [ ODB ] ],
                    "new",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                        "with_db",
                        [ Ty.apply (Ty.path "revm_primitives::db::WrapDatabaseRef") [] [ ODB ] ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        |);
                        Value.StructTuple "revm_primitives::db::WrapDatabaseRef" [ M.read (| db |) ]
                      ]
                    |);
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "external"
                      |)
                    |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [
                        Ty.path "revm::builder::SetGenericStage";
                        EXT;
                        Ty.apply (Ty.path "revm_primitives::db::WrapDatabaseRef") [] [ ODB ]
                      ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_ref_db :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction (Self EXT DB) "with_ref_db" (with_ref_db EXT DB).
    
    (*
        pub fn with_external_context<OEXT>(
            self,
            external: OEXT,
        ) -> EvmBuilder<'a, SetGenericStage, OEXT, DB> {
            EvmBuilder {
                context: Context::new(self.context.evm, external),
                handler: EvmBuilder::<'a, SetGenericStage, OEXT, DB>::handler(self.handler.cfg()),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_external_context
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [ OEXT ], [ self; external ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let external := M.alloc (| external |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "revm::context::Context") [] [ OEXT; DB ],
                    "new",
                    []
                  |),
                  [
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "evm"
                      |)
                    |);
                    M.read (| external |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [ Ty.path "revm::builder::SetGenericStage"; OEXT; DB ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_external_context :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction (Self EXT DB) "with_external_context" (with_external_context EXT DB).
    
    (*
        pub fn with_env_with_handler_cfg(
            mut self,
            env_with_handler_cfg: EnvWithHandlerCfg,
        ) -> EvmBuilder<'a, HandlerStage, EXT, DB> {
            let EnvWithHandlerCfg { env, handler_cfg } = env_with_handler_cfg;
            self.context.evm.env = env;
            EvmBuilder {
                context: self.context,
                handler: EvmBuilder::<'a, HandlerStage, EXT, DB>::handler(handler_cfg),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_env_with_handler_cfg
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [], [ self; env_with_handler_cfg ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let env_with_handler_cfg := M.alloc (| env_with_handler_cfg |) in
          M.read (|
            M.match_operator (|
              env_with_handler_cfg,
              [
                fun γ =>
                  ltac:(M.monadic
                    (let γ0_0 :=
                      M.SubPointer.get_struct_record_field (|
                        γ,
                        "revm_primitives::env::handler_cfg::EnvWithHandlerCfg",
                        "env"
                      |) in
                    let γ0_1 :=
                      M.SubPointer.get_struct_record_field (|
                        γ,
                        "revm_primitives::env::handler_cfg::EnvWithHandlerCfg",
                        "handler_cfg"
                      |) in
                    let env := M.copy (| γ0_0 |) in
                    let handler_cfg := M.copy (| γ0_1 |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::DerefMut",
                              Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                              [],
                              "deref_mut",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.SubPointer.get_struct_record_field (|
                                  self,
                                  "revm::builder::EvmBuilder",
                                  "context"
                                |),
                                "revm::context::Context",
                                "evm"
                              |)
                            ]
                          |),
                          "revm::context::inner_evm_context::InnerEvmContext",
                          "env"
                        |),
                        M.read (| env |)
                      |) in
                    M.alloc (|
                      Value.StructRecord
                        "revm::builder::EvmBuilder"
                        [
                          ("context",
                            M.read (|
                              M.SubPointer.get_struct_record_field (|
                                self,
                                "revm::builder::EvmBuilder",
                                "context"
                              |)
                            |));
                          ("handler",
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "revm::builder::EvmBuilder")
                                  []
                                  [ Ty.path "revm::builder::HandlerStage"; EXT; DB ],
                                "handler",
                                []
                              |),
                              [ M.read (| handler_cfg |) ]
                            |));
                          ("phantom", Value.StructTuple "core::marker::PhantomData" [])
                        ]
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_env_with_handler_cfg :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self EXT DB)
        "with_env_with_handler_cfg"
        (with_env_with_handler_cfg EXT DB).
    
    (*
        pub fn with_context_with_handler_cfg<OEXT, ODB: Database>(
            self,
            context_with_handler_cfg: ContextWithHandlerCfg<OEXT, ODB>,
        ) -> EvmBuilder<'a, HandlerStage, OEXT, ODB> {
            EvmBuilder {
                context: context_with_handler_cfg.context,
                handler: EvmBuilder::<'a, HandlerStage, OEXT, ODB>::handler(
                    context_with_handler_cfg.cfg,
                ),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_context_with_handler_cfg
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [ OEXT; ODB ], [ self; context_with_handler_cfg ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let context_with_handler_cfg := M.alloc (| context_with_handler_cfg |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.read (|
                  M.SubPointer.get_struct_record_field (|
                    context_with_handler_cfg,
                    "revm::context::ContextWithHandlerCfg",
                    "context"
                  |)
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [ Ty.path "revm::builder::HandlerStage"; OEXT; ODB ],
                    "handler",
                    []
                  |),
                  [
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        context_with_handler_cfg,
                        "revm::context::ContextWithHandlerCfg",
                        "cfg"
                      |)
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_context_with_handler_cfg :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self EXT DB)
        "with_context_with_handler_cfg"
        (with_context_with_handler_cfg EXT DB).
    
    (*
        pub fn with_cfg_env_with_handler_cfg(
            mut self,
            cfg_env_and_spec_id: CfgEnvWithHandlerCfg,
        ) -> EvmBuilder<'a, HandlerStage, EXT, DB> {
            self.context.evm.env.cfg = cfg_env_and_spec_id.cfg_env;
    
            EvmBuilder {
                context: self.context,
                handler: EvmBuilder::<'a, HandlerStage, EXT, DB>::handler(
                    cfg_env_and_spec_id.handler_cfg,
                ),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_cfg_env_with_handler_cfg
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [], [ self; cfg_env_and_spec_id ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let cfg_env_and_spec_id := M.alloc (| cfg_env_and_spec_id |) in
          M.read (|
            let~ _ :=
              M.write (|
                M.SubPointer.get_struct_record_field (|
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::deref::DerefMut",
                          Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                          [],
                          "deref_mut",
                          []
                        |),
                        [
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        ]
                      |),
                      "revm::context::inner_evm_context::InnerEvmContext",
                      "env"
                    |)
                  |),
                  "revm_primitives::env::Env",
                  "cfg"
                |),
                M.read (|
                  M.SubPointer.get_struct_record_field (|
                    cfg_env_and_spec_id,
                    "revm_primitives::env::handler_cfg::CfgEnvWithHandlerCfg",
                    "cfg_env"
                  |)
                |)
              |) in
            M.alloc (|
              Value.StructRecord
                "revm::builder::EvmBuilder"
                [
                  ("context",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "revm::builder::EvmBuilder",
                        "context"
                      |)
                    |));
                  ("handler",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::builder::EvmBuilder")
                          []
                          [ Ty.path "revm::builder::HandlerStage"; EXT; DB ],
                        "handler",
                        []
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            cfg_env_and_spec_id,
                            "revm_primitives::env::handler_cfg::CfgEnvWithHandlerCfg",
                            "handler_cfg"
                          |)
                        |)
                      ]
                    |));
                  ("phantom", Value.StructTuple "core::marker::PhantomData" [])
                ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_cfg_env_with_handler_cfg :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self EXT DB)
        "with_cfg_env_with_handler_cfg"
        (with_cfg_env_with_handler_cfg EXT DB).
    
    (*
        pub fn with_handler_cfg(
            self,
            handler_cfg: HandlerCfg,
        ) -> EvmBuilder<'a, HandlerStage, EXT, DB> {
            EvmBuilder {
                context: self.context,
                handler: EvmBuilder::<'a, HandlerStage, EXT, DB>::handler(handler_cfg),
                phantom: PhantomData,
            }
        }
    *)
    Definition with_handler_cfg
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [], [ self; handler_cfg ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let handler_cfg := M.alloc (| handler_cfg |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.read (|
                  M.SubPointer.get_struct_record_field (|
                    self,
                    "revm::builder::EvmBuilder",
                    "context"
                  |)
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [ Ty.path "revm::builder::HandlerStage"; EXT; DB ],
                    "handler",
                    []
                  |),
                  [ M.read (| handler_cfg |) ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_handler_cfg :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction (Self EXT DB) "with_handler_cfg" (with_handler_cfg EXT DB).
  End Impl_revm_builder_EvmBuilder_revm_builder_SetGenericStage_EXT_DB.
  
  Module Impl_revm_builder_EvmBuilder_revm_builder_HandlerStage_EXT_DB.
    Definition Self (EXT DB : Ty.t) : Ty.t :=
      Ty.apply
        (Ty.path "revm::builder::EvmBuilder")
        []
        [ Ty.path "revm::builder::HandlerStage"; EXT; DB ].
    
    (*
        pub fn new(evm: Evm<'a, EXT, DB>) -> Self {
            Self {
                context: evm.context,
                handler: evm.handler,
                phantom: PhantomData,
            }
        }
    *)
    Definition new (EXT DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [], [ evm ] =>
        ltac:(M.monadic
          (let evm := M.alloc (| evm |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.read (|
                  M.SubPointer.get_struct_record_field (| evm, "revm::evm::Evm", "context" |)
                |));
              ("handler",
                M.read (|
                  M.SubPointer.get_struct_record_field (| evm, "revm::evm::Evm", "handler" |)
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_new :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction (Self EXT DB) "new" (new EXT DB).
    
    (*
        pub fn reset_handler_with_empty_db(self) -> EvmBuilder<'a, HandlerStage, EXT, EmptyDB> {
            EvmBuilder {
                context: Context::new(
                    self.context.evm.with_db(EmptyDB::default()),
                    self.context.external,
                ),
                handler: EvmBuilder::<'a, HandlerStage, EXT, EmptyDB>::handler(self.handler.cfg()),
                phantom: PhantomData,
            }
        }
    *)
    Definition reset_handler_with_empty_db
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::context::Context")
                      []
                      [
                        EXT;
                        Ty.apply
                          (Ty.path "revm::db::emptydb::EmptyDBTyped")
                          []
                          [ Ty.path "core::convert::Infallible" ]
                      ],
                    "new",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                        "with_db",
                        [
                          Ty.apply
                            (Ty.path "revm::db::emptydb::EmptyDBTyped")
                            []
                            [ Ty.path "core::convert::Infallible" ]
                        ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        |);
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::default::Default",
                            Ty.apply
                              (Ty.path "revm::db::emptydb::EmptyDBTyped")
                              []
                              [ Ty.path "core::convert::Infallible" ],
                            [],
                            "default",
                            []
                          |),
                          []
                        |)
                      ]
                    |);
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "external"
                      |)
                    |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [
                        Ty.path "revm::builder::HandlerStage";
                        EXT;
                        Ty.apply
                          (Ty.path "revm::db::emptydb::EmptyDBTyped")
                          []
                          [ Ty.path "core::convert::Infallible" ]
                      ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_reset_handler_with_empty_db :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self EXT DB)
        "reset_handler_with_empty_db"
        (reset_handler_with_empty_db EXT DB).
    
    (*
        pub fn reset_handler_with_db<ODB: Database>(
            self,
            db: ODB,
        ) -> EvmBuilder<'a, SetGenericStage, EXT, ODB> {
            EvmBuilder {
                context: Context::new(self.context.evm.with_db(db), self.context.external),
                handler: EvmBuilder::<'a, SetGenericStage, EXT, ODB>::handler(self.handler.cfg()),
                phantom: PhantomData,
            }
        }
    *)
    Definition reset_handler_with_db
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [ ODB ], [ self; db ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let db := M.alloc (| db |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "revm::context::Context") [] [ EXT; ODB ],
                    "new",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                        "with_db",
                        [ ODB ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        |);
                        M.read (| db |)
                      ]
                    |);
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "external"
                      |)
                    |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [ Ty.path "revm::builder::SetGenericStage"; EXT; ODB ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_reset_handler_with_db :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction (Self EXT DB) "reset_handler_with_db" (reset_handler_with_db EXT DB).
    
    (*
        pub fn reset_handler_with_ref_db<ODB: DatabaseRef>(
            self,
            db: ODB,
        ) -> EvmBuilder<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>> {
            EvmBuilder {
                context: Context::new(
                    self.context.evm.with_db(WrapDatabaseRef(db)),
                    self.context.external,
                ),
                handler: EvmBuilder::<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>>::handler(
                    self.handler.cfg(),
                ),
                phantom: PhantomData,
            }
        }
    *)
    Definition reset_handler_with_ref_db
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [ ODB ], [ self; db ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let db := M.alloc (| db |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::context::Context")
                      []
                      [ EXT; Ty.apply (Ty.path "revm_primitives::db::WrapDatabaseRef") [] [ ODB ] ],
                    "new",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                        "with_db",
                        [ Ty.apply (Ty.path "revm_primitives::db::WrapDatabaseRef") [] [ ODB ] ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        |);
                        Value.StructTuple "revm_primitives::db::WrapDatabaseRef" [ M.read (| db |) ]
                      ]
                    |);
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "external"
                      |)
                    |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [
                        Ty.path "revm::builder::SetGenericStage";
                        EXT;
                        Ty.apply (Ty.path "revm_primitives::db::WrapDatabaseRef") [] [ ODB ]
                      ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_reset_handler_with_ref_db :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self EXT DB)
        "reset_handler_with_ref_db"
        (reset_handler_with_ref_db EXT DB).
    
    (*
        pub fn reset_handler_with_external_context<OEXT>(
            self,
            external: OEXT,
        ) -> EvmBuilder<'a, SetGenericStage, OEXT, DB> {
            EvmBuilder {
                context: Context::new(self.context.evm, external),
                handler: EvmBuilder::<'a, SetGenericStage, OEXT, DB>::handler(self.handler.cfg()),
                phantom: PhantomData,
            }
        }
    *)
    Definition reset_handler_with_external_context
        (EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self EXT DB in
      match ε, τ, α with
      | [], [ OEXT ], [ self; external ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let external := M.alloc (| external |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "revm::context::Context") [] [ OEXT; DB ],
                    "new",
                    []
                  |),
                  [
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "evm"
                      |)
                    |);
                    M.read (| external |)
                  ]
                |));
              ("handler",
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::builder::EvmBuilder")
                      []
                      [ Ty.path "revm::builder::SetGenericStage"; OEXT; DB ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_reset_handler_with_external_context :
      forall (EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self EXT DB)
        "reset_handler_with_external_context"
        (reset_handler_with_external_context EXT DB).
  End Impl_revm_builder_EvmBuilder_revm_builder_HandlerStage_EXT_DB.
  
  Module Impl_revm_builder_EvmBuilder_BuilderStage_EXT_DB.
    Definition Self (BuilderStage EXT DB : Ty.t) : Ty.t :=
      Ty.apply (Ty.path "revm::builder::EvmBuilder") [] [ BuilderStage; EXT; DB ].
    
    (*
        fn handler(handler_cfg: HandlerCfg) -> Handler<'a, Evm<'a, EXT, DB>, EXT, DB> {
            Handler::new(handler_cfg)
        }
    *)
    Definition handler
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ handler_cfg ] =>
        ltac:(M.monadic
          (let handler_cfg := M.alloc (| handler_cfg |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.apply
                (Ty.path "revm::handler::Handler")
                []
                [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
              "new",
              []
            |),
            [ M.read (| handler_cfg |) ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_handler :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction (Self BuilderStage EXT DB) "handler" (handler BuilderStage EXT DB).
    
    (*
        pub fn with_handler(
            self,
            handler: Handler<'a, Evm<'a, EXT, DB>, EXT, DB>,
        ) -> EvmBuilder<'a, BuilderStage, EXT, DB> {
            EvmBuilder {
                context: self.context,
                handler,
                phantom: PhantomData,
            }
        }
    *)
    Definition with_handler
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self; handler ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let handler := M.alloc (| handler |) in
          Value.StructRecord
            "revm::builder::EvmBuilder"
            [
              ("context",
                M.read (|
                  M.SubPointer.get_struct_record_field (|
                    self,
                    "revm::builder::EvmBuilder",
                    "context"
                  |)
                |));
              ("handler", M.read (| handler |));
              ("phantom", Value.StructTuple "core::marker::PhantomData" [])
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_handler :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "with_handler"
        (with_handler BuilderStage EXT DB).
    
    (*
        pub fn build(self) -> Evm<'a, EXT, DB> {
            Evm::new(self.context, self.handler)
        }
    *)
    Definition build
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ],
              "new",
              []
            |),
            [
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  self,
                  "revm::builder::EvmBuilder",
                  "context"
                |)
              |);
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  self,
                  "revm::builder::EvmBuilder",
                  "handler"
                |)
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_build :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction (Self BuilderStage EXT DB) "build" (build BuilderStage EXT DB).
    
    (*
        pub fn append_handler_register(
            mut self,
            handle_register: register::HandleRegister<EXT, DB>,
        ) -> EvmBuilder<'a, HandlerStage, EXT, DB> {
            self.handler
                .append_handler_register(register::HandleRegisters::Plain(handle_register));
            EvmBuilder {
                context: self.context,
                handler: self.handler,
    
                phantom: PhantomData,
            }
        }
    *)
    Definition append_handler_register
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self; handle_register ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let handle_register := M.alloc (| handle_register |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::handler::Handler")
                      []
                      [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                    "append_handler_register",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "revm::builder::EvmBuilder",
                      "handler"
                    |);
                    Value.StructTuple
                      "revm::handler::register::HandleRegisters::Plain"
                      [ M.read (| handle_register |) ]
                  ]
                |)
              |) in
            M.alloc (|
              Value.StructRecord
                "revm::builder::EvmBuilder"
                [
                  ("context",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "revm::builder::EvmBuilder",
                        "context"
                      |)
                    |));
                  ("handler",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "revm::builder::EvmBuilder",
                        "handler"
                      |)
                    |));
                  ("phantom", Value.StructTuple "core::marker::PhantomData" [])
                ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_append_handler_register :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "append_handler_register"
        (append_handler_register BuilderStage EXT DB).
    
    (*
        pub fn append_handler_register_box(
            mut self,
            handle_register: register::HandleRegisterBox<EXT, DB>,
        ) -> EvmBuilder<'a, HandlerStage, EXT, DB> {
            self.handler
                .append_handler_register(register::HandleRegisters::Box(handle_register));
            EvmBuilder {
                context: self.context,
                handler: self.handler,
    
                phantom: PhantomData,
            }
        }
    *)
    Definition append_handler_register_box
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self; handle_register ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let handle_register := M.alloc (| handle_register |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::handler::Handler")
                      []
                      [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                    "append_handler_register",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "revm::builder::EvmBuilder",
                      "handler"
                    |);
                    Value.StructTuple
                      "revm::handler::register::HandleRegisters::Box"
                      [ M.read (| handle_register |) ]
                  ]
                |)
              |) in
            M.alloc (|
              Value.StructRecord
                "revm::builder::EvmBuilder"
                [
                  ("context",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "revm::builder::EvmBuilder",
                        "context"
                      |)
                    |));
                  ("handler",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "revm::builder::EvmBuilder",
                        "handler"
                      |)
                    |));
                  ("phantom", Value.StructTuple "core::marker::PhantomData" [])
                ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_append_handler_register_box :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "append_handler_register_box"
        (append_handler_register_box BuilderStage EXT DB).
    
    (*
        pub fn with_spec_id(mut self, spec_id: SpecId) -> Self {
            self.handler.modify_spec_id(spec_id);
            EvmBuilder {
                context: self.context,
                handler: self.handler,
    
                phantom: PhantomData,
            }
        }
    *)
    Definition with_spec_id
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self; spec_id ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let spec_id := M.alloc (| spec_id |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply
                      (Ty.path "revm::handler::Handler")
                      []
                      [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                    "modify_spec_id",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "revm::builder::EvmBuilder",
                      "handler"
                    |);
                    M.read (| spec_id |)
                  ]
                |)
              |) in
            M.alloc (|
              Value.StructRecord
                "revm::builder::EvmBuilder"
                [
                  ("context",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "revm::builder::EvmBuilder",
                        "context"
                      |)
                    |));
                  ("handler",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "revm::builder::EvmBuilder",
                        "handler"
                      |)
                    |));
                  ("phantom", Value.StructTuple "core::marker::PhantomData" [])
                ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_spec_id :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "with_spec_id"
        (with_spec_id BuilderStage EXT DB).
    
    (*
        pub fn modify_db(mut self, f: impl FnOnce(&mut DB)) -> Self {
            f(&mut self.context.evm.db);
            self
        }
    *)
    Definition modify_db
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [ impl_FnOnce__mut_DB_ ], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::function::FnOnce",
                    impl_FnOnce__mut_DB_,
                    [ Ty.tuple [ Ty.apply (Ty.path "&mut") [] [ DB ] ] ],
                    "call_once",
                    []
                  |),
                  [
                    M.read (| f |);
                    Value.Tuple
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::DerefMut",
                              Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                              [],
                              "deref_mut",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.SubPointer.get_struct_record_field (|
                                  self,
                                  "revm::builder::EvmBuilder",
                                  "context"
                                |),
                                "revm::context::Context",
                                "evm"
                              |)
                            ]
                          |),
                          "revm::context::inner_evm_context::InnerEvmContext",
                          "db"
                        |)
                      ]
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_modify_db :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction (Self BuilderStage EXT DB) "modify_db" (modify_db BuilderStage EXT DB).
    
    (*
        pub fn modify_external_context(mut self, f: impl FnOnce(&mut EXT)) -> Self {
            f(&mut self.context.external);
            self
        }
    *)
    Definition modify_external_context
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [ impl_FnOnce__mut_EXT_ ], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::function::FnOnce",
                    impl_FnOnce__mut_EXT_,
                    [ Ty.tuple [ Ty.apply (Ty.path "&mut") [] [ EXT ] ] ],
                    "call_once",
                    []
                  |),
                  [
                    M.read (| f |);
                    Value.Tuple
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.SubPointer.get_struct_record_field (|
                            self,
                            "revm::builder::EvmBuilder",
                            "context"
                          |),
                          "revm::context::Context",
                          "external"
                        |)
                      ]
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_modify_external_context :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "modify_external_context"
        (modify_external_context BuilderStage EXT DB).
    
    (*
        pub fn modify_env(mut self, f: impl FnOnce(&mut Box<Env>)) -> Self {
            f(&mut self.context.evm.env);
            self
        }
    *)
    Definition modify_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [ impl_FnOnce__mut_Box_Env__ ], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::function::FnOnce",
                    impl_FnOnce__mut_Box_Env__,
                    [
                      Ty.tuple
                        [
                          Ty.apply
                            (Ty.path "&mut")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::boxed::Box")
                                []
                                [
                                  Ty.path "revm_primitives::env::Env";
                                  Ty.path "alloc::alloc::Global"
                                ]
                            ]
                        ]
                    ],
                    "call_once",
                    []
                  |),
                  [
                    M.read (| f |);
                    Value.Tuple
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::DerefMut",
                              Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                              [],
                              "deref_mut",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.SubPointer.get_struct_record_field (|
                                  self,
                                  "revm::builder::EvmBuilder",
                                  "context"
                                |),
                                "revm::context::Context",
                                "evm"
                              |)
                            ]
                          |),
                          "revm::context::inner_evm_context::InnerEvmContext",
                          "env"
                        |)
                      ]
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_modify_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "modify_env"
        (modify_env BuilderStage EXT DB).
    
    (*
        pub fn with_env(mut self, env: Box<Env>) -> Self {
            self.context.evm.env = env;
            self
        }
    *)
    Definition with_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self; env ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let env := M.alloc (| env |) in
          M.read (|
            let~ _ :=
              M.write (|
                M.SubPointer.get_struct_record_field (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::ops::deref::DerefMut",
                      Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                      [],
                      "deref_mut",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "context"
                        |),
                        "revm::context::Context",
                        "evm"
                      |)
                    ]
                  |),
                  "revm::context::inner_evm_context::InnerEvmContext",
                  "env"
                |),
                M.read (| env |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction (Self BuilderStage EXT DB) "with_env" (with_env BuilderStage EXT DB).
    
    (*
        pub fn modify_tx_env(mut self, f: impl FnOnce(&mut TxEnv)) -> Self {
            f(&mut self.context.evm.env.tx);
            self
        }
    *)
    Definition modify_tx_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [ impl_FnOnce__mut_TxEnv_ ], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::function::FnOnce",
                    impl_FnOnce__mut_TxEnv_,
                    [
                      Ty.tuple
                        [ Ty.apply (Ty.path "&mut") [] [ Ty.path "revm_primitives::env::TxEnv" ] ]
                    ],
                    "call_once",
                    []
                  |),
                  [
                    M.read (| f |);
                    Value.Tuple
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (|
                            M.SubPointer.get_struct_record_field (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::deref::DerefMut",
                                  Ty.apply
                                    (Ty.path "revm::context::evm_context::EvmContext")
                                    []
                                    [ DB ],
                                  [],
                                  "deref_mut",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.SubPointer.get_struct_record_field (|
                                      self,
                                      "revm::builder::EvmBuilder",
                                      "context"
                                    |),
                                    "revm::context::Context",
                                    "evm"
                                  |)
                                ]
                              |),
                              "revm::context::inner_evm_context::InnerEvmContext",
                              "env"
                            |)
                          |),
                          "revm_primitives::env::Env",
                          "tx"
                        |)
                      ]
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_modify_tx_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "modify_tx_env"
        (modify_tx_env BuilderStage EXT DB).
    
    (*
        pub fn with_tx_env(mut self, tx_env: TxEnv) -> Self {
            self.context.evm.env.tx = tx_env;
            self
        }
    *)
    Definition with_tx_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self; tx_env ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let tx_env := M.alloc (| tx_env |) in
          M.read (|
            let~ _ :=
              M.write (|
                M.SubPointer.get_struct_record_field (|
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::deref::DerefMut",
                          Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                          [],
                          "deref_mut",
                          []
                        |),
                        [
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        ]
                      |),
                      "revm::context::inner_evm_context::InnerEvmContext",
                      "env"
                    |)
                  |),
                  "revm_primitives::env::Env",
                  "tx"
                |),
                M.read (| tx_env |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_tx_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "with_tx_env"
        (with_tx_env BuilderStage EXT DB).
    
    (*
        pub fn modify_block_env(mut self, f: impl FnOnce(&mut BlockEnv)) -> Self {
            f(&mut self.context.evm.env.block);
            self
        }
    *)
    Definition modify_block_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [ impl_FnOnce__mut_BlockEnv_ ], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::function::FnOnce",
                    impl_FnOnce__mut_BlockEnv_,
                    [
                      Ty.tuple
                        [ Ty.apply (Ty.path "&mut") [] [ Ty.path "revm_primitives::env::BlockEnv" ]
                        ]
                    ],
                    "call_once",
                    []
                  |),
                  [
                    M.read (| f |);
                    Value.Tuple
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (|
                            M.SubPointer.get_struct_record_field (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::deref::DerefMut",
                                  Ty.apply
                                    (Ty.path "revm::context::evm_context::EvmContext")
                                    []
                                    [ DB ],
                                  [],
                                  "deref_mut",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.SubPointer.get_struct_record_field (|
                                      self,
                                      "revm::builder::EvmBuilder",
                                      "context"
                                    |),
                                    "revm::context::Context",
                                    "evm"
                                  |)
                                ]
                              |),
                              "revm::context::inner_evm_context::InnerEvmContext",
                              "env"
                            |)
                          |),
                          "revm_primitives::env::Env",
                          "block"
                        |)
                      ]
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_modify_block_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "modify_block_env"
        (modify_block_env BuilderStage EXT DB).
    
    (*
        pub fn with_block_env(mut self, block_env: BlockEnv) -> Self {
            self.context.evm.env.block = block_env;
            self
        }
    *)
    Definition with_block_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self; block_env ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let block_env := M.alloc (| block_env |) in
          M.read (|
            let~ _ :=
              M.write (|
                M.SubPointer.get_struct_record_field (|
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::deref::DerefMut",
                          Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                          [],
                          "deref_mut",
                          []
                        |),
                        [
                          M.SubPointer.get_struct_record_field (|
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "revm::builder::EvmBuilder",
                              "context"
                            |),
                            "revm::context::Context",
                            "evm"
                          |)
                        ]
                      |),
                      "revm::context::inner_evm_context::InnerEvmContext",
                      "env"
                    |)
                  |),
                  "revm_primitives::env::Env",
                  "block"
                |),
                M.read (| block_env |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_block_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "with_block_env"
        (with_block_env BuilderStage EXT DB).
    
    (*
        pub fn modify_cfg_env(mut self, f: impl FnOnce(&mut CfgEnv)) -> Self {
            f(&mut self.context.evm.env.cfg);
            self
        }
    *)
    Definition modify_cfg_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [ impl_FnOnce__mut_CfgEnv_ ], [ self; f ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let f := M.alloc (| f |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::function::FnOnce",
                    impl_FnOnce__mut_CfgEnv_,
                    [
                      Ty.tuple
                        [ Ty.apply (Ty.path "&mut") [] [ Ty.path "revm_primitives::env::CfgEnv" ] ]
                    ],
                    "call_once",
                    []
                  |),
                  [
                    M.read (| f |);
                    Value.Tuple
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (|
                            M.SubPointer.get_struct_record_field (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::deref::DerefMut",
                                  Ty.apply
                                    (Ty.path "revm::context::evm_context::EvmContext")
                                    []
                                    [ DB ],
                                  [],
                                  "deref_mut",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.SubPointer.get_struct_record_field (|
                                      self,
                                      "revm::builder::EvmBuilder",
                                      "context"
                                    |),
                                    "revm::context::Context",
                                    "evm"
                                  |)
                                ]
                              |),
                              "revm::context::inner_evm_context::InnerEvmContext",
                              "env"
                            |)
                          |),
                          "revm_primitives::env::Env",
                          "cfg"
                        |)
                      ]
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_modify_cfg_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "modify_cfg_env"
        (modify_cfg_env BuilderStage EXT DB).
    
    (*
        pub fn with_clear_env(mut self) -> Self {
            self.context.evm.env.clear();
            self
        }
    *)
    Definition with_clear_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (| Ty.path "revm_primitives::env::Env", "clear", [] |),
                  [
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::deref::DerefMut",
                            Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                            [],
                            "deref_mut",
                            []
                          |),
                          [
                            M.SubPointer.get_struct_record_field (|
                              M.SubPointer.get_struct_record_field (|
                                self,
                                "revm::builder::EvmBuilder",
                                "context"
                              |),
                              "revm::context::Context",
                              "evm"
                            |)
                          ]
                        |),
                        "revm::context::inner_evm_context::InnerEvmContext",
                        "env"
                      |)
                    |)
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_clear_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "with_clear_env"
        (with_clear_env BuilderStage EXT DB).
    
    (*
        pub fn with_clear_tx_env(mut self) -> Self {
            self.context.evm.env.tx.clear();
            self
        }
    *)
    Definition with_clear_tx_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.path "revm_primitives::env::TxEnv",
                    "clear",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::DerefMut",
                              Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                              [],
                              "deref_mut",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.SubPointer.get_struct_record_field (|
                                  self,
                                  "revm::builder::EvmBuilder",
                                  "context"
                                |),
                                "revm::context::Context",
                                "evm"
                              |)
                            ]
                          |),
                          "revm::context::inner_evm_context::InnerEvmContext",
                          "env"
                        |)
                      |),
                      "revm_primitives::env::Env",
                      "tx"
                    |)
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_clear_tx_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "with_clear_tx_env"
        (with_clear_tx_env BuilderStage EXT DB).
    
    (*
        pub fn with_clear_block_env(mut self) -> Self {
            self.context.evm.env.block.clear();
            self
        }
    *)
    Definition with_clear_block_env
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            let~ _ :=
              M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.path "revm_primitives::env::BlockEnv",
                    "clear",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::deref::DerefMut",
                              Ty.apply (Ty.path "revm::context::evm_context::EvmContext") [] [ DB ],
                              [],
                              "deref_mut",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.SubPointer.get_struct_record_field (|
                                  self,
                                  "revm::builder::EvmBuilder",
                                  "context"
                                |),
                                "revm::context::Context",
                                "evm"
                              |)
                            ]
                          |),
                          "revm::context::inner_evm_context::InnerEvmContext",
                          "env"
                        |)
                      |),
                      "revm_primitives::env::Env",
                      "block"
                    |)
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_with_clear_block_env :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "with_clear_block_env"
        (with_clear_block_env BuilderStage EXT DB).
    
    (*
        pub fn reset_handler(mut self) -> Self {
            self.handler = Self::handler(self.handler.cfg());
            self
        }
    *)
    Definition reset_handler
        (BuilderStage EXT DB : Ty.t)
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      let Self : Ty.t := Self BuilderStage EXT DB in
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            let~ _ :=
              M.write (|
                M.SubPointer.get_struct_record_field (|
                  self,
                  "revm::builder::EvmBuilder",
                  "handler"
                |),
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "revm::builder::EvmBuilder") [] [ BuilderStage; EXT; DB ],
                    "handler",
                    []
                  |),
                  [
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "revm::handler::Handler")
                          []
                          [ Ty.apply (Ty.path "revm::evm::Evm") [] [ EXT; DB ]; EXT; DB ],
                        "cfg",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "revm::builder::EvmBuilder",
                          "handler"
                        |)
                      ]
                    |)
                  ]
                |)
              |) in
            self
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_reset_handler :
      forall (BuilderStage EXT DB : Ty.t),
      M.IsAssociatedFunction
        (Self BuilderStage EXT DB)
        "reset_handler"
        (reset_handler BuilderStage EXT DB).
  End Impl_revm_builder_EvmBuilder_BuilderStage_EXT_DB.
End builder.
