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

Module control_flow_v5.
  (*
  pub fn verify(
      verifier_config: &VerifierConfig,
      current_function_opt: Option<FunctionDefinitionIndex>,
      code: &CodeUnit,
  ) -> PartialVMResult<()> {
      let current_function = current_function_opt.unwrap_or(FunctionDefinitionIndex(0));
  
      // check fallthrough
      verify_fallthrough(current_function, &code.code)?;
  
      // check jumps
      let context = &ControlFlowVerifier {
          current_function,
          code: &code.code,
      };
      let labels = instruction_labels(context);
      check_jumps(verifier_config, context, labels)
  }
  *)
  Definition verify (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ verifier_config; current_function_opt; code ] =>
      ltac:(M.monadic
        (let verifier_config := M.alloc (| verifier_config |) in
        let current_function_opt := M.alloc (| current_function_opt |) in
        let code := M.alloc (| code |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ current_function :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply
                        (Ty.path "core::option::Option")
                        []
                        [ Ty.path "move_binary_format::file_format::FunctionDefinitionIndex" ],
                      "unwrap_or",
                      []
                    |),
                    [
                      M.read (| current_function_opt |);
                      Value.StructTuple
                        "move_binary_format::file_format::FunctionDefinitionIndex"
                        [ Value.Integer IntegerKind.U16 0 ]
                    ]
                  |)
                |) in
              let~ _ :=
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::try_trait::Try",
                        Ty.apply
                          (Ty.path "core::result::Result")
                          []
                          [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ],
                        [],
                        "branch",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_function (|
                            "move_bytecode_verifier::control_flow_v5::verify_fallthrough",
                            []
                          |),
                          [
                            M.read (| current_function |);
                            M.SubPointer.get_struct_record_field (|
                              M.read (| code |),
                              "move_binary_format::file_format::CodeUnit",
                              "code"
                            |)
                          ]
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Break",
                            0
                          |) in
                        let residual := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::FromResidual",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      []
                                      [
                                        Ty.tuple [];
                                        Ty.path "move_binary_format::errors::PartialVMError"
                                      ],
                                    [
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        []
                                        [
                                          Ty.path "core::convert::Infallible";
                                          Ty.path "move_binary_format::errors::PartialVMError"
                                        ]
                                    ],
                                    "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~ context :=
                M.alloc (|
                  M.alloc (|
                    Value.StructRecord
                      "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier"
                      [
                        ("current_function", M.read (| current_function |));
                        ("code",
                          M.SubPointer.get_struct_record_field (|
                            M.read (| code |),
                            "move_binary_format::file_format::CodeUnit",
                            "code"
                          |))
                      ]
                  |)
                |) in
              let~ labels :=
                M.alloc (|
                  M.call_closure (|
                    M.get_function (|
                      "move_bytecode_verifier::control_flow_v5::instruction_labels",
                      []
                    |),
                    [ M.read (| context |) ]
                  |)
                |) in
              M.alloc (|
                M.call_closure (|
                  M.get_function (| "move_bytecode_verifier::control_flow_v5::check_jumps", [] |),
                  [ M.read (| verifier_config |); M.read (| context |); M.read (| labels |) ]
                |)
              |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_verify : M.IsFunction "move_bytecode_verifier::control_flow_v5::verify" verify.
  
  (*
  fn verify_fallthrough(
      current_function: FunctionDefinitionIndex,
      code: &Vec<Bytecode>,
  ) -> PartialVMResult<()> {
      // Check to make sure that the bytecode vector ends with a branching instruction.
      match code.last() {
          None => Err(PartialVMError::new(StatusCode::EMPTY_CODE_UNIT)),
          Some(last) if !last.is_unconditional_branch() => {
              Err(PartialVMError::new(StatusCode::INVALID_FALL_THROUGH)
                  .at_code_offset(current_function, (code.len() - 1) as CodeOffset))
          }
          Some(_) => Ok(()),
      }
  }
  *)
  Definition verify_fallthrough (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ current_function; code ] =>
      ltac:(M.monadic
        (let current_function := M.alloc (| current_function |) in
        let code := M.alloc (| code |) in
        M.read (|
          M.match_operator (|
            M.alloc (|
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "slice")
                    []
                    [ Ty.path "move_binary_format::file_format::Bytecode" ],
                  "last",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::ops::deref::Deref",
                      Ty.apply
                        (Ty.path "alloc::vec::Vec")
                        []
                        [
                          Ty.path "move_binary_format::file_format::Bytecode";
                          Ty.path "alloc::alloc::Global"
                        ],
                      [],
                      "deref",
                      []
                    |),
                    [ M.read (| code |) ]
                  |)
                ]
              |)
            |),
            [
              fun γ =>
                ltac:(M.monadic
                  (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::result::Result::Err"
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "move_binary_format::errors::PartialVMError",
                            "new",
                            []
                          |),
                          [
                            Value.StructTuple
                              "move_core_types::vm_status::StatusCode::EMPTY_CODE_UNIT"
                              []
                          ]
                        |)
                      ]
                  |)));
              fun γ =>
                ltac:(M.monadic
                  (let γ0_0 :=
                    M.SubPointer.get_struct_tuple_field (| γ, "core::option::Option::Some", 0 |) in
                  let last := M.copy (| γ0_0 |) in
                  let γ :=
                    M.alloc (|
                      UnOp.not (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "move_binary_format::file_format::Bytecode",
                            "is_unconditional_branch",
                            []
                          |),
                          [ M.read (| last |) ]
                        |)
                      |)
                    |) in
                  let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::result::Result::Err"
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "move_binary_format::errors::PartialVMError",
                            "at_code_offset",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "move_binary_format::errors::PartialVMError",
                                "new",
                                []
                              |),
                              [
                                Value.StructTuple
                                  "move_core_types::vm_status::StatusCode::INVALID_FALL_THROUGH"
                                  []
                              ]
                            |);
                            M.read (| current_function |);
                            M.rust_cast
                              (BinOp.Wrap.sub (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::vec::Vec")
                                      []
                                      [
                                        Ty.path "move_binary_format::file_format::Bytecode";
                                        Ty.path "alloc::alloc::Global"
                                      ],
                                    "len",
                                    []
                                  |),
                                  [ M.read (| code |) ]
                                |),
                                Value.Integer IntegerKind.Usize 1
                              |))
                          ]
                        |)
                      ]
                  |)));
              fun γ =>
                ltac:(M.monadic
                  (let γ0_0 :=
                    M.SubPointer.get_struct_tuple_field (| γ, "core::option::Option::Some", 0 |) in
                  M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)))
            ]
          |)
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_verify_fallthrough :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::verify_fallthrough" verify_fallthrough.
  
  (*
  Enum Label
  {
    const_params := [];
    ty_params := [];
    variants :=
      [
        {
          name := "Loop";
          item := StructRecord [ ("last_continue", Ty.path "u16") ];
          discriminant := None;
        };
        {
          name := "Code";
          item := StructTuple [];
          discriminant := None;
        }
      ];
  }
  *)
  
  Module Impl_core_clone_Clone_for_move_bytecode_verifier_control_flow_v5_Label.
    Definition Self : Ty.t := Ty.path "move_bytecode_verifier::control_flow_v5::Label".
    
    (* Clone *)
    Definition clone (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.read (|
            M.match_operator (|
              Value.DeclaredButUndefined,
              [ fun γ => ltac:(M.monadic (M.read (| self |))) ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::clone::Clone"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("clone", InstanceField.Method clone) ].
  End Impl_core_clone_Clone_for_move_bytecode_verifier_control_flow_v5_Label.
  
  Module Impl_core_marker_Copy_for_move_bytecode_verifier_control_flow_v5_Label.
    Definition Self : Ty.t := Ty.path "move_bytecode_verifier::control_flow_v5::Label".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::Copy"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_Copy_for_move_bytecode_verifier_control_flow_v5_Label.
  
  (* StructRecord
    {
      name := "ControlFlowVerifier";
      const_params := [];
      ty_params := [];
      fields :=
        [
          ("current_function", Ty.path "move_binary_format::file_format::FunctionDefinitionIndex");
          ("code",
            Ty.apply
              (Ty.path "&")
              []
              [
                Ty.apply
                  (Ty.path "alloc::vec::Vec")
                  []
                  [
                    Ty.path "move_binary_format::file_format::Bytecode";
                    Ty.path "alloc::alloc::Global"
                  ]
              ])
        ];
    } *)
  
  Module Impl_move_bytecode_verifier_control_flow_v5_ControlFlowVerifier.
    Definition Self : Ty.t :=
      Ty.path "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier".
    
    (*
        fn code(&self) -> impl Iterator<Item = (CodeOffset, &'a Bytecode)> {
            self.code
                .iter()
                .enumerate()
                .map(|(idx, instr)| (idx.try_into().unwrap(), instr))
        }
    *)
    Definition code (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      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::enumerate::Enumerate")
                []
                [
                  Ty.apply
                    (Ty.path "core::slice::iter::Iter")
                    []
                    [ Ty.path "move_binary_format::file_format::Bytecode" ]
                ],
              [],
              "map",
              [
                Ty.tuple
                  [
                    Ty.path "u16";
                    Ty.apply
                      (Ty.path "&")
                      []
                      [ Ty.path "move_binary_format::file_format::Bytecode" ]
                  ];
                Ty.function
                  [
                    Ty.tuple
                      [
                        Ty.tuple
                          [
                            Ty.path "usize";
                            Ty.apply
                              (Ty.path "&")
                              []
                              [ Ty.path "move_binary_format::file_format::Bytecode" ]
                          ]
                      ]
                  ]
                  (Ty.tuple
                    [
                      Ty.path "u16";
                      Ty.apply
                        (Ty.path "&")
                        []
                        [ Ty.path "move_binary_format::file_format::Bytecode" ]
                    ])
              ]
            |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::slice::iter::Iter")
                    []
                    [ Ty.path "move_binary_format::file_format::Bytecode" ],
                  [],
                  "enumerate",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply
                        (Ty.path "slice")
                        []
                        [ Ty.path "move_binary_format::file_format::Bytecode" ],
                      "iter",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::deref::Deref",
                          Ty.apply
                            (Ty.path "alloc::vec::Vec")
                            []
                            [
                              Ty.path "move_binary_format::file_format::Bytecode";
                              Ty.path "alloc::alloc::Global"
                            ],
                          [],
                          "deref",
                          []
                        |),
                        [
                          M.read (|
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                              "code"
                            |)
                          |)
                        ]
                      |)
                    ]
                  |)
                ]
              |);
              M.closure
                (fun γ =>
                  ltac:(M.monadic
                    match γ with
                    | [ α0 ] =>
                      ltac:(M.monadic
                        (M.match_operator (|
                          M.alloc (| α0 |),
                          [
                            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 idx := M.copy (| γ0_0 |) in
                                let instr := M.copy (| γ0_1 |) in
                                Value.Tuple
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.path "u16";
                                            Ty.path "core::num::error::TryFromIntError"
                                          ],
                                        "unwrap",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::convert::TryInto",
                                            Ty.path "usize",
                                            [ Ty.path "u16" ],
                                            "try_into",
                                            []
                                          |),
                                          [ M.read (| idx |) ]
                                        |)
                                      ]
                                    |);
                                    M.read (| instr |)
                                  ]))
                          ]
                        |)))
                    | _ => M.impossible "wrong number of arguments"
                    end))
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_code : M.IsAssociatedFunction Self "code" code.
    
    (*
        fn labeled_code<'b: 'a>(
            &self,
            labels: &'b [Label],
        ) -> impl Iterator<Item = (CodeOffset, &'a Bytecode, &'b Label)> {
            self.code()
                .zip(labels)
                .map(|((i, instr), lbl)| (i, instr, lbl))
        }
    *)
    Definition labeled_code (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self; labels ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let labels := M.alloc (| labels |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::iter::traits::iterator::Iterator",
              Ty.apply
                (Ty.path "core::iter::adapters::zip::Zip")
                []
                [
                  Ty.associated;
                  Ty.apply
                    (Ty.path "core::slice::iter::Iter")
                    []
                    [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                ],
              [],
              "map",
              [
                Ty.tuple
                  [
                    Ty.path "u16";
                    Ty.apply
                      (Ty.path "&")
                      []
                      [ Ty.path "move_binary_format::file_format::Bytecode" ];
                    Ty.apply
                      (Ty.path "&")
                      []
                      [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                  ];
                Ty.function
                  [
                    Ty.tuple
                      [
                        Ty.tuple
                          [
                            Ty.tuple
                              [
                                Ty.path "u16";
                                Ty.apply
                                  (Ty.path "&")
                                  []
                                  [ Ty.path "move_binary_format::file_format::Bytecode" ]
                              ];
                            Ty.apply
                              (Ty.path "&")
                              []
                              [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                          ]
                      ]
                  ]
                  (Ty.tuple
                    [
                      Ty.path "u16";
                      Ty.apply
                        (Ty.path "&")
                        []
                        [ Ty.path "move_binary_format::file_format::Bytecode" ];
                      Ty.apply
                        (Ty.path "&")
                        []
                        [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                    ])
              ]
            |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.associated,
                  [],
                  "zip",
                  [
                    Ty.apply
                      (Ty.path "&")
                      []
                      [
                        Ty.apply
                          (Ty.path "slice")
                          []
                          [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                      ]
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                      "code",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.read (| labels |)
                ]
              |);
              M.closure
                (fun γ =>
                  ltac:(M.monadic
                    match γ with
                    | [ α0 ] =>
                      ltac:(M.monadic
                        (M.match_operator (|
                          M.alloc (| α0 |),
                          [
                            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 γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                let i := M.copy (| γ1_0 |) in
                                let instr := M.copy (| γ1_1 |) in
                                let lbl := M.copy (| γ0_1 |) in
                                Value.Tuple
                                  [ M.read (| i |); M.read (| instr |); M.read (| lbl |) ]))
                          ]
                        |)))
                    | _ => M.impossible "wrong number of arguments"
                    end))
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_labeled_code : M.IsAssociatedFunction Self "labeled_code" labeled_code.
    
    (*
        fn error(&self, status: StatusCode, offset: CodeOffset) -> PartialVMError {
            PartialVMError::new(status).at_code_offset(self.current_function, offset)
        }
    *)
    Definition error (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self; status; offset ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let status := M.alloc (| status |) in
          let offset := M.alloc (| offset |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "move_binary_format::errors::PartialVMError",
              "at_code_offset",
              []
            |),
            [
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "move_binary_format::errors::PartialVMError",
                  "new",
                  []
                |),
                [ M.read (| status |) ]
              |);
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                  "current_function"
                |)
              |);
              M.read (| offset |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_error : M.IsAssociatedFunction Self "error" error.
  End Impl_move_bytecode_verifier_control_flow_v5_ControlFlowVerifier.
  
  (*
  fn instruction_labels(context: &ControlFlowVerifier) -> Vec<Label> {
      let mut labels: Vec<Label> = (0..context.code.len()).map(|_| Label::Code).collect();
      let mut loop_continue = |loop_idx: CodeOffset, last_continue: CodeOffset| {
          labels[loop_idx as usize] = Label::Loop { last_continue }
      };
      for (i, instr) in context.code() {
          match instr {
              // Back jump/"continue"
              Bytecode::Branch(prev) | Bytecode::BrTrue(prev) | Bytecode::BrFalse(prev)
                  if is_back_edge(i, *prev) =>
              {
                  loop_continue( *prev, i)
              }
              _ => (),
          }
      }
      labels
  }
  *)
  Definition instruction_labels (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ context ] =>
      ltac:(M.monadic
        (let context := M.alloc (| context |) in
        M.read (|
          let~ labels :=
            M.alloc (|
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply
                    (Ty.path "core::iter::adapters::map::Map")
                    []
                    [
                      Ty.apply (Ty.path "core::ops::range::Range") [] [ Ty.path "usize" ];
                      Ty.function
                        [ Ty.tuple [ Ty.path "usize" ] ]
                        (Ty.path "move_bytecode_verifier::control_flow_v5::Label")
                    ],
                  [],
                  "collect",
                  [
                    Ty.apply
                      (Ty.path "alloc::vec::Vec")
                      []
                      [
                        Ty.path "move_bytecode_verifier::control_flow_v5::Label";
                        Ty.path "alloc::alloc::Global"
                      ]
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "core::ops::range::Range") [] [ Ty.path "usize" ],
                      [],
                      "map",
                      [
                        Ty.path "move_bytecode_verifier::control_flow_v5::Label";
                        Ty.function
                          [ Ty.tuple [ Ty.path "usize" ] ]
                          (Ty.path "move_bytecode_verifier::control_flow_v5::Label")
                      ]
                    |),
                    [
                      Value.StructRecord
                        "core::ops::range::Range"
                        [
                          ("start", Value.Integer IntegerKind.Usize 0);
                          ("end_",
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::vec::Vec")
                                  []
                                  [
                                    Ty.path "move_binary_format::file_format::Bytecode";
                                    Ty.path "alloc::alloc::Global"
                                  ],
                                "len",
                                []
                              |),
                              [
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| context |),
                                    "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                                    "code"
                                  |)
                                |)
                              ]
                            |))
                        ];
                      M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (Value.StructTuple
                                          "move_bytecode_verifier::control_flow_v5::Label::Code"
                                          []))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end))
                    ]
                  |)
                ]
              |)
            |) in
          let~ loop_continue :=
            M.alloc (|
              M.closure
                (fun γ =>
                  ltac:(M.monadic
                    match γ with
                    | [ α0; α1 ] =>
                      ltac:(M.monadic
                        (M.match_operator (|
                          M.alloc (| α0 |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let loop_idx := M.copy (| γ |) in
                                M.match_operator (|
                                  M.alloc (| α1 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let last_continue := M.copy (| γ |) in
                                        M.read (|
                                          M.write (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::index::IndexMut",
                                                Ty.apply
                                                  (Ty.path "alloc::vec::Vec")
                                                  []
                                                  [
                                                    Ty.path
                                                      "move_bytecode_verifier::control_flow_v5::Label";
                                                    Ty.path "alloc::alloc::Global"
                                                  ],
                                                [ Ty.path "usize" ],
                                                "index_mut",
                                                []
                                              |),
                                              [ labels; M.rust_cast (M.read (| loop_idx |)) ]
                                            |),
                                            Value.StructRecord
                                              "move_bytecode_verifier::control_flow_v5::Label::Loop"
                                              [ ("last_continue", M.read (| last_continue |)) ]
                                          |)
                                        |)))
                                  ]
                                |)))
                          ]
                        |)))
                    | _ => M.impossible "wrong number of arguments"
                    end))
            |) in
          let~ _ :=
            M.use
              (M.match_operator (|
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::collect::IntoIterator",
                      Ty.associated,
                      [],
                      "into_iter",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.path "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                          "code",
                          []
                        |),
                        [ M.read (| context |) ]
                      |)
                    ]
                  |)
                |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let iter := M.copy (| γ |) in
                      M.loop (|
                        ltac:(M.monadic
                          (let~ _ :=
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::iter::traits::iterator::Iterator",
                                    Ty.associated,
                                    [],
                                    "next",
                                    []
                                  |),
                                  [ iter ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let _ :=
                                      M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                    M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::option::Option::Some",
                                        0
                                      |) in
                                    let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                    let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                    let i := M.copy (| γ1_0 |) in
                                    let instr := M.copy (| γ1_1 |) in
                                    M.match_operator (|
                                      instr,
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (M.find_or_pattern (|
                                              γ,
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ := M.read (| γ |) in
                                                    let γ1_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "move_binary_format::file_format::Bytecode::Branch",
                                                        0
                                                      |) in
                                                    let prev := M.alloc (| γ1_0 |) in
                                                    Value.Tuple [ prev ]));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ := M.read (| γ |) in
                                                    let γ1_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "move_binary_format::file_format::Bytecode::BrTrue",
                                                        0
                                                      |) in
                                                    let prev := M.alloc (| γ1_0 |) in
                                                    Value.Tuple [ prev ]));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ := M.read (| γ |) in
                                                    let γ1_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "move_binary_format::file_format::Bytecode::BrFalse",
                                                        0
                                                      |) in
                                                    let prev := M.alloc (| γ1_0 |) in
                                                    Value.Tuple [ prev ]))
                                              ],
                                              M.closure
                                                (fun γ =>
                                                  ltac:(M.monadic
                                                    match γ with
                                                    | [ prev ] =>
                                                      ltac:(M.monadic
                                                        (let γ :=
                                                          M.alloc (|
                                                            M.call_closure (|
                                                              M.get_function (|
                                                                "move_bytecode_verifier::control_flow_v5::is_back_edge",
                                                                []
                                                              |),
                                                              [
                                                                M.read (| i |);
                                                                M.read (| M.read (| prev |) |)
                                                              ]
                                                            |)
                                                          |) in
                                                        let _ :=
                                                          M.is_constant_or_break_match (|
                                                            M.read (| γ |),
                                                            Value.Bool true
                                                          |) in
                                                        M.alloc (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::function::FnMut",
                                                              Ty.function
                                                                [
                                                                  Ty.tuple
                                                                    [ Ty.path "u16"; Ty.path "u16" ]
                                                                ]
                                                                (Ty.tuple []),
                                                              [
                                                                Ty.tuple
                                                                  [ Ty.path "u16"; Ty.path "u16" ]
                                                              ],
                                                              "call_mut",
                                                              []
                                                            |),
                                                            [
                                                              loop_continue;
                                                              Value.Tuple
                                                                [
                                                                  M.read (| M.read (| prev |) |);
                                                                  M.read (| i |)
                                                                ]
                                                            ]
                                                          |)
                                                        |)))
                                                    | _ => M.impossible "wrong number of arguments"
                                                    end))
                                            |)));
                                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                      ]
                                    |)))
                              ]
                            |) in
                          M.alloc (| Value.Tuple [] |)))
                      |)))
                ]
              |)) in
          labels
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_instruction_labels :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::instruction_labels" instruction_labels.
  
  (*
  fn check_jumps(
      verifier_config: &VerifierConfig,
      context: &ControlFlowVerifier,
      labels: Vec<Label>,
  ) -> PartialVMResult<()> {
      // All back jumps are only to the current loop
      check_continues(context, &labels)?;
      // All "breaks" go to the "end" of the loop
      check_breaks(context, &labels)?;
  
      let loop_depth = count_loop_depth(&labels);
  
      // All forward jumps do not enter into the middle of a loop
      check_no_loop_splits(context, &labels, &loop_depth)?;
      // Nested loops do not exceed a given depth
      check_loop_depth(verifier_config, context, &labels, &loop_depth)
  }
  *)
  Definition check_jumps (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ verifier_config; context; labels ] =>
      ltac:(M.monadic
        (let verifier_config := M.alloc (| verifier_config |) in
        let context := M.alloc (| context |) in
        let labels := M.alloc (| labels |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ _ :=
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::try_trait::Try",
                        Ty.apply
                          (Ty.path "core::result::Result")
                          []
                          [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ],
                        [],
                        "branch",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_function (|
                            "move_bytecode_verifier::control_flow_v5::check_continues",
                            []
                          |),
                          [
                            M.read (| context |);
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::deref::Deref",
                                Ty.apply
                                  (Ty.path "alloc::vec::Vec")
                                  []
                                  [
                                    Ty.path "move_bytecode_verifier::control_flow_v5::Label";
                                    Ty.path "alloc::alloc::Global"
                                  ],
                                [],
                                "deref",
                                []
                              |),
                              [ labels ]
                            |)
                          ]
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Break",
                            0
                          |) in
                        let residual := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::FromResidual",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      []
                                      [
                                        Ty.tuple [];
                                        Ty.path "move_binary_format::errors::PartialVMError"
                                      ],
                                    [
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        []
                                        [
                                          Ty.path "core::convert::Infallible";
                                          Ty.path "move_binary_format::errors::PartialVMError"
                                        ]
                                    ],
                                    "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.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::try_trait::Try",
                        Ty.apply
                          (Ty.path "core::result::Result")
                          []
                          [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ],
                        [],
                        "branch",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_function (|
                            "move_bytecode_verifier::control_flow_v5::check_breaks",
                            []
                          |),
                          [
                            M.read (| context |);
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::deref::Deref",
                                Ty.apply
                                  (Ty.path "alloc::vec::Vec")
                                  []
                                  [
                                    Ty.path "move_bytecode_verifier::control_flow_v5::Label";
                                    Ty.path "alloc::alloc::Global"
                                  ],
                                [],
                                "deref",
                                []
                              |),
                              [ labels ]
                            |)
                          ]
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Break",
                            0
                          |) in
                        let residual := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::FromResidual",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      []
                                      [
                                        Ty.tuple [];
                                        Ty.path "move_binary_format::errors::PartialVMError"
                                      ],
                                    [
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        []
                                        [
                                          Ty.path "core::convert::Infallible";
                                          Ty.path "move_binary_format::errors::PartialVMError"
                                        ]
                                    ],
                                    "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~ loop_depth :=
                M.alloc (|
                  M.call_closure (|
                    M.get_function (|
                      "move_bytecode_verifier::control_flow_v5::count_loop_depth",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::ops::deref::Deref",
                          Ty.apply
                            (Ty.path "alloc::vec::Vec")
                            []
                            [
                              Ty.path "move_bytecode_verifier::control_flow_v5::Label";
                              Ty.path "alloc::alloc::Global"
                            ],
                          [],
                          "deref",
                          []
                        |),
                        [ labels ]
                      |)
                    ]
                  |)
                |) in
              let~ _ :=
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::try_trait::Try",
                        Ty.apply
                          (Ty.path "core::result::Result")
                          []
                          [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ],
                        [],
                        "branch",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_function (|
                            "move_bytecode_verifier::control_flow_v5::check_no_loop_splits",
                            []
                          |),
                          [
                            M.read (| context |);
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::deref::Deref",
                                Ty.apply
                                  (Ty.path "alloc::vec::Vec")
                                  []
                                  [
                                    Ty.path "move_bytecode_verifier::control_flow_v5::Label";
                                    Ty.path "alloc::alloc::Global"
                                  ],
                                [],
                                "deref",
                                []
                              |),
                              [ labels ]
                            |);
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::deref::Deref",
                                Ty.apply
                                  (Ty.path "alloc::vec::Vec")
                                  []
                                  [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ],
                                [],
                                "deref",
                                []
                              |),
                              [ loop_depth ]
                            |)
                          ]
                        |)
                      ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Break",
                            0
                          |) in
                        let residual := M.copy (| γ0_0 |) in
                        M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::try_trait::FromResidual",
                                    Ty.apply
                                      (Ty.path "core::result::Result")
                                      []
                                      [
                                        Ty.tuple [];
                                        Ty.path "move_binary_format::errors::PartialVMError"
                                      ],
                                    [
                                      Ty.apply
                                        (Ty.path "core::result::Result")
                                        []
                                        [
                                          Ty.path "core::convert::Infallible";
                                          Ty.path "move_binary_format::errors::PartialVMError"
                                        ]
                                    ],
                                    "from_residual",
                                    []
                                  |),
                                  [ M.read (| residual |) ]
                                |)
                              |)
                            |)
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::ops::control_flow::ControlFlow::Continue",
                            0
                          |) in
                        let val := M.copy (| γ0_0 |) in
                        val))
                  ]
                |) in
              M.alloc (|
                M.call_closure (|
                  M.get_function (|
                    "move_bytecode_verifier::control_flow_v5::check_loop_depth",
                    []
                  |),
                  [
                    M.read (| verifier_config |);
                    M.read (| context |);
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::deref::Deref",
                        Ty.apply
                          (Ty.path "alloc::vec::Vec")
                          []
                          [
                            Ty.path "move_bytecode_verifier::control_flow_v5::Label";
                            Ty.path "alloc::alloc::Global"
                          ],
                        [],
                        "deref",
                        []
                      |),
                      [ labels ]
                    |);
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::ops::deref::Deref",
                        Ty.apply
                          (Ty.path "alloc::vec::Vec")
                          []
                          [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ],
                        [],
                        "deref",
                        []
                      |),
                      [ loop_depth ]
                    |)
                  ]
                |)
              |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_check_jumps :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::check_jumps" check_jumps.
  
  (*
  fn check_code<
      F: FnMut(&Vec<(CodeOffset, CodeOffset)>, CodeOffset, &Bytecode) -> PartialVMResult<()>,
  >(
      context: &ControlFlowVerifier,
      labels: &[Label],
      mut check: F,
  ) -> PartialVMResult<()> {
      let mut loop_stack: Vec<(CodeOffset, CodeOffset)> = vec![];
      for (cur_instr, instr, label) in context.labeled_code(labels) {
          // Add loop to stack
          if let Label::Loop { last_continue } = label {
              loop_stack.push((cur_instr, *last_continue));
          }
  
          check(&loop_stack, cur_instr, instr)?;
  
          // Pop if last continue
          match instr {
              // Back jump/"continue"
              Bytecode::Branch(target) | Bytecode::BrTrue(target) | Bytecode::BrFalse(target)
                  if is_back_edge(cur_instr, *target) =>
              {
                  let (_cur_loop_head, last_continue) = safe_unwrap!(loop_stack.last());
                  if cur_instr == *last_continue {
                      loop_stack.pop();
                  }
              }
              _ => (),
          }
      }
      Ok(())
  }
  *)
  Definition check_code (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [ F ], [ context; labels; check ] =>
      ltac:(M.monadic
        (let context := M.alloc (| context |) in
        let labels := M.alloc (| labels |) in
        let check := M.alloc (| check |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ loop_stack :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply
                        (Ty.path "alloc::vec::Vec")
                        []
                        [ Ty.tuple [ Ty.path "u16"; Ty.path "u16" ]; Ty.path "alloc::alloc::Global"
                        ],
                      "new",
                      []
                    |),
                    []
                  |)
                |) in
              let~ _ :=
                M.use
                  (M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::collect::IntoIterator",
                          Ty.associated,
                          [],
                          "into_iter",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.path
                                "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                              "labeled_code",
                              []
                            |),
                            [ M.read (| context |); M.read (| labels |) ]
                          |)
                        ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let iter := M.copy (| γ |) in
                          M.loop (|
                            ltac:(M.monadic
                              (let~ _ :=
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::iter::traits::iterator::Iterator",
                                        Ty.associated,
                                        [],
                                        "next",
                                        []
                                      |),
                                      [ iter ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let _ :=
                                          M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                        M.alloc (|
                                          M.never_to_any (| M.read (| M.break (||) |) |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::option::Option::Some",
                                            0
                                          |) in
                                        let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                        let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                        let γ1_2 := M.SubPointer.get_tuple_field (| γ0_0, 2 |) in
                                        let cur_instr := M.copy (| γ1_0 |) in
                                        let instr := M.copy (| γ1_1 |) in
                                        let label := M.copy (| γ1_2 |) in
                                        let~ _ :=
                                          M.match_operator (|
                                            M.alloc (| Value.Tuple [] |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ := label in
                                                  let γ := M.read (| γ |) in
                                                  let γ1_0 :=
                                                    M.SubPointer.get_struct_record_field (|
                                                      γ,
                                                      "move_bytecode_verifier::control_flow_v5::Label::Loop",
                                                      "last_continue"
                                                    |) in
                                                  let last_continue := M.alloc (| γ1_0 |) in
                                                  let~ _ :=
                                                    M.alloc (|
                                                      M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.apply
                                                            (Ty.path "alloc::vec::Vec")
                                                            []
                                                            [
                                                              Ty.tuple
                                                                [ Ty.path "u16"; Ty.path "u16" ];
                                                              Ty.path "alloc::alloc::Global"
                                                            ],
                                                          "push",
                                                          []
                                                        |),
                                                        [
                                                          loop_stack;
                                                          Value.Tuple
                                                            [
                                                              M.read (| cur_instr |);
                                                              M.read (|
                                                                M.read (| last_continue |)
                                                              |)
                                                            ]
                                                        ]
                                                      |)
                                                    |) in
                                                  M.alloc (| Value.Tuple [] |)));
                                              fun γ =>
                                                ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                            ]
                                          |) in
                                        let~ _ :=
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::Try",
                                                  Ty.apply
                                                    (Ty.path "core::result::Result")
                                                    []
                                                    [
                                                      Ty.tuple [];
                                                      Ty.path
                                                        "move_binary_format::errors::PartialVMError"
                                                    ],
                                                  [],
                                                  "branch",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::function::FnMut",
                                                      F,
                                                      [
                                                        Ty.tuple
                                                          [
                                                            Ty.apply
                                                              (Ty.path "&")
                                                              []
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "alloc::vec::Vec")
                                                                  []
                                                                  [
                                                                    Ty.tuple
                                                                      [ Ty.path "u16"; Ty.path "u16"
                                                                      ];
                                                                    Ty.path "alloc::alloc::Global"
                                                                  ]
                                                              ];
                                                            Ty.path "u16";
                                                            Ty.apply
                                                              (Ty.path "&")
                                                              []
                                                              [
                                                                Ty.path
                                                                  "move_binary_format::file_format::Bytecode"
                                                              ]
                                                          ]
                                                      ],
                                                      "call_mut",
                                                      []
                                                    |),
                                                    [
                                                      check;
                                                      Value.Tuple
                                                        [
                                                          loop_stack;
                                                          M.read (| cur_instr |);
                                                          M.read (| instr |)
                                                        ]
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Break",
                                                      0
                                                    |) in
                                                  let residual := M.copy (| γ0_0 |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.read (|
                                                        M.return_ (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::try_trait::FromResidual",
                                                              Ty.apply
                                                                (Ty.path "core::result::Result")
                                                                []
                                                                [
                                                                  Ty.tuple [];
                                                                  Ty.path
                                                                    "move_binary_format::errors::PartialVMError"
                                                                ],
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "core::result::Result")
                                                                  []
                                                                  [
                                                                    Ty.path
                                                                      "core::convert::Infallible";
                                                                    Ty.path
                                                                      "move_binary_format::errors::PartialVMError"
                                                                  ]
                                                              ],
                                                              "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.match_operator (|
                                          instr,
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (M.find_or_pattern (|
                                                  γ,
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let γ := M.read (| γ |) in
                                                        let γ1_0 :=
                                                          M.SubPointer.get_struct_tuple_field (|
                                                            γ,
                                                            "move_binary_format::file_format::Bytecode::Branch",
                                                            0
                                                          |) in
                                                        let target := M.alloc (| γ1_0 |) in
                                                        Value.Tuple [ target ]));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let γ := M.read (| γ |) in
                                                        let γ1_0 :=
                                                          M.SubPointer.get_struct_tuple_field (|
                                                            γ,
                                                            "move_binary_format::file_format::Bytecode::BrTrue",
                                                            0
                                                          |) in
                                                        let target := M.alloc (| γ1_0 |) in
                                                        Value.Tuple [ target ]));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let γ := M.read (| γ |) in
                                                        let γ1_0 :=
                                                          M.SubPointer.get_struct_tuple_field (|
                                                            γ,
                                                            "move_binary_format::file_format::Bytecode::BrFalse",
                                                            0
                                                          |) in
                                                        let target := M.alloc (| γ1_0 |) in
                                                        Value.Tuple [ target ]))
                                                  ],
                                                  M.closure
                                                    (fun γ =>
                                                      ltac:(M.monadic
                                                        match γ with
                                                        | [ target ] =>
                                                          ltac:(M.monadic
                                                            (let γ :=
                                                              M.alloc (|
                                                                M.call_closure (|
                                                                  M.get_function (|
                                                                    "move_bytecode_verifier::control_flow_v5::is_back_edge",
                                                                    []
                                                                  |),
                                                                  [
                                                                    M.read (| cur_instr |);
                                                                    M.read (| M.read (| target |) |)
                                                                  ]
                                                                |)
                                                              |) in
                                                            let _ :=
                                                              M.is_constant_or_break_match (|
                                                                M.read (| γ |),
                                                                Value.Bool true
                                                              |) in
                                                            M.match_operator (|
                                                              M.match_operator (|
                                                                M.alloc (|
                                                                  M.call_closure (|
                                                                    M.get_associated_function (|
                                                                      Ty.apply
                                                                        (Ty.path "slice")
                                                                        []
                                                                        [
                                                                          Ty.tuple
                                                                            [
                                                                              Ty.path "u16";
                                                                              Ty.path "u16"
                                                                            ]
                                                                        ],
                                                                      "last",
                                                                      []
                                                                    |),
                                                                    [
                                                                      M.call_closure (|
                                                                        M.get_trait_method (|
                                                                          "core::ops::deref::Deref",
                                                                          Ty.apply
                                                                            (Ty.path
                                                                              "alloc::vec::Vec")
                                                                            []
                                                                            [
                                                                              Ty.tuple
                                                                                [
                                                                                  Ty.path "u16";
                                                                                  Ty.path "u16"
                                                                                ];
                                                                              Ty.path
                                                                                "alloc::alloc::Global"
                                                                            ],
                                                                          [],
                                                                          "deref",
                                                                          []
                                                                        |),
                                                                        [ loop_stack ]
                                                                      |)
                                                                    ]
                                                                  |)
                                                                |),
                                                                [
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (let γ0_0 :=
                                                                        M.SubPointer.get_struct_tuple_field (|
                                                                          γ,
                                                                          "core::option::Option::Some",
                                                                          0
                                                                        |) in
                                                                      let x := M.copy (| γ0_0 |) in
                                                                      x));
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (let _ :=
                                                                        M.is_struct_tuple (|
                                                                          γ,
                                                                          "core::option::Option::None"
                                                                        |) in
                                                                      let~ err :=
                                                                        M.alloc (|
                                                                          M.call_closure (|
                                                                            M.get_associated_function (|
                                                                              Ty.path
                                                                                "move_binary_format::errors::PartialVMError",
                                                                              "with_message",
                                                                              []
                                                                            |),
                                                                            [
                                                                              M.call_closure (|
                                                                                M.get_associated_function (|
                                                                                  Ty.path
                                                                                    "move_binary_format::errors::PartialVMError",
                                                                                  "new",
                                                                                  []
                                                                                |),
                                                                                [
                                                                                  Value.StructTuple
                                                                                    "move_core_types::vm_status::StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR"
                                                                                    []
                                                                                ]
                                                                              |);
                                                                              M.call_closure (|
                                                                                M.get_function (|
                                                                                  "core::hint::must_use",
                                                                                  [
                                                                                    Ty.path
                                                                                      "alloc::string::String"
                                                                                  ]
                                                                                |),
                                                                                [
                                                                                  M.read (|
                                                                                    let~ res :=
                                                                                      M.alloc (|
                                                                                        M.call_closure (|
                                                                                          M.get_function (|
                                                                                            "alloc::fmt::format",
                                                                                            []
                                                                                          |),
                                                                                          [
                                                                                            M.call_closure (|
                                                                                              M.get_associated_function (|
                                                                                                Ty.path
                                                                                                  "core::fmt::Arguments",
                                                                                                "new_v1",
                                                                                                []
                                                                                              |),
                                                                                              [
                                                                                                M.alloc (|
                                                                                                  Value.Array
                                                                                                    [
                                                                                                      M.read (|
                                                                                                        Value.String
                                                                                                          "crates/move-bytecode-verifier/src/control_flow_v5.rs:150 (none)"
                                                                                                      |)
                                                                                                    ]
                                                                                                |);
                                                                                                M.alloc (|
                                                                                                  M.call_closure (|
                                                                                                    M.get_associated_function (|
                                                                                                      Ty.path
                                                                                                        "core::fmt::rt::Argument",
                                                                                                      "none",
                                                                                                      []
                                                                                                    |),
                                                                                                    []
                                                                                                  |)
                                                                                                |)
                                                                                              ]
                                                                                            |)
                                                                                          ]
                                                                                        |)
                                                                                      |) in
                                                                                    res
                                                                                  |)
                                                                                ]
                                                                              |)
                                                                            ]
                                                                          |)
                                                                        |) in
                                                                      M.match_operator (|
                                                                        M.alloc (|
                                                                          Value.Tuple []
                                                                        |),
                                                                        [
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (let γ :=
                                                                                M.use
                                                                                  (M.alloc (|
                                                                                    Value.Bool true
                                                                                  |)) in
                                                                              let _ :=
                                                                                M.is_constant_or_break_match (|
                                                                                  M.read (| γ |),
                                                                                  Value.Bool true
                                                                                |) in
                                                                              M.alloc (|
                                                                                M.never_to_any (|
                                                                                  M.call_closure (|
                                                                                    M.get_function (|
                                                                                      "core::panicking::panic_fmt",
                                                                                      []
                                                                                    |),
                                                                                    [
                                                                                      M.call_closure (|
                                                                                        M.get_associated_function (|
                                                                                          Ty.path
                                                                                            "core::fmt::Arguments",
                                                                                          "new_v1",
                                                                                          []
                                                                                        |),
                                                                                        [
                                                                                          M.alloc (|
                                                                                            Value.Array
                                                                                              [
                                                                                                M.read (|
                                                                                                  Value.String
                                                                                                    ""
                                                                                                |)
                                                                                              ]
                                                                                          |);
                                                                                          M.alloc (|
                                                                                            Value.Array
                                                                                              [
                                                                                                M.call_closure (|
                                                                                                  M.get_associated_function (|
                                                                                                    Ty.path
                                                                                                      "core::fmt::rt::Argument",
                                                                                                    "new_debug",
                                                                                                    [
                                                                                                      Ty.path
                                                                                                        "move_binary_format::errors::PartialVMError"
                                                                                                    ]
                                                                                                  |),
                                                                                                  [
                                                                                                    err
                                                                                                  ]
                                                                                                |)
                                                                                              ]
                                                                                          |)
                                                                                        ]
                                                                                      |)
                                                                                    ]
                                                                                  |)
                                                                                |)
                                                                              |)));
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (M.alloc (|
                                                                                M.never_to_any (|
                                                                                  M.read (|
                                                                                    M.return_ (|
                                                                                      Value.StructTuple
                                                                                        "core::result::Result::Err"
                                                                                        [
                                                                                          M.read (|
                                                                                            err
                                                                                          |)
                                                                                        ]
                                                                                    |)
                                                                                  |)
                                                                                |)
                                                                              |)))
                                                                        ]
                                                                      |)))
                                                                ]
                                                              |),
                                                              [
                                                                fun γ =>
                                                                  ltac:(M.monadic
                                                                    (let γ := M.read (| γ |) in
                                                                    let γ1_0 :=
                                                                      M.SubPointer.get_tuple_field (|
                                                                        γ,
                                                                        0
                                                                      |) in
                                                                    let γ1_1 :=
                                                                      M.SubPointer.get_tuple_field (|
                                                                        γ,
                                                                        1
                                                                      |) in
                                                                    let _cur_loop_head :=
                                                                      M.alloc (| γ1_0 |) in
                                                                    let last_continue :=
                                                                      M.alloc (| γ1_1 |) in
                                                                    M.match_operator (|
                                                                      M.alloc (| Value.Tuple [] |),
                                                                      [
                                                                        fun γ =>
                                                                          ltac:(M.monadic
                                                                            (let γ :=
                                                                              M.use
                                                                                (M.alloc (|
                                                                                  BinOp.eq (|
                                                                                    M.read (|
                                                                                      cur_instr
                                                                                    |),
                                                                                    M.read (|
                                                                                      M.read (|
                                                                                        last_continue
                                                                                      |)
                                                                                    |)
                                                                                  |)
                                                                                |)) in
                                                                            let _ :=
                                                                              M.is_constant_or_break_match (|
                                                                                M.read (| γ |),
                                                                                Value.Bool true
                                                                              |) in
                                                                            let~ _ :=
                                                                              M.alloc (|
                                                                                M.call_closure (|
                                                                                  M.get_associated_function (|
                                                                                    Ty.apply
                                                                                      (Ty.path
                                                                                        "alloc::vec::Vec")
                                                                                      []
                                                                                      [
                                                                                        Ty.tuple
                                                                                          [
                                                                                            Ty.path
                                                                                              "u16";
                                                                                            Ty.path
                                                                                              "u16"
                                                                                          ];
                                                                                        Ty.path
                                                                                          "alloc::alloc::Global"
                                                                                      ],
                                                                                    "pop",
                                                                                    []
                                                                                  |),
                                                                                  [ loop_stack ]
                                                                                |)
                                                                              |) in
                                                                            M.alloc (|
                                                                              Value.Tuple []
                                                                            |)));
                                                                        fun γ =>
                                                                          ltac:(M.monadic
                                                                            (M.alloc (|
                                                                              Value.Tuple []
                                                                            |)))
                                                                      ]
                                                                    |)))
                                                              ]
                                                            |)))
                                                        | _ =>
                                                          M.impossible "wrong number of arguments"
                                                        end))
                                                |)));
                                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                          ]
                                        |)))
                                  ]
                                |) in
                              M.alloc (| Value.Tuple [] |)))
                          |)))
                    ]
                  |)) in
              M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_check_code :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::check_code" check_code.
  
  (*
  fn is_back_edge(cur_instr: CodeOffset, target_instr: CodeOffset) -> bool {
      target_instr <= cur_instr
  }
  *)
  Definition is_back_edge (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ cur_instr; target_instr ] =>
      ltac:(M.monadic
        (let cur_instr := M.alloc (| cur_instr |) in
        let target_instr := M.alloc (| target_instr |) in
        BinOp.le (| M.read (| target_instr |), M.read (| cur_instr |) |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_is_back_edge :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::is_back_edge" is_back_edge.
  
  (*
  fn check_continues(context: &ControlFlowVerifier, labels: &[Label]) -> PartialVMResult<()> {
      check_code(context, labels, |loop_stack, cur_instr, instr| {
          match instr {
              // Back jump/"continue"
              Bytecode::Branch(target) | Bytecode::BrTrue(target) | Bytecode::BrFalse(target)
                  if is_back_edge(cur_instr, *target) =>
              {
                  let (cur_loop_head, _last_continue) = safe_unwrap!(loop_stack.last());
                  if target != cur_loop_head {
                      // Invalid back jump. Cannot back jump outside of the current loop
                      Err(context.error(StatusCode::INVALID_LOOP_CONTINUE, cur_instr))
                  } else {
                      Ok(())
                  }
              }
              _ => Ok(()),
          }
      })
  }
  *)
  Definition check_continues (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ context; labels ] =>
      ltac:(M.monadic
        (let context := M.alloc (| context |) in
        let labels := M.alloc (| labels |) in
        M.call_closure (|
          M.get_function (|
            "move_bytecode_verifier::control_flow_v5::check_code",
            [
              Ty.function
                [
                  Ty.tuple
                    [
                      Ty.apply
                        (Ty.path "&")
                        []
                        [
                          Ty.apply
                            (Ty.path "alloc::vec::Vec")
                            []
                            [
                              Ty.tuple [ Ty.path "u16"; Ty.path "u16" ];
                              Ty.path "alloc::alloc::Global"
                            ]
                        ];
                      Ty.path "u16";
                      Ty.apply
                        (Ty.path "&")
                        []
                        [ Ty.path "move_binary_format::file_format::Bytecode" ]
                    ]
                ]
                (Ty.apply
                  (Ty.path "core::result::Result")
                  []
                  [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ])
            ]
          |),
          [
            M.read (| context |);
            M.read (| labels |);
            M.closure
              (fun γ =>
                ltac:(M.monadic
                  match γ with
                  | [ α0; α1; α2 ] =>
                    ltac:(M.monadic
                      (M.match_operator (|
                        M.alloc (| α0 |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let loop_stack := M.copy (| γ |) in
                              M.match_operator (|
                                M.alloc (| α1 |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let cur_instr := M.copy (| γ |) in
                                      M.match_operator (|
                                        M.alloc (| α2 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let instr := M.copy (| γ |) in
                                              M.read (|
                                                M.match_operator (|
                                                  instr,
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.find_or_pattern (|
                                                          γ,
                                                          [
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ := M.read (| γ |) in
                                                                let γ1_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "move_binary_format::file_format::Bytecode::Branch",
                                                                    0
                                                                  |) in
                                                                let target := M.alloc (| γ1_0 |) in
                                                                Value.Tuple [ target ]));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ := M.read (| γ |) in
                                                                let γ1_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "move_binary_format::file_format::Bytecode::BrTrue",
                                                                    0
                                                                  |) in
                                                                let target := M.alloc (| γ1_0 |) in
                                                                Value.Tuple [ target ]));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ := M.read (| γ |) in
                                                                let γ1_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "move_binary_format::file_format::Bytecode::BrFalse",
                                                                    0
                                                                  |) in
                                                                let target := M.alloc (| γ1_0 |) in
                                                                Value.Tuple [ target ]))
                                                          ],
                                                          M.closure
                                                            (fun γ =>
                                                              ltac:(M.monadic
                                                                match γ with
                                                                | [ target ] =>
                                                                  ltac:(M.monadic
                                                                    (let γ :=
                                                                      M.alloc (|
                                                                        M.call_closure (|
                                                                          M.get_function (|
                                                                            "move_bytecode_verifier::control_flow_v5::is_back_edge",
                                                                            []
                                                                          |),
                                                                          [
                                                                            M.read (| cur_instr |);
                                                                            M.read (|
                                                                              M.read (| target |)
                                                                            |)
                                                                          ]
                                                                        |)
                                                                      |) in
                                                                    let _ :=
                                                                      M.is_constant_or_break_match (|
                                                                        M.read (| γ |),
                                                                        Value.Bool true
                                                                      |) in
                                                                    M.match_operator (|
                                                                      M.match_operator (|
                                                                        M.alloc (|
                                                                          M.call_closure (|
                                                                            M.get_associated_function (|
                                                                              Ty.apply
                                                                                (Ty.path "slice")
                                                                                []
                                                                                [
                                                                                  Ty.tuple
                                                                                    [
                                                                                      Ty.path "u16";
                                                                                      Ty.path "u16"
                                                                                    ]
                                                                                ],
                                                                              "last",
                                                                              []
                                                                            |),
                                                                            [
                                                                              M.call_closure (|
                                                                                M.get_trait_method (|
                                                                                  "core::ops::deref::Deref",
                                                                                  Ty.apply
                                                                                    (Ty.path
                                                                                      "alloc::vec::Vec")
                                                                                    []
                                                                                    [
                                                                                      Ty.tuple
                                                                                        [
                                                                                          Ty.path
                                                                                            "u16";
                                                                                          Ty.path
                                                                                            "u16"
                                                                                        ];
                                                                                      Ty.path
                                                                                        "alloc::alloc::Global"
                                                                                    ],
                                                                                  [],
                                                                                  "deref",
                                                                                  []
                                                                                |),
                                                                                [
                                                                                  M.read (|
                                                                                    loop_stack
                                                                                  |)
                                                                                ]
                                                                              |)
                                                                            ]
                                                                          |)
                                                                        |),
                                                                        [
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (let γ0_0 :=
                                                                                M.SubPointer.get_struct_tuple_field (|
                                                                                  γ,
                                                                                  "core::option::Option::Some",
                                                                                  0
                                                                                |) in
                                                                              let x :=
                                                                                M.copy (| γ0_0 |) in
                                                                              x));
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (let _ :=
                                                                                M.is_struct_tuple (|
                                                                                  γ,
                                                                                  "core::option::Option::None"
                                                                                |) in
                                                                              let~ err :=
                                                                                M.alloc (|
                                                                                  M.call_closure (|
                                                                                    M.get_associated_function (|
                                                                                      Ty.path
                                                                                        "move_binary_format::errors::PartialVMError",
                                                                                      "with_message",
                                                                                      []
                                                                                    |),
                                                                                    [
                                                                                      M.call_closure (|
                                                                                        M.get_associated_function (|
                                                                                          Ty.path
                                                                                            "move_binary_format::errors::PartialVMError",
                                                                                          "new",
                                                                                          []
                                                                                        |),
                                                                                        [
                                                                                          Value.StructTuple
                                                                                            "move_core_types::vm_status::StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR"
                                                                                            []
                                                                                        ]
                                                                                      |);
                                                                                      M.call_closure (|
                                                                                        M.get_function (|
                                                                                          "core::hint::must_use",
                                                                                          [
                                                                                            Ty.path
                                                                                              "alloc::string::String"
                                                                                          ]
                                                                                        |),
                                                                                        [
                                                                                          M.read (|
                                                                                            let~
                                                                                                  res :=
                                                                                              M.alloc (|
                                                                                                M.call_closure (|
                                                                                                  M.get_function (|
                                                                                                    "alloc::fmt::format",
                                                                                                    []
                                                                                                  |),
                                                                                                  [
                                                                                                    M.call_closure (|
                                                                                                      M.get_associated_function (|
                                                                                                        Ty.path
                                                                                                          "core::fmt::Arguments",
                                                                                                        "new_v1",
                                                                                                        []
                                                                                                      |),
                                                                                                      [
                                                                                                        M.alloc (|
                                                                                                          Value.Array
                                                                                                            [
                                                                                                              M.read (|
                                                                                                                Value.String
                                                                                                                  "crates/move-bytecode-verifier/src/control_flow_v5.rs:173 (none)"
                                                                                                              |)
                                                                                                            ]
                                                                                                        |);
                                                                                                        M.alloc (|
                                                                                                          M.call_closure (|
                                                                                                            M.get_associated_function (|
                                                                                                              Ty.path
                                                                                                                "core::fmt::rt::Argument",
                                                                                                              "none",
                                                                                                              []
                                                                                                            |),
                                                                                                            []
                                                                                                          |)
                                                                                                        |)
                                                                                                      ]
                                                                                                    |)
                                                                                                  ]
                                                                                                |)
                                                                                              |) in
                                                                                            res
                                                                                          |)
                                                                                        ]
                                                                                      |)
                                                                                    ]
                                                                                  |)
                                                                                |) in
                                                                              M.match_operator (|
                                                                                M.alloc (|
                                                                                  Value.Tuple []
                                                                                |),
                                                                                [
                                                                                  fun γ =>
                                                                                    ltac:(M.monadic
                                                                                      (let γ :=
                                                                                        M.use
                                                                                          (M.alloc (|
                                                                                            Value.Bool
                                                                                              true
                                                                                          |)) in
                                                                                      let _ :=
                                                                                        M.is_constant_or_break_match (|
                                                                                          M.read (|
                                                                                            γ
                                                                                          |),
                                                                                          Value.Bool
                                                                                            true
                                                                                        |) in
                                                                                      M.alloc (|
                                                                                        M.never_to_any (|
                                                                                          M.call_closure (|
                                                                                            M.get_function (|
                                                                                              "core::panicking::panic_fmt",
                                                                                              []
                                                                                            |),
                                                                                            [
                                                                                              M.call_closure (|
                                                                                                M.get_associated_function (|
                                                                                                  Ty.path
                                                                                                    "core::fmt::Arguments",
                                                                                                  "new_v1",
                                                                                                  []
                                                                                                |),
                                                                                                [
                                                                                                  M.alloc (|
                                                                                                    Value.Array
                                                                                                      [
                                                                                                        M.read (|
                                                                                                          Value.String
                                                                                                            ""
                                                                                                        |)
                                                                                                      ]
                                                                                                  |);
                                                                                                  M.alloc (|
                                                                                                    Value.Array
                                                                                                      [
                                                                                                        M.call_closure (|
                                                                                                          M.get_associated_function (|
                                                                                                            Ty.path
                                                                                                              "core::fmt::rt::Argument",
                                                                                                            "new_debug",
                                                                                                            [
                                                                                                              Ty.path
                                                                                                                "move_binary_format::errors::PartialVMError"
                                                                                                            ]
                                                                                                          |),
                                                                                                          [
                                                                                                            err
                                                                                                          ]
                                                                                                        |)
                                                                                                      ]
                                                                                                  |)
                                                                                                ]
                                                                                              |)
                                                                                            ]
                                                                                          |)
                                                                                        |)
                                                                                      |)));
                                                                                  fun γ =>
                                                                                    ltac:(M.monadic
                                                                                      (M.alloc (|
                                                                                        M.never_to_any (|
                                                                                          M.read (|
                                                                                            M.return_ (|
                                                                                              Value.StructTuple
                                                                                                "core::result::Result::Err"
                                                                                                [
                                                                                                  M.read (|
                                                                                                    err
                                                                                                  |)
                                                                                                ]
                                                                                            |)
                                                                                          |)
                                                                                        |)
                                                                                      |)))
                                                                                ]
                                                                              |)))
                                                                        ]
                                                                      |),
                                                                      [
                                                                        fun γ =>
                                                                          ltac:(M.monadic
                                                                            (let γ :=
                                                                              M.read (| γ |) in
                                                                            let γ1_0 :=
                                                                              M.SubPointer.get_tuple_field (|
                                                                                γ,
                                                                                0
                                                                              |) in
                                                                            let γ1_1 :=
                                                                              M.SubPointer.get_tuple_field (|
                                                                                γ,
                                                                                1
                                                                              |) in
                                                                            let cur_loop_head :=
                                                                              M.alloc (| γ1_0 |) in
                                                                            let _last_continue :=
                                                                              M.alloc (| γ1_1 |) in
                                                                            M.match_operator (|
                                                                              M.alloc (|
                                                                                Value.Tuple []
                                                                              |),
                                                                              [
                                                                                fun γ =>
                                                                                  ltac:(M.monadic
                                                                                    (let γ :=
                                                                                      M.use
                                                                                        (M.alloc (|
                                                                                          M.call_closure (|
                                                                                            M.get_trait_method (|
                                                                                              "core::cmp::PartialEq",
                                                                                              Ty.apply
                                                                                                (Ty.path
                                                                                                  "&")
                                                                                                []
                                                                                                [
                                                                                                  Ty.path
                                                                                                    "u16"
                                                                                                ],
                                                                                              [
                                                                                                Ty.apply
                                                                                                  (Ty.path
                                                                                                    "&")
                                                                                                  []
                                                                                                  [
                                                                                                    Ty.path
                                                                                                      "u16"
                                                                                                  ]
                                                                                              ],
                                                                                              "ne",
                                                                                              []
                                                                                            |),
                                                                                            [
                                                                                              target;
                                                                                              cur_loop_head
                                                                                            ]
                                                                                          |)
                                                                                        |)) in
                                                                                    let _ :=
                                                                                      M.is_constant_or_break_match (|
                                                                                        M.read (|
                                                                                          γ
                                                                                        |),
                                                                                        Value.Bool
                                                                                          true
                                                                                      |) in
                                                                                    M.alloc (|
                                                                                      Value.StructTuple
                                                                                        "core::result::Result::Err"
                                                                                        [
                                                                                          M.call_closure (|
                                                                                            M.get_associated_function (|
                                                                                              Ty.path
                                                                                                "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                                                                                              "error",
                                                                                              []
                                                                                            |),
                                                                                            [
                                                                                              M.read (|
                                                                                                context
                                                                                              |);
                                                                                              Value.StructTuple
                                                                                                "move_core_types::vm_status::StatusCode::INVALID_LOOP_CONTINUE"
                                                                                                [];
                                                                                              M.read (|
                                                                                                cur_instr
                                                                                              |)
                                                                                            ]
                                                                                          |)
                                                                                        ]
                                                                                    |)));
                                                                                fun γ =>
                                                                                  ltac:(M.monadic
                                                                                    (M.alloc (|
                                                                                      Value.StructTuple
                                                                                        "core::result::Result::Ok"
                                                                                        [
                                                                                          Value.Tuple
                                                                                            []
                                                                                        ]
                                                                                    |)))
                                                                              ]
                                                                            |)))
                                                                      ]
                                                                    |)))
                                                                | _ =>
                                                                  M.impossible
                                                                    "wrong number of arguments"
                                                                end))
                                                        |)));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.alloc (|
                                                          Value.StructTuple
                                                            "core::result::Result::Ok"
                                                            [ Value.Tuple [] ]
                                                        |)))
                                                  ]
                                                |)
                                              |)))
                                        ]
                                      |)))
                                ]
                              |)))
                        ]
                      |)))
                  | _ => M.impossible "wrong number of arguments"
                  end))
          ]
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_check_continues :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::check_continues" check_continues.
  
  (*
  fn check_breaks(context: &ControlFlowVerifier, labels: &[Label]) -> PartialVMResult<()> {
      check_code(context, labels, |loop_stack, cur_instr, instr| {
          match instr {
              // Forward jump/"break"
              Bytecode::Branch(target) | Bytecode::BrTrue(target) | Bytecode::BrFalse(target)
                  if !is_back_edge(cur_instr, *target) =>
              {
                  match loop_stack.last() {
                      Some((_cur_loop_head, last_continue))
                          if target > last_continue && *target != last_continue + 1 =>
                      {
                          // Invalid loop break. Must break immediately to the instruction after
                          // the last continue
                          Err(context.error(StatusCode::INVALID_LOOP_BREAK, cur_instr))
                      }
                      _ => Ok(()),
                  }
              }
              _ => Ok(()),
          }
      })
  }
  *)
  Definition check_breaks (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ context; labels ] =>
      ltac:(M.monadic
        (let context := M.alloc (| context |) in
        let labels := M.alloc (| labels |) in
        M.call_closure (|
          M.get_function (|
            "move_bytecode_verifier::control_flow_v5::check_code",
            [
              Ty.function
                [
                  Ty.tuple
                    [
                      Ty.apply
                        (Ty.path "&")
                        []
                        [
                          Ty.apply
                            (Ty.path "alloc::vec::Vec")
                            []
                            [
                              Ty.tuple [ Ty.path "u16"; Ty.path "u16" ];
                              Ty.path "alloc::alloc::Global"
                            ]
                        ];
                      Ty.path "u16";
                      Ty.apply
                        (Ty.path "&")
                        []
                        [ Ty.path "move_binary_format::file_format::Bytecode" ]
                    ]
                ]
                (Ty.apply
                  (Ty.path "core::result::Result")
                  []
                  [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ])
            ]
          |),
          [
            M.read (| context |);
            M.read (| labels |);
            M.closure
              (fun γ =>
                ltac:(M.monadic
                  match γ with
                  | [ α0; α1; α2 ] =>
                    ltac:(M.monadic
                      (M.match_operator (|
                        M.alloc (| α0 |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let loop_stack := M.copy (| γ |) in
                              M.match_operator (|
                                M.alloc (| α1 |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let cur_instr := M.copy (| γ |) in
                                      M.match_operator (|
                                        M.alloc (| α2 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let instr := M.copy (| γ |) in
                                              M.read (|
                                                M.match_operator (|
                                                  instr,
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.find_or_pattern (|
                                                          γ,
                                                          [
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ := M.read (| γ |) in
                                                                let γ1_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "move_binary_format::file_format::Bytecode::Branch",
                                                                    0
                                                                  |) in
                                                                let target := M.alloc (| γ1_0 |) in
                                                                Value.Tuple [ target ]));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ := M.read (| γ |) in
                                                                let γ1_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "move_binary_format::file_format::Bytecode::BrTrue",
                                                                    0
                                                                  |) in
                                                                let target := M.alloc (| γ1_0 |) in
                                                                Value.Tuple [ target ]));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (let γ := M.read (| γ |) in
                                                                let γ1_0 :=
                                                                  M.SubPointer.get_struct_tuple_field (|
                                                                    γ,
                                                                    "move_binary_format::file_format::Bytecode::BrFalse",
                                                                    0
                                                                  |) in
                                                                let target := M.alloc (| γ1_0 |) in
                                                                Value.Tuple [ target ]))
                                                          ],
                                                          M.closure
                                                            (fun γ =>
                                                              ltac:(M.monadic
                                                                match γ with
                                                                | [ target ] =>
                                                                  ltac:(M.monadic
                                                                    (let γ :=
                                                                      M.alloc (|
                                                                        UnOp.not (|
                                                                          M.call_closure (|
                                                                            M.get_function (|
                                                                              "move_bytecode_verifier::control_flow_v5::is_back_edge",
                                                                              []
                                                                            |),
                                                                            [
                                                                              M.read (|
                                                                                cur_instr
                                                                              |);
                                                                              M.read (|
                                                                                M.read (| target |)
                                                                              |)
                                                                            ]
                                                                          |)
                                                                        |)
                                                                      |) in
                                                                    let _ :=
                                                                      M.is_constant_or_break_match (|
                                                                        M.read (| γ |),
                                                                        Value.Bool true
                                                                      |) in
                                                                    M.match_operator (|
                                                                      M.alloc (|
                                                                        M.call_closure (|
                                                                          M.get_associated_function (|
                                                                            Ty.apply
                                                                              (Ty.path "slice")
                                                                              []
                                                                              [
                                                                                Ty.tuple
                                                                                  [
                                                                                    Ty.path "u16";
                                                                                    Ty.path "u16"
                                                                                  ]
                                                                              ],
                                                                            "last",
                                                                            []
                                                                          |),
                                                                          [
                                                                            M.call_closure (|
                                                                              M.get_trait_method (|
                                                                                "core::ops::deref::Deref",
                                                                                Ty.apply
                                                                                  (Ty.path
                                                                                    "alloc::vec::Vec")
                                                                                  []
                                                                                  [
                                                                                    Ty.tuple
                                                                                      [
                                                                                        Ty.path
                                                                                          "u16";
                                                                                        Ty.path
                                                                                          "u16"
                                                                                      ];
                                                                                    Ty.path
                                                                                      "alloc::alloc::Global"
                                                                                  ],
                                                                                [],
                                                                                "deref",
                                                                                []
                                                                              |),
                                                                              [
                                                                                M.read (|
                                                                                  loop_stack
                                                                                |)
                                                                              ]
                                                                            |)
                                                                          ]
                                                                        |)
                                                                      |),
                                                                      [
                                                                        fun γ =>
                                                                          ltac:(M.monadic
                                                                            (let γ0_0 :=
                                                                              M.SubPointer.get_struct_tuple_field (|
                                                                                γ,
                                                                                "core::option::Option::Some",
                                                                                0
                                                                              |) in
                                                                            let γ0_0 :=
                                                                              M.read (| γ0_0 |) in
                                                                            let γ2_0 :=
                                                                              M.SubPointer.get_tuple_field (|
                                                                                γ0_0,
                                                                                0
                                                                              |) in
                                                                            let γ2_1 :=
                                                                              M.SubPointer.get_tuple_field (|
                                                                                γ0_0,
                                                                                1
                                                                              |) in
                                                                            let _cur_loop_head :=
                                                                              M.alloc (| γ2_0 |) in
                                                                            let last_continue :=
                                                                              M.alloc (| γ2_1 |) in
                                                                            let γ :=
                                                                              M.alloc (|
                                                                                M.call_closure (|
                                                                                  M.get_trait_method (|
                                                                                    "core::cmp::PartialOrd",
                                                                                    Ty.apply
                                                                                      (Ty.path "&")
                                                                                      []
                                                                                      [
                                                                                        Ty.path
                                                                                          "u16"
                                                                                      ],
                                                                                    [
                                                                                      Ty.apply
                                                                                        (Ty.path
                                                                                          "&")
                                                                                        []
                                                                                        [
                                                                                          Ty.path
                                                                                            "u16"
                                                                                        ]
                                                                                    ],
                                                                                    "gt",
                                                                                    []
                                                                                  |),
                                                                                  [
                                                                                    target;
                                                                                    M.alloc (|
                                                                                      M.read (|
                                                                                        last_continue
                                                                                      |)
                                                                                    |)
                                                                                  ]
                                                                                |)
                                                                              |) in
                                                                            let _ :=
                                                                              M.is_constant_or_break_match (|
                                                                                M.read (| γ |),
                                                                                Value.Bool true
                                                                              |) in
                                                                            let γ :=
                                                                              M.alloc (|
                                                                                BinOp.ne (|
                                                                                  M.read (|
                                                                                    M.read (|
                                                                                      target
                                                                                    |)
                                                                                  |),
                                                                                  M.call_closure (|
                                                                                    M.get_trait_method (|
                                                                                      "core::ops::arith::Add",
                                                                                      Ty.apply
                                                                                        (Ty.path
                                                                                          "&")
                                                                                        []
                                                                                        [
                                                                                          Ty.path
                                                                                            "u16"
                                                                                        ],
                                                                                      [
                                                                                        Ty.path
                                                                                          "u16"
                                                                                      ],
                                                                                      "add",
                                                                                      []
                                                                                    |),
                                                                                    [
                                                                                      M.read (|
                                                                                        last_continue
                                                                                      |);
                                                                                      Value.Integer
                                                                                        IntegerKind.U16
                                                                                        1
                                                                                    ]
                                                                                  |)
                                                                                |)
                                                                              |) in
                                                                            let _ :=
                                                                              M.is_constant_or_break_match (|
                                                                                M.read (| γ |),
                                                                                Value.Bool true
                                                                              |) in
                                                                            M.alloc (|
                                                                              Value.StructTuple
                                                                                "core::result::Result::Err"
                                                                                [
                                                                                  M.call_closure (|
                                                                                    M.get_associated_function (|
                                                                                      Ty.path
                                                                                        "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                                                                                      "error",
                                                                                      []
                                                                                    |),
                                                                                    [
                                                                                      M.read (|
                                                                                        context
                                                                                      |);
                                                                                      Value.StructTuple
                                                                                        "move_core_types::vm_status::StatusCode::INVALID_LOOP_BREAK"
                                                                                        [];
                                                                                      M.read (|
                                                                                        cur_instr
                                                                                      |)
                                                                                    ]
                                                                                  |)
                                                                                ]
                                                                            |)));
                                                                        fun γ =>
                                                                          ltac:(M.monadic
                                                                            (M.alloc (|
                                                                              Value.StructTuple
                                                                                "core::result::Result::Ok"
                                                                                [ Value.Tuple [] ]
                                                                            |)))
                                                                      ]
                                                                    |)))
                                                                | _ =>
                                                                  M.impossible
                                                                    "wrong number of arguments"
                                                                end))
                                                        |)));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.alloc (|
                                                          Value.StructTuple
                                                            "core::result::Result::Ok"
                                                            [ Value.Tuple [] ]
                                                        |)))
                                                  ]
                                                |)
                                              |)))
                                        ]
                                      |)))
                                ]
                              |)))
                        ]
                      |)))
                  | _ => M.impossible "wrong number of arguments"
                  end))
          ]
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_check_breaks :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::check_breaks" check_breaks.
  
  (*
  fn check_no_loop_splits(
      context: &ControlFlowVerifier,
      labels: &[Label],
      loop_depth: &[usize],
  ) -> PartialVMResult<()> {
      let is_break = |loop_stack: &Vec<(CodeOffset, CodeOffset)>, jump_target: CodeOffset| -> bool {
          match loop_stack.last() {
              None => false,
              Some((_cur_loop_head, last_continue)) => jump_target > *last_continue,
          }
      };
      check_code(context, labels, |loop_stack, i, instr| {
          match instr {
              // Forward jump/"break"
              Bytecode::Branch(j) | Bytecode::BrTrue(j) | Bytecode::BrFalse(j)
                  if *j > i && !is_break(loop_stack, *j) =>
              {
                  let j = *j;
                  let before_depth = loop_depth[i as usize];
                  let after_depth = match &labels[j as usize] {
                      Label::Loop { .. } => loop_depth[j as usize] - 1,
                      Label::Code => loop_depth[j as usize],
                  };
                  if before_depth != after_depth {
                      // Invalid forward jump. Entered the middle of a loop
                      Err(context.error(StatusCode::INVALID_LOOP_SPLIT, i))
                  } else {
                      Ok(())
                  }
              }
              _ => Ok(()),
          }
      })
  }
  *)
  Definition check_no_loop_splits (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ context; labels; loop_depth ] =>
      ltac:(M.monadic
        (let context := M.alloc (| context |) in
        let labels := M.alloc (| labels |) in
        let loop_depth := M.alloc (| loop_depth |) in
        M.read (|
          let~ is_break :=
            M.alloc (|
              M.closure
                (fun γ =>
                  ltac:(M.monadic
                    match γ with
                    | [ α0; α1 ] =>
                      ltac:(M.monadic
                        (M.match_operator (|
                          M.alloc (| α0 |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let loop_stack := M.copy (| γ |) in
                                M.match_operator (|
                                  M.alloc (| α1 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let jump_target := M.copy (| γ |) in
                                        M.read (|
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path "slice")
                                                    []
                                                    [ Ty.tuple [ Ty.path "u16"; Ty.path "u16" ] ],
                                                  "last",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::deref::Deref",
                                                      Ty.apply
                                                        (Ty.path "alloc::vec::Vec")
                                                        []
                                                        [
                                                          Ty.tuple [ Ty.path "u16"; Ty.path "u16" ];
                                                          Ty.path "alloc::alloc::Global"
                                                        ],
                                                      [],
                                                      "deref",
                                                      []
                                                    |),
                                                    [ M.read (| loop_stack |) ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let _ :=
                                                    M.is_struct_tuple (|
                                                      γ,
                                                      "core::option::Option::None"
                                                    |) in
                                                  M.alloc (| Value.Bool false |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::option::Option::Some",
                                                      0
                                                    |) in
                                                  let γ0_0 := M.read (| γ0_0 |) in
                                                  let γ2_0 :=
                                                    M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                                  let γ2_1 :=
                                                    M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                                  let _cur_loop_head := M.alloc (| γ2_0 |) in
                                                  let last_continue := M.alloc (| γ2_1 |) in
                                                  M.alloc (|
                                                    BinOp.gt (|
                                                      M.read (| jump_target |),
                                                      M.read (| M.read (| last_continue |) |)
                                                    |)
                                                  |)))
                                            ]
                                          |)
                                        |)))
                                  ]
                                |)))
                          ]
                        |)))
                    | _ => M.impossible "wrong number of arguments"
                    end))
            |) in
          M.alloc (|
            M.call_closure (|
              M.get_function (|
                "move_bytecode_verifier::control_flow_v5::check_code",
                [
                  Ty.function
                    [
                      Ty.tuple
                        [
                          Ty.apply
                            (Ty.path "&")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::vec::Vec")
                                []
                                [
                                  Ty.tuple [ Ty.path "u16"; Ty.path "u16" ];
                                  Ty.path "alloc::alloc::Global"
                                ]
                            ];
                          Ty.path "u16";
                          Ty.apply
                            (Ty.path "&")
                            []
                            [ Ty.path "move_binary_format::file_format::Bytecode" ]
                        ]
                    ]
                    (Ty.apply
                      (Ty.path "core::result::Result")
                      []
                      [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ])
                ]
              |),
              [
                M.read (| context |);
                M.read (| labels |);
                M.closure
                  (fun γ =>
                    ltac:(M.monadic
                      match γ with
                      | [ α0; α1; α2 ] =>
                        ltac:(M.monadic
                          (M.match_operator (|
                            M.alloc (| α0 |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let loop_stack := M.copy (| γ |) in
                                  M.match_operator (|
                                    M.alloc (| α1 |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let i := M.copy (| γ |) in
                                          M.match_operator (|
                                            M.alloc (| α2 |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let instr := M.copy (| γ |) in
                                                  M.read (|
                                                    M.match_operator (|
                                                      instr,
                                                      [
                                                        fun γ =>
                                                          ltac:(M.monadic
                                                            (M.find_or_pattern (|
                                                              γ,
                                                              [
                                                                fun γ =>
                                                                  ltac:(M.monadic
                                                                    (let γ := M.read (| γ |) in
                                                                    let γ1_0 :=
                                                                      M.SubPointer.get_struct_tuple_field (|
                                                                        γ,
                                                                        "move_binary_format::file_format::Bytecode::Branch",
                                                                        0
                                                                      |) in
                                                                    let j := M.alloc (| γ1_0 |) in
                                                                    Value.Tuple [ j ]));
                                                                fun γ =>
                                                                  ltac:(M.monadic
                                                                    (let γ := M.read (| γ |) in
                                                                    let γ1_0 :=
                                                                      M.SubPointer.get_struct_tuple_field (|
                                                                        γ,
                                                                        "move_binary_format::file_format::Bytecode::BrTrue",
                                                                        0
                                                                      |) in
                                                                    let j := M.alloc (| γ1_0 |) in
                                                                    Value.Tuple [ j ]));
                                                                fun γ =>
                                                                  ltac:(M.monadic
                                                                    (let γ := M.read (| γ |) in
                                                                    let γ1_0 :=
                                                                      M.SubPointer.get_struct_tuple_field (|
                                                                        γ,
                                                                        "move_binary_format::file_format::Bytecode::BrFalse",
                                                                        0
                                                                      |) in
                                                                    let j := M.alloc (| γ1_0 |) in
                                                                    Value.Tuple [ j ]))
                                                              ],
                                                              M.closure
                                                                (fun γ =>
                                                                  ltac:(M.monadic
                                                                    match γ with
                                                                    | [ j ] =>
                                                                      ltac:(M.monadic
                                                                        (let γ :=
                                                                          M.alloc (|
                                                                            BinOp.gt (|
                                                                              M.read (|
                                                                                M.read (| j |)
                                                                              |),
                                                                              M.read (| i |)
                                                                            |)
                                                                          |) in
                                                                        let _ :=
                                                                          M.is_constant_or_break_match (|
                                                                            M.read (| γ |),
                                                                            Value.Bool true
                                                                          |) in
                                                                        let γ :=
                                                                          M.alloc (|
                                                                            UnOp.not (|
                                                                              M.call_closure (|
                                                                                M.get_trait_method (|
                                                                                  "core::ops::function::Fn",
                                                                                  Ty.function
                                                                                    [
                                                                                      Ty.tuple
                                                                                        [
                                                                                          Ty.apply
                                                                                            (Ty.path
                                                                                              "&")
                                                                                            []
                                                                                            [
                                                                                              Ty.apply
                                                                                                (Ty.path
                                                                                                  "alloc::vec::Vec")
                                                                                                []
                                                                                                [
                                                                                                  Ty.tuple
                                                                                                    [
                                                                                                      Ty.path
                                                                                                        "u16";
                                                                                                      Ty.path
                                                                                                        "u16"
                                                                                                    ];
                                                                                                  Ty.path
                                                                                                    "alloc::alloc::Global"
                                                                                                ]
                                                                                            ];
                                                                                          Ty.path
                                                                                            "u16"
                                                                                        ]
                                                                                    ]
                                                                                    (Ty.path
                                                                                      "bool"),
                                                                                  [
                                                                                    Ty.tuple
                                                                                      [
                                                                                        Ty.apply
                                                                                          (Ty.path
                                                                                            "&")
                                                                                          []
                                                                                          [
                                                                                            Ty.apply
                                                                                              (Ty.path
                                                                                                "alloc::vec::Vec")
                                                                                              []
                                                                                              [
                                                                                                Ty.tuple
                                                                                                  [
                                                                                                    Ty.path
                                                                                                      "u16";
                                                                                                    Ty.path
                                                                                                      "u16"
                                                                                                  ];
                                                                                                Ty.path
                                                                                                  "alloc::alloc::Global"
                                                                                              ]
                                                                                          ];
                                                                                        Ty.path
                                                                                          "u16"
                                                                                      ]
                                                                                  ],
                                                                                  "call",
                                                                                  []
                                                                                |),
                                                                                [
                                                                                  is_break;
                                                                                  Value.Tuple
                                                                                    [
                                                                                      M.read (|
                                                                                        loop_stack
                                                                                      |);
                                                                                      M.read (|
                                                                                        M.read (|
                                                                                          j
                                                                                        |)
                                                                                      |)
                                                                                    ]
                                                                                ]
                                                                              |)
                                                                            |)
                                                                          |) in
                                                                        let _ :=
                                                                          M.is_constant_or_break_match (|
                                                                            M.read (| γ |),
                                                                            Value.Bool true
                                                                          |) in
                                                                        let~ j :=
                                                                          M.copy (|
                                                                            M.read (| j |)
                                                                          |) in
                                                                        let~ before_depth :=
                                                                          M.copy (|
                                                                            M.SubPointer.get_array_field (|
                                                                              M.read (|
                                                                                loop_depth
                                                                              |),
                                                                              M.alloc (|
                                                                                M.rust_cast
                                                                                  (M.read (| i |))
                                                                              |)
                                                                            |)
                                                                          |) in
                                                                        let~ after_depth :=
                                                                          M.copy (|
                                                                            M.match_operator (|
                                                                              M.alloc (|
                                                                                M.SubPointer.get_array_field (|
                                                                                  M.read (|
                                                                                    labels
                                                                                  |),
                                                                                  M.alloc (|
                                                                                    M.rust_cast
                                                                                      (M.read (|
                                                                                        j
                                                                                      |))
                                                                                  |)
                                                                                |)
                                                                              |),
                                                                              [
                                                                                fun γ =>
                                                                                  ltac:(M.monadic
                                                                                    (let γ :=
                                                                                      M.read (|
                                                                                        γ
                                                                                      |) in
                                                                                    let _ :=
                                                                                      M.is_struct_tuple (|
                                                                                        γ,
                                                                                        "move_bytecode_verifier::control_flow_v5::Label::Loop"
                                                                                      |) in
                                                                                    M.alloc (|
                                                                                      BinOp.Wrap.sub (|
                                                                                        M.read (|
                                                                                          M.SubPointer.get_array_field (|
                                                                                            M.read (|
                                                                                              loop_depth
                                                                                            |),
                                                                                            M.alloc (|
                                                                                              M.rust_cast
                                                                                                (M.read (|
                                                                                                  j
                                                                                                |))
                                                                                            |)
                                                                                          |)
                                                                                        |),
                                                                                        Value.Integer
                                                                                          IntegerKind.Usize
                                                                                          1
                                                                                      |)
                                                                                    |)));
                                                                                fun γ =>
                                                                                  ltac:(M.monadic
                                                                                    (let γ :=
                                                                                      M.read (|
                                                                                        γ
                                                                                      |) in
                                                                                    let _ :=
                                                                                      M.is_struct_tuple (|
                                                                                        γ,
                                                                                        "move_bytecode_verifier::control_flow_v5::Label::Code"
                                                                                      |) in
                                                                                    M.SubPointer.get_array_field (|
                                                                                      M.read (|
                                                                                        loop_depth
                                                                                      |),
                                                                                      M.alloc (|
                                                                                        M.rust_cast
                                                                                          (M.read (|
                                                                                            j
                                                                                          |))
                                                                                      |)
                                                                                    |)))
                                                                              ]
                                                                            |)
                                                                          |) in
                                                                        M.match_operator (|
                                                                          M.alloc (|
                                                                            Value.Tuple []
                                                                          |),
                                                                          [
                                                                            fun γ =>
                                                                              ltac:(M.monadic
                                                                                (let γ :=
                                                                                  M.use
                                                                                    (M.alloc (|
                                                                                      BinOp.ne (|
                                                                                        M.read (|
                                                                                          before_depth
                                                                                        |),
                                                                                        M.read (|
                                                                                          after_depth
                                                                                        |)
                                                                                      |)
                                                                                    |)) in
                                                                                let _ :=
                                                                                  M.is_constant_or_break_match (|
                                                                                    M.read (| γ |),
                                                                                    Value.Bool true
                                                                                  |) in
                                                                                M.alloc (|
                                                                                  Value.StructTuple
                                                                                    "core::result::Result::Err"
                                                                                    [
                                                                                      M.call_closure (|
                                                                                        M.get_associated_function (|
                                                                                          Ty.path
                                                                                            "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                                                                                          "error",
                                                                                          []
                                                                                        |),
                                                                                        [
                                                                                          M.read (|
                                                                                            context
                                                                                          |);
                                                                                          Value.StructTuple
                                                                                            "move_core_types::vm_status::StatusCode::INVALID_LOOP_SPLIT"
                                                                                            [];
                                                                                          M.read (|
                                                                                            i
                                                                                          |)
                                                                                        ]
                                                                                      |)
                                                                                    ]
                                                                                |)));
                                                                            fun γ =>
                                                                              ltac:(M.monadic
                                                                                (M.alloc (|
                                                                                  Value.StructTuple
                                                                                    "core::result::Result::Ok"
                                                                                    [ Value.Tuple []
                                                                                    ]
                                                                                |)))
                                                                          ]
                                                                        |)))
                                                                    | _ =>
                                                                      M.impossible
                                                                        "wrong number of arguments"
                                                                    end))
                                                            |)));
                                                        fun γ =>
                                                          ltac:(M.monadic
                                                            (M.alloc (|
                                                              Value.StructTuple
                                                                "core::result::Result::Ok"
                                                                [ Value.Tuple [] ]
                                                            |)))
                                                      ]
                                                    |)
                                                  |)))
                                            ]
                                          |)))
                                    ]
                                  |)))
                            ]
                          |)))
                      | _ => M.impossible "wrong number of arguments"
                      end))
              ]
            |)
          |)
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_check_no_loop_splits :
    M.IsFunction
      "move_bytecode_verifier::control_flow_v5::check_no_loop_splits"
      check_no_loop_splits.
  
  (*
  fn check_loop_depth(
      verifier_config: &VerifierConfig,
      context: &ControlFlowVerifier,
      labels: &[Label],
      loop_depth: &[usize],
  ) -> PartialVMResult<()> {
      let max_depth = match verifier_config.max_loop_depth {
          Some(depth) => depth,
          None => return Ok(()),
      };
      check_code(context, labels, |_loop_stack, i, _instr| {
          if loop_depth[i as usize] > max_depth {
              return Err(context.error(StatusCode::LOOP_MAX_DEPTH_REACHED, i));
          }
          Ok(())
      })
  }
  *)
  Definition check_loop_depth (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ verifier_config; context; labels; loop_depth ] =>
      ltac:(M.monadic
        (let verifier_config := M.alloc (| verifier_config |) in
        let context := M.alloc (| context |) in
        let labels := M.alloc (| labels |) in
        let loop_depth := M.alloc (| loop_depth |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ max_depth :=
                M.copy (|
                  M.match_operator (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| verifier_config |),
                      "move_vm_config::verifier::VerifierConfig",
                      "max_loop_depth"
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ0_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "core::option::Option::Some",
                              0
                            |) in
                          let depth := M.copy (| γ0_0 |) in
                          depth));
                      fun γ =>
                        ltac:(M.monadic
                          (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                          M.alloc (|
                            M.never_to_any (|
                              M.read (|
                                M.return_ (|
                                  Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ]
                                |)
                              |)
                            |)
                          |)))
                    ]
                  |)
                |) in
              M.alloc (|
                M.call_closure (|
                  M.get_function (|
                    "move_bytecode_verifier::control_flow_v5::check_code",
                    [
                      Ty.function
                        [
                          Ty.tuple
                            [
                              Ty.apply
                                (Ty.path "&")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::vec::Vec")
                                    []
                                    [
                                      Ty.tuple [ Ty.path "u16"; Ty.path "u16" ];
                                      Ty.path "alloc::alloc::Global"
                                    ]
                                ];
                              Ty.path "u16";
                              Ty.apply
                                (Ty.path "&")
                                []
                                [ Ty.path "move_binary_format::file_format::Bytecode" ]
                            ]
                        ]
                        (Ty.apply
                          (Ty.path "core::result::Result")
                          []
                          [ Ty.tuple []; Ty.path "move_binary_format::errors::PartialVMError" ])
                    ]
                  |),
                  [
                    M.read (| context |);
                    M.read (| labels |);
                    M.closure
                      (fun γ =>
                        ltac:(M.monadic
                          match γ with
                          | [ α0; α1; α2 ] =>
                            ltac:(M.monadic
                              (M.match_operator (|
                                M.alloc (| α0 |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let _loop_stack := M.copy (| γ |) in
                                      M.match_operator (|
                                        M.alloc (| α1 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let i := M.copy (| γ |) in
                                              M.match_operator (|
                                                M.alloc (| α2 |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let _instr := M.copy (| γ |) in
                                                      M.read (|
                                                        let~ _ :=
                                                          M.match_operator (|
                                                            M.alloc (| Value.Tuple [] |),
                                                            [
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ :=
                                                                    M.use
                                                                      (M.alloc (|
                                                                        BinOp.gt (|
                                                                          M.read (|
                                                                            M.SubPointer.get_array_field (|
                                                                              M.read (|
                                                                                loop_depth
                                                                              |),
                                                                              M.alloc (|
                                                                                M.rust_cast
                                                                                  (M.read (| i |))
                                                                              |)
                                                                            |)
                                                                          |),
                                                                          M.read (| max_depth |)
                                                                        |)
                                                                      |)) in
                                                                  let _ :=
                                                                    M.is_constant_or_break_match (|
                                                                      M.read (| γ |),
                                                                      Value.Bool true
                                                                    |) in
                                                                  M.alloc (|
                                                                    M.never_to_any (|
                                                                      M.read (|
                                                                        M.return_ (|
                                                                          Value.StructTuple
                                                                            "core::result::Result::Err"
                                                                            [
                                                                              M.call_closure (|
                                                                                M.get_associated_function (|
                                                                                  Ty.path
                                                                                    "move_bytecode_verifier::control_flow_v5::ControlFlowVerifier",
                                                                                  "error",
                                                                                  []
                                                                                |),
                                                                                [
                                                                                  M.read (|
                                                                                    context
                                                                                  |);
                                                                                  Value.StructTuple
                                                                                    "move_core_types::vm_status::StatusCode::LOOP_MAX_DEPTH_REACHED"
                                                                                    [];
                                                                                  M.read (| i |)
                                                                                ]
                                                                              |)
                                                                            ]
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)));
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (M.alloc (| Value.Tuple [] |)))
                                                            ]
                                                          |) in
                                                        M.alloc (|
                                                          Value.StructTuple
                                                            "core::result::Result::Ok"
                                                            [ Value.Tuple [] ]
                                                        |)
                                                      |)))
                                                ]
                                              |)))
                                        ]
                                      |)))
                                ]
                              |)))
                          | _ => M.impossible "wrong number of arguments"
                          end))
                  ]
                |)
              |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_check_loop_depth :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::check_loop_depth" check_loop_depth.
  
  (*
  fn count_loop_depth(labels: &[Label]) -> Vec<usize> {
      let last_continues: HashSet<CodeOffset> = labels
          .iter()
          .filter_map(|label| match label {
              Label::Loop { last_continue } => Some( *last_continue),
              Label::Code => None,
          })
          .collect();
      let mut count = 0;
      let mut counts = vec![];
      for (idx, label) in labels.iter().enumerate() {
          if let Label::Loop { .. } = label {
              count += 1
          }
          counts.push(count);
          if last_continues.contains(&idx.try_into().unwrap()) {
              count -= 1;
          }
      }
      counts
  }
  *)
  Definition count_loop_depth (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ labels ] =>
      ltac:(M.monadic
        (let labels := M.alloc (| labels |) in
        M.read (|
          let~ last_continues :=
            M.alloc (|
              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::slice::iter::Iter")
                        []
                        [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ];
                      Ty.function
                        [
                          Ty.tuple
                            [
                              Ty.apply
                                (Ty.path "&")
                                []
                                [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                            ]
                        ]
                        (Ty.apply (Ty.path "core::option::Option") [] [ Ty.path "u16" ])
                    ],
                  [],
                  "collect",
                  [
                    Ty.apply
                      (Ty.path "std::collections::hash::set::HashSet")
                      []
                      [ Ty.path "u16"; Ty.path "std::hash::random::RandomState" ]
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply
                        (Ty.path "core::slice::iter::Iter")
                        []
                        [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ],
                      [],
                      "filter_map",
                      [
                        Ty.path "u16";
                        Ty.function
                          [
                            Ty.tuple
                              [
                                Ty.apply
                                  (Ty.path "&")
                                  []
                                  [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                              ]
                          ]
                          (Ty.apply (Ty.path "core::option::Option") [] [ Ty.path "u16" ])
                      ]
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "slice")
                            []
                            [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ],
                          "iter",
                          []
                        |),
                        [ M.read (| labels |) ]
                      |);
                      M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let label := M.copy (| γ |) in
                                        M.read (|
                                          M.match_operator (|
                                            label,
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ := M.read (| γ |) in
                                                  let γ1_0 :=
                                                    M.SubPointer.get_struct_record_field (|
                                                      γ,
                                                      "move_bytecode_verifier::control_flow_v5::Label::Loop",
                                                      "last_continue"
                                                    |) in
                                                  let last_continue := M.alloc (| γ1_0 |) in
                                                  M.alloc (|
                                                    Value.StructTuple
                                                      "core::option::Option::Some"
                                                      [ M.read (| M.read (| last_continue |) |) ]
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ := M.read (| γ |) in
                                                  let _ :=
                                                    M.is_struct_tuple (|
                                                      γ,
                                                      "move_bytecode_verifier::control_flow_v5::Label::Code"
                                                    |) in
                                                  M.alloc (|
                                                    Value.StructTuple
                                                      "core::option::Option::None"
                                                      []
                                                  |)))
                                            ]
                                          |)
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end))
                    ]
                  |)
                ]
              |)
            |) in
          let~ count := M.alloc (| Value.Integer IntegerKind.Usize 0 |) in
          let~ counts :=
            M.alloc (|
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "alloc::vec::Vec")
                    []
                    [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ],
                  "new",
                  []
                |),
                []
              |)
            |) in
          let~ _ :=
            M.use
              (M.match_operator (|
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::collect::IntoIterator",
                      Ty.apply
                        (Ty.path "core::iter::adapters::enumerate::Enumerate")
                        []
                        [
                          Ty.apply
                            (Ty.path "core::slice::iter::Iter")
                            []
                            [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ]
                        ],
                      [],
                      "into_iter",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::iterator::Iterator",
                          Ty.apply
                            (Ty.path "core::slice::iter::Iter")
                            []
                            [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ],
                          [],
                          "enumerate",
                          []
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "slice")
                                []
                                [ Ty.path "move_bytecode_verifier::control_flow_v5::Label" ],
                              "iter",
                              []
                            |),
                            [ M.read (| labels |) ]
                          |)
                        ]
                      |)
                    ]
                  |)
                |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let iter := M.copy (| γ |) in
                      M.loop (|
                        ltac:(M.monadic
                          (let~ _ :=
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::iter::traits::iterator::Iterator",
                                    Ty.apply
                                      (Ty.path "core::iter::adapters::enumerate::Enumerate")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "core::slice::iter::Iter")
                                          []
                                          [ Ty.path "move_bytecode_verifier::control_flow_v5::Label"
                                          ]
                                      ],
                                    [],
                                    "next",
                                    []
                                  |),
                                  [ iter ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let _ :=
                                      M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                    M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::option::Option::Some",
                                        0
                                      |) in
                                    let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                    let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                    let idx := M.copy (| γ1_0 |) in
                                    let label := M.copy (| γ1_1 |) in
                                    let~ _ :=
                                      M.match_operator (|
                                        M.alloc (| Value.Tuple [] |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ := label in
                                              let γ := M.read (| γ |) in
                                              let _ :=
                                                M.is_struct_tuple (|
                                                  γ,
                                                  "move_bytecode_verifier::control_flow_v5::Label::Loop"
                                                |) in
                                              let β := count in
                                              M.write (|
                                                β,
                                                BinOp.Wrap.add (|
                                                  M.read (| β |),
                                                  Value.Integer IntegerKind.Usize 1
                                                |)
                                              |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |) in
                                    let~ _ :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::vec::Vec")
                                              []
                                              [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ],
                                            "push",
                                            []
                                          |),
                                          [ counts; M.read (| count |) ]
                                        |)
                                      |) in
                                    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
                                                          "std::collections::hash::set::HashSet")
                                                        []
                                                        [
                                                          Ty.path "u16";
                                                          Ty.path "std::hash::random::RandomState"
                                                        ],
                                                      "contains",
                                                      [ Ty.path "u16" ]
                                                    |),
                                                    [
                                                      last_continues;
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.apply
                                                              (Ty.path "core::result::Result")
                                                              []
                                                              [
                                                                Ty.path "u16";
                                                                Ty.path
                                                                  "core::num::error::TryFromIntError"
                                                              ],
                                                            "unwrap",
                                                            []
                                                          |),
                                                          [
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::convert::TryInto",
                                                                Ty.path "usize",
                                                                [ Ty.path "u16" ],
                                                                "try_into",
                                                                []
                                                              |),
                                                              [ M.read (| idx |) ]
                                                            |)
                                                          ]
                                                        |)
                                                      |)
                                                    ]
                                                  |)
                                                |)) in
                                            let _ :=
                                              M.is_constant_or_break_match (|
                                                M.read (| γ |),
                                                Value.Bool true
                                              |) in
                                            let~ _ :=
                                              let β := count in
                                              M.write (|
                                                β,
                                                BinOp.Wrap.sub (|
                                                  M.read (| β |),
                                                  Value.Integer IntegerKind.Usize 1
                                                |)
                                              |) in
                                            M.alloc (| Value.Tuple [] |)));
                                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                      ]
                                    |)))
                              ]
                            |) in
                          M.alloc (| Value.Tuple [] |)))
                      |)))
                ]
              |)) in
          counts
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_count_loop_depth :
    M.IsFunction "move_bytecode_verifier::control_flow_v5::count_loop_depth" count_loop_depth.
End control_flow_v5.
