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

Module num.
  Module dec2flt.
    Module parse.
      Definition value_MIN_19DIGIT_INT : Value.t :=
        M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 1000000000000000000 |))).
      
      (*
      fn parse_8digits(mut v: u64) -> u64 {
          const MASK: u64 = 0x0000_00FF_0000_00FF;
          const MUL1: u64 = 0x000F_4240_0000_0064;
          const MUL2: u64 = 0x0000_2710_0000_0001;
          v -= 0x3030_3030_3030_3030;
          v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
          let v1 = (v & MASK).wrapping_mul(MUL1);
          let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
          ((v1.wrapping_add(v2) >> 32) as u32) as u64
      }
      *)
      Definition parse_8digits (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [], [ v ] =>
          ltac:(M.monadic
            (let v := M.alloc (| v |) in
            M.read (|
              let~ _ :=
                let β := v in
                M.write (|
                  β,
                  BinOp.Wrap.sub (|
                    M.read (| β |),
                    Value.Integer IntegerKind.U64 3472328296227680304
                  |)
                |) in
              let~ _ :=
                M.write (|
                  v,
                  BinOp.Wrap.add (|
                    BinOp.Wrap.mul (| M.read (| v |), Value.Integer IntegerKind.U64 10 |),
                    BinOp.Wrap.shr (| M.read (| v |), Value.Integer IntegerKind.I32 8 |)
                  |)
                |) in
              let~ v1 :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (| Ty.path "u64", "wrapping_mul", [] |),
                    [
                      BinOp.bit_and
                        (M.read (| v |))
                        (M.read (|
                          M.get_constant (| "core::num::dec2flt::parse::parse_8digits::MASK" |)
                        |));
                      M.read (|
                        M.get_constant (| "core::num::dec2flt::parse::parse_8digits::MUL1" |)
                      |)
                    ]
                  |)
                |) in
              let~ v2 :=
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (| Ty.path "u64", "wrapping_mul", [] |),
                    [
                      BinOp.bit_and
                        (BinOp.Wrap.shr (| M.read (| v |), Value.Integer IntegerKind.I32 16 |))
                        (M.read (|
                          M.get_constant (| "core::num::dec2flt::parse::parse_8digits::MASK" |)
                        |));
                      M.read (|
                        M.get_constant (| "core::num::dec2flt::parse::parse_8digits::MUL2" |)
                      |)
                    ]
                  |)
                |) in
              M.alloc (|
                M.rust_cast
                  (M.rust_cast
                    (BinOp.Wrap.shr (|
                      M.call_closure (|
                        M.get_associated_function (| Ty.path "u64", "wrapping_add", [] |),
                        [ M.read (| v1 |); M.read (| v2 |) ]
                      |),
                      Value.Integer IntegerKind.I32 32
                    |)))
              |)
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_parse_8digits :
        M.IsFunction "core::num::dec2flt::parse::parse_8digits" parse_8digits.
      
      Module parse_8digits.
        Definition value_MASK : Value.t :=
          M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 1095216660735 |))).
        
        Definition value_MUL1 : Value.t :=
          M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 4294967296000100 |))).
        
        Definition value_MUL2 : Value.t :=
          M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 42949672960001 |))).
      End parse_8digits.
      
      (*
      fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
          // may cause overflows, to be handled later
      
          while s.len() >= 8 {
              let num = s.read_u64();
              if is_8digits(num) {
                  x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
                  s = &s[8..];
              } else {
                  break;
              }
          }
      
          s = s.parse_digits(|digit| {
              x = x.wrapping_mul(10).wrapping_add(digit as _);
          });
      
          (s, x)
      }
      *)
      Definition try_parse_digits (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [], [ s; x ] =>
          ltac:(M.monadic
            (let s := M.alloc (| s |) in
            let x := M.alloc (| x |) in
            M.read (|
              let~ _ :=
                M.loop (|
                  ltac:(M.monadic
                    (M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.ge (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                        "len",
                                        []
                                      |),
                                      [ M.read (| s |) ]
                                    |),
                                    Value.Integer IntegerKind.Usize 8
                                  |)
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            let~ num :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::num::dec2flt::common::ByteSlice",
                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                    [],
                                    "read_u64",
                                    []
                                  |),
                                  [ M.read (| s |) ]
                                |)
                              |) in
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.use
                                        (M.alloc (|
                                          M.call_closure (|
                                            M.get_function (|
                                              "core::num::dec2flt::common::is_8digits",
                                              []
                                            |),
                                            [ M.read (| num |) ]
                                          |)
                                        |)) in
                                    let _ :=
                                      M.is_constant_or_break_match (|
                                        M.read (| γ |),
                                        Value.Bool true
                                      |) in
                                    let~ _ :=
                                      M.write (|
                                        x,
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "u64",
                                            "wrapping_add",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.path "u64",
                                                "wrapping_mul",
                                                []
                                              |),
                                              [
                                                M.read (| x |);
                                                Value.Integer IntegerKind.U64 100000000
                                              ]
                                            |);
                                            M.call_closure (|
                                              M.get_function (|
                                                "core::num::dec2flt::parse::parse_8digits",
                                                []
                                              |),
                                              [ M.read (| num |) ]
                                            |)
                                          ]
                                        |)
                                      |) in
                                    let~ _ :=
                                      M.write (|
                                        s,
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::index::Index",
                                            Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                            [
                                              Ty.apply
                                                (Ty.path "core::ops::range::RangeFrom")
                                                []
                                                [ Ty.path "usize" ]
                                            ],
                                            "index",
                                            []
                                          |),
                                          [
                                            M.read (| s |);
                                            Value.StructRecord
                                              "core::ops::range::RangeFrom"
                                              [ ("start", Value.Integer IntegerKind.Usize 8) ]
                                          ]
                                        |)
                                      |) in
                                    M.alloc (| Value.Tuple [] |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |)))
                              ]
                            |)));
                        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
              let~ _ :=
                M.write (|
                  s,
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::num::dec2flt::common::ByteSlice",
                      Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                      [],
                      "parse_digits",
                      [ Ty.function [ Ty.tuple [ Ty.path "u8" ] ] (Ty.tuple []) ]
                    |),
                    [
                      M.read (| s |);
                      M.closure
                        (fun γ =>
                          ltac:(M.monadic
                            match γ with
                            | [ α0 ] =>
                              ltac:(M.monadic
                                (M.match_operator (|
                                  M.alloc (| α0 |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let digit := M.copy (| γ |) in
                                        M.read (|
                                          let~ _ :=
                                            M.write (|
                                              x,
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.path "u64",
                                                  "wrapping_add",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path "u64",
                                                      "wrapping_mul",
                                                      []
                                                    |),
                                                    [
                                                      M.read (| x |);
                                                      Value.Integer IntegerKind.U64 10
                                                    ]
                                                  |);
                                                  M.rust_cast (M.read (| digit |))
                                                ]
                                              |)
                                            |) in
                                          M.alloc (| Value.Tuple [] |)
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end))
                    ]
                  |)
                |) in
              M.alloc (| Value.Tuple [ M.read (| s |); M.read (| x |) ] |)
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_try_parse_digits :
        M.IsFunction "core::num::dec2flt::parse::try_parse_digits" try_parse_digits.
      
      (*
      fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
          let mut s = *s_ref;
      
          while *x < MIN_19DIGIT_INT {
              if let Some((c, s_next)) = s.split_first() {
                  let digit = c.wrapping_sub(b'0');
      
                  if digit < 10 {
                      *x = ( *x * 10) + digit as u64; // no overflows here
                      s = s_next;
                  } else {
                      break;
                  }
              } else {
                  break;
              }
          }
      
          *s_ref = s;
      }
      *)
      Definition try_parse_19digits (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [], [ s_ref; x ] =>
          ltac:(M.monadic
            (let s_ref := M.alloc (| s_ref |) in
            let x := M.alloc (| x |) in
            M.read (|
              let~ s := M.copy (| M.read (| s_ref |) |) 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 (| M.read (| x |) |),
                                    M.read (|
                                      M.get_constant (|
                                        "core::num::dec2flt::parse::MIN_19DIGIT_INT"
                                      |)
                                    |)
                                  |)
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                            "split_first",
                                            []
                                          |),
                                          [ M.read (| s |) ]
                                        |)
                                      |) in
                                    let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "core::option::Option::Some",
                                        0
                                      |) in
                                    let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                    let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                    let c := M.copy (| γ1_0 |) in
                                    let s_next := M.copy (| γ1_1 |) in
                                    let~ digit :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "u8",
                                            "wrapping_sub",
                                            []
                                          |),
                                          [
                                            M.read (| M.read (| c |) |);
                                            M.read (| UnsupportedLiteral |)
                                          ]
                                        |)
                                      |) in
                                    M.match_operator (|
                                      M.alloc (| Value.Tuple [] |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ :=
                                              M.use
                                                (M.alloc (|
                                                  BinOp.lt (|
                                                    M.read (| digit |),
                                                    Value.Integer IntegerKind.U8 10
                                                  |)
                                                |)) in
                                            let _ :=
                                              M.is_constant_or_break_match (|
                                                M.read (| γ |),
                                                Value.Bool true
                                              |) in
                                            let~ _ :=
                                              M.write (|
                                                M.read (| x |),
                                                BinOp.Wrap.add (|
                                                  BinOp.Wrap.mul (|
                                                    M.read (| M.read (| x |) |),
                                                    Value.Integer IntegerKind.U64 10
                                                  |),
                                                  M.rust_cast (M.read (| digit |))
                                                |)
                                              |) in
                                            let~ _ := M.write (| s, M.read (| s_next |) |) in
                                            M.alloc (| Value.Tuple [] |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (M.alloc (|
                                              M.never_to_any (| M.read (| M.break (||) |) |)
                                            |)))
                                      ]
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |)))
                              ]
                            |)));
                        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
              let~ _ := M.write (| M.read (| s_ref |), M.read (| s |) |) in
              M.alloc (| Value.Tuple [] |)
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_try_parse_19digits :
        M.IsFunction "core::num::dec2flt::parse::try_parse_19digits" try_parse_19digits.
      
      (*
      fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
          let mut exponent = 0i64;
          let mut negative = false;
      
          let mut s = *s_ref;
      
          if let Some((&c, s_next)) = s.split_first() {
              negative = c == b'-';
              if c == b'-' || c == b'+' {
                  s = s_next;
              }
          }
      
          if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
              *s_ref = s.parse_digits(|digit| {
                  // no overflows here, saturate well before overflow
                  if exponent < 0x10000 {
                      exponent = 10 * exponent + digit as i64;
                  }
              });
              if negative { Some(-exponent) } else { Some(exponent) }
          } else {
              *s_ref = s;
              None
          }
      }
      *)
      Definition parse_scientific (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [], [ s_ref ] =>
          ltac:(M.monadic
            (let s_ref := M.alloc (| s_ref |) in
            M.read (|
              let~ exponent := M.alloc (| Value.Integer IntegerKind.I64 0 |) in
              let~ negative := M.alloc (| Value.Bool false |) in
              let~ s := M.copy (| M.read (| s_ref |) |) in
              let~ _ :=
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                "split_first",
                                []
                              |),
                              [ M.read (| s |) ]
                            |)
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                        let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                        let γ1_0 := M.read (| γ1_0 |) in
                        let c := M.copy (| γ1_0 |) in
                        let s_next := M.copy (| γ1_1 |) in
                        let~ _ :=
                          M.write (|
                            negative,
                            BinOp.eq (| M.read (| c |), M.read (| UnsupportedLiteral |) |)
                          |) in
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      LogicalOp.or (|
                                        BinOp.eq (|
                                          M.read (| c |),
                                          M.read (| UnsupportedLiteral |)
                                        |),
                                        ltac:(M.monadic
                                          (BinOp.eq (|
                                            M.read (| c |),
                                            M.read (| UnsupportedLiteral |)
                                          |)))
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                let~ _ := M.write (| s, M.read (| s_next |) |) in
                                M.alloc (| Value.Tuple [] |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              M.match_operator (|
                M.alloc (| Value.Tuple [] |),
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ :=
                        M.use
                          (M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                  "first",
                                  []
                                |),
                                [ M.read (| s |) ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::option::Option::Some",
                                      0
                                    |) in
                                  let γ0_0 := M.read (| γ0_0 |) in
                                  let x := M.copy (| γ0_0 |) in
                                  let γ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "u8",
                                          "is_ascii_digit",
                                          []
                                        |),
                                        [ x ]
                                      |)
                                    |) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (| Value.Bool true |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Bool false |)))
                            ]
                          |)) in
                      let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                      let~ _ :=
                        M.write (|
                          M.read (| s_ref |),
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::num::dec2flt::common::ByteSlice",
                              Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                              [],
                              "parse_digits",
                              [ Ty.function [ Ty.tuple [ Ty.path "u8" ] ] (Ty.tuple []) ]
                            |),
                            [
                              M.read (| s |);
                              M.closure
                                (fun γ =>
                                  ltac:(M.monadic
                                    match γ with
                                    | [ α0 ] =>
                                      ltac:(M.monadic
                                        (M.match_operator (|
                                          M.alloc (| α0 |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let digit := M.copy (| γ |) in
                                                M.read (|
                                                  M.match_operator (|
                                                    M.alloc (| Value.Tuple [] |),
                                                    [
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (let γ :=
                                                            M.use
                                                              (M.alloc (|
                                                                BinOp.lt (|
                                                                  M.read (| exponent |),
                                                                  Value.Integer
                                                                    IntegerKind.I64
                                                                    65536
                                                                |)
                                                              |)) in
                                                          let _ :=
                                                            M.is_constant_or_break_match (|
                                                              M.read (| γ |),
                                                              Value.Bool true
                                                            |) in
                                                          let~ _ :=
                                                            M.write (|
                                                              exponent,
                                                              BinOp.Wrap.add (|
                                                                BinOp.Wrap.mul (|
                                                                  Value.Integer IntegerKind.I64 10,
                                                                  M.read (| exponent |)
                                                                |),
                                                                M.rust_cast (M.read (| digit |))
                                                              |)
                                                            |) in
                                                          M.alloc (| Value.Tuple [] |)));
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.alloc (| Value.Tuple [] |)))
                                                    ]
                                                  |)
                                                |)))
                                          ]
                                        |)))
                                    | _ => M.impossible "wrong number of arguments"
                                    end))
                            ]
                          |)
                        |) in
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ := M.use negative in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [ UnOp.neg (| M.read (| exponent |) |) ]
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (M.alloc (|
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [ M.read (| exponent |) ]
                              |)))
                        ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (let~ _ := M.write (| M.read (| s_ref |), M.read (| s |) |) in
                      M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                ]
              |)
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_parse_scientific :
        M.IsFunction "core::num::dec2flt::parse::parse_scientific" parse_scientific.
      
      (*
      fn parse_partial_number(mut s: &[u8]) -> Option<(Number, usize)> {
          debug_assert!(!s.is_empty());
      
          // parse initial digits before dot
          let mut mantissa = 0_u64;
          let start = s;
          let tmp = try_parse_digits(s, mantissa);
          s = tmp.0;
          mantissa = tmp.1;
          let mut n_digits = s.offset_from(start);
      
          // handle dot with the following digits
          let mut n_after_dot = 0;
          let mut exponent = 0_i64;
          let int_end = s;
      
          if let Some((&b'.', s_next)) = s.split_first() {
              s = s_next;
              let before = s;
              let tmp = try_parse_digits(s, mantissa);
              s = tmp.0;
              mantissa = tmp.1;
              n_after_dot = s.offset_from(before);
              exponent = -n_after_dot as i64;
          }
      
          n_digits += n_after_dot;
          if n_digits == 0 {
              return None;
          }
      
          // handle scientific format
          let mut exp_number = 0_i64;
          if let Some((&c, s_next)) = s.split_first() {
              if c == b'e' || c == b'E' {
                  s = s_next;
                  // If None, we have no trailing digits after exponent, or an invalid float.
                  exp_number = parse_scientific(&mut s)?;
                  exponent += exp_number;
              }
          }
      
          let len = s.offset_from(start) as _;
      
          // handle uncommon case with many digits
          if n_digits <= 19 {
              return Some((Number { exponent, mantissa, negative: false, many_digits: false }, len));
          }
      
          n_digits -= 19;
          let mut many_digits = false;
          let mut p = start;
          while let Some((&c, p_next)) = p.split_first() {
              if c == b'.' || c == b'0' {
                  n_digits -= c.saturating_sub(b'0' - 1) as isize;
                  p = p_next;
              } else {
                  break;
              }
          }
          if n_digits > 0 {
              // at this point we have more than 19 significant digits, let's try again
              many_digits = true;
              mantissa = 0;
              let mut s = start;
              try_parse_19digits(&mut s, &mut mantissa);
              exponent = if mantissa >= MIN_19DIGIT_INT {
                  // big int
                  int_end.offset_from(s)
              } else {
                  s = &s[1..];
                  let before = s;
                  try_parse_19digits(&mut s, &mut mantissa);
                  -s.offset_from(before)
              } as i64;
              // add back the explicit part
              exponent += exp_number;
          }
      
          Some((Number { exponent, mantissa, negative: false, many_digits }, len))
      }
      *)
      Definition parse_partial_number (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [], [ s ] =>
          ltac:(M.monadic
            (let s := M.alloc (| s |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ := M.use (M.alloc (| Value.Bool true |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            let~ _ :=
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            UnOp.not (|
                                              UnOp.not (|
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                                    "is_empty",
                                                    []
                                                  |),
                                                  [ M.read (| s |) ]
                                                |)
                                              |)
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.call_closure (|
                                            M.get_function (| "core::panicking::panic", [] |),
                                            [
                                              M.read (|
                                                Value.String "assertion failed: !s.is_empty()"
                                              |)
                                            ]
                                          |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            M.alloc (| Value.Tuple [] |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  let~ mantissa := M.alloc (| Value.Integer IntegerKind.U64 0 |) in
                  let~ start := M.copy (| s |) in
                  let~ tmp :=
                    M.alloc (|
                      M.call_closure (|
                        M.get_function (| "core::num::dec2flt::parse::try_parse_digits", [] |),
                        [ M.read (| s |); M.read (| mantissa |) ]
                      |)
                    |) in
                  let~ _ :=
                    M.write (| s, M.read (| M.SubPointer.get_tuple_field (| tmp, 0 |) |) |) in
                  let~ _ :=
                    M.write (|
                      mantissa,
                      M.read (| M.SubPointer.get_tuple_field (| tmp, 1 |) |)
                    |) in
                  let~ n_digits :=
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::num::dec2flt::common::ByteSlice",
                          Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                          [],
                          "offset_from",
                          []
                        |),
                        [ M.read (| s |); M.read (| start |) ]
                      |)
                    |) in
                  let~ n_after_dot := M.alloc (| Value.Integer IntegerKind.Isize 0 |) in
                  let~ exponent := M.alloc (| Value.Integer IntegerKind.I64 0 |) in
                  let~ int_end := M.copy (| s |) in
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                    "split_first",
                                    []
                                  |),
                                  [ M.read (| s |) ]
                                |)
                              |) in
                            let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::option::Option::Some",
                                0
                              |) in
                            let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                            let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                            let γ1_0 := M.read (| γ1_0 |) in
                            let _ :=
                              M.is_constant_or_break_match (|
                                M.read (| γ1_0 |),
                                Value.Integer IntegerKind.U8 46
                              |) in
                            let s_next := M.copy (| γ1_1 |) in
                            let~ _ := M.write (| s, M.read (| s_next |) |) in
                            let~ before := M.copy (| s |) in
                            let~ tmp :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "core::num::dec2flt::parse::try_parse_digits",
                                    []
                                  |),
                                  [ M.read (| s |); M.read (| mantissa |) ]
                                |)
                              |) in
                            let~ _ :=
                              M.write (|
                                s,
                                M.read (| M.SubPointer.get_tuple_field (| tmp, 0 |) |)
                              |) in
                            let~ _ :=
                              M.write (|
                                mantissa,
                                M.read (| M.SubPointer.get_tuple_field (| tmp, 1 |) |)
                              |) in
                            let~ _ :=
                              M.write (|
                                n_after_dot,
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::num::dec2flt::common::ByteSlice",
                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                    [],
                                    "offset_from",
                                    []
                                  |),
                                  [ M.read (| s |); M.read (| before |) ]
                                |)
                              |) in
                            let~ _ :=
                              M.write (|
                                exponent,
                                M.rust_cast (UnOp.neg (| M.read (| n_after_dot |) |))
                              |) in
                            M.alloc (| Value.Tuple [] |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  let~ _ :=
                    let β := n_digits in
                    M.write (|
                      β,
                      BinOp.Wrap.add (| M.read (| β |), M.read (| n_after_dot |) |)
                    |) in
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.eq (|
                                    M.read (| n_digits |),
                                    Value.Integer IntegerKind.Isize 0
                                  |)
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  M.return_ (| Value.StructTuple "core::option::Option::None" [] |)
                                |)
                              |)
                            |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  let~ exp_number := M.alloc (| Value.Integer IntegerKind.I64 0 |) in
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                    "split_first",
                                    []
                                  |),
                                  [ M.read (| s |) ]
                                |)
                              |) in
                            let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::option::Option::Some",
                                0
                              |) in
                            let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                            let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                            let γ1_0 := M.read (| γ1_0 |) in
                            let c := M.copy (| γ1_0 |) in
                            let s_next := M.copy (| γ1_1 |) in
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.use
                                        (M.alloc (|
                                          LogicalOp.or (|
                                            BinOp.eq (|
                                              M.read (| c |),
                                              M.read (| UnsupportedLiteral |)
                                            |),
                                            ltac:(M.monadic
                                              (BinOp.eq (|
                                                M.read (| c |),
                                                M.read (| UnsupportedLiteral |)
                                              |)))
                                          |)
                                        |)) in
                                    let _ :=
                                      M.is_constant_or_break_match (|
                                        M.read (| γ |),
                                        Value.Bool true
                                      |) in
                                    let~ _ := M.write (| s, M.read (| s_next |) |) in
                                    let~ _ :=
                                      M.write (|
                                        exp_number,
                                        M.read (|
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::Try",
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [ Ty.path "i64" ],
                                                  [],
                                                  "branch",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_function (|
                                                      "core::num::dec2flt::parse::parse_scientific",
                                                      []
                                                    |),
                                                    [ s ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              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.tuple
                                                                    [
                                                                      Ty.path
                                                                        "core::num::dec2flt::number::Number";
                                                                      Ty.path "usize"
                                                                    ]
                                                                ],
                                                              [
                                                                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~ _ :=
                                      let β := exponent in
                                      M.write (|
                                        β,
                                        BinOp.Wrap.add (| M.read (| β |), M.read (| exp_number |) |)
                                      |) in
                                    M.alloc (| Value.Tuple [] |)));
                                fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                              ]
                            |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  let~ len :=
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_trait_method (|
                            "core::num::dec2flt::common::ByteSlice",
                            Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                            [],
                            "offset_from",
                            []
                          |),
                          [ M.read (| s |); M.read (| start |) ]
                        |))
                    |) in
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.le (|
                                    M.read (| n_digits |),
                                    Value.Integer IntegerKind.Isize 19
                                  |)
                                |)) 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"
                                      [
                                        Value.Tuple
                                          [
                                            Value.StructRecord
                                              "core::num::dec2flt::number::Number"
                                              [
                                                ("exponent", M.read (| exponent |));
                                                ("mantissa", M.read (| mantissa |));
                                                ("negative", Value.Bool false);
                                                ("many_digits", Value.Bool false)
                                              ];
                                            M.read (| len |)
                                          ]
                                      ]
                                  |)
                                |)
                              |)
                            |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  let~ _ :=
                    let β := n_digits in
                    M.write (|
                      β,
                      BinOp.Wrap.sub (| M.read (| β |), Value.Integer IntegerKind.Isize 19 |)
                    |) in
                  let~ many_digits := M.alloc (| Value.Bool false |) in
                  let~ p := M.copy (| start |) in
                  let~ _ :=
                    M.loop (|
                      ltac:(M.monadic
                        (M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                        "split_first",
                                        []
                                      |),
                                      [ M.read (| p |) ]
                                    |)
                                  |) in
                                let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                                let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                                let γ1_0 := M.read (| γ1_0 |) in
                                let c := M.copy (| γ1_0 |) in
                                let p_next := M.copy (| γ1_1 |) in
                                M.match_operator (|
                                  M.alloc (| Value.Tuple [] |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ :=
                                          M.use
                                            (M.alloc (|
                                              LogicalOp.or (|
                                                BinOp.eq (|
                                                  M.read (| c |),
                                                  M.read (| UnsupportedLiteral |)
                                                |),
                                                ltac:(M.monadic
                                                  (BinOp.eq (|
                                                    M.read (| c |),
                                                    M.read (| UnsupportedLiteral |)
                                                  |)))
                                              |)
                                            |)) in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        let~ _ :=
                                          let β := n_digits in
                                          M.write (|
                                            β,
                                            BinOp.Wrap.sub (|
                                              M.read (| β |),
                                              M.rust_cast
                                                (M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.path "u8",
                                                    "saturating_sub",
                                                    []
                                                  |),
                                                  [
                                                    M.read (| c |);
                                                    BinOp.Wrap.sub (|
                                                      M.read (| UnsupportedLiteral |),
                                                      Value.Integer IntegerKind.U8 1
                                                    |)
                                                  ]
                                                |))
                                            |)
                                          |) in
                                        let~ _ := M.write (| p, M.read (| p_next |) |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (M.alloc (|
                                          M.never_to_any (| M.read (| M.break (||) |) |)
                                        |)))
                                  ]
                                |)));
                            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
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.gt (|
                                    M.read (| n_digits |),
                                    Value.Integer IntegerKind.Isize 0
                                  |)
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            let~ _ := M.write (| many_digits, Value.Bool true |) in
                            let~ _ := M.write (| mantissa, Value.Integer IntegerKind.U64 0 |) in
                            let~ s := M.copy (| start |) in
                            let~ _ :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "core::num::dec2flt::parse::try_parse_19digits",
                                    []
                                  |),
                                  [ s; mantissa ]
                                |)
                              |) in
                            let~ _ :=
                              M.write (|
                                exponent,
                                M.rust_cast
                                  (M.read (|
                                    M.match_operator (|
                                      M.alloc (| Value.Tuple [] |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ :=
                                              M.use
                                                (M.alloc (|
                                                  BinOp.ge (|
                                                    M.read (| mantissa |),
                                                    M.read (|
                                                      M.get_constant (|
                                                        "core::num::dec2flt::parse::MIN_19DIGIT_INT"
                                                      |)
                                                    |)
                                                  |)
                                                |)) in
                                            let _ :=
                                              M.is_constant_or_break_match (|
                                                M.read (| γ |),
                                                Value.Bool true
                                              |) in
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::num::dec2flt::common::ByteSlice",
                                                  Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                                  [],
                                                  "offset_from",
                                                  []
                                                |),
                                                [ M.read (| int_end |); M.read (| s |) ]
                                              |)
                                            |)));
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let~ _ :=
                                              M.write (|
                                                s,
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::index::Index",
                                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                                    [
                                                      Ty.apply
                                                        (Ty.path "core::ops::range::RangeFrom")
                                                        []
                                                        [ Ty.path "usize" ]
                                                    ],
                                                    "index",
                                                    []
                                                  |),
                                                  [
                                                    M.read (| s |);
                                                    Value.StructRecord
                                                      "core::ops::range::RangeFrom"
                                                      [ ("start", Value.Integer IntegerKind.Usize 1)
                                                      ]
                                                  ]
                                                |)
                                              |) in
                                            let~ before := M.copy (| s |) in
                                            let~ _ :=
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_function (|
                                                    "core::num::dec2flt::parse::try_parse_19digits",
                                                    []
                                                  |),
                                                  [ s; mantissa ]
                                                |)
                                              |) in
                                            M.alloc (|
                                              UnOp.neg (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::num::dec2flt::common::ByteSlice",
                                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                                    [],
                                                    "offset_from",
                                                    []
                                                  |),
                                                  [ M.read (| s |); M.read (| before |) ]
                                                |)
                                              |)
                                            |)))
                                      ]
                                    |)
                                  |))
                              |) in
                            let~ _ :=
                              let β := exponent in
                              M.write (|
                                β,
                                BinOp.Wrap.add (| M.read (| β |), M.read (| exp_number |) |)
                              |) in
                            M.alloc (| Value.Tuple [] |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::option::Option::Some"
                      [
                        Value.Tuple
                          [
                            Value.StructRecord
                              "core::num::dec2flt::number::Number"
                              [
                                ("exponent", M.read (| exponent |));
                                ("mantissa", M.read (| mantissa |));
                                ("negative", Value.Bool false);
                                ("many_digits", M.read (| many_digits |))
                              ];
                            M.read (| len |)
                          ]
                      ]
                  |)
                |)))
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_parse_partial_number :
        M.IsFunction "core::num::dec2flt::parse::parse_partial_number" parse_partial_number.
      
      (*
      pub fn parse_number(s: &[u8]) -> Option<Number> {
          if let Some((float, rest)) = parse_partial_number(s) {
              if rest == s.len() {
                  return Some(float);
              }
          }
          None
      }
      *)
      Definition parse_number (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [], [ s ] =>
          ltac:(M.monadic
            (let s := M.alloc (| s |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "core::num::dec2flt::parse::parse_partial_number",
                                    []
                                  |),
                                  [ M.read (| s |) ]
                                |)
                              |) in
                            let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::option::Option::Some",
                                0
                              |) in
                            let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                            let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                            let float := M.copy (| γ1_0 |) in
                            let rest := M.copy (| γ1_1 |) in
                            M.match_operator (|
                              M.alloc (| Value.Tuple [] |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ :=
                                      M.use
                                        (M.alloc (|
                                          BinOp.eq (|
                                            M.read (| rest |),
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                                "len",
                                                []
                                              |),
                                              [ M.read (| s |) ]
                                            |)
                                          |)
                                        |)) 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.read (| float |) ]
                                          |)
                                        |)
                                      |)
                                    |)));
                                fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                              ]
                            |)));
                        fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                      ]
                    |) in
                  M.alloc (| Value.StructTuple "core::option::Option::None" [] |)
                |)))
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_parse_number :
        M.IsFunction "core::num::dec2flt::parse::parse_number" parse_number.
      
      (*
      pub(crate) fn parse_inf_nan<F: RawFloat>(s: &[u8], negative: bool) -> Option<F> {
          // Since a valid string has at most the length 8, we can load
          // all relevant characters into a u64 and work from there.
          // This also generates much better code.
      
          let mut register;
          let len: usize;
      
          // All valid strings are either of length 8 or 3.
          if s.len() == 8 {
              register = s.read_u64();
              len = 8;
          } else if s.len() == 3 {
              let a = s[0] as u64;
              let b = s[1] as u64;
              let c = s[2] as u64;
              register = (c << 16) | (b << 8) | a;
              len = 3;
          } else {
              return None;
          }
      
          // Clear out the bits which turn ASCII uppercase characters into
          // lowercase characters. The resulting string is all uppercase.
          // What happens to other characters is irrelevant.
          register &= 0xDFDFDFDFDFDFDFDF;
      
          // u64 values corresponding to relevant cases
          const INF_3: u64 = 0x464E49; // "INF"
          const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
          const NAN: u64 = 0x4E414E; // "NAN"
      
          // Match register value to constant to parse string.
          // Also match on the string length to catch edge cases
          // like "inf\0\0\0\0\0".
          let float = match (register, len) {
              (INF_3, 3) => F::INFINITY,
              (INF_8, 8) => F::INFINITY,
              (NAN, 3) => F::NAN,
              _ => return None,
          };
      
          if negative { Some(-float) } else { Some(float) }
      }
      *)
      Definition parse_inf_nan (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ F ], [ s; negative ] =>
          ltac:(M.monadic
            (let s := M.alloc (| s |) in
            let negative := M.alloc (| negative |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let~ register := M.copy (| Value.DeclaredButUndefined |) in
                  let~ len := M.copy (| Value.DeclaredButUndefined |) in
                  let~ _ :=
                    M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.eq (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                        "len",
                                        []
                                      |),
                                      [ M.read (| s |) ]
                                    |),
                                    Value.Integer IntegerKind.Usize 8
                                  |)
                                |)) in
                            let _ :=
                              M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                            let~ _ :=
                              M.write (|
                                register,
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::num::dec2flt::common::ByteSlice",
                                    Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                    [],
                                    "read_u64",
                                    []
                                  |),
                                  [ M.read (| s |) ]
                                |)
                              |) in
                            let~ _ := M.write (| len, Value.Integer IntegerKind.Usize 8 |) 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 (|
                                          BinOp.eq (|
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                                "len",
                                                []
                                              |),
                                              [ M.read (| s |) ]
                                            |),
                                            Value.Integer IntegerKind.Usize 3
                                          |)
                                        |)) in
                                    let _ :=
                                      M.is_constant_or_break_match (|
                                        M.read (| γ |),
                                        Value.Bool true
                                      |) in
                                    let~ a :=
                                      M.alloc (|
                                        M.rust_cast
                                          (M.read (|
                                            M.SubPointer.get_array_field (|
                                              M.read (| s |),
                                              M.alloc (| Value.Integer IntegerKind.Usize 0 |)
                                            |)
                                          |))
                                      |) in
                                    let~ b :=
                                      M.alloc (|
                                        M.rust_cast
                                          (M.read (|
                                            M.SubPointer.get_array_field (|
                                              M.read (| s |),
                                              M.alloc (| Value.Integer IntegerKind.Usize 1 |)
                                            |)
                                          |))
                                      |) in
                                    let~ c :=
                                      M.alloc (|
                                        M.rust_cast
                                          (M.read (|
                                            M.SubPointer.get_array_field (|
                                              M.read (| s |),
                                              M.alloc (| Value.Integer IntegerKind.Usize 2 |)
                                            |)
                                          |))
                                      |) in
                                    let~ _ :=
                                      M.write (|
                                        register,
                                        BinOp.bit_or
                                          (BinOp.bit_or
                                            (BinOp.Wrap.shl (|
                                              M.read (| c |),
                                              Value.Integer IntegerKind.I32 16
                                            |))
                                            (BinOp.Wrap.shl (|
                                              M.read (| b |),
                                              Value.Integer IntegerKind.I32 8
                                            |)))
                                          (M.read (| a |))
                                      |) in
                                    let~ _ :=
                                      M.write (| len, Value.Integer IntegerKind.Usize 3 |) in
                                    M.alloc (| Value.Tuple [] |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (M.alloc (|
                                      M.never_to_any (|
                                        M.read (|
                                          M.return_ (|
                                            Value.StructTuple "core::option::Option::None" []
                                          |)
                                        |)
                                      |)
                                    |)))
                              ]
                            |)))
                      ]
                    |) in
                  let~ _ :=
                    let β := register in
                    M.write (|
                      β,
                      BinOp.bit_and
                        (M.read (| β |))
                        (Value.Integer IntegerKind.U64 16131858542891098079)
                    |) in
                  let~ float :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (| Value.Tuple [ M.read (| register |); M.read (| len |) ] |),
                        [
                          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.U64 4607561
                                |) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ0_1 |),
                                  Value.Integer IntegerKind.Usize 3
                                |) in
                              M.get_constant (|
                                "core::num::dec2flt::float::RawFloat::INFINITY"
                              |)));
                          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.U64 6436850368004902473
                                |) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ0_1 |),
                                  Value.Integer IntegerKind.Usize 8
                                |) in
                              M.get_constant (|
                                "core::num::dec2flt::float::RawFloat::INFINITY"
                              |)));
                          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.U64 5128526
                                |) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ0_1 |),
                                  Value.Integer IntegerKind.Usize 3
                                |) in
                              M.get_constant (| "core::num::dec2flt::float::RawFloat::NAN" |)));
                          fun γ =>
                            ltac:(M.monadic
                              (M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      Value.StructTuple "core::option::Option::None" []
                                    |)
                                  |)
                                |)
                              |)))
                        ]
                      |)
                    |) in
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ := M.use negative in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            Value.StructTuple
                              "core::option::Option::Some"
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::arith::Neg",
                                    F,
                                    [],
                                    "neg",
                                    []
                                  |),
                                  [ M.read (| float |) ]
                                |)
                              ]
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (M.alloc (|
                            Value.StructTuple "core::option::Option::Some" [ M.read (| float |) ]
                          |)))
                    ]
                  |)
                |)))
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Function_parse_inf_nan :
        M.IsFunction "core::num::dec2flt::parse::parse_inf_nan" parse_inf_nan.
      
      Module parse_inf_nan.
        Definition value_INF_3 : Value.t :=
          M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 4607561 |))).
        
        Definition value_INF_8 : Value.t :=
          M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 6436850368004902473 |))).
        
        Definition value_NAN : Value.t :=
          M.run ltac:(M.monadic (M.alloc (| Value.Integer IntegerKind.U64 5128526 |))).
      End parse_inf_nan.
    End parse.
  End dec2flt.
End num.
