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

Module iter.
  Module adapters.
    Module flatten.
      (* StructRecord
        {
          name := "FlatMap";
          const_params := [];
          ty_params := [ "I"; "U"; "F" ];
          fields :=
            [
              ("inner",
                Ty.apply
                  (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                  []
                  [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                  ])
            ];
        } *)
      
      Module Impl_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        (*
            pub(in crate::iter) fn new(iter: I, f: F) -> FlatMap<I, U, F> {
                FlatMap { inner: FlattenCompat::new(iter.map(f)) }
            }
        *)
        Definition new (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ iter; f ] =>
            ltac:(M.monadic
              (let iter := M.alloc (| iter |) in
              let f := M.alloc (| f |) in
              Value.StructRecord
                "core::iter::adapters::flatten::FlatMap"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                          []
                          [
                            Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ];
                            Ty.associated
                          ],
                        "new",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::iterator::Iterator",
                            I,
                            [],
                            "map",
                            [ U; F ]
                          |),
                          [ M.read (| iter |); M.read (| f |) ]
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_new :
          forall (I U F : Ty.t),
          M.IsAssociatedFunction (Self I U F) "new" (new I U F).
        
        (*
            pub(crate) fn into_parts(self) -> (Option<U::IntoIter>, Option<I>, Option<U::IntoIter>) {
                (
                    self.inner.frontiter,
                    self.inner.iter.into_inner().map(Map::into_inner),
                    self.inner.backiter,
                )
            }
        *)
        Definition into_parts
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.Tuple
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "core::iter::adapters::flatten::FlatMap",
                        "inner"
                      |),
                      "core::iter::adapters::flatten::FlattenCompat",
                      "frontiter"
                    |)
                  |);
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply
                        (Ty.path "core::option::Option")
                        []
                        [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ] ],
                      "map",
                      [
                        I;
                        Ty.function
                          [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ] ]
                          I
                      ]
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::iter::adapters::fuse::Fuse")
                            []
                            [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ] ],
                          "into_inner",
                          []
                        |),
                        [
                          M.read (|
                            M.SubPointer.get_struct_record_field (|
                              M.SubPointer.get_struct_record_field (|
                                self,
                                "core::iter::adapters::flatten::FlatMap",
                                "inner"
                              |),
                              "core::iter::adapters::flatten::FlattenCompat",
                              "iter"
                            |)
                          |)
                        ]
                      |);
                      M.get_associated_function (|
                        Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ],
                        "into_inner",
                        []
                      |)
                    ]
                  |);
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.SubPointer.get_struct_record_field (|
                        self,
                        "core::iter::adapters::flatten::FlatMap",
                        "inner"
                      |),
                      "core::iter::adapters::flatten::FlattenCompat",
                      "backiter"
                    |)
                  |)
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_into_parts :
          forall (I U F : Ty.t),
          M.IsAssociatedFunction (Self I U F) "into_parts" (into_parts I U F).
      End Impl_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_clone_Clone_F_where_core_clone_Clone_U_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        (*
            fn clone(&self) -> Self {
                FlatMap { inner: self.inner.clone() }
            }
        *)
        Definition clone (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "core::iter::adapters::flatten::FlatMap"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply
                          (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                          []
                          [
                            Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ];
                            Ty.associated
                          ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlatMap",
                          "inner"
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone I U F)) ].
      End Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_clone_Clone_F_where_core_clone_Clone_U_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_struct("FlatMap").field("inner", &self.inner).finish()
            }
        *)
        Definition fmt (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F 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::DebugStruct",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugStruct",
                      "field",
                      []
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_struct",
                            []
                          |),
                          [ M.read (| f |); M.read (| Value.String "FlatMap" |) ]
                        |)
                      |);
                      M.read (| Value.String "inner" |);
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "core::iter::adapters::flatten::FlatMap",
                        "inner"
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt I U F)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_U_where_core_ops_function_FnMut_F_Tuple_associated_type__for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        (*     type Item = U::Item; *)
        Definition _Item (I U F : Ty.t) : Ty.t := Ty.associated.
        
        (*
            fn next(&mut self) -> Option<U::Item> {
                self.inner.next()
            }
        *)
        Definition next (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "next",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlatMap",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlatMap",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                self.inner.try_fold(init, fold)
            }
        *)
        Definition try_fold
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "try_fold",
                  [ Acc; Fold; R ]
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlatMap",
                    "inner"
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                self.inner.fold(init, fold)
            }
        *)
        Definition fold (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "fold",
                  [ Acc; Fold ]
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::FlatMap",
                      "inner"
                    |)
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                self.inner.advance_by(n)
            }
        *)
        Definition advance_by
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "advance_by",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlatMap",
                    "inner"
                  |);
                  M.read (| n |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn count(self) -> usize {
                self.inner.count()
            }
        *)
        Definition count (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "count",
                  []
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::FlatMap",
                      "inner"
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(self) -> Option<Self::Item> {
                self.inner.last()
            }
        *)
        Definition last (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "last",
                  []
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::FlatMap",
                      "inner"
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item I U F));
              ("next", InstanceField.Method (next I U F));
              ("size_hint", InstanceField.Method (size_hint I U F));
              ("try_fold", InstanceField.Method (try_fold I U F));
              ("fold", InstanceField.Method (fold I U F));
              ("advance_by", InstanceField.Method (advance_by I U F));
              ("count", InstanceField.Method (count I U F));
              ("last", InstanceField.Method (last I U F))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_U_where_core_ops_function_FnMut_F_Tuple_associated_type__for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_ops_function_FnMut_F_Tuple_associated_type__where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        (*
            fn next_back(&mut self) -> Option<U::Item> {
                self.inner.next_back()
            }
        *)
        Definition next_back
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "next_back",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlatMap",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                self.inner.try_rfold(init, fold)
            }
        *)
        Definition try_rfold
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "try_rfold",
                  [ Acc; Fold; R ]
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlatMap",
                    "inner"
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                self.inner.rfold(init, fold)
            }
        *)
        Definition rfold (I U F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "rfold",
                  [ Acc; Fold ]
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::FlatMap",
                      "inner"
                    |)
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                self.inner.advance_back_by(n)
            }
        *)
        Definition advance_back_by
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ]; Ty.associated
                    ],
                  [],
                  "advance_back_by",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlatMap",
                    "inner"
                  |);
                  M.read (| n |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("next_back", InstanceField.Method (next_back I U F));
              ("try_rfold", InstanceField.Method (try_rfold I U F));
              ("rfold", InstanceField.Method (rfold I U F));
              ("advance_back_by", InstanceField.Method (advance_back_by I U F))
            ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_ops_function_FnMut_F_Tuple_associated_type__where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_iter_traits_marker_FusedIterator_where_core_iter_traits_marker_FusedIterator_I_where_core_iter_traits_collect_IntoIterator_U_where_core_ops_function_FnMut_F_Tuple_associated_type__for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_where_core_iter_traits_marker_FusedIterator_I_where_core_iter_traits_collect_IntoIterator_U_where_core_ops_function_FnMut_F_Tuple_associated_type__for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_iter_traits_marker_TrustedLen_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_U_where_core_ops_function_FnMut_F_Tuple_associated_type__where_core_iter_traits_marker_TrustedLen_core_iter_adapters_flatten_FlattenCompat_core_iter_adapters_map_Map_I_F_associated_type_for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::TrustedLen"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_TrustedLen_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_U_where_core_ops_function_FnMut_F_Tuple_associated_type__where_core_iter_traits_marker_TrustedLen_core_iter_adapters_flatten_FlattenCompat_core_iter_adapters_map_Map_I_F_associated_type_for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_iter_traits_marker_InPlaceIterable_where_core_iter_traits_marker_InPlaceIterable_I_where_core_iter_adapters_flatten_BoundedSize_U_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        (*
            const EXPAND_BY: Option<NonZero<usize>> = const {
                match (I::EXPAND_BY, U::UPPER_BOUND) {
                    (Some(m), Some(n)) => m.checked_mul(n),
                    _ => None,
                }
            };
        *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_EXPAND_BY (I U F : Ty.t) : Value.t :=
          let Self : Ty.t := Self I U F in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::adapters::flatten::EXPAND_BY_discriminant" |))).
        
        (*     const MERGE_BY: Option<NonZero<usize>> = I::MERGE_BY; *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_MERGE_BY (I U F : Ty.t) : Value.t :=
          let Self : Ty.t := Self I U F in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::traits::marker::InPlaceIterable::MERGE_BY" |))).
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::InPlaceIterable"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("value_EXPAND_BY", InstanceField.Constant (value_EXPAND_BY I U F));
              ("value_MERGE_BY", InstanceField.Constant (value_MERGE_BY I U F))
            ].
      End Impl_core_iter_traits_marker_InPlaceIterable_where_core_iter_traits_marker_InPlaceIterable_I_where_core_iter_adapters_flatten_BoundedSize_U_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      Module Impl_core_iter_adapters_SourceIter_where_core_iter_adapters_SourceIter_I_where_core_iter_traits_marker_TrustedFused_I_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
        Definition Self (I U F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlatMap") [] [ I; U; F ].
        
        (*     type Source = I::Source; *)
        Definition _Source (I U F : Ty.t) : Ty.t := Ty.associated.
        
        (*
            unsafe fn as_inner(&mut self) -> &mut I::Source {
                // SAFETY: unsafe function forwarding to unsafe function with the same requirements
                unsafe { SourceIter::as_inner(&mut self.inner.iter) }
            }
        *)
        Definition as_inner
            (I U F : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U F in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::adapters::SourceIter",
                  Ty.apply
                    (Ty.path "core::iter::adapters::fuse::Fuse")
                    []
                    [ Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ] ],
                  [],
                  "as_inner",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "core::iter::adapters::flatten::FlatMap",
                      "inner"
                    |),
                    "core::iter::adapters::flatten::FlattenCompat",
                    "iter"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U F : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::SourceIter"
            (Self I U F)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Source", InstanceField.Ty (_Source I U F));
              ("as_inner", InstanceField.Method (as_inner I U F))
            ].
      End Impl_core_iter_adapters_SourceIter_where_core_iter_adapters_SourceIter_I_where_core_iter_traits_marker_TrustedFused_I_where_core_iter_traits_collect_IntoIterator_U_for_core_iter_adapters_flatten_FlatMap_I_U_F.
      
      (* Trait *)
      (* Empty module 'BoundedSize' *)
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_core_option_Option_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::option::Option") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_core_option_Option_T.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_core_option_IntoIter_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::option::IntoIter") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_core_option_IntoIter_T.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_core_result_Result_T_U.
        Definition Self (T U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::result::Result") [] [ T; U ].
        
        Axiom Implements :
          forall (T U : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self T U)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_core_result_Result_T_U.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_core_result_IntoIter_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::result::IntoIter") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_core_result_IntoIter_T.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_core_iter_sources_once_Once_T.
        Definition Self (T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::sources::once::Once") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_core_iter_sources_once_Once_T.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_core_iter_sources_once_with_OnceWith_T.
        Definition Self (T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::sources::once_with::OnceWith") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_core_iter_sources_once_with_OnceWith_T.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_array_N_T.
        Definition Self (N : Value.t) (T : Ty.t) : Ty.t := Ty.apply (Ty.path "array") [ N ] [ T ].
        
        (*     const UPPER_BOUND: Option<NonZero<usize>> = NonZero::new(N); *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_UPPER_BOUND (N : Value.t) (T : Ty.t) : Value.t :=
          let Self : Ty.t := Self N T in
          M.run
            ltac:(M.monadic
              (M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ],
                    "new",
                    []
                  |),
                  [ M.read (| M.get_constant (| "core::iter::adapters::flatten::N" |) |) ]
                |)
              |))).
        
        Axiom Implements :
          forall (N : Value.t) (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self N T)
            (* Trait polymorphic types *) []
            (* Instance *)
            [ ("value_UPPER_BOUND", InstanceField.Constant (value_UPPER_BOUND N T)) ].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_array_N_T.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_for_core_array_iter_IntoIter_N_T.
        Definition Self (N : Value.t) (T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::array::iter::IntoIter") [ N ] [ T ].
        
        (*     const UPPER_BOUND: Option<NonZero<usize>> = NonZero::new(N); *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_UPPER_BOUND (N : Value.t) (T : Ty.t) : Value.t :=
          let Self : Ty.t := Self N T in
          M.run
            ltac:(M.monadic
              (M.alloc (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ],
                    "new",
                    []
                  |),
                  [ M.read (| M.get_constant (| "core::iter::adapters::flatten::N" |) |) ]
                |)
              |))).
        
        Axiom Implements :
          forall (N : Value.t) (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self N T)
            (* Trait polymorphic types *) []
            (* Instance *)
            [ ("value_UPPER_BOUND", InstanceField.Constant (value_UPPER_BOUND N T)) ].
      End Impl_core_iter_adapters_flatten_BoundedSize_for_core_array_iter_IntoIter_N_T.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_filter_Filter_I_P.
        Definition Self (I P : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::filter::Filter") [] [ I; P ].
        
        (*     const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND; *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_UPPER_BOUND (I P : Ty.t) : Value.t :=
          let Self : Ty.t := Self I P in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::adapters::flatten::BoundedSize::UPPER_BOUND" |))).
        
        Axiom Implements :
          forall (I P : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self I P)
            (* Trait polymorphic types *) []
            (* Instance *)
            [ ("value_UPPER_BOUND", InstanceField.Constant (value_UPPER_BOUND I P)) ].
      End Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_filter_Filter_I_P.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_filter_map_FilterMap_I_P.
        Definition Self (I P : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::filter_map::FilterMap") [] [ I; P ].
        
        (*     const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND; *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_UPPER_BOUND (I P : Ty.t) : Value.t :=
          let Self : Ty.t := Self I P in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::adapters::flatten::BoundedSize::UPPER_BOUND" |))).
        
        Axiom Implements :
          forall (I P : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self I P)
            (* Trait polymorphic types *) []
            (* Instance *)
            [ ("value_UPPER_BOUND", InstanceField.Constant (value_UPPER_BOUND I P)) ].
      End Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_filter_map_FilterMap_I_P.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_map_Map_I_F.
        Definition Self (I F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ].
        
        (*     const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND; *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_UPPER_BOUND (I F : Ty.t) : Value.t :=
          let Self : Ty.t := Self I F in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::adapters::flatten::BoundedSize::UPPER_BOUND" |))).
        
        Axiom Implements :
          forall (I F : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self I F)
            (* Trait polymorphic types *) []
            (* Instance *)
            [ ("value_UPPER_BOUND", InstanceField.Constant (value_UPPER_BOUND I F)) ].
      End Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_map_Map_I_F.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_copied_Copied_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::copied::Copied") [] [ I ].
        
        (*     const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND; *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_UPPER_BOUND (I : Ty.t) : Value.t :=
          let Self : Ty.t := Self I in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::adapters::flatten::BoundedSize::UPPER_BOUND" |))).
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("value_UPPER_BOUND", InstanceField.Constant (value_UPPER_BOUND I)) ].
      End Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_copied_Copied_I.
      
      Module Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_cloned_Cloned_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::cloned::Cloned") [] [ I ].
        
        (*     const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND; *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_UPPER_BOUND (I : Ty.t) : Value.t :=
          let Self : Ty.t := Self I in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::adapters::flatten::BoundedSize::UPPER_BOUND" |))).
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::BoundedSize"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("value_UPPER_BOUND", InstanceField.Constant (value_UPPER_BOUND I)) ].
      End Impl_core_iter_adapters_flatten_BoundedSize_where_core_iter_adapters_flatten_BoundedSize_I_for_core_iter_adapters_cloned_Cloned_I.
      
      (* StructRecord
        {
          name := "Flatten";
          const_params := [];
          ty_params := [ "I" ];
          fields :=
            [
              ("inner",
                Ty.apply
                  (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                  []
                  [ I; Ty.associated ])
            ];
        } *)
      
      Module Impl_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*
            pub(in super::super) fn new(iter: I) -> Flatten<I> {
                Flatten { inner: FlattenCompat::new(iter) }
            }
        *)
        Definition new (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [ iter ] =>
            ltac:(M.monadic
              (let iter := M.alloc (| iter |) in
              Value.StructRecord
                "core::iter::adapters::flatten::Flatten"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                          []
                          [ I; Ty.associated ],
                        "new",
                        []
                      |),
                      [ M.read (| iter |) ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_new :
          forall (I : Ty.t),
          M.IsAssociatedFunction (Self I) "new" (new I).
      End Impl_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_iter_traits_iterator_Iterator_I_where_core_fmt_Debug_U_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_struct("Flatten").field("inner", &self.inner).finish()
            }
        *)
        Definition fmt (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U 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::DebugStruct",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugStruct",
                      "field",
                      []
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_struct",
                            []
                          |),
                          [ M.read (| f |); M.read (| Value.String "Flatten" |) ]
                        |)
                      |);
                      M.read (| Value.String "inner" |);
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "core::iter::adapters::flatten::Flatten",
                        "inner"
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt I U)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_iter_traits_iterator_Iterator_I_where_core_fmt_Debug_U_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_iter_traits_iterator_Iterator_I_where_core_clone_Clone_U_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*
            fn clone(&self) -> Self {
                Flatten { inner: self.inner.clone() }
            }
        *)
        Definition clone (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "core::iter::adapters::flatten::Flatten"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply
                          (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                          []
                          [ I; U ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::Flatten",
                          "inner"
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone I U)) ].
      End Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_iter_traits_iterator_Iterator_I_where_core_clone_Clone_U_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*     type Item = U::Item; *)
        Definition _Item (I U : Ty.t) : Ty.t := Ty.associated.
        
        (*
            fn next(&mut self) -> Option<U::Item> {
                self.inner.next()
            }
        *)
        Definition next (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "next",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::Flatten",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::Flatten",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                self.inner.try_fold(init, fold)
            }
        *)
        Definition try_fold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "try_fold",
                  [ Acc; Fold; R ]
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::Flatten",
                    "inner"
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                self.inner.fold(init, fold)
            }
        *)
        Definition fold (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "fold",
                  [ Acc; Fold ]
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::Flatten",
                      "inner"
                    |)
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                self.inner.advance_by(n)
            }
        *)
        Definition advance_by
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "advance_by",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::Flatten",
                    "inner"
                  |);
                  M.read (| n |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn count(self) -> usize {
                self.inner.count()
            }
        *)
        Definition count (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "count",
                  []
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::Flatten",
                      "inner"
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(self) -> Option<Self::Item> {
                self.inner.last()
            }
        *)
        Definition last (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "last",
                  []
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::Flatten",
                      "inner"
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item I U));
              ("next", InstanceField.Method (next I U));
              ("size_hint", InstanceField.Method (size_hint I U));
              ("try_fold", InstanceField.Method (try_fold I U));
              ("fold", InstanceField.Method (fold I U));
              ("advance_by", InstanceField.Method (advance_by I U));
              ("count", InstanceField.Method (count I U));
              ("last", InstanceField.Method (last I U))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_iter_traits_double_ended_DoubleEndedIterator_U_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*
            fn next_back(&mut self) -> Option<U::Item> {
                self.inner.next_back()
            }
        *)
        Definition next_back
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "next_back",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::Flatten",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                self.inner.try_rfold(init, fold)
            }
        *)
        Definition try_rfold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "try_rfold",
                  [ Acc; Fold; R ]
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::Flatten",
                    "inner"
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                self.inner.rfold(init, fold)
            }
        *)
        Definition rfold (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "rfold",
                  [ Acc; Fold ]
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::Flatten",
                      "inner"
                    |)
                  |);
                  M.read (| init |);
                  M.read (| fold |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                self.inner.advance_back_by(n)
            }
        *)
        Definition advance_back_by
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  [],
                  "advance_back_by",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::Flatten",
                    "inner"
                  |);
                  M.read (| n |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("next_back", InstanceField.Method (next_back I U));
              ("try_rfold", InstanceField.Method (try_rfold I U));
              ("rfold", InstanceField.Method (rfold I U));
              ("advance_back_by", InstanceField.Method (advance_back_by I U))
            ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_iter_traits_double_ended_DoubleEndedIterator_U_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_iter_traits_marker_FusedIterator_where_core_iter_traits_marker_FusedIterator_I_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_where_core_iter_traits_marker_FusedIterator_I_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_iter_traits_marker_TrustedLen_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_marker_TrustedLen_core_iter_adapters_flatten_FlattenCompat_I_associated_type_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::TrustedLen"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_TrustedLen_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_marker_TrustedLen_core_iter_adapters_flatten_FlattenCompat_I_associated_type_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_iter_traits_marker_InPlaceIterable_where_core_iter_traits_marker_InPlaceIterable_I_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_associated_type_where_core_iter_adapters_flatten_BoundedSize_associated_type_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*
            const EXPAND_BY: Option<NonZero<usize>> = const {
                match (I::EXPAND_BY, I::Item::UPPER_BOUND) {
                    (Some(m), Some(n)) => m.checked_mul(n),
                    _ => None,
                }
            };
        *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_EXPAND_BY (I : Ty.t) : Value.t :=
          let Self : Ty.t := Self I in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::adapters::flatten::EXPAND_BY_discriminant" |))).
        
        (*     const MERGE_BY: Option<NonZero<usize>> = I::MERGE_BY; *)
        (* Ty.apply
          (Ty.path "core::option::Option")
          []
          [ Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ] ] *)
        Definition value_MERGE_BY (I : Ty.t) : Value.t :=
          let Self : Ty.t := Self I in
          M.run
            ltac:(M.monadic
              (M.get_constant (| "core::iter::traits::marker::InPlaceIterable::MERGE_BY" |))).
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::InPlaceIterable"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("value_EXPAND_BY", InstanceField.Constant (value_EXPAND_BY I));
              ("value_MERGE_BY", InstanceField.Constant (value_MERGE_BY I))
            ].
      End Impl_core_iter_traits_marker_InPlaceIterable_where_core_iter_traits_marker_InPlaceIterable_I_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_associated_type_where_core_iter_adapters_flatten_BoundedSize_associated_type_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_iter_adapters_SourceIter_where_core_iter_adapters_SourceIter_I_where_core_iter_traits_marker_TrustedFused_I_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_associated_type_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*     type Source = I::Source; *)
        Definition _Source (I : Ty.t) : Ty.t := Ty.associated.
        
        (*
            unsafe fn as_inner(&mut self) -> &mut I::Source {
                // SAFETY: unsafe function forwarding to unsafe function with the same requirements
                unsafe { SourceIter::as_inner(&mut self.inner.iter) }
            }
        *)
        Definition as_inner (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.call_closure (|
                M.get_trait_method (|
                  "core::iter::adapters::SourceIter",
                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                  [],
                  "as_inner",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "core::iter::adapters::flatten::Flatten",
                      "inner"
                    |),
                    "core::iter::adapters::flatten::FlattenCompat",
                    "iter"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::SourceIter"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Source", InstanceField.Ty (_Source I));
              ("as_inner", InstanceField.Method (as_inner I))
            ].
      End Impl_core_iter_adapters_SourceIter_where_core_iter_adapters_SourceIter_I_where_core_iter_traits_marker_TrustedFused_I_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_collect_IntoIterator_associated_type_for_core_iter_adapters_flatten_Flatten_I.
      
      Module Impl_core_default_Default_where_core_default_Default_I_where_core_iter_traits_iterator_Iterator_I_for_core_iter_adapters_flatten_Flatten_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ].
        
        (*
            fn default() -> Self {
                Flatten::new(Default::default())
            }
        *)
        Definition default (I : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::iter::adapters::flatten::Flatten") [] [ I ],
                  "new",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (| "core::default::Default", I, [], "default", [] |),
                    []
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default I)) ].
      End Impl_core_default_Default_where_core_default_Default_I_where_core_iter_traits_iterator_Iterator_I_for_core_iter_adapters_flatten_Flatten_I.
      
      (* StructRecord
        {
          name := "FlattenCompat";
          const_params := [];
          ty_params := [ "I"; "U" ];
          fields :=
            [
              ("iter", Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ]);
              ("frontiter", Ty.apply (Ty.path "core::option::Option") [] [ U ]);
              ("backiter", Ty.apply (Ty.path "core::option::Option") [] [ U ])
            ];
        } *)
      
      Module Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_clone_Clone_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ].
        
        (* Clone *)
        Definition clone (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "core::iter::adapters::flatten::FlattenCompat"
                [
                  ("iter",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "iter"
                        |)
                      ]
                    |));
                  ("frontiter",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply (Ty.path "core::option::Option") [] [ U ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "frontiter"
                        |)
                      ]
                    |));
                  ("backiter",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply (Ty.path "core::option::Option") [] [ U ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "backiter"
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone I U)) ].
      End Impl_core_clone_Clone_where_core_clone_Clone_I_where_core_clone_Clone_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_fmt_Debug_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ].
        
        (* Debug *)
        Definition fmt (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U 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::Formatter",
                  "debug_struct_field3_finish",
                  []
                |),
                [
                  M.read (| f |);
                  M.read (| Value.String "FlattenCompat" |);
                  M.read (| Value.String "iter" |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlattenCompat",
                    "iter"
                  |);
                  M.read (| Value.String "frontiter" |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlattenCompat",
                    "frontiter"
                  |);
                  M.read (| Value.String "backiter" |);
                  M.alloc (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "core::iter::adapters::flatten::FlattenCompat",
                      "backiter"
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt I U)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_I_where_core_fmt_Debug_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
      
      Module Impl_core_iter_adapters_flatten_FlattenCompat_I_U.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ].
        
        (*
            fn new(iter: I) -> FlattenCompat<I, U> {
                FlattenCompat { iter: iter.fuse(), frontiter: None, backiter: None }
            }
        *)
        Definition new (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ iter ] =>
            ltac:(M.monadic
              (let iter := M.alloc (| iter |) in
              Value.StructRecord
                "core::iter::adapters::flatten::FlattenCompat"
                [
                  ("iter",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::iterator::Iterator",
                        I,
                        [],
                        "fuse",
                        []
                      |),
                      [ M.read (| iter |) ]
                    |));
                  ("frontiter", Value.StructTuple "core::option::Option::None" []);
                  ("backiter", Value.StructTuple "core::option::Option::None" [])
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_new :
          forall (I U : Ty.t),
          M.IsAssociatedFunction (Self I U) "new" (new I U).
        (*
            fn iter_fold<Acc, Fold>(self, mut acc: Acc, mut fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, U) -> Acc,
            {
                #[inline]
                fn flatten<T: IntoIterator, Acc>(
                    fold: &mut impl FnMut(Acc, T::IntoIter) -> Acc,
                ) -> impl FnMut(Acc, T) -> Acc + '_ {
                    move |acc, iter| fold(acc, iter.into_iter())
                }
        
                if let Some(iter) = self.frontiter {
                    acc = fold(acc, iter);
                }
        
                acc = self.iter.fold(acc, flatten(&mut fold));
        
                if let Some(iter) = self.backiter {
                    acc = fold(acc, iter);
                }
        
                acc
            }
        *)
        Definition iter_fold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; acc; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let acc := M.alloc (| acc |) in
              let fold := M.alloc (| fold |) in
              M.read (|
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "core::iter::adapters::flatten::FlattenCompat",
                              "frontiter"
                            |) in
                          let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let iter := M.copy (| γ0_0 |) in
                          let~ _ :=
                            M.write (|
                              acc,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::function::FnMut",
                                  Fold,
                                  [ Ty.tuple [ Acc; U ] ],
                                  "call_mut",
                                  []
                                |),
                                [ fold; Value.Tuple [ M.read (| acc |); M.read (| iter |) ] ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                let~ _ :=
                  M.write (|
                    acc,
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::iterator::Iterator",
                        Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                        [],
                        "fold",
                        [ Acc; Ty.associated ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            self,
                            "core::iter::adapters::flatten::FlattenCompat",
                            "iter"
                          |)
                        |);
                        M.read (| acc |);
                        M.call_closure (|
                          M.get_associated_function (| Self, "flatten.iter_fold", [] |),
                          [ fold ]
                        |)
                      ]
                    |)
                  |) in
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "core::iter::adapters::flatten::FlattenCompat",
                              "backiter"
                            |) in
                          let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let iter := M.copy (| γ0_0 |) in
                          let~ _ :=
                            M.write (|
                              acc,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::function::FnMut",
                                  Fold,
                                  [ Ty.tuple [ Acc; U ] ],
                                  "call_mut",
                                  []
                                |),
                                [ fold; Value.Tuple [ M.read (| acc |); M.read (| iter |) ] ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                acc
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter_fold :
          forall (I U : Ty.t),
          M.IsAssociatedFunction (Self I U) "iter_fold" (iter_fold I U).
        
        (*
            fn iter_try_fold<Acc, Fold, R>(&mut self, mut acc: Acc, mut fold: Fold) -> R
            where
                Fold: FnMut(Acc, &mut U) -> R,
                R: Try<Output = Acc>,
            {
                #[inline]
                fn flatten<'a, T: IntoIterator, Acc, R: Try<Output = Acc>>(
                    frontiter: &'a mut Option<T::IntoIter>,
                    fold: &'a mut impl FnMut(Acc, &mut T::IntoIter) -> R,
                ) -> impl FnMut(Acc, T) -> R + 'a {
                    move |acc, iter| fold(acc, frontiter.insert(iter.into_iter()))
                }
        
                if let Some(iter) = &mut self.frontiter {
                    acc = fold(acc, iter)?;
                }
                self.frontiter = None;
        
                acc = self.iter.try_fold(acc, flatten(&mut self.frontiter, &mut fold))?;
                self.frontiter = None;
        
                if let Some(iter) = &mut self.backiter {
                    acc = fold(acc, iter)?;
                }
                self.backiter = None;
        
                try { acc }
            }
        *)
        Definition iter_try_fold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; acc; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let acc := M.alloc (| acc |) in
              let fold := M.alloc (| fold |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "frontiter"
                                  |)
                                |) in
                              let γ := M.read (| γ |) in
                              let γ1_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let iter := M.alloc (| γ1_0 |) in
                              let~ _ :=
                                M.write (|
                                  acc,
                                  M.read (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            R,
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::function::FnMut",
                                                Fold,
                                                [
                                                  Ty.tuple
                                                    [ Acc; Ty.apply (Ty.path "&mut") [] [ U ] ]
                                                ],
                                                "call_mut",
                                                []
                                              |),
                                              [
                                                fold;
                                                Value.Tuple [ M.read (| acc |); M.read (| iter |) ]
                                              ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        R,
                                                        [ Ty.associated ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |)
                                |) in
                              M.alloc (| Value.Tuple [] |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "frontiter"
                        |),
                        Value.StructTuple "core::option::Option::None" []
                      |) in
                    let~ _ :=
                      M.write (|
                        acc,
                        M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  R,
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::iter::traits::iterator::Iterator",
                                      Ty.apply
                                        (Ty.path "core::iter::adapters::fuse::Fuse")
                                        []
                                        [ I ],
                                      [],
                                      "try_fold",
                                      [ Acc; Ty.associated; R ]
                                    |),
                                    [
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "core::iter::adapters::flatten::FlattenCompat",
                                        "iter"
                                      |);
                                      M.read (| acc |);
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Self,
                                          "flatten.iter_try_fold",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "core::iter::adapters::flatten::FlattenCompat",
                                            "frontiter"
                                          |);
                                          fold
                                        ]
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              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",
                                              R,
                                              [ Ty.associated ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |)
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "frontiter"
                        |),
                        Value.StructTuple "core::option::Option::None" []
                      |) in
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "backiter"
                                  |)
                                |) in
                              let γ := M.read (| γ |) in
                              let γ1_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let iter := M.alloc (| γ1_0 |) in
                              let~ _ :=
                                M.write (|
                                  acc,
                                  M.read (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            R,
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::function::FnMut",
                                                Fold,
                                                [
                                                  Ty.tuple
                                                    [ Acc; Ty.apply (Ty.path "&mut") [] [ U ] ]
                                                ],
                                                "call_mut",
                                                []
                                              |),
                                              [
                                                fold;
                                                Value.Tuple [ M.read (| acc |); M.read (| iter |) ]
                                              ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        R,
                                                        [ Ty.associated ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |)
                                |) in
                              M.alloc (| Value.Tuple [] |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "backiter"
                        |),
                        Value.StructTuple "core::option::Option::None" []
                      |) in
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          R,
                          [],
                          "from_output",
                          []
                        |),
                        [ M.read (| acc |) ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter_try_fold :
          forall (I U : Ty.t),
          M.IsAssociatedFunction (Self I U) "iter_try_fold" (iter_try_fold I U).
        (*
            fn iter_rfold<Acc, Fold>(self, mut acc: Acc, mut fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, U) -> Acc,
            {
                #[inline]
                fn flatten<T: IntoIterator, Acc>(
                    fold: &mut impl FnMut(Acc, T::IntoIter) -> Acc,
                ) -> impl FnMut(Acc, T) -> Acc + '_ {
                    move |acc, iter| fold(acc, iter.into_iter())
                }
        
                if let Some(iter) = self.backiter {
                    acc = fold(acc, iter);
                }
        
                acc = self.iter.rfold(acc, flatten(&mut fold));
        
                if let Some(iter) = self.frontiter {
                    acc = fold(acc, iter);
                }
        
                acc
            }
        *)
        Definition iter_rfold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; acc; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let acc := M.alloc (| acc |) in
              let fold := M.alloc (| fold |) in
              M.read (|
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "core::iter::adapters::flatten::FlattenCompat",
                              "backiter"
                            |) in
                          let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let iter := M.copy (| γ0_0 |) in
                          let~ _ :=
                            M.write (|
                              acc,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::function::FnMut",
                                  Fold,
                                  [ Ty.tuple [ Acc; U ] ],
                                  "call_mut",
                                  []
                                |),
                                [ fold; Value.Tuple [ M.read (| acc |); M.read (| iter |) ] ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                let~ _ :=
                  M.write (|
                    acc,
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::double_ended::DoubleEndedIterator",
                        Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                        [],
                        "rfold",
                        [ Acc; Ty.associated ]
                      |),
                      [
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            self,
                            "core::iter::adapters::flatten::FlattenCompat",
                            "iter"
                          |)
                        |);
                        M.read (| acc |);
                        M.call_closure (|
                          M.get_associated_function (| Self, "flatten.iter_rfold", [] |),
                          [ fold ]
                        |)
                      ]
                    |)
                  |) in
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.SubPointer.get_struct_record_field (|
                              self,
                              "core::iter::adapters::flatten::FlattenCompat",
                              "frontiter"
                            |) in
                          let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let iter := M.copy (| γ0_0 |) in
                          let~ _ :=
                            M.write (|
                              acc,
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::function::FnMut",
                                  Fold,
                                  [ Ty.tuple [ Acc; U ] ],
                                  "call_mut",
                                  []
                                |),
                                [ fold; Value.Tuple [ M.read (| acc |); M.read (| iter |) ] ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                acc
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter_rfold :
          forall (I U : Ty.t),
          M.IsAssociatedFunction (Self I U) "iter_rfold" (iter_rfold I U).
        
        (*
            fn iter_try_rfold<Acc, Fold, R>(&mut self, mut acc: Acc, mut fold: Fold) -> R
            where
                Fold: FnMut(Acc, &mut U) -> R,
                R: Try<Output = Acc>,
            {
                #[inline]
                fn flatten<'a, T: IntoIterator, Acc, R: Try>(
                    backiter: &'a mut Option<T::IntoIter>,
                    fold: &'a mut impl FnMut(Acc, &mut T::IntoIter) -> R,
                ) -> impl FnMut(Acc, T) -> R + 'a {
                    move |acc, iter| fold(acc, backiter.insert(iter.into_iter()))
                }
        
                if let Some(iter) = &mut self.backiter {
                    acc = fold(acc, iter)?;
                }
                self.backiter = None;
        
                acc = self.iter.try_rfold(acc, flatten(&mut self.backiter, &mut fold))?;
                self.backiter = None;
        
                if let Some(iter) = &mut self.frontiter {
                    acc = fold(acc, iter)?;
                }
                self.frontiter = None;
        
                try { acc }
            }
        *)
        Definition iter_try_rfold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; acc; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let acc := M.alloc (| acc |) in
              let fold := M.alloc (| fold |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "backiter"
                                  |)
                                |) in
                              let γ := M.read (| γ |) in
                              let γ1_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let iter := M.alloc (| γ1_0 |) in
                              let~ _ :=
                                M.write (|
                                  acc,
                                  M.read (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            R,
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::function::FnMut",
                                                Fold,
                                                [
                                                  Ty.tuple
                                                    [ Acc; Ty.apply (Ty.path "&mut") [] [ U ] ]
                                                ],
                                                "call_mut",
                                                []
                                              |),
                                              [
                                                fold;
                                                Value.Tuple [ M.read (| acc |); M.read (| iter |) ]
                                              ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        R,
                                                        [ Ty.associated ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |)
                                |) in
                              M.alloc (| Value.Tuple [] |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "backiter"
                        |),
                        Value.StructTuple "core::option::Option::None" []
                      |) in
                    let~ _ :=
                      M.write (|
                        acc,
                        M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  R,
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::iter::traits::double_ended::DoubleEndedIterator",
                                      Ty.apply
                                        (Ty.path "core::iter::adapters::fuse::Fuse")
                                        []
                                        [ I ],
                                      [],
                                      "try_rfold",
                                      [ Acc; Ty.associated; R ]
                                    |),
                                    [
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "core::iter::adapters::flatten::FlattenCompat",
                                        "iter"
                                      |);
                                      M.read (| acc |);
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Self,
                                          "flatten.iter_try_rfold",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "core::iter::adapters::flatten::FlattenCompat",
                                            "backiter"
                                          |);
                                          fold
                                        ]
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              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",
                                              R,
                                              [ Ty.associated ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |)
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "backiter"
                        |),
                        Value.StructTuple "core::option::Option::None" []
                      |) in
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "frontiter"
                                  |)
                                |) in
                              let γ := M.read (| γ |) in
                              let γ1_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let iter := M.alloc (| γ1_0 |) in
                              let~ _ :=
                                M.write (|
                                  acc,
                                  M.read (|
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::Try",
                                            R,
                                            [],
                                            "branch",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::function::FnMut",
                                                Fold,
                                                [
                                                  Ty.tuple
                                                    [ Acc; Ty.apply (Ty.path "&mut") [] [ U ] ]
                                                ],
                                                "call_mut",
                                                []
                                              |),
                                              [
                                                fold;
                                                Value.Tuple [ M.read (| acc |); M.read (| iter |) ]
                                              ]
                                            |)
                                          ]
                                        |)
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Break",
                                                0
                                              |) in
                                            let residual := M.copy (| γ0_0 |) in
                                            M.alloc (|
                                              M.never_to_any (|
                                                M.read (|
                                                  M.return_ (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::ops::try_trait::FromResidual",
                                                        R,
                                                        [ Ty.associated ],
                                                        "from_residual",
                                                        []
                                                      |),
                                                      [ M.read (| residual |) ]
                                                    |)
                                                  |)
                                                |)
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ,
                                                "core::ops::control_flow::ControlFlow::Continue",
                                                0
                                              |) in
                                            let val := M.copy (| γ0_0 |) in
                                            val))
                                      ]
                                    |)
                                  |)
                                |) in
                              M.alloc (| Value.Tuple [] |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "frontiter"
                        |),
                        Value.StructTuple "core::option::Option::None" []
                      |) in
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::try_trait::Try",
                          R,
                          [],
                          "from_output",
                          []
                        |),
                        [ M.read (| acc |) ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter_try_rfold :
          forall (I U : Ty.t),
          M.IsAssociatedFunction (Self I U) "iter_try_rfold" (iter_try_rfold I U).
      End Impl_core_iter_adapters_flatten_FlattenCompat_I_U.
      
      
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ].
        
        (*     type Item = U::Item; *)
        Definition _Item (I U : Ty.t) : Ty.t := Ty.associated.
        
        (*
            default fn next(&mut self) -> Option<U::Item> {
                loop {
                    if let elt @ Some(_) = and_then_or_clear(&mut self.frontiter, Iterator::next) {
                        return elt;
                    }
                    match self.iter.next() {
                        None => return and_then_or_clear(&mut self.backiter, Iterator::next),
                        Some(inner) => self.frontiter = Some(inner.into_iter()),
                    }
                }
            }
        *)
        Definition next (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.never_to_any (|
                    M.read (|
                      M.loop (|
                        ltac:(M.monadic
                          (let~ _ :=
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_function (|
                                            "core::iter::adapters::flatten::and_then_or_clear",
                                            [
                                              U;
                                              Ty.associated;
                                              Ty.function
                                                [ Ty.apply (Ty.path "&mut") [] [ U ] ]
                                                (Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  []
                                                  [ Ty.associated ])
                                            ]
                                          |),
                                          [
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "core::iter::adapters::flatten::FlattenCompat",
                                              "frontiter"
                                            |);
                                            M.get_trait_method (|
                                              "core::iter::traits::iterator::Iterator",
                                              U,
                                              [],
                                              "next",
                                              []
                                            |)
                                          ]
                                        |)
                                      |) in
                                    let elt := M.copy (| γ |) in
                                    let γ1_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::option::Option::Some",
                                        0
                                      |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (| M.return_ (| M.read (| elt |) |) |)
                                      |)
                                    |)));
                                fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                              ]
                            |) in
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::iterator::Iterator",
                                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                                  [],
                                  "next",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "iter"
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_function (|
                                              "core::iter::adapters::flatten::and_then_or_clear",
                                              [
                                                U;
                                                Ty.associated;
                                                Ty.function
                                                  [ Ty.apply (Ty.path "&mut") [] [ U ] ]
                                                  (Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [ Ty.associated ])
                                              ]
                                            |),
                                            [
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "core::iter::adapters::flatten::FlattenCompat",
                                                "backiter"
                                              |);
                                              M.get_trait_method (|
                                                "core::iter::traits::iterator::Iterator",
                                                U,
                                                [],
                                                "next",
                                                []
                                              |)
                                            ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::option::Option::Some",
                                      0
                                    |) in
                                  let inner := M.copy (| γ0_0 |) in
                                  M.write (|
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "core::iter::adapters::flatten::FlattenCompat",
                                      "frontiter"
                                    |),
                                    Value.StructTuple
                                      "core::option::Option::Some"
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::iter::traits::collect::IntoIterator",
                                            Ty.associated,
                                            [],
                                            "into_iter",
                                            []
                                          |),
                                          [ M.read (| inner |) ]
                                        |)
                                      ]
                                  |)))
                            ]
                          |)))
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn size_hint(&self) -> (usize, Option<usize>) {
                let (flo, fhi) = self.frontiter.as_ref().map_or((0, Some(0)), U::size_hint);
                let (blo, bhi) = self.backiter.as_ref().map_or((0, Some(0)), U::size_hint);
                let lo = flo.saturating_add(blo);
        
                if let Some(fixed_size) = <<I as Iterator>::Item as ConstSizeIntoIterator>::size() {
                    let (lower, upper) = self.iter.size_hint();
        
                    let lower = lower.saturating_mul(fixed_size).saturating_add(lo);
                    let upper =
                        try { fhi?.checked_add(bhi?)?.checked_add(fixed_size.checked_mul(upper?)?)? };
        
                    return (lower, upper);
                }
        
                match (self.iter.size_hint(), fhi, bhi) {
                    ((0, Some(0)), Some(a), Some(b)) => (lo, a.checked_add(b)),
                    _ => (lo, None),
                }
            }
        *)
        Definition size_hint
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "core::option::Option")
                              []
                              [ Ty.apply (Ty.path "&") [] [ U ] ],
                            "map_or",
                            [
                              Ty.tuple
                                [
                                  Ty.path "usize";
                                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.path "usize" ]
                                ];
                              Ty.function
                                [ Ty.apply (Ty.path "&") [] [ U ] ]
                                (Ty.tuple
                                  [
                                    Ty.path "usize";
                                    Ty.apply (Ty.path "core::option::Option") [] [ Ty.path "usize" ]
                                  ])
                            ]
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply (Ty.path "core::option::Option") [] [ U ],
                                "as_ref",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "core::iter::adapters::flatten::FlattenCompat",
                                  "frontiter"
                                |)
                              ]
                            |);
                            Value.Tuple
                              [
                                Value.Integer IntegerKind.Usize 0;
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [ Value.Integer IntegerKind.Usize 0 ]
                              ];
                            M.get_trait_method (|
                              "core::iter::traits::iterator::Iterator",
                              U,
                              [],
                              "size_hint",
                              []
                            |)
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                            let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                            let flo := M.copy (| γ0_0 |) in
                            let fhi := M.copy (| γ0_1 |) in
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [ Ty.apply (Ty.path "&") [] [ U ] ],
                                    "map_or",
                                    [
                                      Ty.tuple
                                        [
                                          Ty.path "usize";
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [ Ty.path "usize" ]
                                        ];
                                      Ty.function
                                        [ Ty.apply (Ty.path "&") [] [ U ] ]
                                        (Ty.tuple
                                          [
                                            Ty.path "usize";
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [ Ty.path "usize" ]
                                          ])
                                    ]
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "core::option::Option") [] [ U ],
                                        "as_ref",
                                        []
                                      |),
                                      [
                                        M.SubPointer.get_struct_record_field (|
                                          M.read (| self |),
                                          "core::iter::adapters::flatten::FlattenCompat",
                                          "backiter"
                                        |)
                                      ]
                                    |);
                                    Value.Tuple
                                      [
                                        Value.Integer IntegerKind.Usize 0;
                                        Value.StructTuple
                                          "core::option::Option::Some"
                                          [ Value.Integer IntegerKind.Usize 0 ]
                                      ];
                                    M.get_trait_method (|
                                      "core::iter::traits::iterator::Iterator",
                                      U,
                                      [],
                                      "size_hint",
                                      []
                                    |)
                                  ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                    let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                    let blo := M.copy (| γ0_0 |) in
                                    let bhi := M.copy (| γ0_1 |) in
                                    let~ lo :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "usize",
                                            "saturating_add",
                                            []
                                          |),
                                          [ M.read (| flo |); M.read (| blo |) ]
                                        |)
                                      |) in
                                    let~ _ :=
                                      M.match_operator (|
                                        M.alloc (| Value.Tuple [] |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::iter::adapters::flatten::ConstSizeIntoIterator",
                                                      Ty.associated,
                                                      [],
                                                      "size",
                                                      []
                                                    |),
                                                    []
                                                  |)
                                                |) in
                                              let γ0_0 :=
                                                M.SubPointer.get_struct_tuple_field (|
                                                  γ,
                                                  "core::option::Option::Some",
                                                  0
                                                |) in
                                              let fixed_size := M.copy (| γ0_0 |) in
                                              M.alloc (|
                                                M.never_to_any (|
                                                  M.read (|
                                                    M.match_operator (|
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::iter::traits::iterator::Iterator",
                                                            Ty.apply
                                                              (Ty.path
                                                                "core::iter::adapters::fuse::Fuse")
                                                              []
                                                              [ I ],
                                                            [],
                                                            "size_hint",
                                                            []
                                                          |),
                                                          [
                                                            M.SubPointer.get_struct_record_field (|
                                                              M.read (| self |),
                                                              "core::iter::adapters::flatten::FlattenCompat",
                                                              "iter"
                                                            |)
                                                          ]
                                                        |)
                                                      |),
                                                      [
                                                        fun γ =>
                                                          ltac:(M.monadic
                                                            (let γ0_0 :=
                                                              M.SubPointer.get_tuple_field (|
                                                                γ,
                                                                0
                                                              |) in
                                                            let γ0_1 :=
                                                              M.SubPointer.get_tuple_field (|
                                                                γ,
                                                                1
                                                              |) in
                                                            let lower := M.copy (| γ0_0 |) in
                                                            let upper := M.copy (| γ0_1 |) in
                                                            let~ lower :=
                                                              M.alloc (|
                                                                M.call_closure (|
                                                                  M.get_associated_function (|
                                                                    Ty.path "usize",
                                                                    "saturating_add",
                                                                    []
                                                                  |),
                                                                  [
                                                                    M.call_closure (|
                                                                      M.get_associated_function (|
                                                                        Ty.path "usize",
                                                                        "saturating_mul",
                                                                        []
                                                                      |),
                                                                      [
                                                                        M.read (| lower |);
                                                                        M.read (| fixed_size |)
                                                                      ]
                                                                    |);
                                                                    M.read (| lo |)
                                                                  ]
                                                                |)
                                                              |) in
                                                            let~ upper :=
                                                              M.alloc (|
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::ops::try_trait::Try",
                                                                    Ty.apply
                                                                      (Ty.path
                                                                        "core::option::Option")
                                                                      []
                                                                      [ Ty.path "usize" ],
                                                                    [],
                                                                    "from_output",
                                                                    []
                                                                  |),
                                                                  [
                                                                    M.read (|
                                                                      M.match_operator (|
                                                                        M.alloc (|
                                                                          M.call_closure (|
                                                                            M.get_trait_method (|
                                                                              "core::ops::try_trait::Try",
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::option::Option")
                                                                                []
                                                                                [ Ty.path "usize" ],
                                                                              [],
                                                                              "branch",
                                                                              []
                                                                            |),
                                                                            [
                                                                              M.call_closure (|
                                                                                M.get_associated_function (|
                                                                                  Ty.path "usize",
                                                                                  "checked_add",
                                                                                  []
                                                                                |),
                                                                                [
                                                                                  M.read (|
                                                                                    M.match_operator (|
                                                                                      M.alloc (|
                                                                                        M.call_closure (|
                                                                                          M.get_trait_method (|
                                                                                            "core::ops::try_trait::Try",
                                                                                            Ty.apply
                                                                                              (Ty.path
                                                                                                "core::option::Option")
                                                                                              []
                                                                                              [
                                                                                                Ty.path
                                                                                                  "usize"
                                                                                              ],
                                                                                            [],
                                                                                            "branch",
                                                                                            []
                                                                                          |),
                                                                                          [
                                                                                            M.call_closure (|
                                                                                              M.get_associated_function (|
                                                                                                Ty.path
                                                                                                  "usize",
                                                                                                "checked_add",
                                                                                                []
                                                                                              |),
                                                                                              [
                                                                                                M.read (|
                                                                                                  M.match_operator (|
                                                                                                    M.alloc (|
                                                                                                      M.call_closure (|
                                                                                                        M.get_trait_method (|
                                                                                                          "core::ops::try_trait::Try",
                                                                                                          Ty.apply
                                                                                                            (Ty.path
                                                                                                              "core::option::Option")
                                                                                                            []
                                                                                                            [
                                                                                                              Ty.path
                                                                                                                "usize"
                                                                                                            ],
                                                                                                          [],
                                                                                                          "branch",
                                                                                                          []
                                                                                                        |),
                                                                                                        [
                                                                                                          M.read (|
                                                                                                            fhi
                                                                                                          |)
                                                                                                        ]
                                                                                                      |)
                                                                                                    |),
                                                                                                    [
                                                                                                      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.break (||)
                                                                                                              |)
                                                                                                            |)
                                                                                                          |)));
                                                                                                      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))
                                                                                                    ]
                                                                                                  |)
                                                                                                |);
                                                                                                M.read (|
                                                                                                  M.match_operator (|
                                                                                                    M.alloc (|
                                                                                                      M.call_closure (|
                                                                                                        M.get_trait_method (|
                                                                                                          "core::ops::try_trait::Try",
                                                                                                          Ty.apply
                                                                                                            (Ty.path
                                                                                                              "core::option::Option")
                                                                                                            []
                                                                                                            [
                                                                                                              Ty.path
                                                                                                                "usize"
                                                                                                            ],
                                                                                                          [],
                                                                                                          "branch",
                                                                                                          []
                                                                                                        |),
                                                                                                        [
                                                                                                          M.read (|
                                                                                                            bhi
                                                                                                          |)
                                                                                                        ]
                                                                                                      |)
                                                                                                    |),
                                                                                                    [
                                                                                                      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.break (||)
                                                                                                              |)
                                                                                                            |)
                                                                                                          |)));
                                                                                                      fun
                                                                                                          γ =>
                                                                                                        ltac:(M.monadic
                                                                                                          (let
                                                                                                                γ0_0 :=
                                                                                                            M.SubPointer.get_struct_tuple_field (|
                                                                                                              γ,
                                                                                                              "core::ops::control_flow::ControlFlow::Continue",
                                                                                                              0
                                                                                                            |) in
                                                                                                          let
                                                                                                                val :=
                                                                                                            M.copy (|
                                                                                                              γ0_0
                                                                                                            |) in
                                                                                                          val))
                                                                                                    ]
                                                                                                  |)
                                                                                                |)
                                                                                              ]
                                                                                            |)
                                                                                          ]
                                                                                        |)
                                                                                      |),
                                                                                      [
                                                                                        fun γ =>
                                                                                          ltac:(M.monadic
                                                                                            (let
                                                                                                  γ0_0 :=
                                                                                              M.SubPointer.get_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.break (||)
                                                                                                |)
                                                                                              |)
                                                                                            |)));
                                                                                        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))
                                                                                      ]
                                                                                    |)
                                                                                  |);
                                                                                  M.read (|
                                                                                    M.match_operator (|
                                                                                      M.alloc (|
                                                                                        M.call_closure (|
                                                                                          M.get_trait_method (|
                                                                                            "core::ops::try_trait::Try",
                                                                                            Ty.apply
                                                                                              (Ty.path
                                                                                                "core::option::Option")
                                                                                              []
                                                                                              [
                                                                                                Ty.path
                                                                                                  "usize"
                                                                                              ],
                                                                                            [],
                                                                                            "branch",
                                                                                            []
                                                                                          |),
                                                                                          [
                                                                                            M.call_closure (|
                                                                                              M.get_associated_function (|
                                                                                                Ty.path
                                                                                                  "usize",
                                                                                                "checked_mul",
                                                                                                []
                                                                                              |),
                                                                                              [
                                                                                                M.read (|
                                                                                                  fixed_size
                                                                                                |);
                                                                                                M.read (|
                                                                                                  M.match_operator (|
                                                                                                    M.alloc (|
                                                                                                      M.call_closure (|
                                                                                                        M.get_trait_method (|
                                                                                                          "core::ops::try_trait::Try",
                                                                                                          Ty.apply
                                                                                                            (Ty.path
                                                                                                              "core::option::Option")
                                                                                                            []
                                                                                                            [
                                                                                                              Ty.path
                                                                                                                "usize"
                                                                                                            ],
                                                                                                          [],
                                                                                                          "branch",
                                                                                                          []
                                                                                                        |),
                                                                                                        [
                                                                                                          M.read (|
                                                                                                            upper
                                                                                                          |)
                                                                                                        ]
                                                                                                      |)
                                                                                                    |),
                                                                                                    [
                                                                                                      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.break (||)
                                                                                                              |)
                                                                                                            |)
                                                                                                          |)));
                                                                                                      fun
                                                                                                          γ =>
                                                                                                        ltac:(M.monadic
                                                                                                          (let
                                                                                                                γ0_0 :=
                                                                                                            M.SubPointer.get_struct_tuple_field (|
                                                                                                              γ,
                                                                                                              "core::ops::control_flow::ControlFlow::Continue",
                                                                                                              0
                                                                                                            |) in
                                                                                                          let
                                                                                                                val :=
                                                                                                            M.copy (|
                                                                                                              γ0_0
                                                                                                            |) in
                                                                                                          val))
                                                                                                    ]
                                                                                                  |)
                                                                                                |)
                                                                                              ]
                                                                                            |)
                                                                                          ]
                                                                                        |)
                                                                                      |),
                                                                                      [
                                                                                        fun γ =>
                                                                                          ltac:(M.monadic
                                                                                            (let
                                                                                                  γ0_0 :=
                                                                                              M.SubPointer.get_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.break (||)
                                                                                                |)
                                                                                              |)
                                                                                            |)));
                                                                                        fun γ =>
                                                                                          ltac:(M.monadic
                                                                                            (let
                                                                                                  γ0_0 :=
                                                                                              M.SubPointer.get_struct_tuple_field (|
                                                                                                γ,
                                                                                                "core::ops::control_flow::ControlFlow::Continue",
                                                                                                0
                                                                                              |) in
                                                                                            let
                                                                                                  val :=
                                                                                              M.copy (|
                                                                                                γ0_0
                                                                                              |) in
                                                                                            val))
                                                                                      ]
                                                                                    |)
                                                                                  |)
                                                                                ]
                                                                              |)
                                                                            ]
                                                                          |)
                                                                        |),
                                                                        [
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (let γ0_0 :=
                                                                                M.SubPointer.get_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.break (||)
                                                                                  |)
                                                                                |)
                                                                              |)));
                                                                          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.return_ (|
                                                              Value.Tuple
                                                                [
                                                                  M.read (| lower |);
                                                                  M.read (| upper |)
                                                                ]
                                                            |)))
                                                      ]
                                                    |)
                                                  |)
                                                |)
                                              |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |) in
                                    M.match_operator (|
                                      M.alloc (|
                                        Value.Tuple
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::iter::traits::iterator::Iterator",
                                                Ty.apply
                                                  (Ty.path "core::iter::adapters::fuse::Fuse")
                                                  []
                                                  [ I ],
                                                [],
                                                "size_hint",
                                                []
                                              |),
                                              [
                                                M.SubPointer.get_struct_record_field (|
                                                  M.read (| self |),
                                                  "core::iter::adapters::flatten::FlattenCompat",
                                                  "iter"
                                                |)
                                              ]
                                            |);
                                            M.read (| fhi |);
                                            M.read (| bhi |)
                                          ]
                                      |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                            let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                            let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in
                                            let γ1_0 :=
                                              M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                            let γ1_1 :=
                                              M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                            let _ :=
                                              M.is_constant_or_break_match (|
                                                M.read (| γ1_0 |),
                                                Value.Integer IntegerKind.Usize 0
                                              |) in
                                            let γ2_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ1_1,
                                                "core::option::Option::Some",
                                                0
                                              |) in
                                            let _ :=
                                              M.is_constant_or_break_match (|
                                                M.read (| γ2_0 |),
                                                Value.Integer IntegerKind.Usize 0
                                              |) in
                                            let γ1_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ0_1,
                                                "core::option::Option::Some",
                                                0
                                              |) in
                                            let a := M.copy (| γ1_0 |) in
                                            let γ1_0 :=
                                              M.SubPointer.get_struct_tuple_field (|
                                                γ0_2,
                                                "core::option::Option::Some",
                                                0
                                              |) in
                                            let b := M.copy (| γ1_0 |) in
                                            M.alloc (|
                                              Value.Tuple
                                                [
                                                  M.read (| lo |);
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path "usize",
                                                      "checked_add",
                                                      []
                                                    |),
                                                    [ M.read (| a |); M.read (| b |) ]
                                                  |)
                                                ]
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (M.alloc (|
                                              Value.Tuple
                                                [
                                                  M.read (| lo |);
                                                  Value.StructTuple "core::option::Option::None" []
                                                ]
                                            |)))
                                      ]
                                    |)))
                              ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                #[inline]
                fn flatten<U: Iterator, Acc, R: Try<Output = Acc>>(
                    mut fold: impl FnMut(Acc, U::Item) -> R,
                ) -> impl FnMut(Acc, &mut U) -> R {
                    move |acc, iter| iter.try_fold(acc, &mut fold)
                }
        
                self.iter_try_fold(init, flatten(fold))
            }
        *)
        Definition try_fold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  "iter_try_fold",
                  [ Acc; Ty.associated; R ]
                |),
                [
                  M.read (| self |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_associated_function (| Self, "flatten.try_fold", [] |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                #[inline]
                fn flatten<U: Iterator, Acc>(
                    mut fold: impl FnMut(Acc, U::Item) -> Acc,
                ) -> impl FnMut(Acc, U) -> Acc {
                    move |acc, iter| iter.fold(acc, &mut fold)
                }
        
                self.iter_fold(init, flatten(fold))
            }
        *)
        Definition fold (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  "iter_fold",
                  [ Acc; Ty.associated ]
                |),
                [
                  M.read (| self |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_associated_function (| Self, "flatten.fold", [] |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                #[inline]
                #[rustc_inherit_overflow_checks]
                fn advance<U: Iterator>(n: usize, iter: &mut U) -> ControlFlow<(), usize> {
                    match iter.advance_by(n) {
                        Ok(()) => ControlFlow::Break(()),
                        Err(remaining) => ControlFlow::Continue(remaining.get()),
                    }
                }
        
                match self.iter_try_fold(n, advance) {
                    ControlFlow::Continue(remaining) => NonZero::new(remaining).map_or(Ok(()), Err),
                    _ => Ok(()),
                }
            }
        *)
        Definition advance_by
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                          []
                          [ I; U ],
                        "iter_try_fold",
                        [
                          Ty.path "usize";
                          Ty.function
                            [ Ty.path "usize"; Ty.apply (Ty.path "&mut") [] [ U ] ]
                            (Ty.apply
                              (Ty.path "core::ops::control_flow::ControlFlow")
                              []
                              [ Ty.tuple []; Ty.path "usize" ]);
                          Ty.apply
                            (Ty.path "core::ops::control_flow::ControlFlow")
                            []
                            [ Ty.tuple []; Ty.path "usize" ]
                        ]
                      |),
                      [
                        M.read (| self |);
                        M.read (| n |);
                        M.get_associated_function (| Self, "advance.advance_by", [] |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Continue",
                            0
                          |) in
                        let remaining := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::option::Option")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "core::num::nonzero::NonZero")
                                    []
                                    [ Ty.path "usize" ]
                                ],
                              "map_or",
                              [
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [
                                    Ty.tuple [];
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ];
                                Ty.function
                                  [
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ]
                                  (Ty.apply
                                    (Ty.path "core::result::Result")
                                    []
                                    [
                                      Ty.tuple [];
                                      Ty.apply
                                        (Ty.path "core::num::nonzero::NonZero")
                                        []
                                        [ Ty.path "usize" ]
                                    ])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "core::num::nonzero::NonZero")
                                    []
                                    [ Ty.path "usize" ],
                                  "new",
                                  []
                                |),
                                [ M.read (| remaining |) ]
                              |);
                              Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ];
                              M.constructor_as_closure "core::result::Result::Err"
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn count(self) -> usize {
                #[inline]
                #[rustc_inherit_overflow_checks]
                fn count<U: Iterator>(acc: usize, iter: U) -> usize {
                    acc + iter.count()
                }
        
                self.iter_fold(0, count)
            }
        *)
        Definition count (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  "iter_fold",
                  [ Ty.path "usize"; Ty.function [ Ty.path "usize"; U ] (Ty.path "usize") ]
                |),
                [
                  M.read (| self |);
                  Value.Integer IntegerKind.Usize 0;
                  M.get_associated_function (| Self, "count.count", [] |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn last(self) -> Option<Self::Item> {
                #[inline]
                fn last<U: Iterator>(last: Option<U::Item>, iter: U) -> Option<U::Item> {
                    iter.last().or(last)
                }
        
                self.iter_fold(None, last)
            }
        *)
        Definition last (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  "iter_fold",
                  [
                    Ty.apply (Ty.path "core::option::Option") [] [ Ty.associated ];
                    Ty.function
                      [ Ty.apply (Ty.path "core::option::Option") [] [ Ty.associated ]; U ]
                      (Ty.apply (Ty.path "core::option::Option") [] [ Ty.associated ])
                  ]
                |),
                [
                  M.read (| self |);
                  Value.StructTuple "core::option::Option::None" [];
                  M.get_associated_function (| Self, "last.last", [] |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item I U));
              ("next", InstanceField.Method (next I U));
              ("size_hint", InstanceField.Method (size_hint I U));
              ("try_fold", InstanceField.Method (try_fold I U));
              ("fold", InstanceField.Method (fold I U));
              ("advance_by", InstanceField.Method (advance_by I U));
              ("count", InstanceField.Method (count I U));
              ("last", InstanceField.Method (last I U))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_iterator_Iterator_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_iter_traits_double_ended_DoubleEndedIterator_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ].
        
        (*
            default fn next_back(&mut self) -> Option<U::Item> {
                loop {
                    if let elt @ Some(_) = and_then_or_clear(&mut self.backiter, |b| b.next_back()) {
                        return elt;
                    }
                    match self.iter.next_back() {
                        None => return and_then_or_clear(&mut self.frontiter, |f| f.next_back()),
                        Some(inner) => self.backiter = Some(inner.into_iter()),
                    }
                }
            }
        *)
        Definition next_back
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.never_to_any (|
                    M.read (|
                      M.loop (|
                        ltac:(M.monadic
                          (let~ _ :=
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_function (|
                                            "core::iter::adapters::flatten::and_then_or_clear",
                                            [
                                              U;
                                              Ty.associated;
                                              Ty.function
                                                [ Ty.tuple [ Ty.apply (Ty.path "&mut") [] [ U ] ] ]
                                                (Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  []
                                                  [ Ty.associated ])
                                            ]
                                          |),
                                          [
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "core::iter::adapters::flatten::FlattenCompat",
                                              "backiter"
                                            |);
                                            M.closure
                                              (fun γ =>
                                                ltac:(M.monadic
                                                  match γ with
                                                  | [ α0 ] =>
                                                    ltac:(M.monadic
                                                      (M.match_operator (|
                                                        M.alloc (| α0 |),
                                                        [
                                                          fun γ =>
                                                            ltac:(M.monadic
                                                              (let b := M.copy (| γ |) in
                                                              M.call_closure (|
                                                                M.get_trait_method (|
                                                                  "core::iter::traits::double_ended::DoubleEndedIterator",
                                                                  U,
                                                                  [],
                                                                  "next_back",
                                                                  []
                                                                |),
                                                                [ M.read (| b |) ]
                                                              |)))
                                                        ]
                                                      |)))
                                                  | _ => M.impossible "wrong number of arguments"
                                                  end))
                                          ]
                                        |)
                                      |) in
                                    let elt := M.copy (| γ |) in
                                    let γ1_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::option::Option::Some",
                                        0
                                      |) in
                                    M.alloc (|
                                      M.never_to_any (|
                                        M.read (| M.return_ (| M.read (| elt |) |) |)
                                      |)
                                    |)));
                                fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                              ]
                            |) in
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::double_ended::DoubleEndedIterator",
                                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                                  [],
                                  "next_back",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "iter"
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let _ :=
                                    M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_function (|
                                              "core::iter::adapters::flatten::and_then_or_clear",
                                              [
                                                U;
                                                Ty.associated;
                                                Ty.function
                                                  [ Ty.tuple [ Ty.apply (Ty.path "&mut") [] [ U ] ]
                                                  ]
                                                  (Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [ Ty.associated ])
                                              ]
                                            |),
                                            [
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "core::iter::adapters::flatten::FlattenCompat",
                                                "frontiter"
                                              |);
                                              M.closure
                                                (fun γ =>
                                                  ltac:(M.monadic
                                                    match γ with
                                                    | [ α0 ] =>
                                                      ltac:(M.monadic
                                                        (M.match_operator (|
                                                          M.alloc (| α0 |),
                                                          [
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let f := M.copy (| γ |) in
                                                                M.call_closure (|
                                                                  M.get_trait_method (|
                                                                    "core::iter::traits::double_ended::DoubleEndedIterator",
                                                                    U,
                                                                    [],
                                                                    "next_back",
                                                                    []
                                                                  |),
                                                                  [ M.read (| f |) ]
                                                                |)))
                                                          ]
                                                        |)))
                                                    | _ => M.impossible "wrong number of arguments"
                                                    end))
                                            ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::option::Option::Some",
                                      0
                                    |) in
                                  let inner := M.copy (| γ0_0 |) in
                                  M.write (|
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "core::iter::adapters::flatten::FlattenCompat",
                                      "backiter"
                                    |),
                                    Value.StructTuple
                                      "core::option::Option::Some"
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::iter::traits::collect::IntoIterator",
                                            Ty.associated,
                                            [],
                                            "into_iter",
                                            []
                                          |),
                                          [ M.read (| inner |) ]
                                        |)
                                      ]
                                  |)))
                            ]
                          |)))
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                #[inline]
                fn flatten<U: DoubleEndedIterator, Acc, R: Try<Output = Acc>>(
                    mut fold: impl FnMut(Acc, U::Item) -> R,
                ) -> impl FnMut(Acc, &mut U) -> R {
                    move |acc, iter| iter.try_rfold(acc, &mut fold)
                }
        
                self.iter_try_rfold(init, flatten(fold))
            }
        *)
        Definition try_rfold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  "iter_try_rfold",
                  [ Acc; Ty.associated; R ]
                |),
                [
                  M.read (| self |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_associated_function (| Self, "flatten.try_rfold", [] |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                #[inline]
                fn flatten<U: DoubleEndedIterator, Acc>(
                    mut fold: impl FnMut(Acc, U::Item) -> Acc,
                ) -> impl FnMut(Acc, U) -> Acc {
                    move |acc, iter| iter.rfold(acc, &mut fold)
                }
        
                self.iter_rfold(init, flatten(fold))
            }
        *)
        Definition rfold (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ],
                  "iter_rfold",
                  [ Acc; Ty.associated ]
                |),
                [
                  M.read (| self |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_associated_function (| Self, "flatten.rfold", [] |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            default fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                #[inline]
                #[rustc_inherit_overflow_checks]
                fn advance<U: DoubleEndedIterator>(n: usize, iter: &mut U) -> ControlFlow<(), usize> {
                    match iter.advance_back_by(n) {
                        Ok(()) => ControlFlow::Break(()),
                        Err(remaining) => ControlFlow::Continue(remaining.get()),
                    }
                }
        
                match self.iter_try_rfold(n, advance) {
                    ControlFlow::Continue(remaining) => NonZero::new(remaining).map_or(Ok(()), Err),
                    _ => Ok(()),
                }
            }
        *)
        Definition advance_back_by
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::iter::adapters::flatten::FlattenCompat")
                          []
                          [ I; U ],
                        "iter_try_rfold",
                        [
                          Ty.path "usize";
                          Ty.function
                            [ Ty.path "usize"; Ty.apply (Ty.path "&mut") [] [ U ] ]
                            (Ty.apply
                              (Ty.path "core::ops::control_flow::ControlFlow")
                              []
                              [ Ty.tuple []; Ty.path "usize" ]);
                          Ty.apply
                            (Ty.path "core::ops::control_flow::ControlFlow")
                            []
                            [ Ty.tuple []; Ty.path "usize" ]
                        ]
                      |),
                      [
                        M.read (| self |);
                        M.read (| n |);
                        M.get_associated_function (| Self, "advance.advance_back_by", [] |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Continue",
                            0
                          |) in
                        let remaining := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::option::Option")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "core::num::nonzero::NonZero")
                                    []
                                    [ Ty.path "usize" ]
                                ],
                              "map_or",
                              [
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [
                                    Ty.tuple [];
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ];
                                Ty.function
                                  [
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ]
                                  (Ty.apply
                                    (Ty.path "core::result::Result")
                                    []
                                    [
                                      Ty.tuple [];
                                      Ty.apply
                                        (Ty.path "core::num::nonzero::NonZero")
                                        []
                                        [ Ty.path "usize" ]
                                    ])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "core::num::nonzero::NonZero")
                                    []
                                    [ Ty.path "usize" ],
                                  "new",
                                  []
                                |),
                                [ M.read (| remaining |) ]
                              |);
                              Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ];
                              M.constructor_as_closure "core::result::Result::Err"
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("next_back", InstanceField.Method (next_back I U));
              ("try_rfold", InstanceField.Method (try_rfold I U));
              ("rfold", InstanceField.Method (rfold I U));
              ("advance_back_by", InstanceField.Method (advance_back_by I U))
            ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_iter_traits_double_ended_DoubleEndedIterator_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
      
      Module Impl_core_iter_traits_marker_TrustedLen_where_core_iter_traits_marker_TrustedLen_I_for_core_iter_adapters_flatten_FlattenCompat_I_associated_type.
        Definition Self (N : Value.t) (I T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; Ty.associated ].
        
        Axiom Implements :
          forall (N : Value.t) (I T : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::TrustedLen"
            (Self N I T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
        Axiom Implements :
          forall (N : Value.t) (I T : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::TrustedLen"
            (Self N I T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
        Axiom Implements :
          forall (N : Value.t) (I T : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::TrustedLen"
            (Self N I T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_TrustedLen_where_core_iter_traits_marker_TrustedLen_I_for_core_iter_adapters_flatten_FlattenCompat_I_associated_type.
      
      
      
      (* Trait *)
      (* Empty module 'ConstSizeIntoIterator' *)
      
      Module Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_where_core_iter_traits_collect_IntoIterator_T_for_T.
        Definition Self (T : Ty.t) : Ty.t := T.
        
        (*
            default fn size() -> Option<usize> {
                None
            }
        *)
        Definition size (T : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self T in
          match ε, τ, α with
          | [], [], [] => ltac:(M.monadic (Value.StructTuple "core::option::Option::None" []))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::ConstSizeIntoIterator"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("size", InstanceField.Method (size T)) ].
      End Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_where_core_iter_traits_collect_IntoIterator_T_for_T.
      
      Module Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_for_array_N_T.
        Definition Self (N : Value.t) (T : Ty.t) : Ty.t := Ty.apply (Ty.path "array") [ N ] [ T ].
        
        (*
            fn size() -> Option<usize> {
                Some(N)
            }
        *)
        Definition size
            (N : Value.t)
            (T : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self N T in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructTuple
                "core::option::Option::Some"
                [ M.read (| M.get_constant (| "core::iter::adapters::flatten::N" |) |) ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (N : Value.t) (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::ConstSizeIntoIterator"
            (Self N T)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("size", InstanceField.Method (size N T)) ].
      End Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_for_array_N_T.
      
      Module Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_for_ref__array_N_T.
        Definition Self (N : Value.t) (T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "&") [] [ Ty.apply (Ty.path "array") [ N ] [ T ] ].
        
        (*
            fn size() -> Option<usize> {
                Some(N)
            }
        *)
        Definition size
            (N : Value.t)
            (T : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self N T in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructTuple
                "core::option::Option::Some"
                [ M.read (| M.get_constant (| "core::iter::adapters::flatten::N" |) |) ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (N : Value.t) (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::ConstSizeIntoIterator"
            (Self N T)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("size", InstanceField.Method (size N T)) ].
      End Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_for_ref__array_N_T.
      
      Module Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_for_ref_mut_array_N_T.
        Definition Self (N : Value.t) (T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "&mut") [] [ Ty.apply (Ty.path "array") [ N ] [ T ] ].
        
        (*
            fn size() -> Option<usize> {
                Some(N)
            }
        *)
        Definition size
            (N : Value.t)
            (T : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self N T in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructTuple
                "core::option::Option::Some"
                [ M.read (| M.get_constant (| "core::iter::adapters::flatten::N" |) |) ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (N : Value.t) (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::ConstSizeIntoIterator"
            (Self N T)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("size", InstanceField.Method (size N T)) ].
      End Impl_core_iter_adapters_flatten_ConstSizeIntoIterator_for_ref_mut_array_N_T.
      
      (*
      fn and_then_or_clear<T, U>(opt: &mut Option<T>, f: impl FnOnce(&mut T) -> Option<U>) -> Option<U> {
          let x = f(opt.as_mut()?);
          if x.is_none() {
              *opt = None;
          }
          x
      }
      *)
      Definition and_then_or_clear (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ T; U; impl_FnOnce__mut_T__arrow_Option_U_ ], [ opt; f ] =>
          ltac:(M.monadic
            (let opt := M.alloc (| opt |) in
            let f := M.alloc (| f |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let~ x :=
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::function::FnOnce",
                          impl_FnOnce__mut_T__arrow_Option_U_,
                          [ Ty.tuple [ Ty.apply (Ty.path "&mut") [] [ T ] ] ],
                          "call_once",
                          []
                        |),
                        [
                          M.read (| f |);
                          Value.Tuple
                            [
                              M.read (|
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::try_trait::Try",
                                        Ty.apply
                                          (Ty.path "core::option::Option")
                                          []
                                          [ Ty.apply (Ty.path "&mut") [] [ T ] ],
                                        [],
                                        "branch",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply (Ty.path "core::option::Option") [] [ T ],
                                            "as_mut",
                                            []
                                          |),
                                          [ M.read (| opt |) ]
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    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::option::Option")
                                                      []
                                                      [ U ],
                                                    [
                                                      Ty.apply
                                                        (Ty.path "core::option::Option")
                                                        []
                                                        [ Ty.path "core::convert::Infallible" ]
                                                    ],
                                                    "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
                                        M.alloc (| M.read (| val |) |)))
                                  ]
                                |)
                              |)
                            ]
                        ]
                      |)
                    |) in
                  let~ _ :=
                    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 "core::option::Option") [] [ U ],
                                      "is_none",
                                      []
                                    |),
                                    [ x ]
                                  |)
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            let~ _ :=
                              M.write (|
                                M.read (| opt |),
                                Value.StructTuple "core::option::Option::None" []
                              |) in
                            M.alloc (| Value.Tuple [] |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  x
                |)))
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_and_then_or_clear :
        M.IsFunction "core::iter::adapters::flatten::and_then_or_clear" and_then_or_clear.
      
      (* Trait *)
      (* Empty module 'OneShot' *)
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_iter_sources_once_Once_T.
        Definition Self (T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::sources::once::Once") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_iter_sources_once_Once_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_iter_sources_once_with_OnceWith_F.
        Definition Self (F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::sources::once_with::OnceWith") [] [ F ].
        
        Axiom Implements :
          forall (F : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self F)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_iter_sources_once_with_OnceWith_F.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_array_iter_IntoIter_Usize_1_T.
        Definition Self (T : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "core::array::iter::IntoIter")
            [ Value.Integer IntegerKind.Usize 1 ]
            [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_array_iter_IntoIter_Usize_1_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_option_IntoIter_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::option::IntoIter") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_option_IntoIter_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_option_Iter_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::option::Iter") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_option_Iter_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_option_IterMut_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::option::IterMut") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_option_IterMut_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_result_IntoIter_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::result::IntoIter") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_result_IntoIter_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_result_Iter_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::result::Iter") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_result_Iter_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_result_IterMut_T.
        Definition Self (T : Ty.t) : Ty.t := Ty.apply (Ty.path "core::result::IterMut") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_result_IterMut_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_iter_sources_empty_Empty_T.
        Definition Self (T : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::sources::empty::Empty") [] [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_iter_sources_empty_Empty_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_for_core_array_iter_IntoIter_Usize_0_T.
        Definition Self (T : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "core::array::iter::IntoIter")
            [ Value.Integer IntegerKind.Usize 0 ]
            [ T ].
        
        Axiom Implements :
          forall (T : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self T)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_for_core_array_iter_IntoIter_Usize_0_T.
      
      Module Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_cloned_Cloned_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::cloned::Cloned") [] [ I ].
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_cloned_Cloned_I.
      
      Module Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_copied_Copied_I.
        Definition Self (I : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::copied::Copied") [] [ I ].
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_copied_Copied_I.
      
      Module Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_filter_Filter_I_P.
        Definition Self (I P : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::filter::Filter") [] [ I; P ].
        
        Axiom Implements :
          forall (I P : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self I P)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_filter_Filter_I_P.
      
      Module Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_filter_map_FilterMap_I_P.
        Definition Self (I P : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::filter_map::FilterMap") [] [ I; P ].
        
        Axiom Implements :
          forall (I P : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self I P)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_filter_map_FilterMap_I_P.
      
      Module Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_map_Map_I_F.
        Definition Self (I F : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::map::Map") [] [ I; F ].
        
        Axiom Implements :
          forall (I F : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self I F)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_core_iter_adapters_map_Map_I_F.
      
      Module Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_ref_mut_I.
        Definition Self (I : Ty.t) : Ty.t := Ty.apply (Ty.path "&mut") [] [ I ].
        
        Axiom Implements :
          forall (I : Ty.t),
          M.IsTraitInstance
            "core::iter::adapters::flatten::OneShot"
            (Self I)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_adapters_flatten_OneShot_where_core_iter_adapters_flatten_OneShot_I_for_ref_mut_I.
      
      (*
      fn into_item<I>(inner: I) -> Option<I::Item>
      where
          I: IntoIterator<IntoIter: OneShot>,
      {
          inner.into_iter().next()
      }
      *)
      Definition into_item (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ _ as I ], [ inner ] =>
          ltac:(M.monadic
            (let inner := M.alloc (| inner |) in
            M.call_closure (|
              M.get_trait_method (|
                "core::iter::traits::iterator::Iterator",
                Ty.associated,
                [],
                "next",
                []
              |),
              [
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::collect::IntoIterator",
                      I,
                      [],
                      "into_iter",
                      []
                    |),
                    [ M.read (| inner |) ]
                  |)
                |)
              ]
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_into_item : M.IsFunction "core::iter::adapters::flatten::into_item" into_item.
      
      (*
      fn flatten_one<I: IntoIterator<IntoIter: OneShot>, Acc>(
          mut fold: impl FnMut(Acc, I::Item) -> Acc,
      ) -> impl FnMut(Acc, I) -> Acc {
          move |acc, inner| match inner.into_iter().next() {
              Some(item) => fold(acc, item),
              None => acc,
          }
      }
      *)
      Definition flatten_one (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ _ as I; Acc; impl_FnMut_Acc__I_Item__arrow_Acc ], [ fold ] =>
          ltac:(M.monadic
            (let fold := M.alloc (| fold |) in
            M.closure
              (fun γ =>
                ltac:(M.monadic
                  match γ with
                  | [ α0; α1 ] =>
                    ltac:(M.monadic
                      (M.match_operator (|
                        M.alloc (| α0 |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let acc := M.copy (| γ |) in
                              M.match_operator (|
                                M.alloc (| α1 |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let inner := M.copy (| γ |) in
                                      M.read (|
                                        M.match_operator (|
                                          M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::iter::traits::iterator::Iterator",
                                                Ty.associated,
                                                [],
                                                "next",
                                                []
                                              |),
                                              [
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::iter::traits::collect::IntoIterator",
                                                      I,
                                                      [],
                                                      "into_iter",
                                                      []
                                                    |),
                                                    [ M.read (| inner |) ]
                                                  |)
                                                |)
                                              ]
                                            |)
                                          |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let γ0_0 :=
                                                  M.SubPointer.get_struct_tuple_field (|
                                                    γ,
                                                    "core::option::Option::Some",
                                                    0
                                                  |) in
                                                let item := M.copy (| γ0_0 |) in
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::function::FnMut",
                                                      impl_FnMut_Acc__I_Item__arrow_Acc,
                                                      [ Ty.tuple [ Acc; Ty.associated ] ],
                                                      "call_mut",
                                                      []
                                                    |),
                                                    [
                                                      fold;
                                                      Value.Tuple
                                                        [ M.read (| acc |); M.read (| item |) ]
                                                    ]
                                                  |)
                                                |)));
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let _ :=
                                                  M.is_struct_tuple (|
                                                    γ,
                                                    "core::option::Option::None"
                                                  |) in
                                                acc))
                                          ]
                                        |)
                                      |)))
                                ]
                              |)))
                        ]
                      |)))
                  | _ => M.impossible "wrong number of arguments"
                  end))))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_flatten_one :
        M.IsFunction "core::iter::adapters::flatten::flatten_one" flatten_one.
      
      Module flatten_one.
        (* Error OpaqueTy *)
      End flatten_one.
      
      (*
      fn try_flatten_one<I: IntoIterator<IntoIter: OneShot>, Acc, R: Try<Output = Acc>>(
          mut fold: impl FnMut(Acc, I::Item) -> R,
      ) -> impl FnMut(Acc, I) -> R {
          move |acc, inner| match inner.into_iter().next() {
              Some(item) => fold(acc, item),
              None => try { acc },
          }
      }
      *)
      Definition try_flatten_one (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ _ as I; Acc; R; impl_FnMut_Acc__I_Item__arrow_R ], [ fold ] =>
          ltac:(M.monadic
            (let fold := M.alloc (| fold |) in
            M.closure
              (fun γ =>
                ltac:(M.monadic
                  match γ with
                  | [ α0; α1 ] =>
                    ltac:(M.monadic
                      (M.match_operator (|
                        M.alloc (| α0 |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let acc := M.copy (| γ |) in
                              M.match_operator (|
                                M.alloc (| α1 |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let inner := M.copy (| γ |) in
                                      M.read (|
                                        M.match_operator (|
                                          M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::iter::traits::iterator::Iterator",
                                                Ty.associated,
                                                [],
                                                "next",
                                                []
                                              |),
                                              [
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::iter::traits::collect::IntoIterator",
                                                      I,
                                                      [],
                                                      "into_iter",
                                                      []
                                                    |),
                                                    [ M.read (| inner |) ]
                                                  |)
                                                |)
                                              ]
                                            |)
                                          |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let γ0_0 :=
                                                  M.SubPointer.get_struct_tuple_field (|
                                                    γ,
                                                    "core::option::Option::Some",
                                                    0
                                                  |) in
                                                let item := M.copy (| γ0_0 |) in
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::function::FnMut",
                                                      impl_FnMut_Acc__I_Item__arrow_R,
                                                      [ Ty.tuple [ Acc; Ty.associated ] ],
                                                      "call_mut",
                                                      []
                                                    |),
                                                    [
                                                      fold;
                                                      Value.Tuple
                                                        [ M.read (| acc |); M.read (| item |) ]
                                                    ]
                                                  |)
                                                |)));
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let _ :=
                                                  M.is_struct_tuple (|
                                                    γ,
                                                    "core::option::Option::None"
                                                  |) in
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::try_trait::Try",
                                                      R,
                                                      [],
                                                      "from_output",
                                                      []
                                                    |),
                                                    [ M.read (| acc |) ]
                                                  |)
                                                |)))
                                          ]
                                        |)
                                      |)))
                                ]
                              |)))
                        ]
                      |)))
                  | _ => M.impossible "wrong number of arguments"
                  end))))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_try_flatten_one :
        M.IsFunction "core::iter::adapters::flatten::try_flatten_one" try_flatten_one.
      
      Module try_flatten_one.
        (* Error OpaqueTy *)
      End try_flatten_one.
      
      (*
      fn advance_by_one<I>(n: NonZero<usize>, inner: I) -> Option<NonZero<usize>>
      where
          I: IntoIterator<IntoIter: OneShot>,
      {
          match inner.into_iter().next() {
              Some(_) => NonZero::new(n.get() - 1),
              None => Some(n),
          }
      }
      *)
      Definition advance_by_one (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ _ as I ], [ n; inner ] =>
          ltac:(M.monadic
            (let n := M.alloc (| n |) in
            let inner := M.alloc (| inner |) in
            M.read (|
              M.match_operator (|
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.associated,
                      [],
                      "next",
                      []
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::collect::IntoIterator",
                            I,
                            [],
                            "into_iter",
                            []
                          |),
                          [ M.read (| inner |) ]
                        |)
                      |)
                    ]
                  |)
                |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ0_0 :=
                        M.SubPointer.get_struct_tuple_field (|
                          γ,
                          "core::option::Option::Some",
                          0
                        |) in
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply (Ty.path "core::num::nonzero::NonZero") [] [ Ty.path "usize" ],
                            "new",
                            []
                          |),
                          [
                            BinOp.Wrap.sub (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "core::num::nonzero::NonZero")
                                    []
                                    [ Ty.path "usize" ],
                                  "get",
                                  []
                                |),
                                [ M.read (| n |) ]
                              |),
                              Value.Integer IntegerKind.Usize 1
                            |)
                          ]
                        |)
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                      M.alloc (|
                        Value.StructTuple "core::option::Option::Some" [ M.read (| n |) ]
                      |)))
                ]
              |)
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_advance_by_one :
        M.IsFunction "core::iter::adapters::flatten::advance_by_one" advance_by_one.
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_iterator_Iterator_U_where_core_iter_adapters_flatten_OneShot_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ].
        
        (*
            fn next(&mut self) -> Option<U::Item> {
                while let Some(inner) = self.iter.next() {
                    if let item @ Some(_) = inner.into_iter().next() {
                        return item;
                    }
                }
                None
            }
        *)
        Definition next (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.loop (|
                        ltac:(M.monadic
                          (M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::iter::traits::iterator::Iterator",
                                          Ty.apply
                                            (Ty.path "core::iter::adapters::fuse::Fuse")
                                            []
                                            [ I ],
                                          [],
                                          "next",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "core::iter::adapters::flatten::FlattenCompat",
                                            "iter"
                                          |)
                                        ]
                                      |)
                                    |) in
                                  let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::option::Option::Some",
                                      0
                                    |) in
                                  let inner := M.copy (| γ0_0 |) in
                                  M.match_operator (|
                                    M.alloc (| Value.Tuple [] |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ :=
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::iter::traits::iterator::Iterator",
                                                  U,
                                                  [],
                                                  "next",
                                                  []
                                                |),
                                                [
                                                  M.alloc (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::iter::traits::collect::IntoIterator",
                                                        Ty.associated,
                                                        [],
                                                        "into_iter",
                                                        []
                                                      |),
                                                      [ M.read (| inner |) ]
                                                    |)
                                                  |)
                                                ]
                                              |)
                                            |) in
                                          let item := M.copy (| γ |) in
                                          let γ1_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::option::Option::Some",
                                              0
                                            |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (| M.return_ (| M.read (| item |) |) |)
                                            |)
                                          |)));
                                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        let~ _ :=
                                          M.alloc (|
                                            M.never_to_any (| M.read (| M.break (||) |) |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)
                                      |)
                                    |)
                                  |)))
                            ]
                          |)))
                      |) in
                    M.alloc (| Value.StructTuple "core::option::Option::None" [] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                let (lower, upper) = self.iter.size_hint();
                match <I::Item as ConstSizeIntoIterator>::size() {
                    Some(0) => (0, Some(0)),
                    Some(1) => (lower, upper),
                    _ => (0, upper),
                }
            }
        *)
        Definition size_hint
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::iterator::Iterator",
                        Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                        [],
                        "size_hint",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "core::iter::adapters::flatten::FlattenCompat",
                          "iter"
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                        let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                        let lower := M.copy (| γ0_0 |) in
                        let upper := M.copy (| γ0_1 |) in
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::iter::adapters::flatten::ConstSizeIntoIterator",
                                Ty.associated,
                                [],
                                "size",
                                []
                              |),
                              []
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ0_0 |),
                                    Value.Integer IntegerKind.Usize 0
                                  |) in
                                M.alloc (|
                                  Value.Tuple
                                    [
                                      Value.Integer IntegerKind.Usize 0;
                                      Value.StructTuple
                                        "core::option::Option::Some"
                                        [ Value.Integer IntegerKind.Usize 0 ]
                                    ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ0_0 |),
                                    Value.Integer IntegerKind.Usize 1
                                  |) in
                                M.alloc (|
                                  Value.Tuple [ M.read (| lower |); M.read (| upper |) ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (M.alloc (|
                                  Value.Tuple
                                    [ Value.Integer IntegerKind.Usize 0; M.read (| upper |) ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                self.iter.try_fold(init, try_flatten_one(fold))
            }
        *)
        Definition try_fold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                  [],
                  "try_fold",
                  [ Acc; Ty.associated; R ]
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlattenCompat",
                    "iter"
                  |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_function (|
                      "core::iter::adapters::flatten::try_flatten_one",
                      [ Ty.associated; Acc; R; Fold ]
                    |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                self.iter.fold(init, flatten_one(fold))
            }
        *)
        Definition fold (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                  [],
                  "fold",
                  [ Acc; Ty.associated ]
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::FlattenCompat",
                      "iter"
                    |)
                  |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_function (|
                      "core::iter::adapters::flatten::flatten_one",
                      [ Ty.associated; Acc; Fold ]
                    |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                if let Some(n) = NonZero::new(n) {
                    self.iter.try_fold(n, advance_by_one).map_or(Ok(()), Err)
                } else {
                    // Just advance the outer iterator
                    self.iter.advance_by(0)
                }
            }
        *)
        Definition advance_by
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::num::nonzero::NonZero")
                                  []
                                  [ Ty.path "usize" ],
                                "new",
                                []
                              |),
                              [ M.read (| n |) ]
                            |)
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let n := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::option::Option")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "core::num::nonzero::NonZero")
                                    []
                                    [ Ty.path "usize" ]
                                ],
                              "map_or",
                              [
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [
                                    Ty.tuple [];
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ];
                                Ty.function
                                  [
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ]
                                  (Ty.apply
                                    (Ty.path "core::result::Result")
                                    []
                                    [
                                      Ty.tuple [];
                                      Ty.apply
                                        (Ty.path "core::num::nonzero::NonZero")
                                        []
                                        [ Ty.path "usize" ]
                                    ])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::iterator::Iterator",
                                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                                  [],
                                  "try_fold",
                                  [
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ];
                                    Ty.function
                                      [
                                        Ty.apply
                                          (Ty.path "core::num::nonzero::NonZero")
                                          []
                                          [ Ty.path "usize" ];
                                        Ty.associated
                                      ]
                                      (Ty.apply
                                        (Ty.path "core::option::Option")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "core::num::nonzero::NonZero")
                                            []
                                            [ Ty.path "usize" ]
                                        ]);
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "core::num::nonzero::NonZero")
                                          []
                                          [ Ty.path "usize" ]
                                      ]
                                  ]
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "iter"
                                  |);
                                  M.read (| n |);
                                  M.get_function (|
                                    "core::iter::adapters::flatten::advance_by_one",
                                    [ Ty.associated ]
                                  |)
                                ]
                              |);
                              Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ];
                              M.constructor_as_closure "core::result::Result::Err"
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::iter::traits::iterator::Iterator",
                              Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                              [],
                              "advance_by",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "core::iter::adapters::flatten::FlattenCompat",
                                "iter"
                              |);
                              Value.Integer IntegerKind.Usize 0
                            ]
                          |)
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn count(self) -> usize {
                self.iter.filter_map(into_item).count()
            }
        *)
        Definition count (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::filter_map::FilterMap")
                    []
                    [
                      Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ];
                      Ty.function
                        [ Ty.associated ]
                        (Ty.apply (Ty.path "core::option::Option") [] [ Ty.associated ])
                    ],
                  [],
                  "count",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                      [],
                      "filter_map",
                      [
                        Ty.associated;
                        Ty.function
                          [ Ty.associated ]
                          (Ty.apply (Ty.path "core::option::Option") [] [ Ty.associated ])
                      ]
                    |),
                    [
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "core::iter::adapters::flatten::FlattenCompat",
                          "iter"
                        |)
                      |);
                      M.get_function (|
                        "core::iter::adapters::flatten::into_item",
                        [ Ty.associated ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(self) -> Option<Self::Item> {
                self.iter.filter_map(into_item).last()
            }
        *)
        Definition last (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::filter_map::FilterMap")
                    []
                    [
                      Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ];
                      Ty.function
                        [ Ty.associated ]
                        (Ty.apply (Ty.path "core::option::Option") [] [ Ty.associated ])
                    ],
                  [],
                  "last",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                      [],
                      "filter_map",
                      [
                        Ty.associated;
                        Ty.function
                          [ Ty.associated ]
                          (Ty.apply (Ty.path "core::option::Option") [] [ Ty.associated ])
                      ]
                    |),
                    [
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          self,
                          "core::iter::adapters::flatten::FlattenCompat",
                          "iter"
                        |)
                      |);
                      M.get_function (|
                        "core::iter::adapters::flatten::into_item",
                        [ Ty.associated ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("next", InstanceField.Method (next I U));
              ("size_hint", InstanceField.Method (size_hint I U));
              ("try_fold", InstanceField.Method (try_fold I U));
              ("fold", InstanceField.Method (fold I U));
              ("advance_by", InstanceField.Method (advance_by I U));
              ("count", InstanceField.Method (count I U));
              ("last", InstanceField.Method (last I U))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_iter_traits_iterator_Iterator_I_where_core_iter_traits_iterator_Iterator_U_where_core_iter_adapters_flatten_OneShot_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_iter_traits_double_ended_DoubleEndedIterator_U_where_core_iter_adapters_flatten_OneShot_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
        Definition Self (I U : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "core::iter::adapters::flatten::FlattenCompat") [] [ I; U ].
        
        (*
            fn next_back(&mut self) -> Option<U::Item> {
                while let Some(inner) = self.iter.next_back() {
                    if let item @ Some(_) = inner.into_iter().next() {
                        return item;
                    }
                }
                None
            }
        *)
        Definition next_back
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.loop (|
                        ltac:(M.monadic
                          (M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::iter::traits::double_ended::DoubleEndedIterator",
                                          Ty.apply
                                            (Ty.path "core::iter::adapters::fuse::Fuse")
                                            []
                                            [ I ],
                                          [],
                                          "next_back",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "core::iter::adapters::flatten::FlattenCompat",
                                            "iter"
                                          |)
                                        ]
                                      |)
                                    |) in
                                  let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::option::Option::Some",
                                      0
                                    |) in
                                  let inner := M.copy (| γ0_0 |) in
                                  M.match_operator (|
                                    M.alloc (| Value.Tuple [] |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let γ :=
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::iter::traits::iterator::Iterator",
                                                  U,
                                                  [],
                                                  "next",
                                                  []
                                                |),
                                                [
                                                  M.alloc (|
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::iter::traits::collect::IntoIterator",
                                                        Ty.associated,
                                                        [],
                                                        "into_iter",
                                                        []
                                                      |),
                                                      [ M.read (| inner |) ]
                                                    |)
                                                  |)
                                                ]
                                              |)
                                            |) in
                                          let item := M.copy (| γ |) in
                                          let γ1_0 :=
                                            M.SubPointer.get_struct_tuple_field (|
                                              γ,
                                              "core::option::Option::Some",
                                              0
                                            |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.read (| M.return_ (| M.read (| item |) |) |)
                                            |)
                                          |)));
                                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        let~ _ :=
                                          M.alloc (|
                                            M.never_to_any (| M.read (| M.break (||) |) |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)
                                      |)
                                    |)
                                  |)))
                            ]
                          |)))
                      |) in
                    M.alloc (| Value.StructTuple "core::option::Option::None" [] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
            where
                Self: Sized,
                Fold: FnMut(Acc, Self::Item) -> R,
                R: Try<Output = Acc>,
            {
                self.iter.try_rfold(init, try_flatten_one(fold))
            }
        *)
        Definition try_rfold
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold; R ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                  [],
                  "try_rfold",
                  [ Acc; Ty.associated; R ]
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "core::iter::adapters::flatten::FlattenCompat",
                    "iter"
                  |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_function (|
                      "core::iter::adapters::flatten::try_flatten_one",
                      [ Ty.associated; Acc; R; Fold ]
                    |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
            where
                Fold: FnMut(Acc, Self::Item) -> Acc,
            {
                self.iter.rfold(init, flatten_one(fold))
            }
        *)
        Definition rfold (I U : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [ Acc; Fold ], [ self; init; fold ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let init := M.alloc (| init |) in
              let fold := M.alloc (| fold |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                  [],
                  "rfold",
                  [ Acc; Ty.associated ]
                |),
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      self,
                      "core::iter::adapters::flatten::FlattenCompat",
                      "iter"
                    |)
                  |);
                  M.read (| init |);
                  M.call_closure (|
                    M.get_function (|
                      "core::iter::adapters::flatten::flatten_one",
                      [ Ty.associated; Acc; Fold ]
                    |),
                    [ M.read (| fold |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
                if let Some(n) = NonZero::new(n) {
                    self.iter.try_rfold(n, advance_by_one).map_or(Ok(()), Err)
                } else {
                    // Just advance the outer iterator
                    self.iter.advance_back_by(0)
                }
            }
        *)
        Definition advance_back_by
            (I U : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self I U in
          match ε, τ, α with
          | [], [], [ self; n ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let n := M.alloc (| n |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::num::nonzero::NonZero")
                                  []
                                  [ Ty.path "usize" ],
                                "new",
                                []
                              |),
                              [ M.read (| n |) ]
                            |)
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let n := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::option::Option")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "core::num::nonzero::NonZero")
                                    []
                                    [ Ty.path "usize" ]
                                ],
                              "map_or",
                              [
                                Ty.apply
                                  (Ty.path "core::result::Result")
                                  []
                                  [
                                    Ty.tuple [];
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ];
                                Ty.function
                                  [
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ]
                                  ]
                                  (Ty.apply
                                    (Ty.path "core::result::Result")
                                    []
                                    [
                                      Ty.tuple [];
                                      Ty.apply
                                        (Ty.path "core::num::nonzero::NonZero")
                                        []
                                        [ Ty.path "usize" ]
                                    ])
                              ]
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::double_ended::DoubleEndedIterator",
                                  Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                                  [],
                                  "try_rfold",
                                  [
                                    Ty.apply
                                      (Ty.path "core::num::nonzero::NonZero")
                                      []
                                      [ Ty.path "usize" ];
                                    Ty.function
                                      [
                                        Ty.apply
                                          (Ty.path "core::num::nonzero::NonZero")
                                          []
                                          [ Ty.path "usize" ];
                                        Ty.associated
                                      ]
                                      (Ty.apply
                                        (Ty.path "core::option::Option")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "core::num::nonzero::NonZero")
                                            []
                                            [ Ty.path "usize" ]
                                        ]);
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "core::num::nonzero::NonZero")
                                          []
                                          [ Ty.path "usize" ]
                                      ]
                                  ]
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "core::iter::adapters::flatten::FlattenCompat",
                                    "iter"
                                  |);
                                  M.read (| n |);
                                  M.get_function (|
                                    "core::iter::adapters::flatten::advance_by_one",
                                    [ Ty.associated ]
                                  |)
                                ]
                              |);
                              Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ];
                              M.constructor_as_closure "core::result::Result::Err"
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::iter::traits::double_ended::DoubleEndedIterator",
                              Ty.apply (Ty.path "core::iter::adapters::fuse::Fuse") [] [ I ],
                              [],
                              "advance_back_by",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "core::iter::adapters::flatten::FlattenCompat",
                                "iter"
                              |);
                              Value.Integer IntegerKind.Usize 0
                            ]
                          |)
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (I U : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self I U)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("next_back", InstanceField.Method (next_back I U));
              ("try_rfold", InstanceField.Method (try_rfold I U));
              ("rfold", InstanceField.Method (rfold I U));
              ("advance_back_by", InstanceField.Method (advance_back_by I U))
            ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_iter_traits_double_ended_DoubleEndedIterator_I_where_core_iter_traits_double_ended_DoubleEndedIterator_U_where_core_iter_adapters_flatten_OneShot_U_for_core_iter_adapters_flatten_FlattenCompat_I_U.
    End flatten.
  End adapters.
End iter.
