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

Module str.
  Module validations.
    (*
    const fn utf8_first_byte(byte: u8, width: u32) -> u32 {
        (byte & (0x7F >> width)) as u32
    }
    *)
    Definition utf8_first_byte (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ byte; width ] =>
        ltac:(M.monadic
          (let byte := M.alloc (| byte |) in
          let width := M.alloc (| width |) in
          M.rust_cast
            (BinOp.bit_and
              (M.read (| byte |))
              (BinOp.Wrap.shr (| Value.Integer IntegerKind.U8 127, M.read (| width |) |)))))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_utf8_first_byte :
      M.IsFunction "core::str::validations::utf8_first_byte" utf8_first_byte.
    
    (*
    const fn utf8_acc_cont_byte(ch: u32, byte: u8) -> u32 {
        (ch << 6) | (byte & CONT_MASK) as u32
    }
    *)
    Definition utf8_acc_cont_byte (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ ch; byte ] =>
        ltac:(M.monadic
          (let ch := M.alloc (| ch |) in
          let byte := M.alloc (| byte |) in
          BinOp.bit_or
            (BinOp.Wrap.shl (| M.read (| ch |), Value.Integer IntegerKind.I32 6 |))
            (M.rust_cast
              (BinOp.bit_and
                (M.read (| byte |))
                (M.read (| M.get_constant (| "core::str::validations::CONT_MASK" |) |))))))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_utf8_acc_cont_byte :
      M.IsFunction "core::str::validations::utf8_acc_cont_byte" utf8_acc_cont_byte.
    
    (*
    pub(super) const fn utf8_is_cont_byte(byte: u8) -> bool {
        (byte as i8) < -64
    }
    *)
    Definition utf8_is_cont_byte (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ byte ] =>
        ltac:(M.monadic
          (let byte := M.alloc (| byte |) in
          BinOp.lt (| M.rust_cast (M.read (| byte |)), Value.Integer IntegerKind.I8 (-64) |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_utf8_is_cont_byte :
      M.IsFunction "core::str::validations::utf8_is_cont_byte" utf8_is_cont_byte.
    
    (*
    pub unsafe fn next_code_point<'a, I: Iterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> {
        // Decode UTF-8
        let x = *bytes.next()?;
        if x < 128 {
            return Some(x as u32);
        }
    
        // Multibyte case follows
        // Decode from a byte combination out of: [[[x y] z] w]
        // NOTE: Performance is sensitive to the exact formulation here
        let init = utf8_first_byte(x, 2);
        // SAFETY: `bytes` produces an UTF-8-like string,
        // so the iterator must produce a value here.
        let y = unsafe { *bytes.next().unwrap_unchecked() };
        let mut ch = utf8_acc_cont_byte(init, y);
        if x >= 0xE0 {
            // [[x y z] w] case
            // 5th bit in 0xE0 .. 0xEF is always clear, so `init` is still valid
            // SAFETY: `bytes` produces an UTF-8-like string,
            // so the iterator must produce a value here.
            let z = unsafe { *bytes.next().unwrap_unchecked() };
            let y_z = utf8_acc_cont_byte((y & CONT_MASK) as u32, z);
            ch = init << 12 | y_z;
            if x >= 0xF0 {
                // [x y z w] case
                // use only the lower 3 bits of `init`
                // SAFETY: `bytes` produces an UTF-8-like string,
                // so the iterator must produce a value here.
                let w = unsafe { *bytes.next().unwrap_unchecked() };
                ch = (init & 7) << 18 | utf8_acc_cont_byte(y_z, w);
            }
        }
    
        Some(ch)
    }
    *)
    Definition next_code_point (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [ _ as I ], [ bytes ] =>
        ltac:(M.monadic
          (let bytes := M.alloc (| bytes |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let~ x :=
                  M.copy (|
                    M.read (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::option::Option")
                                []
                                [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::iter::traits::iterator::Iterator",
                                  I,
                                  [],
                                  "next",
                                  []
                                |),
                                [ M.read (| bytes |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [ Ty.path "u32" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |)
                  |) in
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                BinOp.lt (| M.read (| x |), Value.Integer IntegerKind.U8 128 |)
                              |)) 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::option::Option::Some"
                                    [ M.rust_cast (M.read (| x |)) ]
                                |)
                              |)
                            |)
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                let~ init :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_function (| "core::str::validations::utf8_first_byte", [] |),
                      [ M.read (| x |); Value.Integer IntegerKind.U32 2 ]
                    |)
                  |) in
                let~ y :=
                  M.copy (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::option::Option")
                          []
                          [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                        "unwrap_unchecked",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::iterator::Iterator",
                            I,
                            [],
                            "next",
                            []
                          |),
                          [ M.read (| bytes |) ]
                        |)
                      ]
                    |)
                  |) in
                let~ ch :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_function (| "core::str::validations::utf8_acc_cont_byte", [] |),
                      [ M.read (| init |); M.read (| y |) ]
                    |)
                  |) in
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                BinOp.ge (| M.read (| x |), Value.Integer IntegerKind.U8 224 |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          let~ z :=
                            M.copy (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "core::option::Option")
                                    []
                                    [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                                  "unwrap_unchecked",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::iter::traits::iterator::Iterator",
                                      I,
                                      [],
                                      "next",
                                      []
                                    |),
                                    [ M.read (| bytes |) ]
                                  |)
                                ]
                              |)
                            |) in
                          let~ y_z :=
                            M.alloc (|
                              M.call_closure (|
                                M.get_function (|
                                  "core::str::validations::utf8_acc_cont_byte",
                                  []
                                |),
                                [
                                  M.rust_cast
                                    (BinOp.bit_and
                                      (M.read (| y |))
                                      (M.read (|
                                        M.get_constant (| "core::str::validations::CONT_MASK" |)
                                      |)));
                                  M.read (| z |)
                                ]
                              |)
                            |) in
                          let~ _ :=
                            M.write (|
                              ch,
                              BinOp.bit_or
                                (BinOp.Wrap.shl (|
                                  M.read (| init |),
                                  Value.Integer IntegerKind.I32 12
                                |))
                                (M.read (| y_z |))
                            |) in
                          M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.use
                                      (M.alloc (|
                                        BinOp.ge (|
                                          M.read (| x |),
                                          Value.Integer IntegerKind.U8 240
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  let~ w :=
                                    M.copy (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                                          "unwrap_unchecked",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::iter::traits::iterator::Iterator",
                                              I,
                                              [],
                                              "next",
                                              []
                                            |),
                                            [ M.read (| bytes |) ]
                                          |)
                                        ]
                                      |)
                                    |) in
                                  let~ _ :=
                                    M.write (|
                                      ch,
                                      BinOp.bit_or
                                        (BinOp.Wrap.shl (|
                                          BinOp.bit_and
                                            (M.read (| init |))
                                            (Value.Integer IntegerKind.U32 7),
                                          Value.Integer IntegerKind.I32 18
                                        |))
                                        (M.call_closure (|
                                          M.get_function (|
                                            "core::str::validations::utf8_acc_cont_byte",
                                            []
                                          |),
                                          [ M.read (| y_z |); M.read (| w |) ]
                                        |))
                                    |) in
                                  M.alloc (| Value.Tuple [] |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                M.alloc (| Value.StructTuple "core::option::Option::Some" [ M.read (| ch |) ] |)
              |)))
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_next_code_point :
      M.IsFunction "core::str::validations::next_code_point" next_code_point.
    
    (*
    pub(super) unsafe fn next_code_point_reverse<'a, I>(bytes: &mut I) -> Option<u32>
    where
        I: DoubleEndedIterator<Item = &'a u8>,
    {
        // Decode UTF-8
        let w = match *bytes.next_back()? {
            next_byte if next_byte < 128 => return Some(next_byte as u32),
            back_byte => back_byte,
        };
    
        // Multibyte case follows
        // Decode from a byte combination out of: [x [y [z w]]]
        let mut ch;
        // SAFETY: `bytes` produces an UTF-8-like string,
        // so the iterator must produce a value here.
        let z = unsafe { *bytes.next_back().unwrap_unchecked() };
        ch = utf8_first_byte(z, 2);
        if utf8_is_cont_byte(z) {
            // SAFETY: `bytes` produces an UTF-8-like string,
            // so the iterator must produce a value here.
            let y = unsafe { *bytes.next_back().unwrap_unchecked() };
            ch = utf8_first_byte(y, 3);
            if utf8_is_cont_byte(y) {
                // SAFETY: `bytes` produces an UTF-8-like string,
                // so the iterator must produce a value here.
                let x = unsafe { *bytes.next_back().unwrap_unchecked() };
                ch = utf8_first_byte(x, 4);
                ch = utf8_acc_cont_byte(ch, y);
            }
            ch = utf8_acc_cont_byte(ch, z);
        }
        ch = utf8_acc_cont_byte(ch, w);
    
        Some(ch)
    }
    *)
    Definition next_code_point_reverse (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [ _ as I ], [ bytes ] =>
        ltac:(M.monadic
          (let bytes := M.alloc (| bytes |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let~ w :=
                  M.copy (|
                    M.match_operator (|
                      M.read (|
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::try_trait::Try",
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::iter::traits::double_ended::DoubleEndedIterator",
                                    I,
                                    [],
                                    "next_back",
                                    []
                                  |),
                                  [ M.read (| bytes |) ]
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Break",
                                    0
                                  |) in
                                let residual := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::try_trait::FromResidual",
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [ Ty.path "u32" ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                []
                                                [ Ty.path "core::convert::Infallible" ]
                                            ],
                                            "from_residual",
                                            []
                                          |),
                                          [ M.read (| residual |) ]
                                        |)
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::ops::control_flow::ControlFlow::Continue",
                                    0
                                  |) in
                                let val := M.copy (| γ0_0 |) in
                                val))
                          ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let next_byte := M.copy (| γ |) in
                            let γ :=
                              M.alloc (|
                                BinOp.lt (|
                                  M.read (| next_byte |),
                                  Value.Integer IntegerKind.U8 128
                                |)
                              |) 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::option::Option::Some"
                                      [ M.rust_cast (M.read (| next_byte |)) ]
                                  |)
                                |)
                              |)
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let back_byte := M.copy (| γ |) in
                            back_byte))
                      ]
                    |)
                  |) in
                let~ ch := M.copy (| Value.DeclaredButUndefined |) in
                let~ z :=
                  M.copy (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::option::Option")
                          []
                          [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                        "unwrap_unchecked",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::double_ended::DoubleEndedIterator",
                            I,
                            [],
                            "next_back",
                            []
                          |),
                          [ M.read (| bytes |) ]
                        |)
                      ]
                    |)
                  |) in
                let~ _ :=
                  M.write (|
                    ch,
                    M.call_closure (|
                      M.get_function (| "core::str::validations::utf8_first_byte", [] |),
                      [ M.read (| z |); Value.Integer IntegerKind.U32 2 ]
                    |)
                  |) in
                let~ _ :=
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "core::str::validations::utf8_is_cont_byte",
                                    []
                                  |),
                                  [ M.read (| z |) ]
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          let~ y :=
                            M.copy (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "core::option::Option")
                                    []
                                    [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                                  "unwrap_unchecked",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::iter::traits::double_ended::DoubleEndedIterator",
                                      I,
                                      [],
                                      "next_back",
                                      []
                                    |),
                                    [ M.read (| bytes |) ]
                                  |)
                                ]
                              |)
                            |) in
                          let~ _ :=
                            M.write (|
                              ch,
                              M.call_closure (|
                                M.get_function (| "core::str::validations::utf8_first_byte", [] |),
                                [ M.read (| y |); Value.Integer IntegerKind.U32 3 ]
                              |)
                            |) in
                          let~ _ :=
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.use
                                        (M.alloc (|
                                          M.call_closure (|
                                            M.get_function (|
                                              "core::str::validations::utf8_is_cont_byte",
                                              []
                                            |),
                                            [ M.read (| y |) ]
                                          |)
                                        |)) in
                                    let _ :=
                                      M.is_constant_or_break_match (|
                                        M.read (| γ |),
                                        Value.Bool true
                                      |) in
                                    let~ x :=
                                      M.copy (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [ Ty.apply (Ty.path "&") [] [ Ty.path "u8" ] ],
                                            "unwrap_unchecked",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::iter::traits::double_ended::DoubleEndedIterator",
                                                I,
                                                [],
                                                "next_back",
                                                []
                                              |),
                                              [ M.read (| bytes |) ]
                                            |)
                                          ]
                                        |)
                                      |) in
                                    let~ _ :=
                                      M.write (|
                                        ch,
                                        M.call_closure (|
                                          M.get_function (|
                                            "core::str::validations::utf8_first_byte",
                                            []
                                          |),
                                          [ M.read (| x |); Value.Integer IntegerKind.U32 4 ]
                                        |)
                                      |) in
                                    let~ _ :=
                                      M.write (|
                                        ch,
                                        M.call_closure (|
                                          M.get_function (|
                                            "core::str::validations::utf8_acc_cont_byte",
                                            []
                                          |),
                                          [ M.read (| ch |); M.read (| y |) ]
                                        |)
                                      |) in
                                    M.alloc (| Value.Tuple [] |)));
                                fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                              ]
                            |) in
                          let~ _ :=
                            M.write (|
                              ch,
                              M.call_closure (|
                                M.get_function (|
                                  "core::str::validations::utf8_acc_cont_byte",
                                  []
                                |),
                                [ M.read (| ch |); M.read (| z |) ]
                              |)
                            |) in
                          M.alloc (| Value.Tuple [] |)));
                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                    ]
                  |) in
                let~ _ :=
                  M.write (|
                    ch,
                    M.call_closure (|
                      M.get_function (| "core::str::validations::utf8_acc_cont_byte", [] |),
                      [ M.read (| ch |); M.read (| w |) ]
                    |)
                  |) in
                M.alloc (| Value.StructTuple "core::option::Option::Some" [ M.read (| ch |) ] |)
              |)))
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_next_code_point_reverse :
      M.IsFunction "core::str::validations::next_code_point_reverse" next_code_point_reverse.
    
    Definition value_NONASCII_MASK : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            M.call_closure (|
              M.get_associated_function (| Ty.path "usize", "repeat_u8", [] |),
              [ Value.Integer IntegerKind.U8 128 ]
            |)
          |))).
    
    (*
    const fn contains_nonascii(x: usize) -> bool {
        (x & NONASCII_MASK) != 0
    }
    *)
    Definition contains_nonascii (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ x ] =>
        ltac:(M.monadic
          (let x := M.alloc (| x |) in
          BinOp.ne (|
            BinOp.bit_and
              (M.read (| x |))
              (M.read (| M.get_constant (| "core::str::validations::NONASCII_MASK" |) |)),
            Value.Integer IntegerKind.Usize 0
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_contains_nonascii :
      M.IsFunction "core::str::validations::contains_nonascii" contains_nonascii.
    
    (*
    pub(super) const fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
        let mut index = 0;
        let len = v.len();
    
        let usize_bytes = mem::size_of::<usize>();
        let ascii_block_size = 2 * usize_bytes;
        let blocks_end = if len >= ascii_block_size { len - ascii_block_size + 1 } else { 0 };
        let align = v.as_ptr().align_offset(usize_bytes);
    
        while index < len {
            let old_offset = index;
            macro_rules! err {
                ($error_len: expr) => {
                    return Err(Utf8Error { valid_up_to: old_offset, error_len: $error_len })
                };
            }
    
            macro_rules! next {
                () => {{
                    index += 1;
                    // we needed data, but there was none: error!
                    if index >= len {
                        err!(None)
                    }
                    v[index]
                }};
            }
    
            let first = v[index];
            if first >= 128 {
                let w = utf8_char_width(first);
                // 2-byte encoding is for codepoints  \u{0080} to  \u{07ff}
                //        first  C2 80        last DF BF
                // 3-byte encoding is for codepoints  \u{0800} to  \u{ffff}
                //        first  E0 A0 80     last EF BF BF
                //   excluding surrogates codepoints  \u{d800} to  \u{dfff}
                //               ED A0 80 to       ED BF BF
                // 4-byte encoding is for codepoints \u{10000} to \u{10ffff}
                //        first  F0 90 80 80  last F4 8F BF BF
                //
                // Use the UTF-8 syntax from the RFC
                //
                // https://tools.ietf.org/html/rfc3629
                // UTF8-1      = %x00-7F
                // UTF8-2      = %xC2-DF UTF8-tail
                // UTF8-3      = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
                //               %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
                // UTF8-4      = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
                //               %xF4 %x80-8F 2( UTF8-tail )
                match w {
                    2 => {
                        if next!() as i8 >= -64 {
                            err!(Some(1))
                        }
                    }
                    3 => {
                        match (first, next!()) {
                            (0xE0, 0xA0..=0xBF)
                            | (0xE1..=0xEC, 0x80..=0xBF)
                            | (0xED, 0x80..=0x9F)
                            | (0xEE..=0xEF, 0x80..=0xBF) => {}
                            _ => err!(Some(1)),
                        }
                        if next!() as i8 >= -64 {
                            err!(Some(2))
                        }
                    }
                    4 => {
                        match (first, next!()) {
                            (0xF0, 0x90..=0xBF) | (0xF1..=0xF3, 0x80..=0xBF) | (0xF4, 0x80..=0x8F) => {}
                            _ => err!(Some(1)),
                        }
                        if next!() as i8 >= -64 {
                            err!(Some(2))
                        }
                        if next!() as i8 >= -64 {
                            err!(Some(3))
                        }
                    }
                    _ => err!(Some(1)),
                }
                index += 1;
            } else {
                // Ascii case, try to skip forward quickly.
                // When the pointer is aligned, read 2 words of data per iteration
                // until we find a word containing a non-ascii byte.
                if align != usize::MAX && align.wrapping_sub(index) % usize_bytes == 0 {
                    let ptr = v.as_ptr();
                    while index < blocks_end {
                        // SAFETY: since `align - index` and `ascii_block_size` are
                        // multiples of `usize_bytes`, `block = ptr.add(index)` is
                        // always aligned with a `usize` so it's safe to dereference
                        // both `block` and `block.add(1)`.
                        unsafe {
                            let block = ptr.add(index) as *const usize;
                            // break if there is a nonascii byte
                            let zu = contains_nonascii( *block);
                            let zv = contains_nonascii( *block.add(1));
                            if zu || zv {
                                break;
                            }
                        }
                        index += ascii_block_size;
                    }
                    // step from the point where the wordwise loop stopped
                    while index < len && v[index] < 128 {
                        index += 1;
                    }
                } else {
                    index += 1;
                }
            }
        }
    
        Ok(())
    }
    *)
    Definition run_utf8_validation (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ v ] =>
        ltac:(M.monadic
          (let v := M.alloc (| v |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let~ index := M.alloc (| Value.Integer IntegerKind.Usize 0 |) in
                let~ len :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                        "len",
                        []
                      |),
                      [ M.read (| v |) ]
                    |)
                  |) in
                let~ usize_bytes :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_function (| "core::mem::size_of", [ Ty.path "usize" ] |),
                      []
                    |)
                  |) in
                let~ ascii_block_size :=
                  M.alloc (|
                    BinOp.Wrap.mul (| Value.Integer IntegerKind.Usize 2, M.read (| usize_bytes |) |)
                  |) in
                let~ blocks_end :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.ge (| M.read (| len |), M.read (| ascii_block_size |) |)
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            M.alloc (|
                              BinOp.Wrap.add (|
                                BinOp.Wrap.sub (|
                                  M.read (| len |),
                                  M.read (| ascii_block_size |)
                                |),
                                Value.Integer IntegerKind.Usize 1
                              |)
                            |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.Usize 0 |)))
                      ]
                    |)
                  |) in
                let~ align :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "*const") [] [ Ty.path "u8" ],
                        "align_offset",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                            "as_ptr",
                            []
                          |),
                          [ M.read (| v |) ]
                        |);
                        M.read (| usize_bytes |)
                      ]
                    |)
                  |) in
                let~ _ :=
                  M.loop (|
                    ltac:(M.monadic
                      (M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    BinOp.lt (| M.read (| index |), M.read (| len |) |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              let~ old_offset := M.copy (| index |) in
                              let~ first :=
                                M.copy (|
                                  M.SubPointer.get_array_field (| M.read (| v |), index |)
                                |) in
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            BinOp.ge (|
                                              M.read (| first |),
                                              Value.Integer IntegerKind.U8 128
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      let~ w :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_function (|
                                              "core::str::validations::utf8_char_width",
                                              []
                                            |),
                                            [ M.read (| first |) ]
                                          |)
                                        |) in
                                      let~ _ :=
                                        M.match_operator (|
                                          w,
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let _ :=
                                                  M.is_constant_or_break_match (|
                                                    M.read (| γ |),
                                                    Value.Integer IntegerKind.Usize 2
                                                  |) in
                                                M.match_operator (|
                                                  M.alloc (| Value.Tuple [] |),
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let γ :=
                                                          M.use
                                                            (M.alloc (|
                                                              BinOp.ge (|
                                                                M.rust_cast
                                                                  (M.read (|
                                                                    let~ _ :=
                                                                      let β := index in
                                                                      M.write (|
                                                                        β,
                                                                        BinOp.Wrap.add (|
                                                                          M.read (| β |),
                                                                          Value.Integer
                                                                            IntegerKind.Usize
                                                                            1
                                                                        |)
                                                                      |) in
                                                                    let~ _ :=
                                                                      M.match_operator (|
                                                                        M.alloc (|
                                                                          Value.Tuple []
                                                                        |),
                                                                        [
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (let γ :=
                                                                                M.use
                                                                                  (M.alloc (|
                                                                                    BinOp.ge (|
                                                                                      M.read (|
                                                                                        index
                                                                                      |),
                                                                                      M.read (|
                                                                                        len
                                                                                      |)
                                                                                    |)
                                                                                  |)) in
                                                                              let _ :=
                                                                                M.is_constant_or_break_match (|
                                                                                  M.read (| γ |),
                                                                                  Value.Bool true
                                                                                |) in
                                                                              M.alloc (|
                                                                                M.never_to_any (|
                                                                                  M.read (|
                                                                                    M.return_ (|
                                                                                      Value.StructTuple
                                                                                        "core::result::Result::Err"
                                                                                        [
                                                                                          Value.StructRecord
                                                                                            "core::str::error::Utf8Error"
                                                                                            [
                                                                                              ("valid_up_to",
                                                                                                M.read (|
                                                                                                  old_offset
                                                                                                |));
                                                                                              ("error_len",
                                                                                                Value.StructTuple
                                                                                                  "core::option::Option::None"
                                                                                                  [])
                                                                                            ]
                                                                                        ]
                                                                                    |)
                                                                                  |)
                                                                                |)
                                                                              |)));
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (M.alloc (|
                                                                                Value.Tuple []
                                                                              |)))
                                                                        ]
                                                                      |) in
                                                                    M.SubPointer.get_array_field (|
                                                                      M.read (| v |),
                                                                      index
                                                                    |)
                                                                  |)),
                                                                Value.Integer IntegerKind.I8 (-64)
                                                              |)
                                                            |)) in
                                                        let _ :=
                                                          M.is_constant_or_break_match (|
                                                            M.read (| γ |),
                                                            Value.Bool true
                                                          |) in
                                                        M.alloc (|
                                                          M.never_to_any (|
                                                            M.read (|
                                                              M.return_ (|
                                                                Value.StructTuple
                                                                  "core::result::Result::Err"
                                                                  [
                                                                    Value.StructRecord
                                                                      "core::str::error::Utf8Error"
                                                                      [
                                                                        ("valid_up_to",
                                                                          M.read (| old_offset |));
                                                                        ("error_len",
                                                                          Value.StructTuple
                                                                            "core::option::Option::Some"
                                                                            [
                                                                              Value.Integer
                                                                                IntegerKind.U8
                                                                                1
                                                                            ])
                                                                      ]
                                                                  ]
                                                              |)
                                                            |)
                                                          |)
                                                        |)));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.alloc (| Value.Tuple [] |)))
                                                  ]
                                                |)));
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let _ :=
                                                  M.is_constant_or_break_match (|
                                                    M.read (| γ |),
                                                    Value.Integer IntegerKind.Usize 3
                                                  |) in
                                                let~ _ :=
                                                  M.match_operator (|
                                                    M.alloc (|
                                                      Value.Tuple
                                                        [
                                                          M.read (| first |);
                                                          M.read (|
                                                            let~ _ :=
                                                              let β := index in
                                                              M.write (|
                                                                β,
                                                                BinOp.Wrap.add (|
                                                                  M.read (| β |),
                                                                  Value.Integer IntegerKind.Usize 1
                                                                |)
                                                              |) in
                                                            let~ _ :=
                                                              M.match_operator (|
                                                                M.alloc (| Value.Tuple [] |),
                                                                [
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (let γ :=
                                                                        M.use
                                                                          (M.alloc (|
                                                                            BinOp.ge (|
                                                                              M.read (| index |),
                                                                              M.read (| len |)
                                                                            |)
                                                                          |)) in
                                                                      let _ :=
                                                                        M.is_constant_or_break_match (|
                                                                          M.read (| γ |),
                                                                          Value.Bool true
                                                                        |) in
                                                                      M.alloc (|
                                                                        M.never_to_any (|
                                                                          M.read (|
                                                                            M.return_ (|
                                                                              Value.StructTuple
                                                                                "core::result::Result::Err"
                                                                                [
                                                                                  Value.StructRecord
                                                                                    "core::str::error::Utf8Error"
                                                                                    [
                                                                                      ("valid_up_to",
                                                                                        M.read (|
                                                                                          old_offset
                                                                                        |));
                                                                                      ("error_len",
                                                                                        Value.StructTuple
                                                                                          "core::option::Option::None"
                                                                                          [])
                                                                                    ]
                                                                                ]
                                                                            |)
                                                                          |)
                                                                        |)
                                                                      |)));
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (M.alloc (|
                                                                        Value.Tuple []
                                                                      |)))
                                                                ]
                                                              |) in
                                                            M.SubPointer.get_array_field (|
                                                              M.read (| v |),
                                                              index
                                                            |)
                                                          |)
                                                        ]
                                                    |),
                                                    [
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.find_or_pattern (|
                                                            γ,
                                                            [
                                                              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 _ :=
                                                                    M.is_constant_or_break_match (|
                                                                      M.read (| γ0_0 |),
                                                                      Value.Integer
                                                                        IntegerKind.U8
                                                                        224
                                                                    |) in
                                                                  Value.Tuple []));
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ0_0 :=
                                                                    M.SubPointer.get_tuple_field (|
                                                                      γ,
                                                                      0
                                                                    |) in
                                                                  let γ0_1 :=
                                                                    M.SubPointer.get_tuple_field (|
                                                                      γ,
                                                                      1
                                                                    |) in
                                                                  Value.Tuple []));
                                                              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 _ :=
                                                                    M.is_constant_or_break_match (|
                                                                      M.read (| γ0_0 |),
                                                                      Value.Integer
                                                                        IntegerKind.U8
                                                                        237
                                                                    |) in
                                                                  Value.Tuple []));
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ0_0 :=
                                                                    M.SubPointer.get_tuple_field (|
                                                                      γ,
                                                                      0
                                                                    |) in
                                                                  let γ0_1 :=
                                                                    M.SubPointer.get_tuple_field (|
                                                                      γ,
                                                                      1
                                                                    |) in
                                                                  Value.Tuple []))
                                                            ],
                                                            M.closure
                                                              (fun γ =>
                                                                ltac:(M.monadic
                                                                  match γ with
                                                                  | [] =>
                                                                    ltac:(M.monadic
                                                                      (M.alloc (|
                                                                        Value.Tuple []
                                                                      |)))
                                                                  | _ =>
                                                                    M.impossible
                                                                      "wrong number of arguments"
                                                                  end))
                                                          |)));
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.alloc (|
                                                            M.never_to_any (|
                                                              M.read (|
                                                                M.return_ (|
                                                                  Value.StructTuple
                                                                    "core::result::Result::Err"
                                                                    [
                                                                      Value.StructRecord
                                                                        "core::str::error::Utf8Error"
                                                                        [
                                                                          ("valid_up_to",
                                                                            M.read (|
                                                                              old_offset
                                                                            |));
                                                                          ("error_len",
                                                                            Value.StructTuple
                                                                              "core::option::Option::Some"
                                                                              [
                                                                                Value.Integer
                                                                                  IntegerKind.U8
                                                                                  1
                                                                              ])
                                                                        ]
                                                                    ]
                                                                |)
                                                              |)
                                                            |)
                                                          |)))
                                                    ]
                                                  |) in
                                                M.match_operator (|
                                                  M.alloc (| Value.Tuple [] |),
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let γ :=
                                                          M.use
                                                            (M.alloc (|
                                                              BinOp.ge (|
                                                                M.rust_cast
                                                                  (M.read (|
                                                                    let~ _ :=
                                                                      let β := index in
                                                                      M.write (|
                                                                        β,
                                                                        BinOp.Wrap.add (|
                                                                          M.read (| β |),
                                                                          Value.Integer
                                                                            IntegerKind.Usize
                                                                            1
                                                                        |)
                                                                      |) in
                                                                    let~ _ :=
                                                                      M.match_operator (|
                                                                        M.alloc (|
                                                                          Value.Tuple []
                                                                        |),
                                                                        [
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (let γ :=
                                                                                M.use
                                                                                  (M.alloc (|
                                                                                    BinOp.ge (|
                                                                                      M.read (|
                                                                                        index
                                                                                      |),
                                                                                      M.read (|
                                                                                        len
                                                                                      |)
                                                                                    |)
                                                                                  |)) in
                                                                              let _ :=
                                                                                M.is_constant_or_break_match (|
                                                                                  M.read (| γ |),
                                                                                  Value.Bool true
                                                                                |) in
                                                                              M.alloc (|
                                                                                M.never_to_any (|
                                                                                  M.read (|
                                                                                    M.return_ (|
                                                                                      Value.StructTuple
                                                                                        "core::result::Result::Err"
                                                                                        [
                                                                                          Value.StructRecord
                                                                                            "core::str::error::Utf8Error"
                                                                                            [
                                                                                              ("valid_up_to",
                                                                                                M.read (|
                                                                                                  old_offset
                                                                                                |));
                                                                                              ("error_len",
                                                                                                Value.StructTuple
                                                                                                  "core::option::Option::None"
                                                                                                  [])
                                                                                            ]
                                                                                        ]
                                                                                    |)
                                                                                  |)
                                                                                |)
                                                                              |)));
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (M.alloc (|
                                                                                Value.Tuple []
                                                                              |)))
                                                                        ]
                                                                      |) in
                                                                    M.SubPointer.get_array_field (|
                                                                      M.read (| v |),
                                                                      index
                                                                    |)
                                                                  |)),
                                                                Value.Integer IntegerKind.I8 (-64)
                                                              |)
                                                            |)) in
                                                        let _ :=
                                                          M.is_constant_or_break_match (|
                                                            M.read (| γ |),
                                                            Value.Bool true
                                                          |) in
                                                        M.alloc (|
                                                          M.never_to_any (|
                                                            M.read (|
                                                              M.return_ (|
                                                                Value.StructTuple
                                                                  "core::result::Result::Err"
                                                                  [
                                                                    Value.StructRecord
                                                                      "core::str::error::Utf8Error"
                                                                      [
                                                                        ("valid_up_to",
                                                                          M.read (| old_offset |));
                                                                        ("error_len",
                                                                          Value.StructTuple
                                                                            "core::option::Option::Some"
                                                                            [
                                                                              Value.Integer
                                                                                IntegerKind.U8
                                                                                2
                                                                            ])
                                                                      ]
                                                                  ]
                                                              |)
                                                            |)
                                                          |)
                                                        |)));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.alloc (| Value.Tuple [] |)))
                                                  ]
                                                |)));
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let _ :=
                                                  M.is_constant_or_break_match (|
                                                    M.read (| γ |),
                                                    Value.Integer IntegerKind.Usize 4
                                                  |) in
                                                let~ _ :=
                                                  M.match_operator (|
                                                    M.alloc (|
                                                      Value.Tuple
                                                        [
                                                          M.read (| first |);
                                                          M.read (|
                                                            let~ _ :=
                                                              let β := index in
                                                              M.write (|
                                                                β,
                                                                BinOp.Wrap.add (|
                                                                  M.read (| β |),
                                                                  Value.Integer IntegerKind.Usize 1
                                                                |)
                                                              |) in
                                                            let~ _ :=
                                                              M.match_operator (|
                                                                M.alloc (| Value.Tuple [] |),
                                                                [
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (let γ :=
                                                                        M.use
                                                                          (M.alloc (|
                                                                            BinOp.ge (|
                                                                              M.read (| index |),
                                                                              M.read (| len |)
                                                                            |)
                                                                          |)) in
                                                                      let _ :=
                                                                        M.is_constant_or_break_match (|
                                                                          M.read (| γ |),
                                                                          Value.Bool true
                                                                        |) in
                                                                      M.alloc (|
                                                                        M.never_to_any (|
                                                                          M.read (|
                                                                            M.return_ (|
                                                                              Value.StructTuple
                                                                                "core::result::Result::Err"
                                                                                [
                                                                                  Value.StructRecord
                                                                                    "core::str::error::Utf8Error"
                                                                                    [
                                                                                      ("valid_up_to",
                                                                                        M.read (|
                                                                                          old_offset
                                                                                        |));
                                                                                      ("error_len",
                                                                                        Value.StructTuple
                                                                                          "core::option::Option::None"
                                                                                          [])
                                                                                    ]
                                                                                ]
                                                                            |)
                                                                          |)
                                                                        |)
                                                                      |)));
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (M.alloc (|
                                                                        Value.Tuple []
                                                                      |)))
                                                                ]
                                                              |) in
                                                            M.SubPointer.get_array_field (|
                                                              M.read (| v |),
                                                              index
                                                            |)
                                                          |)
                                                        ]
                                                    |),
                                                    [
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.find_or_pattern (|
                                                            γ,
                                                            [
                                                              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 _ :=
                                                                    M.is_constant_or_break_match (|
                                                                      M.read (| γ0_0 |),
                                                                      Value.Integer
                                                                        IntegerKind.U8
                                                                        240
                                                                    |) in
                                                                  Value.Tuple []));
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ0_0 :=
                                                                    M.SubPointer.get_tuple_field (|
                                                                      γ,
                                                                      0
                                                                    |) in
                                                                  let γ0_1 :=
                                                                    M.SubPointer.get_tuple_field (|
                                                                      γ,
                                                                      1
                                                                    |) in
                                                                  Value.Tuple []));
                                                              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 _ :=
                                                                    M.is_constant_or_break_match (|
                                                                      M.read (| γ0_0 |),
                                                                      Value.Integer
                                                                        IntegerKind.U8
                                                                        244
                                                                    |) in
                                                                  Value.Tuple []))
                                                            ],
                                                            M.closure
                                                              (fun γ =>
                                                                ltac:(M.monadic
                                                                  match γ with
                                                                  | [] =>
                                                                    ltac:(M.monadic
                                                                      (M.alloc (|
                                                                        Value.Tuple []
                                                                      |)))
                                                                  | _ =>
                                                                    M.impossible
                                                                      "wrong number of arguments"
                                                                  end))
                                                          |)));
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.alloc (|
                                                            M.never_to_any (|
                                                              M.read (|
                                                                M.return_ (|
                                                                  Value.StructTuple
                                                                    "core::result::Result::Err"
                                                                    [
                                                                      Value.StructRecord
                                                                        "core::str::error::Utf8Error"
                                                                        [
                                                                          ("valid_up_to",
                                                                            M.read (|
                                                                              old_offset
                                                                            |));
                                                                          ("error_len",
                                                                            Value.StructTuple
                                                                              "core::option::Option::Some"
                                                                              [
                                                                                Value.Integer
                                                                                  IntegerKind.U8
                                                                                  1
                                                                              ])
                                                                        ]
                                                                    ]
                                                                |)
                                                              |)
                                                            |)
                                                          |)))
                                                    ]
                                                  |) in
                                                let~ _ :=
                                                  M.match_operator (|
                                                    M.alloc (| Value.Tuple [] |),
                                                    [
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (let γ :=
                                                            M.use
                                                              (M.alloc (|
                                                                BinOp.ge (|
                                                                  M.rust_cast
                                                                    (M.read (|
                                                                      let~ _ :=
                                                                        let β := index in
                                                                        M.write (|
                                                                          β,
                                                                          BinOp.Wrap.add (|
                                                                            M.read (| β |),
                                                                            Value.Integer
                                                                              IntegerKind.Usize
                                                                              1
                                                                          |)
                                                                        |) in
                                                                      let~ _ :=
                                                                        M.match_operator (|
                                                                          M.alloc (|
                                                                            Value.Tuple []
                                                                          |),
                                                                          [
                                                                            fun γ =>
                                                                              ltac:(M.monadic
                                                                                (let γ :=
                                                                                  M.use
                                                                                    (M.alloc (|
                                                                                      BinOp.ge (|
                                                                                        M.read (|
                                                                                          index
                                                                                        |),
                                                                                        M.read (|
                                                                                          len
                                                                                        |)
                                                                                      |)
                                                                                    |)) in
                                                                                let _ :=
                                                                                  M.is_constant_or_break_match (|
                                                                                    M.read (| γ |),
                                                                                    Value.Bool true
                                                                                  |) in
                                                                                M.alloc (|
                                                                                  M.never_to_any (|
                                                                                    M.read (|
                                                                                      M.return_ (|
                                                                                        Value.StructTuple
                                                                                          "core::result::Result::Err"
                                                                                          [
                                                                                            Value.StructRecord
                                                                                              "core::str::error::Utf8Error"
                                                                                              [
                                                                                                ("valid_up_to",
                                                                                                  M.read (|
                                                                                                    old_offset
                                                                                                  |));
                                                                                                ("error_len",
                                                                                                  Value.StructTuple
                                                                                                    "core::option::Option::None"
                                                                                                    [])
                                                                                              ]
                                                                                          ]
                                                                                      |)
                                                                                    |)
                                                                                  |)
                                                                                |)));
                                                                            fun γ =>
                                                                              ltac:(M.monadic
                                                                                (M.alloc (|
                                                                                  Value.Tuple []
                                                                                |)))
                                                                          ]
                                                                        |) in
                                                                      M.SubPointer.get_array_field (|
                                                                        M.read (| v |),
                                                                        index
                                                                      |)
                                                                    |)),
                                                                  Value.Integer IntegerKind.I8 (-64)
                                                                |)
                                                              |)) in
                                                          let _ :=
                                                            M.is_constant_or_break_match (|
                                                              M.read (| γ |),
                                                              Value.Bool true
                                                            |) in
                                                          M.alloc (|
                                                            M.never_to_any (|
                                                              M.read (|
                                                                M.return_ (|
                                                                  Value.StructTuple
                                                                    "core::result::Result::Err"
                                                                    [
                                                                      Value.StructRecord
                                                                        "core::str::error::Utf8Error"
                                                                        [
                                                                          ("valid_up_to",
                                                                            M.read (|
                                                                              old_offset
                                                                            |));
                                                                          ("error_len",
                                                                            Value.StructTuple
                                                                              "core::option::Option::Some"
                                                                              [
                                                                                Value.Integer
                                                                                  IntegerKind.U8
                                                                                  2
                                                                              ])
                                                                        ]
                                                                    ]
                                                                |)
                                                              |)
                                                            |)
                                                          |)));
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.alloc (| Value.Tuple [] |)))
                                                    ]
                                                  |) in
                                                M.match_operator (|
                                                  M.alloc (| Value.Tuple [] |),
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let γ :=
                                                          M.use
                                                            (M.alloc (|
                                                              BinOp.ge (|
                                                                M.rust_cast
                                                                  (M.read (|
                                                                    let~ _ :=
                                                                      let β := index in
                                                                      M.write (|
                                                                        β,
                                                                        BinOp.Wrap.add (|
                                                                          M.read (| β |),
                                                                          Value.Integer
                                                                            IntegerKind.Usize
                                                                            1
                                                                        |)
                                                                      |) in
                                                                    let~ _ :=
                                                                      M.match_operator (|
                                                                        M.alloc (|
                                                                          Value.Tuple []
                                                                        |),
                                                                        [
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (let γ :=
                                                                                M.use
                                                                                  (M.alloc (|
                                                                                    BinOp.ge (|
                                                                                      M.read (|
                                                                                        index
                                                                                      |),
                                                                                      M.read (|
                                                                                        len
                                                                                      |)
                                                                                    |)
                                                                                  |)) in
                                                                              let _ :=
                                                                                M.is_constant_or_break_match (|
                                                                                  M.read (| γ |),
                                                                                  Value.Bool true
                                                                                |) in
                                                                              M.alloc (|
                                                                                M.never_to_any (|
                                                                                  M.read (|
                                                                                    M.return_ (|
                                                                                      Value.StructTuple
                                                                                        "core::result::Result::Err"
                                                                                        [
                                                                                          Value.StructRecord
                                                                                            "core::str::error::Utf8Error"
                                                                                            [
                                                                                              ("valid_up_to",
                                                                                                M.read (|
                                                                                                  old_offset
                                                                                                |));
                                                                                              ("error_len",
                                                                                                Value.StructTuple
                                                                                                  "core::option::Option::None"
                                                                                                  [])
                                                                                            ]
                                                                                        ]
                                                                                    |)
                                                                                  |)
                                                                                |)
                                                                              |)));
                                                                          fun γ =>
                                                                            ltac:(M.monadic
                                                                              (M.alloc (|
                                                                                Value.Tuple []
                                                                              |)))
                                                                        ]
                                                                      |) in
                                                                    M.SubPointer.get_array_field (|
                                                                      M.read (| v |),
                                                                      index
                                                                    |)
                                                                  |)),
                                                                Value.Integer IntegerKind.I8 (-64)
                                                              |)
                                                            |)) in
                                                        let _ :=
                                                          M.is_constant_or_break_match (|
                                                            M.read (| γ |),
                                                            Value.Bool true
                                                          |) in
                                                        M.alloc (|
                                                          M.never_to_any (|
                                                            M.read (|
                                                              M.return_ (|
                                                                Value.StructTuple
                                                                  "core::result::Result::Err"
                                                                  [
                                                                    Value.StructRecord
                                                                      "core::str::error::Utf8Error"
                                                                      [
                                                                        ("valid_up_to",
                                                                          M.read (| old_offset |));
                                                                        ("error_len",
                                                                          Value.StructTuple
                                                                            "core::option::Option::Some"
                                                                            [
                                                                              Value.Integer
                                                                                IntegerKind.U8
                                                                                3
                                                                            ])
                                                                      ]
                                                                  ]
                                                              |)
                                                            |)
                                                          |)
                                                        |)));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.alloc (| Value.Tuple [] |)))
                                                  ]
                                                |)));
                                            fun γ =>
                                              ltac:(M.monadic
                                                (M.alloc (|
                                                  M.never_to_any (|
                                                    M.read (|
                                                      M.return_ (|
                                                        Value.StructTuple
                                                          "core::result::Result::Err"
                                                          [
                                                            Value.StructRecord
                                                              "core::str::error::Utf8Error"
                                                              [
                                                                ("valid_up_to",
                                                                  M.read (| old_offset |));
                                                                ("error_len",
                                                                  Value.StructTuple
                                                                    "core::option::Option::Some"
                                                                    [ Value.Integer IntegerKind.U8 1
                                                                    ])
                                                              ]
                                                          ]
                                                      |)
                                                    |)
                                                  |)
                                                |)))
                                          ]
                                        |) in
                                      let~ _ :=
                                        let β := index in
                                        M.write (|
                                          β,
                                          BinOp.Wrap.add (|
                                            M.read (| β |),
                                            Value.Integer IntegerKind.Usize 1
                                          |)
                                        |) in
                                      M.alloc (| Value.Tuple [] |)));
                                  fun γ =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| Value.Tuple [] |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ :=
                                                M.use
                                                  (M.alloc (|
                                                    LogicalOp.and (|
                                                      BinOp.ne (|
                                                        M.read (| align |),
                                                        M.read (|
                                                          M.get_constant (| "core::num::MAX" |)
                                                        |)
                                                      |),
                                                      ltac:(M.monadic
                                                        (BinOp.eq (|
                                                          BinOp.Wrap.rem (|
                                                            M.call_closure (|
                                                              M.get_associated_function (|
                                                                Ty.path "usize",
                                                                "wrapping_sub",
                                                                []
                                                              |),
                                                              [
                                                                M.read (| align |);
                                                                M.read (| index |)
                                                              ]
                                                            |),
                                                            M.read (| usize_bytes |)
                                                          |),
                                                          Value.Integer IntegerKind.Usize 0
                                                        |)))
                                                    |)
                                                  |)) in
                                              let _ :=
                                                M.is_constant_or_break_match (|
                                                  M.read (| γ |),
                                                  Value.Bool true
                                                |) in
                                              let~ ptr :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path "slice")
                                                        []
                                                        [ Ty.path "u8" ],
                                                      "as_ptr",
                                                      []
                                                    |),
                                                    [ M.read (| v |) ]
                                                  |)
                                                |) in
                                              let~ _ :=
                                                M.loop (|
                                                  ltac:(M.monadic
                                                    (M.match_operator (|
                                                      M.alloc (| Value.Tuple [] |),
                                                      [
                                                        fun γ =>
                                                          ltac:(M.monadic
                                                            (let γ :=
                                                              M.use
                                                                (M.alloc (|
                                                                  BinOp.lt (|
                                                                    M.read (| index |),
                                                                    M.read (| blocks_end |)
                                                                  |)
                                                                |)) in
                                                            let _ :=
                                                              M.is_constant_or_break_match (|
                                                                M.read (| γ |),
                                                                Value.Bool true
                                                              |) in
                                                            let~ _ :=
                                                              let~ block :=
                                                                M.alloc (|
                                                                  M.rust_cast
                                                                    (M.call_closure (|
                                                                      M.get_associated_function (|
                                                                        Ty.apply
                                                                          (Ty.path "*const")
                                                                          []
                                                                          [ Ty.path "u8" ],
                                                                        "add",
                                                                        []
                                                                      |),
                                                                      [
                                                                        M.read (| ptr |);
                                                                        M.read (| index |)
                                                                      ]
                                                                    |))
                                                                |) in
                                                              let~ zu :=
                                                                M.alloc (|
                                                                  M.call_closure (|
                                                                    M.get_function (|
                                                                      "core::str::validations::contains_nonascii",
                                                                      []
                                                                    |),
                                                                    [
                                                                      M.read (|
                                                                        M.read (| block |)
                                                                      |)
                                                                    ]
                                                                  |)
                                                                |) in
                                                              let~ zv :=
                                                                M.alloc (|
                                                                  M.call_closure (|
                                                                    M.get_function (|
                                                                      "core::str::validations::contains_nonascii",
                                                                      []
                                                                    |),
                                                                    [
                                                                      M.read (|
                                                                        M.call_closure (|
                                                                          M.get_associated_function (|
                                                                            Ty.apply
                                                                              (Ty.path "*const")
                                                                              []
                                                                              [ Ty.path "usize" ],
                                                                            "add",
                                                                            []
                                                                          |),
                                                                          [
                                                                            M.read (| block |);
                                                                            Value.Integer
                                                                              IntegerKind.Usize
                                                                              1
                                                                          ]
                                                                        |)
                                                                      |)
                                                                    ]
                                                                  |)
                                                                |) in
                                                              M.match_operator (|
                                                                M.alloc (| Value.Tuple [] |),
                                                                [
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (let γ :=
                                                                        M.use
                                                                          (M.alloc (|
                                                                            LogicalOp.or (|
                                                                              M.read (| zu |),
                                                                              ltac:(M.monadic
                                                                                (M.read (| zv |)))
                                                                            |)
                                                                          |)) in
                                                                      let _ :=
                                                                        M.is_constant_or_break_match (|
                                                                          M.read (| γ |),
                                                                          Value.Bool true
                                                                        |) in
                                                                      M.alloc (|
                                                                        M.never_to_any (|
                                                                          M.read (| M.break (||) |)
                                                                        |)
                                                                      |)));
                                                                  fun γ =>
                                                                    ltac:(M.monadic
                                                                      (M.alloc (|
                                                                        Value.Tuple []
                                                                      |)))
                                                                ]
                                                              |) in
                                                            let~ _ :=
                                                              let β := index in
                                                              M.write (|
                                                                β,
                                                                BinOp.Wrap.add (|
                                                                  M.read (| β |),
                                                                  M.read (| ascii_block_size |)
                                                                |)
                                                              |) in
                                                            M.alloc (| Value.Tuple [] |)));
                                                        fun γ =>
                                                          ltac:(M.monadic
                                                            (M.alloc (|
                                                              M.never_to_any (|
                                                                M.read (|
                                                                  let~ _ :=
                                                                    M.alloc (|
                                                                      M.never_to_any (|
                                                                        M.read (| M.break (||) |)
                                                                      |)
                                                                    |) in
                                                                  M.alloc (| Value.Tuple [] |)
                                                                |)
                                                              |)
                                                            |)))
                                                      ]
                                                    |)))
                                                |) in
                                              M.loop (|
                                                ltac:(M.monadic
                                                  (M.match_operator (|
                                                    M.alloc (| Value.Tuple [] |),
                                                    [
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (let γ :=
                                                            M.use
                                                              (M.alloc (|
                                                                LogicalOp.and (|
                                                                  BinOp.lt (|
                                                                    M.read (| index |),
                                                                    M.read (| len |)
                                                                  |),
                                                                  ltac:(M.monadic
                                                                    (BinOp.lt (|
                                                                      M.read (|
                                                                        M.SubPointer.get_array_field (|
                                                                          M.read (| v |),
                                                                          index
                                                                        |)
                                                                      |),
                                                                      Value.Integer
                                                                        IntegerKind.U8
                                                                        128
                                                                    |)))
                                                                |)
                                                              |)) in
                                                          let _ :=
                                                            M.is_constant_or_break_match (|
                                                              M.read (| γ |),
                                                              Value.Bool true
                                                            |) in
                                                          let~ _ :=
                                                            let β := index in
                                                            M.write (|
                                                              β,
                                                              BinOp.Wrap.add (|
                                                                M.read (| β |),
                                                                Value.Integer IntegerKind.Usize 1
                                                              |)
                                                            |) in
                                                          M.alloc (| Value.Tuple [] |)));
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.alloc (|
                                                            M.never_to_any (|
                                                              M.read (|
                                                                let~ _ :=
                                                                  M.alloc (|
                                                                    M.never_to_any (|
                                                                      M.read (| M.break (||) |)
                                                                    |)
                                                                  |) in
                                                                M.alloc (| Value.Tuple [] |)
                                                              |)
                                                            |)
                                                          |)))
                                                    ]
                                                  |)))
                                              |)));
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let~ _ :=
                                                let β := index in
                                                M.write (|
                                                  β,
                                                  BinOp.Wrap.add (|
                                                    M.read (| β |),
                                                    Value.Integer IntegerKind.Usize 1
                                                  |)
                                                |) in
                                              M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |)))
                                ]
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    let~ _ :=
                                      M.alloc (|
                                        M.never_to_any (| M.read (| M.break (||) |) |)
                                      |) in
                                    M.alloc (| Value.Tuple [] |)
                                  |)
                                |)
                              |)))
                        ]
                      |)))
                  |) in
                M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
              |)))
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_run_utf8_validation :
      M.IsFunction "core::str::validations::run_utf8_validation" run_utf8_validation.
    
    Definition value_UTF8_CHAR_WIDTH : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            M.alloc (|
              Value.Array
                [
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 1;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 2;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 3;
                  Value.Integer IntegerKind.U8 4;
                  Value.Integer IntegerKind.U8 4;
                  Value.Integer IntegerKind.U8 4;
                  Value.Integer IntegerKind.U8 4;
                  Value.Integer IntegerKind.U8 4;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0;
                  Value.Integer IntegerKind.U8 0
                ]
            |)
          |))).
    
    (*
    pub const fn utf8_char_width(b: u8) -> usize {
        UTF8_CHAR_WIDTH[b as usize] as usize
    }
    *)
    Definition utf8_char_width (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ b ] =>
        ltac:(M.monadic
          (let b := M.alloc (| b |) in
          M.rust_cast
            (M.read (|
              M.SubPointer.get_array_field (|
                M.read (| M.get_constant (| "core::str::validations::UTF8_CHAR_WIDTH" |) |),
                M.alloc (| M.rust_cast (M.read (| b |)) |)
              |)
            |))))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_utf8_char_width :
      M.IsFunction "core::str::validations::utf8_char_width" utf8_char_width.
    
    Definition value_CONT_MASK : Value.t :=
      M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U8 63 |))).
  End validations.
End str.
