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

Module collections.
  Module btree.
    Module merge_iter.
      (* StructRecord
        {
          name := "MergeIterInner";
          const_params := [];
          ty_params := [ "I" ];
          fields :=
            [
              ("a", I);
              ("b", I);
              ("peeked",
                Ty.apply
                  (Ty.path "core::option::Option")
                  []
                  [ Ty.apply (Ty.path "alloc::collections::btree::merge_iter::Peeked") [] [ I ] ])
            ];
        } *)
      
      (*
      Enum Peeked
      {
        const_params := [];
        ty_params := [ "I" ];
        variants :=
          [
            {
              name := "A";
              item := StructTuple [ Ty.associated ];
              discriminant := None;
            };
            {
              name := "B";
              item := StructTuple [ Ty.associated ];
              discriminant := None;
            }
          ];
      }
      *)
      
      Module Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_iter_traits_iterator_Iterator_I_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_alloc_collections_btree_merge_iter_Peeked_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::merge_iter::Peeked") [] [ I ].
        
        (* Clone *)
        Definition clone (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  self,
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::merge_iter::Peeked::A",
                            0
                          |) in
                        let __self_0 := M.alloc (| γ1_0 |) in
                        M.alloc (|
                          Value.StructTuple
                            "alloc::collections::btree::merge_iter::Peeked::A"
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::clone::Clone",
                                  Ty.associated,
                                  [],
                                  "clone",
                                  []
                                |),
                                [ M.read (| __self_0 |) ]
                              |)
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::merge_iter::Peeked::B",
                            0
                          |) in
                        let __self_0 := M.alloc (| γ1_0 |) in
                        M.alloc (|
                          Value.StructTuple
                            "alloc::collections::btree::merge_iter::Peeked::B"
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::clone::Clone",
                                  Ty.associated,
                                  [],
                                  "clone",
                                  []
                                |),
                                [ M.read (| __self_0 |) ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone I)) ].
      End Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_iter_traits_iterator_Iterator_I_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_alloc_collections_btree_merge_iter_Peeked_I.
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_iter_traits_iterator_Iterator_I_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_alloc_collections_btree_merge_iter_Peeked_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::merge_iter::Peeked") [] [ I ].
        
        (* Debug *)
        Definition fmt (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.read (|
                M.match_operator (|
                  self,
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::merge_iter::Peeked::A",
                            0
                          |) in
                        let __self_0 := M.alloc (| γ1_0 |) in
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.path "core::fmt::Formatter",
                              "debug_tuple_field1_finish",
                              []
                            |),
                            [ M.read (| f |); M.read (| Value.String "A" |); __self_0 ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::merge_iter::Peeked::B",
                            0
                          |) in
                        let __self_0 := M.alloc (| γ1_0 |) in
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.path "core::fmt::Formatter",
                              "debug_tuple_field1_finish",
                              []
                            |),
                            [ M.read (| f |); M.read (| Value.String "B" |); __self_0 ]
                          |)
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt I)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_iter_traits_iterator_Iterator_I_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_alloc_collections_btree_merge_iter_Peeked_I.
      
      Module Impl_core_clone_Clone_where_core_iter_traits_iterator_Iterator_I_where_core_clone_Clone_I_where_core_clone_Clone_associated_type_for_alloc_collections_btree_merge_iter_MergeIterInner_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::merge_iter::MergeIterInner") [] [ I ].
        
        (*
            fn clone(&self) -> Self {
                Self { a: self.a.clone(), b: self.b.clone(), peeked: self.peeked.clone() }
            }
        *)
        Definition clone (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::merge_iter::MergeIterInner"
                [
                  ("a",
                    M.call_closure (|
                      M.get_trait_method (| "core::clone::Clone", I, [], "clone", [] |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::merge_iter::MergeIterInner",
                          "a"
                        |)
                      ]
                    |));
                  ("b",
                    M.call_closure (|
                      M.get_trait_method (| "core::clone::Clone", I, [], "clone", [] |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::merge_iter::MergeIterInner",
                          "b"
                        |)
                      ]
                    |));
                  ("peeked",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply
                          (Ty.path "core::option::Option")
                          []
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::merge_iter::Peeked")
                              []
                              [ I ]
                          ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::merge_iter::MergeIterInner",
                          "peeked"
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone I)) ].
      End Impl_core_clone_Clone_where_core_iter_traits_iterator_Iterator_I_where_core_clone_Clone_I_where_core_clone_Clone_associated_type_for_alloc_collections_btree_merge_iter_MergeIterInner_I.
      
      Module Impl_core_fmt_Debug_where_core_iter_traits_iterator_Iterator_I_where_core_fmt_Debug_I_where_core_fmt_Debug_associated_type_for_alloc_collections_btree_merge_iter_MergeIterInner_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::merge_iter::MergeIterInner") [] [ I ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_tuple("MergeIterInner").field(&self.a).field(&self.b).field(&self.peeked).finish()
            }
        *)
        Definition fmt (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugTuple",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugTuple",
                      "field",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.path "core::fmt::builders::DebugTuple",
                          "field",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.path "core::fmt::builders::DebugTuple",
                              "field",
                              []
                            |),
                            [
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "core::fmt::Formatter",
                                    "debug_tuple",
                                    []
                                  |),
                                  [ M.read (| f |); M.read (| Value.String "MergeIterInner" |) ]
                                |)
                              |);
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "alloc::collections::btree::merge_iter::MergeIterInner",
                                "a"
                              |)
                            ]
                          |);
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "alloc::collections::btree::merge_iter::MergeIterInner",
                            "b"
                          |)
                        ]
                      |);
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::merge_iter::MergeIterInner",
                        "peeked"
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt I)) ].
      End Impl_core_fmt_Debug_where_core_iter_traits_iterator_Iterator_I_where_core_fmt_Debug_I_where_core_fmt_Debug_associated_type_for_alloc_collections_btree_merge_iter_MergeIterInner_I.
      
      Module Impl_alloc_collections_btree_merge_iter_MergeIterInner_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::merge_iter::MergeIterInner") [] [ I ].
        
        (*
            pub fn new(a: I, b: I) -> Self {
                MergeIterInner { a, b, peeked: None }
            }
        *)
        Definition new (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [ a; b ] =>
            ltac:(M.monadic
              (let a := M.alloc (| a |) in
              let b := M.alloc (| b |) in
              Value.StructRecord
                "alloc::collections::btree::merge_iter::MergeIterInner"
                [
                  ("a", M.read (| a |));
                  ("b", M.read (| b |));
                  ("peeked", Value.StructTuple "core::option::Option::None" [])
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_new :
          forall (I : Ty.t),
          M.IsAssociatedFunction (Self I) "new" (new I).
        
        (*
            pub fn nexts<Cmp: Fn(&I::Item, &I::Item) -> Ordering>(
                &mut self,
                cmp: Cmp,
            ) -> (Option<I::Item>, Option<I::Item>)
            where
                I: FusedIterator,
            {
                let mut a_next;
                let mut b_next;
                match self.peeked.take() {
                    Some(Peeked::A(next)) => {
                        a_next = Some(next);
                        b_next = self.b.next();
                    }
                    Some(Peeked::B(next)) => {
                        b_next = Some(next);
                        a_next = self.a.next();
                    }
                    None => {
                        a_next = self.a.next();
                        b_next = self.b.next();
                    }
                }
                if let (Some(ref a1), Some(ref b1)) = (&a_next, &b_next) {
                    match cmp(a1, b1) {
                        Ordering::Less => self.peeked = b_next.take().map(Peeked::B),
                        Ordering::Greater => self.peeked = a_next.take().map(Peeked::A),
                        Ordering::Equal => (),
                    }
                }
                (a_next, b_next)
            }
        *)
        Definition nexts (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [ Cmp ], [ self; cmp ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let cmp := M.alloc (| cmp |) in
              M.read (|
                let~ a_next := M.copy (| Value.DeclaredButUndefined |) in
                let~ b_next := M.copy (| Value.DeclaredButUndefined |) in
                let~ _ :=
                  M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::option::Option")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::collections::btree::merge_iter::Peeked")
                                []
                                [ I ]
                            ],
                          "take",
                          []
                        |),
                        [
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "alloc::collections::btree::merge_iter::MergeIterInner",
                            "peeked"
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let γ1_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ0_0,
                              "alloc::collections::btree::merge_iter::Peeked::A",
                              0
                            |) in
                          let next := M.copy (| γ1_0 |) in
                          let~ _ :=
                            M.write (|
                              a_next,
                              Value.StructTuple "core::option::Option::Some" [ M.read (| next |) ]
                            |) in
                          let~ _ :=
                            M.write (|
                              b_next,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::iterator::Iterator",
                                  I,
                                  [],
                                  "next",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "b"
                                  |)
                                ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let γ1_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ0_0,
                              "alloc::collections::btree::merge_iter::Peeked::B",
                              0
                            |) in
                          let next := M.copy (| γ1_0 |) in
                          let~ _ :=
                            M.write (|
                              b_next,
                              Value.StructTuple "core::option::Option::Some" [ M.read (| next |) ]
                            |) in
                          let~ _ :=
                            M.write (|
                              a_next,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::iterator::Iterator",
                                  I,
                                  [],
                                  "next",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "a"
                                  |)
                                ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                          let~ _ :=
                            M.write (|
                              a_next,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::iterator::Iterator",
                                  I,
                                  [],
                                  "next",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "a"
                                  |)
                                ]
                              |)
                            |) in
                          let~ _ :=
                            M.write (|
                              b_next,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::iterator::Iterator",
                                  I,
                                  [],
                                  "next",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "b"
                                  |)
                                ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ := M.alloc (| Value.Tuple [ a_next; b_next ] |) in
                          let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                          let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                          let γ0_0 := M.read (| γ0_0 |) in
                          let γ2_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ0_0,
                              "core::option::Option::Some",
                              0
                            |) in
                          let a1 := M.alloc (| γ2_0 |) in
                          let γ0_1 := M.read (| γ0_1 |) in
                          let γ2_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ0_1,
                              "core::option::Option::Some",
                              0
                            |) in
                          let b1 := M.alloc (| γ2_0 |) in
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::function::Fn",
                                  Cmp,
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ Ty.associated ];
                                        Ty.apply (Ty.path "&") [] [ Ty.associated ]
                                      ]
                                  ],
                                  "call",
                                  []
                                |),
                                [ cmp; Value.Tuple [ M.read (| a1 |); M.read (| b1 |) ] ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.is_struct_tuple (| γ, "core::cmp::Ordering::Less" |) in
                                  M.write (|
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::merge_iter::MergeIterInner",
                                      "peeked"
                                    |),
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::option::Option")
                                          []
                                          [ Ty.associated ],
                                        "map",
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "alloc::collections::btree::merge_iter::Peeked")
                                            []
                                            [ I ];
                                          Ty.function
                                            [ Ty.associated ]
                                            (Ty.apply
                                              (Ty.path
                                                "alloc::collections::btree::merge_iter::Peeked")
                                              []
                                              [ I ])
                                        ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [ Ty.associated ],
                                            "take",
                                            []
                                          |),
                                          [ b_next ]
                                        |);
                                        M.constructor_as_closure
                                          "alloc::collections::btree::merge_iter::Peeked::B"
                                      ]
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.is_struct_tuple (| γ, "core::cmp::Ordering::Greater" |) in
                                  M.write (|
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::merge_iter::MergeIterInner",
                                      "peeked"
                                    |),
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::option::Option")
                                          []
                                          [ Ty.associated ],
                                        "map",
                                        [
                                          Ty.apply
                                            (Ty.path
                                              "alloc::collections::btree::merge_iter::Peeked")
                                            []
                                            [ I ];
                                          Ty.function
                                            [ Ty.associated ]
                                            (Ty.apply
                                              (Ty.path
                                                "alloc::collections::btree::merge_iter::Peeked")
                                              []
                                              [ I ])
                                        ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [ Ty.associated ],
                                            "take",
                                            []
                                          |),
                                          [ a_next ]
                                        |);
                                        M.constructor_as_closure
                                          "alloc::collections::btree::merge_iter::Peeked::A"
                                      ]
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.is_struct_tuple (| γ, "core::cmp::Ordering::Equal" |) in
                                  M.alloc (| Value.Tuple [] |)))
                            ]
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                M.alloc (| Value.Tuple [ M.read (| a_next |); M.read (| b_next |) ] |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_nexts :
          forall (I : Ty.t),
          M.IsAssociatedFunction (Self I) "nexts" (nexts I).
        
        (*
            pub fn lens(&self) -> (usize, usize)
            where
                I: ExactSizeIterator,
            {
                match self.peeked {
                    Some(Peeked::A(_)) => (1 + self.a.len(), self.b.len()),
                    Some(Peeked::B(_)) => (self.a.len(), 1 + self.b.len()),
                    _ => (self.a.len(), self.b.len()),
                }
            }
        *)
        Definition lens (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::merge_iter::MergeIterInner",
                    "peeked"
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ0_0,
                            "alloc::collections::btree::merge_iter::Peeked::A",
                            0
                          |) in
                        M.alloc (|
                          Value.Tuple
                            [
                              BinOp.Wrap.add (|
                                Value.Integer IntegerKind.Usize 1,
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::iter::traits::exact_size::ExactSizeIterator",
                                    I,
                                    [],
                                    "len",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::merge_iter::MergeIterInner",
                                      "a"
                                    |)
                                  ]
                                |)
                              |);
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::exact_size::ExactSizeIterator",
                                  I,
                                  [],
                                  "len",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "b"
                                  |)
                                ]
                              |)
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ0_0,
                            "alloc::collections::btree::merge_iter::Peeked::B",
                            0
                          |) in
                        M.alloc (|
                          Value.Tuple
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::exact_size::ExactSizeIterator",
                                  I,
                                  [],
                                  "len",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "a"
                                  |)
                                ]
                              |);
                              BinOp.Wrap.add (|
                                Value.Integer IntegerKind.Usize 1,
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::iter::traits::exact_size::ExactSizeIterator",
                                    I,
                                    [],
                                    "len",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::merge_iter::MergeIterInner",
                                      "b"
                                    |)
                                  ]
                                |)
                              |)
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.Tuple
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::exact_size::ExactSizeIterator",
                                  I,
                                  [],
                                  "len",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "a"
                                  |)
                                ]
                              |);
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::exact_size::ExactSizeIterator",
                                  I,
                                  [],
                                  "len",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::merge_iter::MergeIterInner",
                                    "b"
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_lens :
          forall (I : Ty.t),
          M.IsAssociatedFunction (Self I) "lens" (lens I).
      End Impl_alloc_collections_btree_merge_iter_MergeIterInner_I.
    End merge_iter.
  End btree.
End collections.
