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

Module bn128.
  Module add.
    Definition value_ADDRESS : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            M.call_closure (|
              M.get_function (| "revm_precompile::u64_to_address", [] |),
              [ Value.Integer IntegerKind.U64 6 ]
            |)
          |))).
    
    Definition value_ISTANBUL_ADD_GAS_COST : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 150 |))).
    
    Definition value_ISTANBUL : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            Value.StructTuple
              "revm_precompile::PrecompileWithAddress"
              [
                M.read (| M.get_constant (| "revm_precompile::bn128::add::ADDRESS" |) |);
                Value.StructTuple
                  "revm_primitives::precompile::Precompile::Standard"
                  [
                    (* ClosureFnPointer(Safe) *)
                    M.pointer_coercion
                      (M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0; α1 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let input := M.copy (| γ |) in
                                        M.match_operator (|
                                          M.alloc (| α1 |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let gas_limit := M.copy (| γ |) in
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "revm_precompile::bn128::run_add",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::deref::Deref",
                                                        Ty.path "bytes::bytes::Bytes",
                                                        [],
                                                        "deref",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.path
                                                              "alloy_primitives::bytes_::Bytes",
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [ M.read (| input |) ]
                                                        |)
                                                      ]
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::add::ISTANBUL_ADD_GAS_COST"
                                                      |)
                                                    |);
                                                    M.read (| gas_limit |)
                                                  ]
                                                |)))
                                          ]
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end)))
                  ]
              ]
          |))).
    
    Definition value_BYZANTIUM_ADD_GAS_COST : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 500 |))).
    
    Definition value_BYZANTIUM : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            Value.StructTuple
              "revm_precompile::PrecompileWithAddress"
              [
                M.read (| M.get_constant (| "revm_precompile::bn128::add::ADDRESS" |) |);
                Value.StructTuple
                  "revm_primitives::precompile::Precompile::Standard"
                  [
                    (* ClosureFnPointer(Safe) *)
                    M.pointer_coercion
                      (M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0; α1 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let input := M.copy (| γ |) in
                                        M.match_operator (|
                                          M.alloc (| α1 |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let gas_limit := M.copy (| γ |) in
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "revm_precompile::bn128::run_add",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::deref::Deref",
                                                        Ty.path "bytes::bytes::Bytes",
                                                        [],
                                                        "deref",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.path
                                                              "alloy_primitives::bytes_::Bytes",
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [ M.read (| input |) ]
                                                        |)
                                                      ]
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::add::BYZANTIUM_ADD_GAS_COST"
                                                      |)
                                                    |);
                                                    M.read (| gas_limit |)
                                                  ]
                                                |)))
                                          ]
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end)))
                  ]
              ]
          |))).
  End add.
  
  Module mul.
    Definition value_ADDRESS : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            M.call_closure (|
              M.get_function (| "revm_precompile::u64_to_address", [] |),
              [ Value.Integer IntegerKind.U64 7 ]
            |)
          |))).
    
    Definition value_ISTANBUL_MUL_GAS_COST : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 6000 |))).
    
    Definition value_ISTANBUL : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            Value.StructTuple
              "revm_precompile::PrecompileWithAddress"
              [
                M.read (| M.get_constant (| "revm_precompile::bn128::mul::ADDRESS" |) |);
                Value.StructTuple
                  "revm_primitives::precompile::Precompile::Standard"
                  [
                    (* ClosureFnPointer(Safe) *)
                    M.pointer_coercion
                      (M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0; α1 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let input := M.copy (| γ |) in
                                        M.match_operator (|
                                          M.alloc (| α1 |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let gas_limit := M.copy (| γ |) in
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "revm_precompile::bn128::run_mul",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::deref::Deref",
                                                        Ty.path "bytes::bytes::Bytes",
                                                        [],
                                                        "deref",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.path
                                                              "alloy_primitives::bytes_::Bytes",
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [ M.read (| input |) ]
                                                        |)
                                                      ]
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::mul::ISTANBUL_MUL_GAS_COST"
                                                      |)
                                                    |);
                                                    M.read (| gas_limit |)
                                                  ]
                                                |)))
                                          ]
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end)))
                  ]
              ]
          |))).
    
    Definition value_BYZANTIUM_MUL_GAS_COST : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 40000 |))).
    
    Definition value_BYZANTIUM : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            Value.StructTuple
              "revm_precompile::PrecompileWithAddress"
              [
                M.read (| M.get_constant (| "revm_precompile::bn128::mul::ADDRESS" |) |);
                Value.StructTuple
                  "revm_primitives::precompile::Precompile::Standard"
                  [
                    (* ClosureFnPointer(Safe) *)
                    M.pointer_coercion
                      (M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0; α1 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let input := M.copy (| γ |) in
                                        M.match_operator (|
                                          M.alloc (| α1 |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let gas_limit := M.copy (| γ |) in
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "revm_precompile::bn128::run_mul",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::deref::Deref",
                                                        Ty.path "bytes::bytes::Bytes",
                                                        [],
                                                        "deref",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.path
                                                              "alloy_primitives::bytes_::Bytes",
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [ M.read (| input |) ]
                                                        |)
                                                      ]
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::mul::BYZANTIUM_MUL_GAS_COST"
                                                      |)
                                                    |);
                                                    M.read (| gas_limit |)
                                                  ]
                                                |)))
                                          ]
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end)))
                  ]
              ]
          |))).
  End mul.
  
  Module pair_.
    Definition value_ADDRESS : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            M.call_closure (|
              M.get_function (| "revm_precompile::u64_to_address", [] |),
              [ Value.Integer IntegerKind.U64 8 ]
            |)
          |))).
    
    Definition value_ISTANBUL_PAIR_PER_POINT : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 34000 |))).
    
    Definition value_ISTANBUL_PAIR_BASE : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 45000 |))).
    
    Definition value_ISTANBUL : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            Value.StructTuple
              "revm_precompile::PrecompileWithAddress"
              [
                M.read (| M.get_constant (| "revm_precompile::bn128::pair::ADDRESS" |) |);
                Value.StructTuple
                  "revm_primitives::precompile::Precompile::Standard"
                  [
                    (* ClosureFnPointer(Safe) *)
                    M.pointer_coercion
                      (M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0; α1 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let input := M.copy (| γ |) in
                                        M.match_operator (|
                                          M.alloc (| α1 |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let gas_limit := M.copy (| γ |) in
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "revm_precompile::bn128::run_pair",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::deref::Deref",
                                                        Ty.path "bytes::bytes::Bytes",
                                                        [],
                                                        "deref",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.path
                                                              "alloy_primitives::bytes_::Bytes",
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [ M.read (| input |) ]
                                                        |)
                                                      ]
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::pair::ISTANBUL_PAIR_PER_POINT"
                                                      |)
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::pair::ISTANBUL_PAIR_BASE"
                                                      |)
                                                    |);
                                                    M.read (| gas_limit |)
                                                  ]
                                                |)))
                                          ]
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end)))
                  ]
              ]
          |))).
    
    Definition value_BYZANTIUM_PAIR_PER_POINT : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 80000 |))).
    
    Definition value_BYZANTIUM_PAIR_BASE : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 100000 |))).
    
    Definition value_BYZANTIUM : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            Value.StructTuple
              "revm_precompile::PrecompileWithAddress"
              [
                M.read (| M.get_constant (| "revm_precompile::bn128::pair::ADDRESS" |) |);
                Value.StructTuple
                  "revm_primitives::precompile::Precompile::Standard"
                  [
                    (* ClosureFnPointer(Safe) *)
                    M.pointer_coercion
                      (M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0; α1 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let input := M.copy (| γ |) in
                                        M.match_operator (|
                                          M.alloc (| α1 |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let gas_limit := M.copy (| γ |) in
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "revm_precompile::bn128::run_pair",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::deref::Deref",
                                                        Ty.path "bytes::bytes::Bytes",
                                                        [],
                                                        "deref",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.path
                                                              "alloy_primitives::bytes_::Bytes",
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [ M.read (| input |) ]
                                                        |)
                                                      ]
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::pair::BYZANTIUM_PAIR_PER_POINT"
                                                      |)
                                                    |);
                                                    M.read (|
                                                      M.get_constant (|
                                                        "revm_precompile::bn128::pair::BYZANTIUM_PAIR_BASE"
                                                      |)
                                                    |);
                                                    M.read (| gas_limit |)
                                                  ]
                                                |)))
                                          ]
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end)))
                  ]
              ]
          |))).
  End pair_.
  
  Definition value_ADD_INPUT_LEN : Value.t :=
    M.run
      ltac:(M.monadic
        (M.alloc (|
          BinOp.Wrap.add (|
            Value.Integer IntegerKind.Usize 64,
            Value.Integer IntegerKind.Usize 64
          |)
        |))).
  
  Definition value_MUL_INPUT_LEN : Value.t :=
    M.run
      ltac:(M.monadic
        (M.alloc (|
          BinOp.Wrap.add (|
            Value.Integer IntegerKind.Usize 64,
            Value.Integer IntegerKind.Usize 32
          |)
        |))).
  
  Definition value_PAIR_ELEMENT_LEN : Value.t :=
    M.run
      ltac:(M.monadic
        (M.alloc (|
          BinOp.Wrap.add (|
            Value.Integer IntegerKind.Usize 64,
            Value.Integer IntegerKind.Usize 128
          |)
        |))).
  
  (*
  pub fn read_fq(input: &[u8]) -> Result<Fq, Error> {
      Fq::from_slice(&input[..32]).map_err(|_| Error::Bn128FieldPointNotAMember)
  }
  *)
  Definition read_fq (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ input ] =>
      ltac:(M.monadic
        (let input := M.alloc (| input |) in
        M.call_closure (|
          M.get_associated_function (|
            Ty.apply
              (Ty.path "core::result::Result")
              []
              [ Ty.path "substrate_bn::Fq"; Ty.path "substrate_bn::FieldError" ],
            "map_err",
            [
              Ty.path "revm_primitives::precompile::PrecompileError";
              Ty.function
                [ Ty.tuple [ Ty.path "substrate_bn::FieldError" ] ]
                (Ty.path "revm_primitives::precompile::PrecompileError")
            ]
          |),
          [
            M.call_closure (|
              M.get_associated_function (| Ty.path "substrate_bn::Fq", "from_slice", [] |),
              [
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::index::Index",
                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                    [ Ty.apply (Ty.path "core::ops::range::RangeTo") [] [ Ty.path "usize" ] ],
                    "index",
                    []
                  |),
                  [
                    M.read (| input |);
                    Value.StructRecord
                      "core::ops::range::RangeTo"
                      [ ("end_", Value.Integer IntegerKind.Usize 32) ]
                  ]
                |)
              ]
            |);
            M.closure
              (fun γ =>
                ltac:(M.monadic
                  match γ with
                  | [ α0 ] =>
                    ltac:(M.monadic
                      (M.match_operator (|
                        M.alloc (| α0 |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (Value.StructTuple
                                "revm_primitives::precompile::PrecompileError::Bn128FieldPointNotAMember"
                                []))
                        ]
                      |)))
                  | _ => M.impossible "wrong number of arguments"
                  end))
          ]
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_read_fq : M.IsFunction "revm_precompile::bn128::read_fq" read_fq.
  
  (*
  pub fn read_point(input: &[u8]) -> Result<G1, Error> {
      let px = read_fq(&input[0..32])?;
      let py = read_fq(&input[32..64])?;
      new_g1_point(px, py)
  }
  *)
  Definition read_point (ε : 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 (|
              let~ px :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            []
                            [
                              Ty.path "substrate_bn::Fq";
                              Ty.path "revm_primitives::precompile::PrecompileError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (| "revm_precompile::bn128::read_fq", [] |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::index::Index",
                                  Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                  [
                                    Ty.apply
                                      (Ty.path "core::ops::range::Range")
                                      []
                                      [ Ty.path "usize" ]
                                  ],
                                  "index",
                                  []
                                |),
                                [
                                  M.read (| input |);
                                  Value.StructRecord
                                    "core::ops::range::Range"
                                    [
                                      ("start", Value.Integer IntegerKind.Usize 0);
                                      ("end_", Value.Integer IntegerKind.Usize 32)
                                    ]
                                ]
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        []
                                        [
                                          Ty.path "substrate_bn::G1";
                                          Ty.path "revm_primitives::precompile::PrecompileError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "revm_primitives::precompile::PrecompileError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let~ py :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            []
                            [
                              Ty.path "substrate_bn::Fq";
                              Ty.path "revm_primitives::precompile::PrecompileError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (| "revm_precompile::bn128::read_fq", [] |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::index::Index",
                                  Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                  [
                                    Ty.apply
                                      (Ty.path "core::ops::range::Range")
                                      []
                                      [ Ty.path "usize" ]
                                  ],
                                  "index",
                                  []
                                |),
                                [
                                  M.read (| input |);
                                  Value.StructRecord
                                    "core::ops::range::Range"
                                    [
                                      ("start", Value.Integer IntegerKind.Usize 32);
                                      ("end_", Value.Integer IntegerKind.Usize 64)
                                    ]
                                ]
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Break",
                              0
                            |) in
                          let residual := M.copy (| γ0_0 |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::FromResidual",
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        []
                                        [
                                          Ty.path "substrate_bn::G1";
                                          Ty.path "revm_primitives::precompile::PrecompileError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "revm_primitives::precompile::PrecompileError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              M.alloc (|
                M.call_closure (|
                  M.get_function (| "revm_precompile::bn128::new_g1_point", [] |),
                  [ M.read (| px |); M.read (| py |) ]
                |)
              |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_read_point : M.IsFunction "revm_precompile::bn128::read_point" read_point.
  
  (*
  pub fn new_g1_point(px: Fq, py: Fq) -> Result<G1, Error> {
      if px == Fq::zero() && py == Fq::zero() {
          Ok(G1::zero())
      } else {
          AffineG1::new(px, py)
              .map(Into::into)
              .map_err(|_| Error::Bn128AffineGFailedToCreate)
      }
  }
  *)
  Definition new_g1_point (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ px; py ] =>
      ltac:(M.monadic
        (let px := M.alloc (| px |) in
        let py := M.alloc (| py |) in
        M.read (|
          M.match_operator (|
            M.alloc (| Value.Tuple [] |),
            [
              fun γ =>
                ltac:(M.monadic
                  (let γ :=
                    M.use
                      (M.alloc (|
                        LogicalOp.and (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::cmp::PartialEq",
                              Ty.path "substrate_bn::Fq",
                              [ Ty.path "substrate_bn::Fq" ],
                              "eq",
                              []
                            |),
                            [
                              px;
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "substrate_bn::Fq",
                                    "zero",
                                    []
                                  |),
                                  []
                                |)
                              |)
                            ]
                          |),
                          ltac:(M.monadic
                            (M.call_closure (|
                              M.get_trait_method (|
                                "core::cmp::PartialEq",
                                Ty.path "substrate_bn::Fq",
                                [ Ty.path "substrate_bn::Fq" ],
                                "eq",
                                []
                              |),
                              [
                                py;
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "substrate_bn::Fq",
                                      "zero",
                                      []
                                    |),
                                    []
                                  |)
                                |)
                              ]
                            |)))
                        |)
                      |)) in
                  let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::result::Result::Ok"
                      [
                        M.call_closure (|
                          M.get_trait_method (|
                            "substrate_bn::Group",
                            Ty.path "substrate_bn::G1",
                            [],
                            "zero",
                            []
                          |),
                          []
                        |)
                      ]
                  |)));
              fun γ =>
                ltac:(M.monadic
                  (M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::result::Result")
                          []
                          [ Ty.path "substrate_bn::G1"; Ty.path "substrate_bn::groups::Error" ],
                        "map_err",
                        [
                          Ty.path "revm_primitives::precompile::PrecompileError";
                          Ty.function
                            [ Ty.tuple [ Ty.path "substrate_bn::groups::Error" ] ]
                            (Ty.path "revm_primitives::precompile::PrecompileError")
                        ]
                      |),
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "core::result::Result")
                              []
                              [
                                Ty.path "substrate_bn::AffineG1";
                                Ty.path "substrate_bn::groups::Error"
                              ],
                            "map",
                            [
                              Ty.path "substrate_bn::G1";
                              Ty.function
                                [ Ty.path "substrate_bn::AffineG1" ]
                                (Ty.path "substrate_bn::G1")
                            ]
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "substrate_bn::AffineG1",
                                "new",
                                []
                              |),
                              [ M.read (| px |); M.read (| py |) ]
                            |);
                            M.get_trait_method (|
                              "core::convert::Into",
                              Ty.path "substrate_bn::AffineG1",
                              [ Ty.path "substrate_bn::G1" ],
                              "into",
                              []
                            |)
                          ]
                        |);
                        M.closure
                          (fun γ =>
                            ltac:(M.monadic
                              match γ with
                              | [ α0 ] =>
                                ltac:(M.monadic
                                  (M.match_operator (|
                                    M.alloc (| α0 |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (Value.StructTuple
                                            "revm_primitives::precompile::PrecompileError::Bn128AffineGFailedToCreate"
                                            []))
                                    ]
                                  |)))
                              | _ => M.impossible "wrong number of arguments"
                              end))
                      ]
                    |)
                  |)))
            ]
          |)
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_new_g1_point : M.IsFunction "revm_precompile::bn128::new_g1_point" new_g1_point.
  
  (*
  pub fn run_add(input: &[u8], gas_cost: u64, gas_limit: u64) -> PrecompileResult {
      if gas_cost > gas_limit {
          return Err(Error::OutOfGas);
      }
  
      let input = right_pad::<ADD_INPUT_LEN>(input);
  
      let p1 = read_point(&input[..64])?;
      let p2 = read_point(&input[64..])?;
  
      let mut output = [0u8; 64];
      if let Some(sum) = AffineG1::from_jacobian(p1 + p2) {
          sum.x().to_big_endian(&mut output[..32]).unwrap();
          sum.y().to_big_endian(&mut output[32..]).unwrap();
      }
      Ok((gas_cost, output.into()))
  }
  *)
  Definition run_add (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ input; gas_cost; gas_limit ] =>
      ltac:(M.monadic
        (let input := M.alloc (| input |) in
        let gas_cost := M.alloc (| gas_cost |) in
        let gas_limit := M.alloc (| gas_limit |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.gt (| M.read (| gas_cost |), M.read (| gas_limit |) |)
                            |)) 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::precompile::PrecompileError::OutOfGas"
                                      []
                                  ]
                              |)
                            |)
                          |)
                        |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let~ input :=
                M.alloc (|
                  M.call_closure (|
                    M.get_function (| "revm_precompile::utilities::right_pad", [] |),
                    [ M.read (| input |) ]
                  |)
                |) in
              let~ p1 :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            []
                            [
                              Ty.path "substrate_bn::G1";
                              Ty.path "revm_primitives::precompile::PrecompileError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (| "revm_precompile::bn128::read_point", [] |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::index::Index",
                                  Ty.apply
                                    (Ty.path "array")
                                    [ Value.Integer IntegerKind.Usize 128 ]
                                    [ Ty.path "u8" ],
                                  [
                                    Ty.apply
                                      (Ty.path "core::ops::range::RangeTo")
                                      []
                                      [ Ty.path "usize" ]
                                  ],
                                  "index",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::Deref",
                                      Ty.apply
                                        (Ty.path "alloc::borrow::Cow")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "array")
                                            [ Value.Integer IntegerKind.Usize 128 ]
                                            [ Ty.path "u8" ]
                                        ],
                                      [],
                                      "deref",
                                      []
                                    |),
                                    [ input ]
                                  |);
                                  Value.StructRecord
                                    "core::ops::range::RangeTo"
                                    [ ("end_", Value.Integer IntegerKind.Usize 64) ]
                                ]
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      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 "u64";
                                              Ty.path "alloy_primitives::bytes_::Bytes"
                                            ];
                                          Ty.path "revm_primitives::precompile::PrecompileError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "revm_primitives::precompile::PrecompileError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let~ p2 :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            []
                            [
                              Ty.path "substrate_bn::G1";
                              Ty.path "revm_primitives::precompile::PrecompileError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (| "revm_precompile::bn128::read_point", [] |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::index::Index",
                                  Ty.apply
                                    (Ty.path "array")
                                    [ Value.Integer IntegerKind.Usize 128 ]
                                    [ Ty.path "u8" ],
                                  [
                                    Ty.apply
                                      (Ty.path "core::ops::range::RangeFrom")
                                      []
                                      [ Ty.path "usize" ]
                                  ],
                                  "index",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::Deref",
                                      Ty.apply
                                        (Ty.path "alloc::borrow::Cow")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "array")
                                            [ Value.Integer IntegerKind.Usize 128 ]
                                            [ Ty.path "u8" ]
                                        ],
                                      [],
                                      "deref",
                                      []
                                    |),
                                    [ input ]
                                  |);
                                  Value.StructRecord
                                    "core::ops::range::RangeFrom"
                                    [ ("start", Value.Integer IntegerKind.Usize 64) ]
                                ]
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      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 "u64";
                                              Ty.path "alloy_primitives::bytes_::Bytes"
                                            ];
                                          Ty.path "revm_primitives::precompile::PrecompileError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "revm_primitives::precompile::PrecompileError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let~ output :=
                M.alloc (|
                  repeat (| Value.Integer IntegerKind.U8 0, Value.Integer IntegerKind.Usize 64 |)
                |) in
              let~ _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "substrate_bn::AffineG1",
                                "from_jacobian",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::arith::Add",
                                    Ty.path "substrate_bn::G1",
                                    [ Ty.path "substrate_bn::G1" ],
                                    "add",
                                    []
                                  |),
                                  [ M.read (| p1 |); M.read (| p2 |) ]
                                |)
                              ]
                            |)
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let sum := M.copy (| γ0_0 |) in
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [ Ty.tuple []; Ty.path "substrate_bn::FieldError" ],
                                "unwrap",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "substrate_bn::Fq",
                                    "to_big_endian",
                                    []
                                  |),
                                  [
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "substrate_bn::AffineG1",
                                          "x",
                                          []
                                        |),
                                        [ sum ]
                                      |)
                                    |);
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::index::IndexMut",
                                        Ty.apply
                                          (Ty.path "array")
                                          [ Value.Integer IntegerKind.Usize 64 ]
                                          [ Ty.path "u8" ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::ops::range::RangeTo")
                                            []
                                            [ Ty.path "usize" ]
                                        ],
                                        "index_mut",
                                        []
                                      |),
                                      [
                                        output;
                                        Value.StructRecord
                                          "core::ops::range::RangeTo"
                                          [ ("end_", Value.Integer IntegerKind.Usize 32) ]
                                      ]
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |) in
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [ Ty.tuple []; Ty.path "substrate_bn::FieldError" ],
                                "unwrap",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "substrate_bn::Fq",
                                    "to_big_endian",
                                    []
                                  |),
                                  [
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "substrate_bn::AffineG1",
                                          "y",
                                          []
                                        |),
                                        [ sum ]
                                      |)
                                    |);
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::index::IndexMut",
                                        Ty.apply
                                          (Ty.path "array")
                                          [ Value.Integer IntegerKind.Usize 64 ]
                                          [ Ty.path "u8" ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::ops::range::RangeFrom")
                                            []
                                            [ Ty.path "usize" ]
                                        ],
                                        "index_mut",
                                        []
                                      |),
                                      [
                                        output;
                                        Value.StructRecord
                                          "core::ops::range::RangeFrom"
                                          [ ("start", Value.Integer IntegerKind.Usize 32) ]
                                      ]
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              M.alloc (|
                Value.StructTuple
                  "core::result::Result::Ok"
                  [
                    Value.Tuple
                      [
                        M.read (| gas_cost |);
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::convert::Into",
                            Ty.apply
                              (Ty.path "array")
                              [ Value.Integer IntegerKind.Usize 64 ]
                              [ Ty.path "u8" ],
                            [ Ty.path "alloy_primitives::bytes_::Bytes" ],
                            "into",
                            []
                          |),
                          [ M.read (| output |) ]
                        |)
                      ]
                  ]
              |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_run_add : M.IsFunction "revm_precompile::bn128::run_add" run_add.
  
  (*
  pub fn run_mul(input: &[u8], gas_cost: u64, gas_limit: u64) -> PrecompileResult {
      if gas_cost > gas_limit {
          return Err(Error::OutOfGas);
      }
  
      let input = right_pad::<MUL_INPUT_LEN>(input);
  
      let p = read_point(&input[..64])?;
  
      // `Fr::from_slice` can only fail when the length is not 32.
      let fr = bn::Fr::from_slice(&input[64..96]).unwrap();
  
      let mut output = [0u8; 64];
      if let Some(mul) = AffineG1::from_jacobian(p * fr) {
          mul.x().to_big_endian(&mut output[..32]).unwrap();
          mul.y().to_big_endian(&mut output[32..]).unwrap();
      }
      Ok((gas_cost, output.into()))
  }
  *)
  Definition run_mul (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ input; gas_cost; gas_limit ] =>
      ltac:(M.monadic
        (let input := M.alloc (| input |) in
        let gas_cost := M.alloc (| gas_cost |) in
        let gas_limit := M.alloc (| gas_limit |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.gt (| M.read (| gas_cost |), M.read (| gas_limit |) |)
                            |)) 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::precompile::PrecompileError::OutOfGas"
                                      []
                                  ]
                              |)
                            |)
                          |)
                        |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let~ input :=
                M.alloc (|
                  M.call_closure (|
                    M.get_function (| "revm_precompile::utilities::right_pad", [] |),
                    [ M.read (| input |) ]
                  |)
                |) in
              let~ p :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          Ty.apply
                            (Ty.path "core::result::Result")
                            []
                            [
                              Ty.path "substrate_bn::G1";
                              Ty.path "revm_primitives::precompile::PrecompileError"
                            ],
                          [],
                          "branch",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_function (| "revm_precompile::bn128::read_point", [] |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::index::Index",
                                  Ty.apply
                                    (Ty.path "array")
                                    [ Value.Integer IntegerKind.Usize 96 ]
                                    [ Ty.path "u8" ],
                                  [
                                    Ty.apply
                                      (Ty.path "core::ops::range::RangeTo")
                                      []
                                      [ Ty.path "usize" ]
                                  ],
                                  "index",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::Deref",
                                      Ty.apply
                                        (Ty.path "alloc::borrow::Cow")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "array")
                                            [ Value.Integer IntegerKind.Usize 96 ]
                                            [ Ty.path "u8" ]
                                        ],
                                      [],
                                      "deref",
                                      []
                                    |),
                                    [ input ]
                                  |);
                                  Value.StructRecord
                                    "core::ops::range::RangeTo"
                                    [ ("end_", Value.Integer IntegerKind.Usize 64) ]
                                ]
                              |)
                            ]
                          |)
                        ]
                      |)
                    |),
                    [
                      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 "u64";
                                              Ty.path "alloy_primitives::bytes_::Bytes"
                                            ];
                                          Ty.path "revm_primitives::precompile::PrecompileError"
                                        ],
                                      [
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.path "core::convert::Infallible";
                                            Ty.path "revm_primitives::precompile::PrecompileError"
                                          ]
                                      ],
                                      "from_residual",
                                      []
                                    |),
                                    [ M.read (| residual |) ]
                                  |)
                                |)
                              |)
                            |)
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::ops::control_flow::ControlFlow::Continue",
                              0
                            |) in
                          let val := M.copy (| γ0_0 |) in
                          val))
                    ]
                  |)
                |) in
              let~ fr :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply
                        (Ty.path "core::result::Result")
                        []
                        [ Ty.path "substrate_bn::Fr"; Ty.path "substrate_bn::FieldError" ],
                      "unwrap",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.path "substrate_bn::Fr",
                          "from_slice",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::index::Index",
                              Ty.apply
                                (Ty.path "array")
                                [ Value.Integer IntegerKind.Usize 96 ]
                                [ Ty.path "u8" ],
                              [ Ty.apply (Ty.path "core::ops::range::Range") [] [ Ty.path "usize" ]
                              ],
                              "index",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::deref::Deref",
                                  Ty.apply
                                    (Ty.path "alloc::borrow::Cow")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "array")
                                        [ Value.Integer IntegerKind.Usize 96 ]
                                        [ Ty.path "u8" ]
                                    ],
                                  [],
                                  "deref",
                                  []
                                |),
                                [ input ]
                              |);
                              Value.StructRecord
                                "core::ops::range::Range"
                                [
                                  ("start", Value.Integer IntegerKind.Usize 64);
                                  ("end_", Value.Integer IntegerKind.Usize 96)
                                ]
                            ]
                          |)
                        ]
                      |)
                    ]
                  |)
                |) in
              let~ output :=
                M.alloc (|
                  repeat (| Value.Integer IntegerKind.U8 0, Value.Integer IntegerKind.Usize 64 |)
                |) in
              let~ _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "substrate_bn::AffineG1",
                                "from_jacobian",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::arith::Mul",
                                    Ty.path "substrate_bn::G1",
                                    [ Ty.path "substrate_bn::Fr" ],
                                    "mul",
                                    []
                                  |),
                                  [ M.read (| p |); M.read (| fr |) ]
                                |)
                              ]
                            |)
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let mul := M.copy (| γ0_0 |) in
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [ Ty.tuple []; Ty.path "substrate_bn::FieldError" ],
                                "unwrap",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "substrate_bn::Fq",
                                    "to_big_endian",
                                    []
                                  |),
                                  [
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "substrate_bn::AffineG1",
                                          "x",
                                          []
                                        |),
                                        [ mul ]
                                      |)
                                    |);
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::index::IndexMut",
                                        Ty.apply
                                          (Ty.path "array")
                                          [ Value.Integer IntegerKind.Usize 64 ]
                                          [ Ty.path "u8" ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::ops::range::RangeTo")
                                            []
                                            [ Ty.path "usize" ]
                                        ],
                                        "index_mut",
                                        []
                                      |),
                                      [
                                        output;
                                        Value.StructRecord
                                          "core::ops::range::RangeTo"
                                          [ ("end_", Value.Integer IntegerKind.Usize 32) ]
                                      ]
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |) in
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [ Ty.tuple []; Ty.path "substrate_bn::FieldError" ],
                                "unwrap",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "substrate_bn::Fq",
                                    "to_big_endian",
                                    []
                                  |),
                                  [
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "substrate_bn::AffineG1",
                                          "y",
                                          []
                                        |),
                                        [ mul ]
                                      |)
                                    |);
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::index::IndexMut",
                                        Ty.apply
                                          (Ty.path "array")
                                          [ Value.Integer IntegerKind.Usize 64 ]
                                          [ Ty.path "u8" ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::ops::range::RangeFrom")
                                            []
                                            [ Ty.path "usize" ]
                                        ],
                                        "index_mut",
                                        []
                                      |),
                                      [
                                        output;
                                        Value.StructRecord
                                          "core::ops::range::RangeFrom"
                                          [ ("start", Value.Integer IntegerKind.Usize 32) ]
                                      ]
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              M.alloc (|
                Value.StructTuple
                  "core::result::Result::Ok"
                  [
                    Value.Tuple
                      [
                        M.read (| gas_cost |);
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::convert::Into",
                            Ty.apply
                              (Ty.path "array")
                              [ Value.Integer IntegerKind.Usize 64 ]
                              [ Ty.path "u8" ],
                            [ Ty.path "alloy_primitives::bytes_::Bytes" ],
                            "into",
                            []
                          |),
                          [ M.read (| output |) ]
                        |)
                      ]
                  ]
              |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_run_mul : M.IsFunction "revm_precompile::bn128::run_mul" run_mul.
  
  (*
  pub fn run_pair(
      input: &[u8],
      pair_per_point_cost: u64,
      pair_base_cost: u64,
      gas_limit: u64,
  ) -> PrecompileResult {
      let gas_used = (input.len() / PAIR_ELEMENT_LEN) as u64 * pair_per_point_cost + pair_base_cost;
      if gas_used > gas_limit {
          return Err(Error::OutOfGas);
      }
  
      if input.len() % PAIR_ELEMENT_LEN != 0 {
          return Err(Error::Bn128PairLength);
      }
  
      let success = if input.is_empty() {
          true
      } else {
          let elements = input.len() / PAIR_ELEMENT_LEN;
  
          let mut mul = Gt::one();
          for idx in 0..elements {
              let read_fq_at = |n: usize| {
                  debug_assert!(n < PAIR_ELEMENT_LEN / 32);
                  let start = idx * PAIR_ELEMENT_LEN + n * 32;
                  // SAFETY: We're reading `6 * 32 == PAIR_ELEMENT_LEN` bytes from `input[idx..]`
                  // per iteration. This is guaranteed to be in-bounds.
                  let slice = unsafe { input.get_unchecked(start..start + 32) };
                  Fq::from_slice(slice).map_err(|_| Error::Bn128FieldPointNotAMember)
              };
              let ax = read_fq_at(0)?;
              let ay = read_fq_at(1)?;
              let bay = read_fq_at(2)?;
              let bax = read_fq_at(3)?;
              let bby = read_fq_at(4)?;
              let bbx = read_fq_at(5)?;
  
              let a = new_g1_point(ax, ay)?;
              let b = {
                  let ba = Fq2::new(bax, bay);
                  let bb = Fq2::new(bbx, bby);
                  if ba.is_zero() && bb.is_zero() {
                      G2::zero()
                  } else {
                      G2::from(AffineG2::new(ba, bb).map_err(|_| Error::Bn128AffineGFailedToCreate)?)
                  }
              };
  
              mul = mul * bn::pairing(a, b);
          }
  
          mul == Gt::one()
      };
      Ok((gas_used, bool_to_bytes32(success)))
  }
  *)
  Definition run_pair (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ input; pair_per_point_cost; pair_base_cost; gas_limit ] =>
      ltac:(M.monadic
        (let input := M.alloc (| input |) in
        let pair_per_point_cost := M.alloc (| pair_per_point_cost |) in
        let pair_base_cost := M.alloc (| pair_base_cost |) in
        let gas_limit := M.alloc (| gas_limit |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ gas_used :=
                M.alloc (|
                  BinOp.Wrap.add (|
                    BinOp.Wrap.mul (|
                      M.rust_cast
                        (BinOp.Wrap.div (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                              "len",
                              []
                            |),
                            [ M.read (| input |) ]
                          |),
                          M.read (|
                            M.get_constant (| "revm_precompile::bn128::PAIR_ELEMENT_LEN" |)
                          |)
                        |)),
                      M.read (| pair_per_point_cost |)
                    |),
                    M.read (| pair_base_cost |)
                  |)
                |) in
              let~ _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.gt (| M.read (| gas_used |), M.read (| gas_limit |) |)
                            |)) 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::precompile::PrecompileError::OutOfGas"
                                      []
                                  ]
                              |)
                            |)
                          |)
                        |)));
                    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.ne (|
                                BinOp.Wrap.rem (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                      "len",
                                      []
                                    |),
                                    [ M.read (| input |) ]
                                  |),
                                  M.read (|
                                    M.get_constant (| "revm_precompile::bn128::PAIR_ELEMENT_LEN" |)
                                  |)
                                |),
                                Value.Integer IntegerKind.Usize 0
                              |)
                            |)) 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::precompile::PrecompileError::Bn128PairLength"
                                      []
                                  ]
                              |)
                            |)
                          |)
                        |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let~ success :=
                M.copy (|
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                    "is_empty",
                                    []
                                  |),
                                  [ M.read (| input |) ]
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (| Value.Bool true |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let~ elements :=
                            M.alloc (|
                              BinOp.Wrap.div (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                    "len",
                                    []
                                  |),
                                  [ M.read (| input |) ]
                                |),
                                M.read (|
                                  M.get_constant (| "revm_precompile::bn128::PAIR_ELEMENT_LEN" |)
                                |)
                              |)
                            |) in
                          let~ mul :=
                            M.alloc (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.path "substrate_bn::Gt",
                                  "one",
                                  []
                                |),
                                []
                              |)
                            |) in
                          let~ _ :=
                            M.use
                              (M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::iter::traits::collect::IntoIterator",
                                      Ty.apply
                                        (Ty.path "core::ops::range::Range")
                                        []
                                        [ Ty.path "usize" ],
                                      [],
                                      "into_iter",
                                      []
                                    |),
                                    [
                                      Value.StructRecord
                                        "core::ops::range::Range"
                                        [
                                          ("start", Value.Integer IntegerKind.Usize 0);
                                          ("end_", M.read (| elements |))
                                        ]
                                    ]
                                  |)
                                |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let iter := M.copy (| γ |) in
                                      M.loop (|
                                        ltac:(M.monadic
                                          (let~ _ :=
                                            M.match_operator (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::iter::traits::iterator::Iterator",
                                                    Ty.apply
                                                      (Ty.path "core::ops::range::Range")
                                                      []
                                                      [ Ty.path "usize" ],
                                                    [],
                                                    "next",
                                                    []
                                                  |),
                                                  [ iter ]
                                                |)
                                              |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let _ :=
                                                      M.is_struct_tuple (|
                                                        γ,
                                                        "core::option::Option::None"
                                                      |) in
                                                    M.alloc (|
                                                      M.never_to_any (| M.read (| M.break (||) |) |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::option::Option::Some",
                                                        0
                                                      |) in
                                                    let idx := M.copy (| γ0_0 |) in
                                                    let~ read_fq_at :=
                                                      M.alloc (|
                                                        M.closure
                                                          (fun γ =>
                                                            ltac:(M.monadic
                                                              match γ with
                                                              | [ α0 ] =>
                                                                ltac:(M.monadic
                                                                  (M.match_operator (|
                                                                    M.alloc (| α0 |),
                                                                    [
                                                                      fun γ =>
                                                                        ltac:(M.monadic
                                                                          (let n :=
                                                                            M.copy (| γ |) in
                                                                          M.read (|
                                                                            let~ _ :=
                                                                              M.match_operator (|
                                                                                M.alloc (|
                                                                                  Value.Tuple []
                                                                                |),
                                                                                [
                                                                                  fun γ =>
                                                                                    ltac:(M.monadic
                                                                                      (let γ :=
                                                                                        M.use
                                                                                          (M.alloc (|
                                                                                            Value.Bool
                                                                                              true
                                                                                          |)) in
                                                                                      let _ :=
                                                                                        M.is_constant_or_break_match (|
                                                                                          M.read (|
                                                                                            γ
                                                                                          |),
                                                                                          Value.Bool
                                                                                            true
                                                                                        |) in
                                                                                      let~ _ :=
                                                                                        M.match_operator (|
                                                                                          M.alloc (|
                                                                                            Value.Tuple
                                                                                              []
                                                                                          |),
                                                                                          [
                                                                                            fun γ =>
                                                                                              ltac:(M.monadic
                                                                                                (let
                                                                                                      γ :=
                                                                                                  M.use
                                                                                                    (M.alloc (|
                                                                                                      UnOp.not (|
                                                                                                        BinOp.lt (|
                                                                                                          M.read (|
                                                                                                            n
                                                                                                          |),
                                                                                                          BinOp.Wrap.div (|
                                                                                                            M.read (|
                                                                                                              M.get_constant (|
                                                                                                                "revm_precompile::bn128::PAIR_ELEMENT_LEN"
                                                                                                              |)
                                                                                                            |),
                                                                                                            Value.Integer
                                                                                                              IntegerKind.Usize
                                                                                                              32
                                                                                                          |)
                                                                                                        |)
                                                                                                      |)
                                                                                                    |)) in
                                                                                                let
                                                                                                      _ :=
                                                                                                  M.is_constant_or_break_match (|
                                                                                                    M.read (|
                                                                                                      γ
                                                                                                    |),
                                                                                                    Value.Bool
                                                                                                      true
                                                                                                  |) in
                                                                                                M.alloc (|
                                                                                                  M.never_to_any (|
                                                                                                    M.call_closure (|
                                                                                                      M.get_function (|
                                                                                                        "core::panicking::panic",
                                                                                                        []
                                                                                                      |),
                                                                                                      [
                                                                                                        M.read (|
                                                                                                          Value.String
                                                                                                            "assertion failed: n < PAIR_ELEMENT_LEN / 32"
                                                                                                        |)
                                                                                                      ]
                                                                                                    |)
                                                                                                  |)
                                                                                                |)));
                                                                                            fun γ =>
                                                                                              ltac:(M.monadic
                                                                                                (M.alloc (|
                                                                                                  Value.Tuple
                                                                                                    []
                                                                                                |)))
                                                                                          ]
                                                                                        |) in
                                                                                      M.alloc (|
                                                                                        Value.Tuple
                                                                                          []
                                                                                      |)));
                                                                                  fun γ =>
                                                                                    ltac:(M.monadic
                                                                                      (M.alloc (|
                                                                                        Value.Tuple
                                                                                          []
                                                                                      |)))
                                                                                ]
                                                                              |) in
                                                                            let~ start :=
                                                                              M.alloc (|
                                                                                BinOp.Wrap.add (|
                                                                                  BinOp.Wrap.mul (|
                                                                                    M.read (|
                                                                                      idx
                                                                                    |),
                                                                                    M.read (|
                                                                                      M.get_constant (|
                                                                                        "revm_precompile::bn128::PAIR_ELEMENT_LEN"
                                                                                      |)
                                                                                    |)
                                                                                  |),
                                                                                  BinOp.Wrap.mul (|
                                                                                    M.read (| n |),
                                                                                    Value.Integer
                                                                                      IntegerKind.Usize
                                                                                      32
                                                                                  |)
                                                                                |)
                                                                              |) in
                                                                            let~ slice :=
                                                                              M.alloc (|
                                                                                M.call_closure (|
                                                                                  M.get_associated_function (|
                                                                                    Ty.apply
                                                                                      (Ty.path
                                                                                        "slice")
                                                                                      []
                                                                                      [ Ty.path "u8"
                                                                                      ],
                                                                                    "get_unchecked",
                                                                                    [
                                                                                      Ty.apply
                                                                                        (Ty.path
                                                                                          "core::ops::range::Range")
                                                                                        []
                                                                                        [
                                                                                          Ty.path
                                                                                            "usize"
                                                                                        ]
                                                                                    ]
                                                                                  |),
                                                                                  [
                                                                                    M.read (|
                                                                                      input
                                                                                    |);
                                                                                    Value.StructRecord
                                                                                      "core::ops::range::Range"
                                                                                      [
                                                                                        ("start",
                                                                                          M.read (|
                                                                                            start
                                                                                          |));
                                                                                        ("end_",
                                                                                          BinOp.Wrap.add (|
                                                                                            M.read (|
                                                                                              start
                                                                                            |),
                                                                                            Value.Integer
                                                                                              IntegerKind.Usize
                                                                                              32
                                                                                          |))
                                                                                      ]
                                                                                  ]
                                                                                |)
                                                                              |) in
                                                                            M.alloc (|
                                                                              M.call_closure (|
                                                                                M.get_associated_function (|
                                                                                  Ty.apply
                                                                                    (Ty.path
                                                                                      "core::result::Result")
                                                                                    []
                                                                                    [
                                                                                      Ty.path
                                                                                        "substrate_bn::Fq";
                                                                                      Ty.path
                                                                                        "substrate_bn::FieldError"
                                                                                    ],
                                                                                  "map_err",
                                                                                  [
                                                                                    Ty.path
                                                                                      "revm_primitives::precompile::PrecompileError";
                                                                                    Ty.function
                                                                                      [
                                                                                        Ty.tuple
                                                                                          [
                                                                                            Ty.path
                                                                                              "substrate_bn::FieldError"
                                                                                          ]
                                                                                      ]
                                                                                      (Ty.path
                                                                                        "revm_primitives::precompile::PrecompileError")
                                                                                  ]
                                                                                |),
                                                                                [
                                                                                  M.call_closure (|
                                                                                    M.get_associated_function (|
                                                                                      Ty.path
                                                                                        "substrate_bn::Fq",
                                                                                      "from_slice",
                                                                                      []
                                                                                    |),
                                                                                    [
                                                                                      M.read (|
                                                                                        slice
                                                                                      |)
                                                                                    ]
                                                                                  |);
                                                                                  M.closure
                                                                                    (fun γ =>
                                                                                      ltac:(M.monadic
                                                                                        match γ with
                                                                                        | [ α0 ] =>
                                                                                          ltac:(M.monadic
                                                                                            (M.match_operator (|
                                                                                              M.alloc (|
                                                                                                α0
                                                                                              |),
                                                                                              [
                                                                                                fun
                                                                                                    γ =>
                                                                                                  ltac:(M.monadic
                                                                                                    (Value.StructTuple
                                                                                                      "revm_primitives::precompile::PrecompileError::Bn128FieldPointNotAMember"
                                                                                                      []))
                                                                                              ]
                                                                                            |)))
                                                                                        | _ =>
                                                                                          M.impossible
                                                                                            "wrong number of arguments"
                                                                                        end))
                                                                                ]
                                                                              |)
                                                                            |)
                                                                          |)))
                                                                    ]
                                                                  |)))
                                                              | _ =>
                                                                M.impossible
                                                                  "wrong number of arguments"
                                                              end))
                                                      |) in
                                                    let~ ax :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path "substrate_bn::Fq";
                                                                    Ty.path
                                                                      "revm_primitives::precompile::PrecompileError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::ops::function::Fn",
                                                                    Ty.function
                                                                      [ Ty.tuple [ Ty.path "usize" ]
                                                                      ]
                                                                      (Ty.apply
                                                                        (Ty.path
                                                                          "core::result::Result")
                                                                        []
                                                                        [
                                                                          Ty.path
                                                                            "substrate_bn::Fq";
                                                                          Ty.path
                                                                            "revm_primitives::precompile::PrecompileError"
                                                                        ]),
                                                                    [ Ty.tuple [ Ty.path "usize" ]
                                                                    ],
                                                                    "call",
                                                                    []
                                                                  |),
                                                                  [
                                                                    read_fq_at;
                                                                    Value.Tuple
                                                                      [
                                                                        Value.Integer
                                                                          IntegerKind.Usize
                                                                          0
                                                                      ]
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            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 "u64";
                                                                                    Ty.path
                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                  ];
                                                                                Ty.path
                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                []
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ ay :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path "substrate_bn::Fq";
                                                                    Ty.path
                                                                      "revm_primitives::precompile::PrecompileError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::ops::function::Fn",
                                                                    Ty.function
                                                                      [ Ty.tuple [ Ty.path "usize" ]
                                                                      ]
                                                                      (Ty.apply
                                                                        (Ty.path
                                                                          "core::result::Result")
                                                                        []
                                                                        [
                                                                          Ty.path
                                                                            "substrate_bn::Fq";
                                                                          Ty.path
                                                                            "revm_primitives::precompile::PrecompileError"
                                                                        ]),
                                                                    [ Ty.tuple [ Ty.path "usize" ]
                                                                    ],
                                                                    "call",
                                                                    []
                                                                  |),
                                                                  [
                                                                    read_fq_at;
                                                                    Value.Tuple
                                                                      [
                                                                        Value.Integer
                                                                          IntegerKind.Usize
                                                                          1
                                                                      ]
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Break",
                                                                    0
                                                                  |) in
                                                                let residual := M.copy (| γ0_0 |) in
                                                                M.alloc (|
                                                                  M.never_to_any (|
                                                                    M.read (|
                                                                      M.return_ (|
                                                                        M.call_closure (|
                                                                          M.get_trait_method (|
                                                                            "core::ops::try_trait::FromResidual",
                                                                            Ty.apply
                                                                              (Ty.path
                                                                                "core::result::Result")
                                                                              []
                                                                              [
                                                                                Ty.tuple
                                                                                  [
                                                                                    Ty.path "u64";
                                                                                    Ty.path
                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                  ];
                                                                                Ty.path
                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                []
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ bay :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path "substrate_bn::Fq";
                                                                    Ty.path
                                                                      "revm_primitives::precompile::PrecompileError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::ops::function::Fn",
                                                                    Ty.function
                                                                      [ Ty.tuple [ Ty.path "usize" ]
                                                                      ]
                                                                      (Ty.apply
                                                                        (Ty.path
                                                                          "core::result::Result")
                                                                        []
                                                                        [
                                                                          Ty.path
                                                                            "substrate_bn::Fq";
                                                                          Ty.path
                                                                            "revm_primitives::precompile::PrecompileError"
                                                                        ]),
                                                                    [ Ty.tuple [ Ty.path "usize" ]
                                                                    ],
                                                                    "call",
                                                                    []
                                                                  |),
                                                                  [
                                                                    read_fq_at;
                                                                    Value.Tuple
                                                                      [
                                                                        Value.Integer
                                                                          IntegerKind.Usize
                                                                          2
                                                                      ]
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            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 "u64";
                                                                                    Ty.path
                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                  ];
                                                                                Ty.path
                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                []
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ bax :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path "substrate_bn::Fq";
                                                                    Ty.path
                                                                      "revm_primitives::precompile::PrecompileError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::ops::function::Fn",
                                                                    Ty.function
                                                                      [ Ty.tuple [ Ty.path "usize" ]
                                                                      ]
                                                                      (Ty.apply
                                                                        (Ty.path
                                                                          "core::result::Result")
                                                                        []
                                                                        [
                                                                          Ty.path
                                                                            "substrate_bn::Fq";
                                                                          Ty.path
                                                                            "revm_primitives::precompile::PrecompileError"
                                                                        ]),
                                                                    [ Ty.tuple [ Ty.path "usize" ]
                                                                    ],
                                                                    "call",
                                                                    []
                                                                  |),
                                                                  [
                                                                    read_fq_at;
                                                                    Value.Tuple
                                                                      [
                                                                        Value.Integer
                                                                          IntegerKind.Usize
                                                                          3
                                                                      ]
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            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 "u64";
                                                                                    Ty.path
                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                  ];
                                                                                Ty.path
                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                []
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ bby :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path "substrate_bn::Fq";
                                                                    Ty.path
                                                                      "revm_primitives::precompile::PrecompileError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::ops::function::Fn",
                                                                    Ty.function
                                                                      [ Ty.tuple [ Ty.path "usize" ]
                                                                      ]
                                                                      (Ty.apply
                                                                        (Ty.path
                                                                          "core::result::Result")
                                                                        []
                                                                        [
                                                                          Ty.path
                                                                            "substrate_bn::Fq";
                                                                          Ty.path
                                                                            "revm_primitives::precompile::PrecompileError"
                                                                        ]),
                                                                    [ Ty.tuple [ Ty.path "usize" ]
                                                                    ],
                                                                    "call",
                                                                    []
                                                                  |),
                                                                  [
                                                                    read_fq_at;
                                                                    Value.Tuple
                                                                      [
                                                                        Value.Integer
                                                                          IntegerKind.Usize
                                                                          4
                                                                      ]
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            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 "u64";
                                                                                    Ty.path
                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                  ];
                                                                                Ty.path
                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                []
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ bbx :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path "substrate_bn::Fq";
                                                                    Ty.path
                                                                      "revm_primitives::precompile::PrecompileError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::ops::function::Fn",
                                                                    Ty.function
                                                                      [ Ty.tuple [ Ty.path "usize" ]
                                                                      ]
                                                                      (Ty.apply
                                                                        (Ty.path
                                                                          "core::result::Result")
                                                                        []
                                                                        [
                                                                          Ty.path
                                                                            "substrate_bn::Fq";
                                                                          Ty.path
                                                                            "revm_primitives::precompile::PrecompileError"
                                                                        ]),
                                                                    [ Ty.tuple [ Ty.path "usize" ]
                                                                    ],
                                                                    "call",
                                                                    []
                                                                  |),
                                                                  [
                                                                    read_fq_at;
                                                                    Value.Tuple
                                                                      [
                                                                        Value.Integer
                                                                          IntegerKind.Usize
                                                                          5
                                                                      ]
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            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 "u64";
                                                                                    Ty.path
                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                  ];
                                                                                Ty.path
                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                []
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ a :=
                                                      M.copy (|
                                                        M.match_operator (|
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::Try",
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path "substrate_bn::G1";
                                                                    Ty.path
                                                                      "revm_primitives::precompile::PrecompileError"
                                                                  ],
                                                                [],
                                                                "branch",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_function (|
                                                                    "revm_precompile::bn128::new_g1_point",
                                                                    []
                                                                  |),
                                                                  [ M.read (| ax |); M.read (| ay |)
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |),
                                                          [
                                                            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 "u64";
                                                                                    Ty.path
                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                  ];
                                                                                Ty.path
                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                              ],
                                                                            [
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::result::Result")
                                                                                []
                                                                                [
                                                                                  Ty.path
                                                                                    "core::convert::Infallible";
                                                                                  Ty.path
                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                ]
                                                                            ],
                                                                            "from_residual",
                                                                            []
                                                                          |),
                                                                          [ M.read (| residual |) ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ0_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                    0
                                                                  |) in
                                                                let val := M.copy (| γ0_0 |) in
                                                                val))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ b :=
                                                      M.copy (|
                                                        let~ ba :=
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_associated_function (|
                                                                Ty.path "substrate_bn::Fq2",
                                                                "new",
                                                                []
                                                              |),
                                                              [ M.read (| bax |); M.read (| bay |) ]
                                                            |)
                                                          |) in
                                                        let~ bb :=
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_associated_function (|
                                                                Ty.path "substrate_bn::Fq2",
                                                                "new",
                                                                []
                                                              |),
                                                              [ M.read (| bbx |); M.read (| bby |) ]
                                                            |)
                                                          |) in
                                                        M.match_operator (|
                                                          M.alloc (| Value.Tuple [] |),
                                                          [
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ :=
                                                                  M.use
                                                                    (M.alloc (|
                                                                      LogicalOp.and (|
                                                                        M.call_closure (|
                                                                          M.get_associated_function (|
                                                                            Ty.path
                                                                              "substrate_bn::Fq2",
                                                                            "is_zero",
                                                                            []
                                                                          |),
                                                                          [ ba ]
                                                                        |),
                                                                        ltac:(M.monadic
                                                                          (M.call_closure (|
                                                                            M.get_associated_function (|
                                                                              Ty.path
                                                                                "substrate_bn::Fq2",
                                                                              "is_zero",
                                                                              []
                                                                            |),
                                                                            [ bb ]
                                                                          |)))
                                                                      |)
                                                                    |)) in
                                                                let _ :=
                                                                  M.is_constant_or_break_match (|
                                                                    M.read (| γ |),
                                                                    Value.Bool true
                                                                  |) in
                                                                M.alloc (|
                                                                  M.call_closure (|
                                                                    M.get_trait_method (|
                                                                      "substrate_bn::Group",
                                                                      Ty.path "substrate_bn::G2",
                                                                      [],
                                                                      "zero",
                                                                      []
                                                                    |),
                                                                    []
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (M.alloc (|
                                                                  M.call_closure (|
                                                                    M.get_trait_method (|
                                                                      "core::convert::From",
                                                                      Ty.path "substrate_bn::G2",
                                                                      [
                                                                        Ty.path
                                                                          "substrate_bn::AffineG2"
                                                                      ],
                                                                      "from",
                                                                      []
                                                                    |),
                                                                    [
                                                                      M.read (|
                                                                        M.match_operator (|
                                                                          M.alloc (|
                                                                            M.call_closure (|
                                                                              M.get_trait_method (|
                                                                                "core::ops::try_trait::Try",
                                                                                Ty.apply
                                                                                  (Ty.path
                                                                                    "core::result::Result")
                                                                                  []
                                                                                  [
                                                                                    Ty.path
                                                                                      "substrate_bn::AffineG2";
                                                                                    Ty.path
                                                                                      "revm_primitives::precompile::PrecompileError"
                                                                                  ],
                                                                                [],
                                                                                "branch",
                                                                                []
                                                                              |),
                                                                              [
                                                                                M.call_closure (|
                                                                                  M.get_associated_function (|
                                                                                    Ty.apply
                                                                                      (Ty.path
                                                                                        "core::result::Result")
                                                                                      []
                                                                                      [
                                                                                        Ty.path
                                                                                          "substrate_bn::AffineG2";
                                                                                        Ty.path
                                                                                          "substrate_bn::groups::Error"
                                                                                      ],
                                                                                    "map_err",
                                                                                    [
                                                                                      Ty.path
                                                                                        "revm_primitives::precompile::PrecompileError";
                                                                                      Ty.function
                                                                                        [
                                                                                          Ty.tuple
                                                                                            [
                                                                                              Ty.path
                                                                                                "substrate_bn::groups::Error"
                                                                                            ]
                                                                                        ]
                                                                                        (Ty.path
                                                                                          "revm_primitives::precompile::PrecompileError")
                                                                                    ]
                                                                                  |),
                                                                                  [
                                                                                    M.call_closure (|
                                                                                      M.get_associated_function (|
                                                                                        Ty.path
                                                                                          "substrate_bn::AffineG2",
                                                                                        "new",
                                                                                        []
                                                                                      |),
                                                                                      [
                                                                                        M.read (|
                                                                                          ba
                                                                                        |);
                                                                                        M.read (|
                                                                                          bb
                                                                                        |)
                                                                                      ]
                                                                                    |);
                                                                                    M.closure
                                                                                      (fun γ =>
                                                                                        ltac:(M.monadic
                                                                                          match γ
                                                                                          with
                                                                                          | [ α0
                                                                                              ] =>
                                                                                            ltac:(M.monadic
                                                                                              (M.match_operator (|
                                                                                                M.alloc (|
                                                                                                  α0
                                                                                                |),
                                                                                                [
                                                                                                  fun
                                                                                                      γ =>
                                                                                                    ltac:(M.monadic
                                                                                                      (Value.StructTuple
                                                                                                        "revm_primitives::precompile::PrecompileError::Bn128AffineGFailedToCreate"
                                                                                                        []))
                                                                                                ]
                                                                                              |)))
                                                                                          | _ =>
                                                                                            M.impossible
                                                                                              "wrong number of arguments"
                                                                                          end))
                                                                                  ]
                                                                                |)
                                                                              ]
                                                                            |)
                                                                          |),
                                                                          [
                                                                            fun γ =>
                                                                              ltac:(M.monadic
                                                                                (let γ0_0 :=
                                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                                    γ,
                                                                                    "core::ops::control_flow::ControlFlow::Break",
                                                                                    0
                                                                                  |) in
                                                                                let residual :=
                                                                                  M.copy (|
                                                                                    γ0_0
                                                                                  |) in
                                                                                M.alloc (|
                                                                                  M.never_to_any (|
                                                                                    M.read (|
                                                                                      M.return_ (|
                                                                                        M.call_closure (|
                                                                                          M.get_trait_method (|
                                                                                            "core::ops::try_trait::FromResidual",
                                                                                            Ty.apply
                                                                                              (Ty.path
                                                                                                "core::result::Result")
                                                                                              []
                                                                                              [
                                                                                                Ty.tuple
                                                                                                  [
                                                                                                    Ty.path
                                                                                                      "u64";
                                                                                                    Ty.path
                                                                                                      "alloy_primitives::bytes_::Bytes"
                                                                                                  ];
                                                                                                Ty.path
                                                                                                  "revm_primitives::precompile::PrecompileError"
                                                                                              ],
                                                                                            [
                                                                                              Ty.apply
                                                                                                (Ty.path
                                                                                                  "core::result::Result")
                                                                                                []
                                                                                                [
                                                                                                  Ty.path
                                                                                                    "core::convert::Infallible";
                                                                                                  Ty.path
                                                                                                    "revm_primitives::precompile::PrecompileError"
                                                                                                ]
                                                                                            ],
                                                                                            "from_residual",
                                                                                            []
                                                                                          |),
                                                                                          [
                                                                                            M.read (|
                                                                                              residual
                                                                                            |)
                                                                                          ]
                                                                                        |)
                                                                                      |)
                                                                                    |)
                                                                                  |)
                                                                                |)));
                                                                            fun γ =>
                                                                              ltac:(M.monadic
                                                                                (let γ0_0 :=
                                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                                    γ,
                                                                                    "core::ops::control_flow::ControlFlow::Continue",
                                                                                    0
                                                                                  |) in
                                                                                let val :=
                                                                                  M.copy (|
                                                                                    γ0_0
                                                                                  |) in
                                                                                val))
                                                                          ]
                                                                        |)
                                                                      |)
                                                                    ]
                                                                  |)
                                                                |)))
                                                          ]
                                                        |)
                                                      |) in
                                                    let~ _ :=
                                                      M.write (|
                                                        mul,
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::arith::Mul",
                                                            Ty.path "substrate_bn::Gt",
                                                            [ Ty.path "substrate_bn::Gt" ],
                                                            "mul",
                                                            []
                                                          |),
                                                          [
                                                            M.read (| mul |);
                                                            M.call_closure (|
                                                              M.get_function (|
                                                                "substrate_bn::pairing",
                                                                []
                                                              |),
                                                              [ M.read (| a |); M.read (| b |) ]
                                                            |)
                                                          ]
                                                        |)
                                                      |) in
                                                    M.alloc (| Value.Tuple [] |)))
                                              ]
                                            |) in
                                          M.alloc (| Value.Tuple [] |)))
                                      |)))
                                ]
                              |)) in
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::cmp::PartialEq",
                                Ty.path "substrate_bn::Gt",
                                [ Ty.path "substrate_bn::Gt" ],
                                "eq",
                                []
                              |),
                              [
                                mul;
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "substrate_bn::Gt",
                                      "one",
                                      []
                                    |),
                                    []
                                  |)
                                |)
                              ]
                            |)
                          |)))
                    ]
                  |)
                |) in
              M.alloc (|
                Value.StructTuple
                  "core::result::Result::Ok"
                  [
                    Value.Tuple
                      [
                        M.read (| gas_used |);
                        M.call_closure (|
                          M.get_function (| "revm_precompile::utilities::bool_to_bytes32", [] |),
                          [ M.read (| success |) ]
                        |)
                      ]
                  ]
              |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_run_pair : M.IsFunction "revm_precompile::bn128::run_pair" run_pair.
End bn128.
