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

Module bytecode.
  Module eof.
    Module types_section.
      (* StructRecord
        {
          name := "TypesSection";
          const_params := [];
          ty_params := [];
          fields :=
            [ ("inputs", Ty.path "u8"); ("outputs", Ty.path "u8"); ("max_stack_size", Ty.path "u16")
            ];
        } *)
      
      Module Impl_core_fmt_Debug_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        (* Debug *)
        Definition fmt (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::Formatter",
                  "debug_struct_field3_finish",
                  []
                |),
                [
                  M.read (| f |);
                  M.read (| Value.String "TypesSection" |);
                  M.read (| Value.String "inputs" |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "revm_primitives::bytecode::eof::types_section::TypesSection",
                    "inputs"
                  |);
                  M.read (| Value.String "outputs" |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "revm_primitives::bytecode::eof::types_section::TypesSection",
                    "outputs"
                  |);
                  M.read (| Value.String "max_stack_size" |);
                  M.alloc (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "revm_primitives::bytecode::eof::types_section::TypesSection",
                      "max_stack_size"
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::fmt::Debug"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
      End Impl_core_fmt_Debug_for_revm_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_core_clone_Clone_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        (* Clone *)
        Definition clone (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  Value.DeclaredButUndefined,
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (M.match_operator (|
                          Value.DeclaredButUndefined,
                          [ fun γ => ltac:(M.monadic (M.read (| self |))) ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::clone::Clone"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method clone) ].
      End Impl_core_clone_Clone_for_revm_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_core_default_Default_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        (* Default *)
        Definition default (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "revm_primitives::bytecode::eof::types_section::TypesSection"
                [
                  ("inputs",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.path "u8",
                        [],
                        "default",
                        []
                      |),
                      []
                    |));
                  ("outputs",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.path "u8",
                        [],
                        "default",
                        []
                      |),
                      []
                    |));
                  ("max_stack_size",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.path "u16",
                        [],
                        "default",
                        []
                      |),
                      []
                    |))
                ]))
          | _, _, _ => 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_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_core_hash_Hash_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        (* Hash *)
        Definition hash (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [ __H ], [ self; state ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let state := M.alloc (| state |) in
              M.read (|
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::hash::Hash",
                        Ty.path "u8",
                        [],
                        "hash",
                        [ __H ]
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "revm_primitives::bytecode::eof::types_section::TypesSection",
                          "inputs"
                        |);
                        M.read (| state |)
                      ]
                    |)
                  |) in
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::hash::Hash",
                        Ty.path "u8",
                        [],
                        "hash",
                        [ __H ]
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "revm_primitives::bytecode::eof::types_section::TypesSection",
                          "outputs"
                        |);
                        M.read (| state |)
                      ]
                    |)
                  |) in
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (| "core::hash::Hash", Ty.path "u16", [], "hash", [ __H ] |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "revm_primitives::bytecode::eof::types_section::TypesSection",
                        "max_stack_size"
                      |);
                      M.read (| state |)
                    ]
                  |)
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::hash::Hash"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("hash", InstanceField.Method hash) ].
      End Impl_core_hash_Hash_for_revm_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_core_marker_StructuralPartialEq_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        Axiom Implements :
          M.IsTraitInstance
            "core::marker::StructuralPartialEq"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_marker_StructuralPartialEq_for_revm_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_core_cmp_PartialEq_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        (* PartialEq *)
        Definition eq (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self; other ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let other := M.alloc (| other |) in
              LogicalOp.and (|
                LogicalOp.and (|
                  BinOp.eq (|
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "revm_primitives::bytecode::eof::types_section::TypesSection",
                        "inputs"
                      |)
                    |),
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| other |),
                        "revm_primitives::bytecode::eof::types_section::TypesSection",
                        "inputs"
                      |)
                    |)
                  |),
                  ltac:(M.monadic
                    (BinOp.eq (|
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "revm_primitives::bytecode::eof::types_section::TypesSection",
                          "outputs"
                        |)
                      |),
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| other |),
                          "revm_primitives::bytecode::eof::types_section::TypesSection",
                          "outputs"
                        |)
                      |)
                    |)))
                |),
                ltac:(M.monadic
                  (BinOp.eq (|
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "revm_primitives::bytecode::eof::types_section::TypesSection",
                        "max_stack_size"
                      |)
                    |),
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| other |),
                        "revm_primitives::bytecode::eof::types_section::TypesSection",
                        "max_stack_size"
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::cmp::PartialEq"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("eq", InstanceField.Method eq) ].
      End Impl_core_cmp_PartialEq_for_revm_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_core_cmp_Eq_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        (* Eq *)
        Definition assert_receiver_is_total_eq
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  Value.DeclaredButUndefined,
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (M.match_operator (|
                          Value.DeclaredButUndefined,
                          [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::cmp::Eq"
            Self
            (* Trait polymorphic types *) []
            (* Instance *)
            [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ].
      End Impl_core_cmp_Eq_for_revm_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_core_marker_Copy_for_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        Axiom Implements :
          M.IsTraitInstance
            "core::marker::Copy"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_marker_Copy_for_revm_primitives_bytecode_eof_types_section_TypesSection.
      
      Module Impl_revm_primitives_bytecode_eof_types_section_TypesSection.
        Definition Self : Ty.t :=
          Ty.path "revm_primitives::bytecode::eof::types_section::TypesSection".
        
        (*
            pub const fn io_diff(&self) -> i32 {
                self.outputs as i32 - self.inputs as i32
            }
        *)
        Definition io_diff (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              BinOp.Wrap.sub (|
                M.rust_cast
                  (M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "revm_primitives::bytecode::eof::types_section::TypesSection",
                      "outputs"
                    |)
                  |)),
                M.rust_cast
                  (M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "revm_primitives::bytecode::eof::types_section::TypesSection",
                      "inputs"
                    |)
                  |))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_io_diff : M.IsAssociatedFunction Self "io_diff" io_diff.
        
        (*
            pub fn encode(&self, buffer: &mut Vec<u8>) {
                buffer.push(self.inputs);
                buffer.push(self.outputs);
                buffer.extend_from_slice(&self.max_stack_size.to_be_bytes());
            }
        *)
        Definition encode (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self; buffer ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let buffer := M.alloc (| buffer |) in
              M.read (|
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::vec::Vec")
                          []
                          [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                        "push",
                        []
                      |),
                      [
                        M.read (| buffer |);
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "revm_primitives::bytecode::eof::types_section::TypesSection",
                            "inputs"
                          |)
                        |)
                      ]
                    |)
                  |) in
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::vec::Vec")
                          []
                          [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                        "push",
                        []
                      |),
                      [
                        M.read (| buffer |);
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "revm_primitives::bytecode::eof::types_section::TypesSection",
                            "outputs"
                          |)
                        |)
                      ]
                    |)
                  |) in
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::vec::Vec")
                          []
                          [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ],
                        "extend_from_slice",
                        []
                      |),
                      [
                        M.read (| buffer |);
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "u16", "to_be_bytes", [] |),
                            [
                              M.read (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "revm_primitives::bytecode::eof::types_section::TypesSection",
                                  "max_stack_size"
                                |)
                              |)
                            ]
                          |)
                        |)
                      ]
                    |)
                  |) in
                M.alloc (| Value.Tuple [] |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_encode : M.IsAssociatedFunction Self "encode" encode.
        
        (*
            pub fn decode(input: &[u8]) -> Result<(Self, &[u8]), EofDecodeError> {
                let (input, inputs) = consume_u8(input)?;
                let (input, outputs) = consume_u8(input)?;
                let (input, max_stack_size) = consume_u16(input)?;
                let section = Self {
                    inputs,
                    outputs,
                    max_stack_size,
                };
                section.validate()?;
                Ok((section, input))
            }
        *)
        Definition decode (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ input ] =>
            ltac:(M.monadic
              (let input := M.alloc (| input |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                []
                                [
                                  Ty.tuple
                                    [
                                      Ty.apply
                                        (Ty.path "&")
                                        []
                                        [ Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ] ];
                                      Ty.path "u8"
                                    ];
                                  Ty.path "revm_primitives::bytecode::eof::EofDecodeError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_function (|
                                  "revm_primitives::bytecode::eof::decode_helpers::consume_u8",
                                  []
                                |),
                                [ M.read (| input |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            []
                                            [
                                              Ty.tuple
                                                [
                                                  Ty.path
                                                    "revm_primitives::bytecode::eof::types_section::TypesSection";
                                                  Ty.apply
                                                    (Ty.path "&")
                                                    []
                                                    [ Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ]
                                                    ]
                                                ];
                                              Ty.path
                                                "revm_primitives::bytecode::eof::EofDecodeError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              []
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "revm_primitives::bytecode::eof::EofDecodeError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                            let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                            let input := M.copy (| γ0_0 |) in
                            let inputs := M.copy (| γ0_1 |) in
                            M.match_operator (|
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::Try",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        []
                                        [
                                          Ty.tuple
                                            [
                                              Ty.apply
                                                (Ty.path "&")
                                                []
                                                [ Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ] ];
                                              Ty.path "u8"
                                            ];
                                          Ty.path "revm_primitives::bytecode::eof::EofDecodeError"
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_function (|
                                          "revm_primitives::bytecode::eof::decode_helpers::consume_u8",
                                          []
                                        |),
                                        [ M.read (| input |) ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::ops::control_flow::ControlFlow::Break",
                                          0
                                        |) in
                                      let residual := M.copy (| γ0_0 |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::FromResidual",
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    []
                                                    [
                                                      Ty.tuple
                                                        [
                                                          Ty.path
                                                            "revm_primitives::bytecode::eof::types_section::TypesSection";
                                                          Ty.apply
                                                            (Ty.path "&")
                                                            []
                                                            [
                                                              Ty.apply
                                                                (Ty.path "slice")
                                                                []
                                                                [ Ty.path "u8" ]
                                                            ]
                                                        ];
                                                      Ty.path
                                                        "revm_primitives::bytecode::eof::EofDecodeError"
                                                    ],
                                                  [
                                                    Ty.apply
                                                      (Ty.path "core::result::Result")
                                                      []
                                                      [
                                                        Ty.path "core::convert::Infallible";
                                                        Ty.path
                                                          "revm_primitives::bytecode::eof::EofDecodeError"
                                                      ]
                                                  ],
                                                  "from_residual",
                                                  []
                                                |),
                                                [ M.read (| residual |) ]
                                              |)
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::ops::control_flow::ControlFlow::Continue",
                                          0
                                        |) in
                                      let val := M.copy (| γ0_0 |) in
                                      val))
                                ]
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                    let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                    let input := M.copy (| γ0_0 |) in
                                    let outputs := M.copy (| γ0_1 |) in
                                    M.match_operator (|
                                      M.match_operator (|
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::Try",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                []
                                                [
                                                  Ty.tuple
                                                    [
                                                      Ty.apply
                                                        (Ty.path "&")
                                                        []
                                                        [
                                                          Ty.apply
                                                            (Ty.path "slice")
                                                            []
                                                            [ Ty.path "u8" ]
                                                        ];
                                                      Ty.path "u16"
                                                    ];
                                                  Ty.path
                                                    "revm_primitives::bytecode::eof::EofDecodeError"
                                                ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_function (|
                                                  "revm_primitives::bytecode::eof::decode_helpers::consume_u16",
                                                  []
                                                |),
                                                [ M.read (| input |) ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ0_0 :=
                                                M.SubPointer.get_struct_tuple_field (|
                                                  γ,
                                                  "core::ops::control_flow::ControlFlow::Break",
                                                  0
                                                |) in
                                              let residual := M.copy (| γ0_0 |) in
                                              M.alloc (|
                                                M.never_to_any (|
                                                  M.read (|
                                                    M.return_ (|
                                                      M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::ops::try_trait::FromResidual",
                                                          Ty.apply
                                                            (Ty.path "core::result::Result")
                                                            []
                                                            [
                                                              Ty.tuple
                                                                [
                                                                  Ty.path
                                                                    "revm_primitives::bytecode::eof::types_section::TypesSection";
                                                                  Ty.apply
                                                                    (Ty.path "&")
                                                                    []
                                                                    [
                                                                      Ty.apply
                                                                        (Ty.path "slice")
                                                                        []
                                                                        [ Ty.path "u8" ]
                                                                    ]
                                                                ];
                                                              Ty.path
                                                                "revm_primitives::bytecode::eof::EofDecodeError"
                                                            ],
                                                          [
                                                            Ty.apply
                                                              (Ty.path "core::result::Result")
                                                              []
                                                              [
                                                                Ty.path "core::convert::Infallible";
                                                                Ty.path
                                                                  "revm_primitives::bytecode::eof::EofDecodeError"
                                                              ]
                                                          ],
                                                          "from_residual",
                                                          []
                                                        |),
                                                        [ M.read (| residual |) ]
                                                      |)
                                                    |)
                                                  |)
                                                |)
                                              |)));
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ0_0 :=
                                                M.SubPointer.get_struct_tuple_field (|
                                                  γ,
                                                  "core::ops::control_flow::ControlFlow::Continue",
                                                  0
                                                |) in
                                              let val := M.copy (| γ0_0 |) in
                                              val))
                                        ]
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                            let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                            let input := M.copy (| γ0_0 |) in
                                            let max_stack_size := M.copy (| γ0_1 |) in
                                            let~ section :=
                                              M.alloc (|
                                                Value.StructRecord
                                                  "revm_primitives::bytecode::eof::types_section::TypesSection"
                                                  [
                                                    ("inputs", M.read (| inputs |));
                                                    ("outputs", M.read (| outputs |));
                                                    ("max_stack_size", M.read (| max_stack_size |))
                                                  ]
                                              |) in
                                            let~ _ :=
                                              M.match_operator (|
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::Try",
                                                      Ty.apply
                                                        (Ty.path "core::result::Result")
                                                        []
                                                        [
                                                          Ty.tuple [];
                                                          Ty.path
                                                            "revm_primitives::bytecode::eof::EofDecodeError"
                                                        ],
                                                      [],
                                                      "branch",
                                                      []
                                                    |),
                                                    [
                                                      M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.path
                                                            "revm_primitives::bytecode::eof::types_section::TypesSection",
                                                          "validate",
                                                          []
                                                        |),
                                                        [ section ]
                                                      |)
                                                    ]
                                                  |)
                                                |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let γ0_0 :=
                                                        M.SubPointer.get_struct_tuple_field (|
                                                          γ,
                                                          "core::ops::control_flow::ControlFlow::Break",
                                                          0
                                                        |) in
                                                      let residual := M.copy (| γ0_0 |) in
                                                      M.alloc (|
                                                        M.never_to_any (|
                                                          M.read (|
                                                            M.return_ (|
                                                              M.call_closure (|
                                                                M.get_trait_method (|
                                                                  "core::ops::try_trait::FromResidual",
                                                                  Ty.apply
                                                                    (Ty.path "core::result::Result")
                                                                    []
                                                                    [
                                                                      Ty.tuple
                                                                        [
                                                                          Ty.path
                                                                            "revm_primitives::bytecode::eof::types_section::TypesSection";
                                                                          Ty.apply
                                                                            (Ty.path "&")
                                                                            []
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path "slice")
                                                                                []
                                                                                [ Ty.path "u8" ]
                                                                            ]
                                                                        ];
                                                                      Ty.path
                                                                        "revm_primitives::bytecode::eof::EofDecodeError"
                                                                    ],
                                                                  [
                                                                    Ty.apply
                                                                      (Ty.path
                                                                        "core::result::Result")
                                                                      []
                                                                      [
                                                                        Ty.path
                                                                          "core::convert::Infallible";
                                                                        Ty.path
                                                                          "revm_primitives::bytecode::eof::EofDecodeError"
                                                                      ]
                                                                  ],
                                                                  "from_residual",
                                                                  []
                                                                |),
                                                                [ M.read (| residual |) ]
                                                              |)
                                                            |)
                                                          |)
                                                        |)
                                                      |)));
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let γ0_0 :=
                                                        M.SubPointer.get_struct_tuple_field (|
                                                          γ,
                                                          "core::ops::control_flow::ControlFlow::Continue",
                                                          0
                                                        |) in
                                                      let val := M.copy (| γ0_0 |) in
                                                      val))
                                                ]
                                              |) in
                                            M.alloc (|
                                              Value.StructTuple
                                                "core::result::Result::Ok"
                                                [
                                                  Value.Tuple
                                                    [ M.read (| section |); M.read (| input |) ]
                                                ]
                                            |)))
                                      ]
                                    |)))
                              ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_decode : M.IsAssociatedFunction Self "decode" decode.
        
        (*
            pub fn validate(&self) -> Result<(), EofDecodeError> {
                if self.inputs > 0x7f || self.outputs > 0x80 || self.max_stack_size > 0x03FF {
                    return Err(EofDecodeError::InvalidTypesSection);
                }
                if self.inputs as u16 > self.max_stack_size {
                    return Err(EofDecodeError::InvalidTypesSection);
                }
                Ok(())
            }
        *)
        Definition validate (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    LogicalOp.or (|
                                      LogicalOp.or (|
                                        BinOp.gt (|
                                          M.read (|
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "revm_primitives::bytecode::eof::types_section::TypesSection",
                                              "inputs"
                                            |)
                                          |),
                                          Value.Integer IntegerKind.U8 127
                                        |),
                                        ltac:(M.monadic
                                          (BinOp.gt (|
                                            M.read (|
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "revm_primitives::bytecode::eof::types_section::TypesSection",
                                                "outputs"
                                              |)
                                            |),
                                            Value.Integer IntegerKind.U8 128
                                          |)))
                                      |),
                                      ltac:(M.monadic
                                        (BinOp.gt (|
                                          M.read (|
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "revm_primitives::bytecode::eof::types_section::TypesSection",
                                              "max_stack_size"
                                            |)
                                          |),
                                          Value.Integer IntegerKind.U16 1023
                                        |)))
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      Value.StructTuple
                                        "core::result::Result::Err"
                                        [
                                          Value.StructTuple
                                            "revm_primitives::bytecode::eof::EofDecodeError::InvalidTypesSection"
                                            []
                                        ]
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    BinOp.gt (|
                                      M.rust_cast
                                        (M.read (|
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "revm_primitives::bytecode::eof::types_section::TypesSection",
                                            "inputs"
                                          |)
                                        |)),
                                      M.read (|
                                        M.SubPointer.get_struct_record_field (|
                                          M.read (| self |),
                                          "revm_primitives::bytecode::eof::types_section::TypesSection",
                                          "max_stack_size"
                                        |)
                                      |)
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      Value.StructTuple
                                        "core::result::Result::Err"
                                        [
                                          Value.StructTuple
                                            "revm_primitives::bytecode::eof::EofDecodeError::InvalidTypesSection"
                                            []
                                        ]
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_validate : M.IsAssociatedFunction Self "validate" validate.
      End Impl_revm_primitives_bytecode_eof_types_section_TypesSection.
    End types_section.
  End eof.
End bytecode.
