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

Module num.
  Module int_sqrt.
    Definition value_U8_ISQRT_WITH_REMAINDER : Value.t :=
      M.run
        ltac:(M.monadic
          (let~ result :=
            M.alloc (|
              repeat (|
                Value.Tuple [ Value.Integer IntegerKind.U8 0; Value.Integer IntegerKind.U8 0 ],
                Value.Integer IntegerKind.Usize 256
              |)
            |) in
          let~ n := M.alloc (| Value.Integer IntegerKind.Usize 0 |) in
          let~ isqrt_n := M.alloc (| Value.Integer IntegerKind.Usize 0 |) 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 (| n |),
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "slice")
                                      []
                                      [ Ty.tuple [ Ty.path "u8"; Ty.path "u8" ] ],
                                    "len",
                                    []
                                  |),
                                  [ result ]
                                |)
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        let~ _ :=
                          M.write (|
                            M.SubPointer.get_array_field (| result, n |),
                            Value.Tuple
                              [
                                M.rust_cast (M.read (| isqrt_n |));
                                M.rust_cast
                                  (BinOp.Wrap.sub (|
                                    M.read (| n |),
                                    M.call_closure (|
                                      M.get_associated_function (| Ty.path "usize", "pow", [] |),
                                      [ M.read (| isqrt_n |); Value.Integer IntegerKind.U32 2 ]
                                    |)
                                  |))
                              ]
                          |) in
                        let~ _ :=
                          let β := n in
                          M.write (|
                            β,
                            BinOp.Wrap.add (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                          |) in
                        M.match_operator (|
                          M.alloc (| Value.Tuple [] |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ :=
                                  M.use
                                    (M.alloc (|
                                      BinOp.eq (|
                                        M.read (| n |),
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "usize",
                                            "pow",
                                            []
                                          |),
                                          [
                                            BinOp.Wrap.add (|
                                              M.read (| isqrt_n |),
                                              Value.Integer IntegerKind.Usize 1
                                            |);
                                            Value.Integer IntegerKind.U32 2
                                          ]
                                        |)
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                let~ _ :=
                                  let β := isqrt_n in
                                  M.write (|
                                    β,
                                    BinOp.Wrap.add (|
                                      M.read (| β |),
                                      Value.Integer IntegerKind.Usize 1
                                    |)
                                  |) in
                                M.alloc (| Value.Tuple [] |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              let~ _ :=
                                M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in
                              M.alloc (| Value.Tuple [] |)
                            |)
                          |)
                        |)))
                  ]
                |)))
            |) in
          result)).
    
    (*
    pub const fn u8(n: u8) -> u8 {
        U8_ISQRT_WITH_REMAINDER[n as usize].0
    }
    *)
    Definition u8 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.SubPointer.get_tuple_field (|
              M.SubPointer.get_array_field (|
                M.get_constant (| "core::num::int_sqrt::U8_ISQRT_WITH_REMAINDER" |),
                M.alloc (| M.rust_cast (M.read (| n |)) |)
              |),
              0
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u8 : M.IsFunction "core::num::int_sqrt::u8" u8.
    
    (*
            pub const unsafe fn $SignedT(n: $SignedT) -> $SignedT {
                debug_assert!(n >= 0, "Negative input inside `isqrt`.");
                $UnsignedT(n as $UnsignedT) as $SignedT
            }
    *)
    Definition i8 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          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 (|
                                        BinOp.ge (|
                                          M.read (| n |),
                                          Value.Integer IntegerKind.I8 0
                                        |)
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.call_closure (|
                                      M.get_function (| "core::panicking::panic_fmt", [] |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "core::fmt::Arguments",
                                            "new_const",
                                            []
                                          |),
                                          [
                                            M.alloc (|
                                              Value.Array
                                                [
                                                  M.read (|
                                                    Value.String "Negative input inside `isqrt`."
                                                  |)
                                                ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.alloc (| Value.Tuple [] |)));
                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                ]
              |) in
            M.alloc (|
              M.rust_cast
                (M.call_closure (|
                  M.get_function (| "core::num::int_sqrt::u8", [] |),
                  [ M.rust_cast (M.read (| n |)) ]
                |))
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_i8 : M.IsFunction "core::num::int_sqrt::i8" i8.
    
    (*
            pub const unsafe fn $SignedT(n: $SignedT) -> $SignedT {
                debug_assert!(n >= 0, "Negative input inside `isqrt`.");
                $UnsignedT(n as $UnsignedT) as $SignedT
            }
    *)
    Definition i16 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          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 (|
                                        BinOp.ge (|
                                          M.read (| n |),
                                          Value.Integer IntegerKind.I16 0
                                        |)
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.call_closure (|
                                      M.get_function (| "core::panicking::panic_fmt", [] |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "core::fmt::Arguments",
                                            "new_const",
                                            []
                                          |),
                                          [
                                            M.alloc (|
                                              Value.Array
                                                [
                                                  M.read (|
                                                    Value.String "Negative input inside `isqrt`."
                                                  |)
                                                ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.alloc (| Value.Tuple [] |)));
                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                ]
              |) in
            M.alloc (|
              M.rust_cast
                (M.call_closure (|
                  M.get_function (| "core::num::int_sqrt::u16", [] |),
                  [ M.rust_cast (M.read (| n |)) ]
                |))
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_i16 : M.IsFunction "core::num::int_sqrt::i16" i16.
    
    (*
            pub const unsafe fn $SignedT(n: $SignedT) -> $SignedT {
                debug_assert!(n >= 0, "Negative input inside `isqrt`.");
                $UnsignedT(n as $UnsignedT) as $SignedT
            }
    *)
    Definition i32 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          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 (|
                                        BinOp.ge (|
                                          M.read (| n |),
                                          Value.Integer IntegerKind.I32 0
                                        |)
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.call_closure (|
                                      M.get_function (| "core::panicking::panic_fmt", [] |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "core::fmt::Arguments",
                                            "new_const",
                                            []
                                          |),
                                          [
                                            M.alloc (|
                                              Value.Array
                                                [
                                                  M.read (|
                                                    Value.String "Negative input inside `isqrt`."
                                                  |)
                                                ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.alloc (| Value.Tuple [] |)));
                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                ]
              |) in
            M.alloc (|
              M.rust_cast
                (M.call_closure (|
                  M.get_function (| "core::num::int_sqrt::u32", [] |),
                  [ M.rust_cast (M.read (| n |)) ]
                |))
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_i32 : M.IsFunction "core::num::int_sqrt::i32" i32.
    
    (*
            pub const unsafe fn $SignedT(n: $SignedT) -> $SignedT {
                debug_assert!(n >= 0, "Negative input inside `isqrt`.");
                $UnsignedT(n as $UnsignedT) as $SignedT
            }
    *)
    Definition i64 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          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 (|
                                        BinOp.ge (|
                                          M.read (| n |),
                                          Value.Integer IntegerKind.I64 0
                                        |)
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.call_closure (|
                                      M.get_function (| "core::panicking::panic_fmt", [] |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "core::fmt::Arguments",
                                            "new_const",
                                            []
                                          |),
                                          [
                                            M.alloc (|
                                              Value.Array
                                                [
                                                  M.read (|
                                                    Value.String "Negative input inside `isqrt`."
                                                  |)
                                                ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.alloc (| Value.Tuple [] |)));
                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                ]
              |) in
            M.alloc (|
              M.rust_cast
                (M.call_closure (|
                  M.get_function (| "core::num::int_sqrt::u64", [] |),
                  [ M.rust_cast (M.read (| n |)) ]
                |))
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_i64 : M.IsFunction "core::num::int_sqrt::i64" i64.
    
    (*
            pub const unsafe fn $SignedT(n: $SignedT) -> $SignedT {
                debug_assert!(n >= 0, "Negative input inside `isqrt`.");
                $UnsignedT(n as $UnsignedT) as $SignedT
            }
    *)
    Definition i128 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          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 (|
                                        BinOp.ge (|
                                          M.read (| n |),
                                          Value.Integer IntegerKind.I128 0
                                        |)
                                      |)
                                    |)) in
                                let _ :=
                                  M.is_constant_or_break_match (|
                                    M.read (| γ |),
                                    Value.Bool true
                                  |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.call_closure (|
                                      M.get_function (| "core::panicking::panic_fmt", [] |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "core::fmt::Arguments",
                                            "new_const",
                                            []
                                          |),
                                          [
                                            M.alloc (|
                                              Value.Array
                                                [
                                                  M.read (|
                                                    Value.String "Negative input inside `isqrt`."
                                                  |)
                                                ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |)
                                |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      M.alloc (| Value.Tuple [] |)));
                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                ]
              |) in
            M.alloc (|
              M.rust_cast
                (M.call_closure (|
                  M.get_function (| "core::num::int_sqrt::u128", [] |),
                  [ M.rust_cast (M.read (| n |)) ]
                |))
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_i128 : M.IsFunction "core::num::int_sqrt::i128" i128.
    
    (*
    const fn u16_stages(n: u16) -> u16 {
        let (s, r) = first_stage!(16, n);
        last_stage!(u16, n, s, r)
    }
    *)
    Definition u16_stages (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              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 (|
                                          BinOp.ne (|
                                            M.read (| n |),
                                            Value.Integer IntegerKind.U16 0
                                          |)
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.call_closure (|
                                        M.get_function (| "core::panicking::panic_fmt", [] |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "core::fmt::Arguments",
                                              "new_const",
                                              []
                                            |),
                                            [
                                              M.alloc (|
                                                Value.Array
                                                  [
                                                    M.read (|
                                                      Value.String
                                                        "`$n` is  zero in `first_stage!`."
                                                    |)
                                                  ]
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let~ n :=
                M.alloc (|
                  BinOp.Wrap.shr (|
                    M.read (| n |),
                    M.read (| M.get_constant (| "core::num::int_sqrt::u16_stages::N_SHIFT" |) |)
                  |)
                |) in
              M.match_operator (|
                M.SubPointer.get_array_field (|
                  M.get_constant (| "core::num::int_sqrt::U8_ISQRT_WITH_REMAINDER" |),
                  M.alloc (| M.rust_cast (M.read (| n |)) |)
                |),
                [
                  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 s := M.copy (| γ0_0 |) in
                      let r := M.copy (| γ0_1 |) in
                      let~ _ :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_function (| "core::hint::assert_unchecked", [] |),
                            [ BinOp.ne (| M.read (| s |), Value.Integer IntegerKind.U8 0 |) ]
                          |)
                        |) in
                      M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                ]
              |),
              [
                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 s := M.copy (| γ0_0 |) in
                    let r := M.copy (| γ0_1 |) in
                    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 (|
                                                BinOp.ne (|
                                                  M.read (| s |),
                                                  Value.Integer IntegerKind.U8 0
                                                |)
                                              |)
                                            |)) in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.call_closure (|
                                              M.get_function (| "core::panicking::panic_fmt", [] |),
                                              [
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.path "core::fmt::Arguments",
                                                    "new_const",
                                                    []
                                                  |),
                                                  [
                                                    M.alloc (|
                                                      Value.Array
                                                        [
                                                          M.read (|
                                                            Value.String
                                                              "`$s` is  zero in `last_stage!`."
                                                          |)
                                                        ]
                                                    |)
                                                  ]
                                                |)
                                              ]
                                            |)
                                          |)
                                        |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              M.alloc (| Value.Tuple [] |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ lo :=
                      M.alloc (|
                        BinOp.bit_and
                          (M.read (| n |))
                          (M.read (|
                            M.get_constant (|
                              "core::num::int_sqrt::u16_stages::LOWER_HALF_1_BITS"
                            |)
                          |))
                      |) in
                    let~ numerator :=
                      M.alloc (|
                        BinOp.bit_or
                          (BinOp.Wrap.shl (|
                            M.rust_cast (M.read (| r |)),
                            M.read (|
                              M.get_constant (| "core::num::int_sqrt::u16_stages::QUARTER_BITS" |)
                            |)
                          |))
                          (BinOp.Wrap.shr (|
                            M.read (| lo |),
                            M.read (|
                              M.get_constant (| "core::num::int_sqrt::u16_stages::QUARTER_BITS" |)
                            |)
                          |))
                      |) in
                    let~ denominator :=
                      M.alloc (|
                        BinOp.Wrap.shl (|
                          M.rust_cast (M.read (| s |)),
                          Value.Integer IntegerKind.I32 1
                        |)
                      |) in
                    let~ q :=
                      M.alloc (|
                        BinOp.Wrap.div (| M.read (| numerator |), M.read (| denominator |) |)
                      |) in
                    let~ s :=
                      M.alloc (|
                        BinOp.Wrap.add (|
                          M.rust_cast
                            (BinOp.Wrap.shl (|
                              M.read (| s |),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u16_stages::QUARTER_BITS" |)
                              |)
                            |)),
                          M.read (| q |)
                        |)
                      |) in
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (| Ty.path "u16", "overflowing_mul", [] |),
                          [ M.read (| s |); M.read (| s |) ]
                        |)
                      |),
                      [
                        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 s_squared := M.copy (| γ0_0 |) in
                            let overflow := M.copy (| γ0_1 |) in
                            let~ _ :=
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            LogicalOp.or (|
                                              M.read (| overflow |),
                                              ltac:(M.monadic
                                                (BinOp.gt (|
                                                  M.read (| s_squared |),
                                                  M.read (| n |)
                                                |)))
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      let~ _ :=
                                        let β := s in
                                        M.write (|
                                          β,
                                          BinOp.Wrap.sub (|
                                            M.read (| β |),
                                            Value.Integer IntegerKind.U16 1
                                          |)
                                        |) in
                                      M.alloc (| Value.Tuple [] |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            s))
                      ]
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u16_stages : M.IsFunction "core::num::int_sqrt::u16_stages" u16_stages.
    
    Module u16_stages.
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (| Value.Integer IntegerKind.U32 16, Value.Integer IntegerKind.U32 8 |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U16 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u16_stages::HALF_BITS" |) |)
                |),
                Value.Integer IntegerKind.U16 1
              |)
            |))).
    End u16_stages.
    
    (*
    const fn u32_stages(n: u32) -> u32 {
        let (s, r) = first_stage!(32, n);
        let (s, r) = middle_stage!(32, u16, n, s, r);
        last_stage!(u32, n, s, r)
    }
    *)
    Definition u32_stages (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              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 (|
                                          BinOp.ne (|
                                            M.read (| n |),
                                            Value.Integer IntegerKind.U32 0
                                          |)
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.call_closure (|
                                        M.get_function (| "core::panicking::panic_fmt", [] |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "core::fmt::Arguments",
                                              "new_const",
                                              []
                                            |),
                                            [
                                              M.alloc (|
                                                Value.Array
                                                  [
                                                    M.read (|
                                                      Value.String
                                                        "`$n` is  zero in `first_stage!`."
                                                    |)
                                                  ]
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let~ n :=
                M.alloc (|
                  BinOp.Wrap.shr (|
                    M.read (| n |),
                    M.read (| M.get_constant (| "core::num::int_sqrt::u32_stages::N_SHIFT" |) |)
                  |)
                |) in
              M.match_operator (|
                M.SubPointer.get_array_field (|
                  M.get_constant (| "core::num::int_sqrt::U8_ISQRT_WITH_REMAINDER" |),
                  M.alloc (| M.rust_cast (M.read (| n |)) |)
                |),
                [
                  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 s := M.copy (| γ0_0 |) in
                      let r := M.copy (| γ0_1 |) in
                      let~ _ :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_function (| "core::hint::assert_unchecked", [] |),
                            [ BinOp.ne (| M.read (| s |), Value.Integer IntegerKind.U8 0 |) ]
                          |)
                        |) in
                      M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                ]
              |),
              [
                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 s := M.copy (| γ0_0 |) in
                    let r := M.copy (| γ0_1 |) in
                    M.match_operator (|
                      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 (|
                                                  BinOp.ne (|
                                                    M.read (| s |),
                                                    Value.Integer IntegerKind.U8 0
                                                  |)
                                                |)
                                              |)) in
                                          let _ :=
                                            M.is_constant_or_break_match (|
                                              M.read (| γ |),
                                              Value.Bool true
                                            |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.call_closure (|
                                                M.get_function (|
                                                  "core::panicking::panic_fmt",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path "core::fmt::Arguments",
                                                      "new_const",
                                                      []
                                                    |),
                                                    [
                                                      M.alloc (|
                                                        Value.Array
                                                          [
                                                            M.read (|
                                                              Value.String
                                                                "`$s` is  zero in `middle_stage!`."
                                                            |)
                                                          ]
                                                      |)
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            |)
                                          |)));
                                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |) in
                                M.alloc (| Value.Tuple [] |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      let~ n :=
                        M.alloc (|
                          M.rust_cast
                            (BinOp.Wrap.shr (|
                              M.read (| n |),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u32_stages::N_SHIFT'1" |)
                              |)
                            |))
                        |) in
                      let~ lo :=
                        M.alloc (|
                          BinOp.bit_and
                            (M.read (| n |))
                            (M.read (|
                              M.get_constant (|
                                "core::num::int_sqrt::u32_stages::LOWER_HALF_1_BITS"
                              |)
                            |))
                        |) in
                      let~ numerator :=
                        M.alloc (|
                          BinOp.bit_or
                            (BinOp.Wrap.shl (|
                              M.rust_cast (M.read (| r |)),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u32_stages::QUARTER_BITS" |)
                              |)
                            |))
                            (BinOp.Wrap.shr (|
                              M.read (| lo |),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u32_stages::QUARTER_BITS" |)
                              |)
                            |))
                        |) in
                      let~ denominator :=
                        M.alloc (|
                          BinOp.Wrap.shl (|
                            M.rust_cast (M.read (| s |)),
                            Value.Integer IntegerKind.I32 1
                          |)
                        |) in
                      let~ q :=
                        M.alloc (|
                          BinOp.Wrap.div (| M.read (| numerator |), M.read (| denominator |) |)
                        |) in
                      let~ u :=
                        M.alloc (|
                          BinOp.Wrap.rem (| M.read (| numerator |), M.read (| denominator |) |)
                        |) in
                      let~ s :=
                        M.alloc (|
                          BinOp.Wrap.add (|
                            M.rust_cast
                              (BinOp.Wrap.shl (|
                                M.read (| s |),
                                M.read (|
                                  M.get_constant (|
                                    "core::num::int_sqrt::u32_stages::QUARTER_BITS"
                                  |)
                                |)
                              |)),
                            M.read (| q |)
                          |)
                        |) in
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "u16", "overflowing_sub", [] |),
                            [
                              BinOp.bit_or
                                (BinOp.Wrap.shl (|
                                  M.read (| u |),
                                  M.read (|
                                    M.get_constant (|
                                      "core::num::int_sqrt::u32_stages::QUARTER_BITS"
                                    |)
                                  |)
                                |))
                                (BinOp.bit_and
                                  (M.read (| lo |))
                                  (M.read (|
                                    M.get_constant (|
                                      "core::num::int_sqrt::u32_stages::LOWEST_QUARTER_1_BITS"
                                    |)
                                  |)));
                              BinOp.Wrap.mul (| M.read (| q |), M.read (| q |) |)
                            ]
                          |)
                        |),
                        [
                          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 r := M.copy (| γ0_0 |) in
                              let overflow := M.copy (| γ0_1 |) in
                              let~ _ :=
                                M.match_operator (|
                                  M.alloc (| Value.Tuple [] |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ := M.use overflow in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        let~ _ :=
                                          M.write (|
                                            r,
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.path "u16",
                                                "wrapping_add",
                                                []
                                              |),
                                              [
                                                M.read (| r |);
                                                BinOp.Wrap.sub (|
                                                  BinOp.Wrap.mul (|
                                                    Value.Integer IntegerKind.U16 2,
                                                    M.read (| s |)
                                                  |),
                                                  Value.Integer IntegerKind.U16 1
                                                |)
                                              ]
                                            |)
                                          |) in
                                        let~ _ :=
                                          let β := s in
                                          M.write (|
                                            β,
                                            BinOp.Wrap.sub (|
                                              M.read (| β |),
                                              Value.Integer IntegerKind.U16 1
                                            |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              let~ _ :=
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (| "core::hint::assert_unchecked", [] |),
                                    [ BinOp.ne (| M.read (| s |), Value.Integer IntegerKind.U16 0 |)
                                    ]
                                  |)
                                |) in
                              M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                        ]
                      |),
                      [
                        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 s := M.copy (| γ0_0 |) in
                            let r := M.copy (| γ0_1 |) in
                            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 (|
                                                        BinOp.ne (|
                                                          M.read (| s |),
                                                          Value.Integer IntegerKind.U16 0
                                                        |)
                                                      |)
                                                    |)) in
                                                let _ :=
                                                  M.is_constant_or_break_match (|
                                                    M.read (| γ |),
                                                    Value.Bool true
                                                  |) in
                                                M.alloc (|
                                                  M.never_to_any (|
                                                    M.call_closure (|
                                                      M.get_function (|
                                                        "core::panicking::panic_fmt",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.path "core::fmt::Arguments",
                                                            "new_const",
                                                            []
                                                          |),
                                                          [
                                                            M.alloc (|
                                                              Value.Array
                                                                [
                                                                  M.read (|
                                                                    Value.String
                                                                      "`$s` is  zero in `last_stage!`."
                                                                  |)
                                                                ]
                                                            |)
                                                          ]
                                                        |)
                                                      ]
                                                    |)
                                                  |)
                                                |)));
                                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                          ]
                                        |) in
                                      M.alloc (| Value.Tuple [] |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            let~ lo :=
                              M.alloc (|
                                BinOp.bit_and
                                  (M.read (| n |))
                                  (M.read (|
                                    M.get_constant (|
                                      "core::num::int_sqrt::u32_stages::LOWER_HALF_1_BITS'1"
                                    |)
                                  |))
                              |) in
                            let~ numerator :=
                              M.alloc (|
                                BinOp.bit_or
                                  (BinOp.Wrap.shl (|
                                    M.rust_cast (M.read (| r |)),
                                    M.read (|
                                      M.get_constant (|
                                        "core::num::int_sqrt::u32_stages::QUARTER_BITS'1"
                                      |)
                                    |)
                                  |))
                                  (BinOp.Wrap.shr (|
                                    M.read (| lo |),
                                    M.read (|
                                      M.get_constant (|
                                        "core::num::int_sqrt::u32_stages::QUARTER_BITS'1"
                                      |)
                                    |)
                                  |))
                              |) in
                            let~ denominator :=
                              M.alloc (|
                                BinOp.Wrap.shl (|
                                  M.rust_cast (M.read (| s |)),
                                  Value.Integer IntegerKind.I32 1
                                |)
                              |) in
                            let~ q :=
                              M.alloc (|
                                BinOp.Wrap.div (|
                                  M.read (| numerator |),
                                  M.read (| denominator |)
                                |)
                              |) in
                            let~ s :=
                              M.alloc (|
                                BinOp.Wrap.add (|
                                  M.rust_cast
                                    (BinOp.Wrap.shl (|
                                      M.read (| s |),
                                      M.read (|
                                        M.get_constant (|
                                          "core::num::int_sqrt::u32_stages::QUARTER_BITS'1"
                                        |)
                                      |)
                                    |)),
                                  M.read (| q |)
                                |)
                              |) in
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "u32",
                                    "overflowing_mul",
                                    []
                                  |),
                                  [ M.read (| s |); M.read (| s |) ]
                                |)
                              |),
                              [
                                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 s_squared := M.copy (| γ0_0 |) in
                                    let overflow := M.copy (| γ0_1 |) in
                                    let~ _ :=
                                      M.match_operator (|
                                        M.alloc (| Value.Tuple [] |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let γ :=
                                                M.use
                                                  (M.alloc (|
                                                    LogicalOp.or (|
                                                      M.read (| overflow |),
                                                      ltac:(M.monadic
                                                        (BinOp.gt (|
                                                          M.read (| s_squared |),
                                                          M.read (| n |)
                                                        |)))
                                                    |)
                                                  |)) in
                                              let _ :=
                                                M.is_constant_or_break_match (|
                                                  M.read (| γ |),
                                                  Value.Bool true
                                                |) in
                                              let~ _ :=
                                                let β := s in
                                                M.write (|
                                                  β,
                                                  BinOp.Wrap.sub (|
                                                    M.read (| β |),
                                                    Value.Integer IntegerKind.U32 1
                                                  |)
                                                |) in
                                              M.alloc (| Value.Tuple [] |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |) in
                                    s))
                              ]
                            |)))
                      ]
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u32_stages : M.IsFunction "core::num::int_sqrt::u32_stages" u32_stages.
    
    Module u32_stages.
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (| Value.Integer IntegerKind.U32 32, Value.Integer IntegerKind.U32 8 |)
            |))).
      
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                Value.Integer IntegerKind.U32 32,
                M.read (| M.get_constant (| "core::num::BITS" |) |)
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U16 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u32_stages::HALF_BITS" |) |)
                |),
                Value.Integer IntegerKind.U16 1
              |)
            |))).
      
      Definition value_LOWEST_QUARTER_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U16 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u32_stages::QUARTER_BITS" |) |)
                |),
                Value.Integer IntegerKind.U16 1
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U32 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u32_stages::HALF_BITS'1" |) |)
                |),
                Value.Integer IntegerKind.U32 1
              |)
            |))).
    End u32_stages.
    
    (*
    const fn u64_stages(n: u64) -> u64 {
        let (s, r) = first_stage!(64, n);
        let (s, r) = middle_stage!(64, u16, n, s, r);
        let (s, r) = middle_stage!(64, u32, n, s, r);
        last_stage!(u64, n, s, r)
    }
    *)
    Definition u64_stages (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              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 (|
                                          BinOp.ne (|
                                            M.read (| n |),
                                            Value.Integer IntegerKind.U64 0
                                          |)
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.call_closure (|
                                        M.get_function (| "core::panicking::panic_fmt", [] |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "core::fmt::Arguments",
                                              "new_const",
                                              []
                                            |),
                                            [
                                              M.alloc (|
                                                Value.Array
                                                  [
                                                    M.read (|
                                                      Value.String
                                                        "`$n` is  zero in `first_stage!`."
                                                    |)
                                                  ]
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let~ n :=
                M.alloc (|
                  BinOp.Wrap.shr (|
                    M.read (| n |),
                    M.read (| M.get_constant (| "core::num::int_sqrt::u64_stages::N_SHIFT" |) |)
                  |)
                |) in
              M.match_operator (|
                M.SubPointer.get_array_field (|
                  M.get_constant (| "core::num::int_sqrt::U8_ISQRT_WITH_REMAINDER" |),
                  M.alloc (| M.rust_cast (M.read (| n |)) |)
                |),
                [
                  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 s := M.copy (| γ0_0 |) in
                      let r := M.copy (| γ0_1 |) in
                      let~ _ :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_function (| "core::hint::assert_unchecked", [] |),
                            [ BinOp.ne (| M.read (| s |), Value.Integer IntegerKind.U8 0 |) ]
                          |)
                        |) in
                      M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                ]
              |),
              [
                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 s := M.copy (| γ0_0 |) in
                    let r := M.copy (| γ0_1 |) in
                    M.match_operator (|
                      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 (|
                                                  BinOp.ne (|
                                                    M.read (| s |),
                                                    Value.Integer IntegerKind.U8 0
                                                  |)
                                                |)
                                              |)) in
                                          let _ :=
                                            M.is_constant_or_break_match (|
                                              M.read (| γ |),
                                              Value.Bool true
                                            |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.call_closure (|
                                                M.get_function (|
                                                  "core::panicking::panic_fmt",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path "core::fmt::Arguments",
                                                      "new_const",
                                                      []
                                                    |),
                                                    [
                                                      M.alloc (|
                                                        Value.Array
                                                          [
                                                            M.read (|
                                                              Value.String
                                                                "`$s` is  zero in `middle_stage!`."
                                                            |)
                                                          ]
                                                      |)
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            |)
                                          |)));
                                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |) in
                                M.alloc (| Value.Tuple [] |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      let~ n :=
                        M.alloc (|
                          M.rust_cast
                            (BinOp.Wrap.shr (|
                              M.read (| n |),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u64_stages::N_SHIFT'1" |)
                              |)
                            |))
                        |) in
                      let~ lo :=
                        M.alloc (|
                          BinOp.bit_and
                            (M.read (| n |))
                            (M.read (|
                              M.get_constant (|
                                "core::num::int_sqrt::u64_stages::LOWER_HALF_1_BITS"
                              |)
                            |))
                        |) in
                      let~ numerator :=
                        M.alloc (|
                          BinOp.bit_or
                            (BinOp.Wrap.shl (|
                              M.rust_cast (M.read (| r |)),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u64_stages::QUARTER_BITS" |)
                              |)
                            |))
                            (BinOp.Wrap.shr (|
                              M.read (| lo |),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u64_stages::QUARTER_BITS" |)
                              |)
                            |))
                        |) in
                      let~ denominator :=
                        M.alloc (|
                          BinOp.Wrap.shl (|
                            M.rust_cast (M.read (| s |)),
                            Value.Integer IntegerKind.I32 1
                          |)
                        |) in
                      let~ q :=
                        M.alloc (|
                          BinOp.Wrap.div (| M.read (| numerator |), M.read (| denominator |) |)
                        |) in
                      let~ u :=
                        M.alloc (|
                          BinOp.Wrap.rem (| M.read (| numerator |), M.read (| denominator |) |)
                        |) in
                      let~ s :=
                        M.alloc (|
                          BinOp.Wrap.add (|
                            M.rust_cast
                              (BinOp.Wrap.shl (|
                                M.read (| s |),
                                M.read (|
                                  M.get_constant (|
                                    "core::num::int_sqrt::u64_stages::QUARTER_BITS"
                                  |)
                                |)
                              |)),
                            M.read (| q |)
                          |)
                        |) in
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "u16", "overflowing_sub", [] |),
                            [
                              BinOp.bit_or
                                (BinOp.Wrap.shl (|
                                  M.read (| u |),
                                  M.read (|
                                    M.get_constant (|
                                      "core::num::int_sqrt::u64_stages::QUARTER_BITS"
                                    |)
                                  |)
                                |))
                                (BinOp.bit_and
                                  (M.read (| lo |))
                                  (M.read (|
                                    M.get_constant (|
                                      "core::num::int_sqrt::u64_stages::LOWEST_QUARTER_1_BITS"
                                    |)
                                  |)));
                              BinOp.Wrap.mul (| M.read (| q |), M.read (| q |) |)
                            ]
                          |)
                        |),
                        [
                          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 r := M.copy (| γ0_0 |) in
                              let overflow := M.copy (| γ0_1 |) in
                              let~ _ :=
                                M.match_operator (|
                                  M.alloc (| Value.Tuple [] |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ := M.use overflow in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        let~ _ :=
                                          M.write (|
                                            r,
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.path "u16",
                                                "wrapping_add",
                                                []
                                              |),
                                              [
                                                M.read (| r |);
                                                BinOp.Wrap.sub (|
                                                  BinOp.Wrap.mul (|
                                                    Value.Integer IntegerKind.U16 2,
                                                    M.read (| s |)
                                                  |),
                                                  Value.Integer IntegerKind.U16 1
                                                |)
                                              ]
                                            |)
                                          |) in
                                        let~ _ :=
                                          let β := s in
                                          M.write (|
                                            β,
                                            BinOp.Wrap.sub (|
                                              M.read (| β |),
                                              Value.Integer IntegerKind.U16 1
                                            |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              let~ _ :=
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (| "core::hint::assert_unchecked", [] |),
                                    [ BinOp.ne (| M.read (| s |), Value.Integer IntegerKind.U16 0 |)
                                    ]
                                  |)
                                |) in
                              M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                        ]
                      |),
                      [
                        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 s := M.copy (| γ0_0 |) in
                            let r := M.copy (| γ0_1 |) in
                            M.match_operator (|
                              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 (|
                                                          BinOp.ne (|
                                                            M.read (| s |),
                                                            Value.Integer IntegerKind.U16 0
                                                          |)
                                                        |)
                                                      |)) in
                                                  let _ :=
                                                    M.is_constant_or_break_match (|
                                                      M.read (| γ |),
                                                      Value.Bool true
                                                    |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.call_closure (|
                                                        M.get_function (|
                                                          "core::panicking::panic_fmt",
                                                          []
                                                        |),
                                                        [
                                                          M.call_closure (|
                                                            M.get_associated_function (|
                                                              Ty.path "core::fmt::Arguments",
                                                              "new_const",
                                                              []
                                                            |),
                                                            [
                                                              M.alloc (|
                                                                Value.Array
                                                                  [
                                                                    M.read (|
                                                                      Value.String
                                                                        "`$s` is  zero in `middle_stage!`."
                                                                    |)
                                                                  ]
                                                              |)
                                                            ]
                                                          |)
                                                        ]
                                                      |)
                                                    |)
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                            ]
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              let~ n :=
                                M.alloc (|
                                  M.rust_cast
                                    (BinOp.Wrap.shr (|
                                      M.read (| n |),
                                      M.read (|
                                        M.get_constant (|
                                          "core::num::int_sqrt::u64_stages::N_SHIFT'2"
                                        |)
                                      |)
                                    |))
                                |) in
                              let~ lo :=
                                M.alloc (|
                                  BinOp.bit_and
                                    (M.read (| n |))
                                    (M.read (|
                                      M.get_constant (|
                                        "core::num::int_sqrt::u64_stages::LOWER_HALF_1_BITS'1"
                                      |)
                                    |))
                                |) in
                              let~ numerator :=
                                M.alloc (|
                                  BinOp.bit_or
                                    (BinOp.Wrap.shl (|
                                      M.rust_cast (M.read (| r |)),
                                      M.read (|
                                        M.get_constant (|
                                          "core::num::int_sqrt::u64_stages::QUARTER_BITS'1"
                                        |)
                                      |)
                                    |))
                                    (BinOp.Wrap.shr (|
                                      M.read (| lo |),
                                      M.read (|
                                        M.get_constant (|
                                          "core::num::int_sqrt::u64_stages::QUARTER_BITS'1"
                                        |)
                                      |)
                                    |))
                                |) in
                              let~ denominator :=
                                M.alloc (|
                                  BinOp.Wrap.shl (|
                                    M.rust_cast (M.read (| s |)),
                                    Value.Integer IntegerKind.I32 1
                                  |)
                                |) in
                              let~ q :=
                                M.alloc (|
                                  BinOp.Wrap.div (|
                                    M.read (| numerator |),
                                    M.read (| denominator |)
                                  |)
                                |) in
                              let~ u :=
                                M.alloc (|
                                  BinOp.Wrap.rem (|
                                    M.read (| numerator |),
                                    M.read (| denominator |)
                                  |)
                                |) in
                              let~ s :=
                                M.alloc (|
                                  BinOp.Wrap.add (|
                                    M.rust_cast
                                      (BinOp.Wrap.shl (|
                                        M.read (| s |),
                                        M.read (|
                                          M.get_constant (|
                                            "core::num::int_sqrt::u64_stages::QUARTER_BITS'1"
                                          |)
                                        |)
                                      |)),
                                    M.read (| q |)
                                  |)
                                |) in
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "u32",
                                      "overflowing_sub",
                                      []
                                    |),
                                    [
                                      BinOp.bit_or
                                        (BinOp.Wrap.shl (|
                                          M.read (| u |),
                                          M.read (|
                                            M.get_constant (|
                                              "core::num::int_sqrt::u64_stages::QUARTER_BITS'1"
                                            |)
                                          |)
                                        |))
                                        (BinOp.bit_and
                                          (M.read (| lo |))
                                          (M.read (|
                                            M.get_constant (|
                                              "core::num::int_sqrt::u64_stages::LOWEST_QUARTER_1_BITS'1"
                                            |)
                                          |)));
                                      BinOp.Wrap.mul (| M.read (| q |), M.read (| q |) |)
                                    ]
                                  |)
                                |),
                                [
                                  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 r := M.copy (| γ0_0 |) in
                                      let overflow := M.copy (| γ0_1 |) in
                                      let~ _ :=
                                        M.match_operator (|
                                          M.alloc (| Value.Tuple [] |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let γ := M.use overflow in
                                                let _ :=
                                                  M.is_constant_or_break_match (|
                                                    M.read (| γ |),
                                                    Value.Bool true
                                                  |) in
                                                let~ _ :=
                                                  M.write (|
                                                    r,
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.path "u32",
                                                        "wrapping_add",
                                                        []
                                                      |),
                                                      [
                                                        M.read (| r |);
                                                        BinOp.Wrap.sub (|
                                                          BinOp.Wrap.mul (|
                                                            Value.Integer IntegerKind.U32 2,
                                                            M.read (| s |)
                                                          |),
                                                          Value.Integer IntegerKind.U32 1
                                                        |)
                                                      ]
                                                    |)
                                                  |) in
                                                let~ _ :=
                                                  let β := s in
                                                  M.write (|
                                                    β,
                                                    BinOp.Wrap.sub (|
                                                      M.read (| β |),
                                                      Value.Integer IntegerKind.U32 1
                                                    |)
                                                  |) in
                                                M.alloc (| Value.Tuple [] |)));
                                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                          ]
                                        |) in
                                      let~ _ :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_function (| "core::hint::assert_unchecked", [] |),
                                            [
                                              BinOp.ne (|
                                                M.read (| s |),
                                                Value.Integer IntegerKind.U32 0
                                              |)
                                            ]
                                          |)
                                        |) in
                                      M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                                ]
                              |),
                              [
                                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 s := M.copy (| γ0_0 |) in
                                    let r := M.copy (| γ0_1 |) in
                                    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 (|
                                                                BinOp.ne (|
                                                                  M.read (| s |),
                                                                  Value.Integer IntegerKind.U32 0
                                                                |)
                                                              |)
                                                            |)) in
                                                        let _ :=
                                                          M.is_constant_or_break_match (|
                                                            M.read (| γ |),
                                                            Value.Bool true
                                                          |) in
                                                        M.alloc (|
                                                          M.never_to_any (|
                                                            M.call_closure (|
                                                              M.get_function (|
                                                                "core::panicking::panic_fmt",
                                                                []
                                                              |),
                                                              [
                                                                M.call_closure (|
                                                                  M.get_associated_function (|
                                                                    Ty.path "core::fmt::Arguments",
                                                                    "new_const",
                                                                    []
                                                                  |),
                                                                  [
                                                                    M.alloc (|
                                                                      Value.Array
                                                                        [
                                                                          M.read (|
                                                                            Value.String
                                                                              "`$s` is  zero in `last_stage!`."
                                                                          |)
                                                                        ]
                                                                    |)
                                                                  ]
                                                                |)
                                                              ]
                                                            |)
                                                          |)
                                                        |)));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.alloc (| Value.Tuple [] |)))
                                                  ]
                                                |) in
                                              M.alloc (| Value.Tuple [] |)));
                                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                        ]
                                      |) in
                                    let~ lo :=
                                      M.alloc (|
                                        BinOp.bit_and
                                          (M.read (| n |))
                                          (M.read (|
                                            M.get_constant (|
                                              "core::num::int_sqrt::u64_stages::LOWER_HALF_1_BITS'2"
                                            |)
                                          |))
                                      |) in
                                    let~ numerator :=
                                      M.alloc (|
                                        BinOp.bit_or
                                          (BinOp.Wrap.shl (|
                                            M.rust_cast (M.read (| r |)),
                                            M.read (|
                                              M.get_constant (|
                                                "core::num::int_sqrt::u64_stages::QUARTER_BITS'2"
                                              |)
                                            |)
                                          |))
                                          (BinOp.Wrap.shr (|
                                            M.read (| lo |),
                                            M.read (|
                                              M.get_constant (|
                                                "core::num::int_sqrt::u64_stages::QUARTER_BITS'2"
                                              |)
                                            |)
                                          |))
                                      |) in
                                    let~ denominator :=
                                      M.alloc (|
                                        BinOp.Wrap.shl (|
                                          M.rust_cast (M.read (| s |)),
                                          Value.Integer IntegerKind.I32 1
                                        |)
                                      |) in
                                    let~ q :=
                                      M.alloc (|
                                        BinOp.Wrap.div (|
                                          M.read (| numerator |),
                                          M.read (| denominator |)
                                        |)
                                      |) in
                                    let~ s :=
                                      M.alloc (|
                                        BinOp.Wrap.add (|
                                          M.rust_cast
                                            (BinOp.Wrap.shl (|
                                              M.read (| s |),
                                              M.read (|
                                                M.get_constant (|
                                                  "core::num::int_sqrt::u64_stages::QUARTER_BITS'2"
                                                |)
                                              |)
                                            |)),
                                          M.read (| q |)
                                        |)
                                      |) in
                                    M.match_operator (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.path "u64",
                                            "overflowing_mul",
                                            []
                                          |),
                                          [ M.read (| s |); M.read (| s |) ]
                                        |)
                                      |),
                                      [
                                        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 s_squared := M.copy (| γ0_0 |) in
                                            let overflow := M.copy (| γ0_1 |) in
                                            let~ _ :=
                                              M.match_operator (|
                                                M.alloc (| Value.Tuple [] |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let γ :=
                                                        M.use
                                                          (M.alloc (|
                                                            LogicalOp.or (|
                                                              M.read (| overflow |),
                                                              ltac:(M.monadic
                                                                (BinOp.gt (|
                                                                  M.read (| s_squared |),
                                                                  M.read (| n |)
                                                                |)))
                                                            |)
                                                          |)) in
                                                      let _ :=
                                                        M.is_constant_or_break_match (|
                                                          M.read (| γ |),
                                                          Value.Bool true
                                                        |) in
                                                      let~ _ :=
                                                        let β := s in
                                                        M.write (|
                                                          β,
                                                          BinOp.Wrap.sub (|
                                                            M.read (| β |),
                                                            Value.Integer IntegerKind.U64 1
                                                          |)
                                                        |) in
                                                      M.alloc (| Value.Tuple [] |)));
                                                  fun γ =>
                                                    ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                                ]
                                              |) in
                                            s))
                                      ]
                                    |)))
                              ]
                            |)))
                      ]
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u64_stages : M.IsFunction "core::num::int_sqrt::u64_stages" u64_stages.
    
    Module u64_stages.
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (| Value.Integer IntegerKind.U32 64, Value.Integer IntegerKind.U32 8 |)
            |))).
      
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                Value.Integer IntegerKind.U32 64,
                M.read (| M.get_constant (| "core::num::BITS" |) |)
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U16 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u64_stages::HALF_BITS" |) |)
                |),
                Value.Integer IntegerKind.U16 1
              |)
            |))).
      
      Definition value_LOWEST_QUARTER_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U16 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u64_stages::QUARTER_BITS" |) |)
                |),
                Value.Integer IntegerKind.U16 1
              |)
            |))).
      
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                Value.Integer IntegerKind.U32 64,
                M.read (| M.get_constant (| "core::num::BITS" |) |)
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U32 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u64_stages::HALF_BITS'1" |) |)
                |),
                Value.Integer IntegerKind.U32 1
              |)
            |))).
      
      Definition value_LOWEST_QUARTER_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U32 1,
                  M.read (|
                    M.get_constant (| "core::num::int_sqrt::u64_stages::QUARTER_BITS'1" |)
                  |)
                |),
                Value.Integer IntegerKind.U32 1
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U64 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u64_stages::HALF_BITS'2" |) |)
                |),
                Value.Integer IntegerKind.U64 1
              |)
            |))).
    End u64_stages.
    
    (*
    const fn u128_stages(n: u128) -> u128 {
        let (s, r) = first_stage!(128, n);
        let (s, r) = middle_stage!(128, u16, n, s, r);
        let (s, r) = middle_stage!(128, u32, n, s, r);
        let (s, r) = middle_stage!(128, u64, n, s, r);
        last_stage!(u128, n, s, r)
    }
    *)
    Definition u128_stages (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              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 (|
                                          BinOp.ne (|
                                            M.read (| n |),
                                            Value.Integer IntegerKind.U128 0
                                          |)
                                        |)
                                      |)) in
                                  let _ :=
                                    M.is_constant_or_break_match (|
                                      M.read (| γ |),
                                      Value.Bool true
                                    |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.call_closure (|
                                        M.get_function (| "core::panicking::panic_fmt", [] |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "core::fmt::Arguments",
                                              "new_const",
                                              []
                                            |),
                                            [
                                              M.alloc (|
                                                Value.Array
                                                  [
                                                    M.read (|
                                                      Value.String
                                                        "`$n` is  zero in `first_stage!`."
                                                    |)
                                                  ]
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    |)
                                  |)));
                              fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                            ]
                          |) in
                        M.alloc (| Value.Tuple [] |)));
                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                  ]
                |) in
              let~ n :=
                M.alloc (|
                  BinOp.Wrap.shr (|
                    M.read (| n |),
                    M.read (| M.get_constant (| "core::num::int_sqrt::u128_stages::N_SHIFT" |) |)
                  |)
                |) in
              M.match_operator (|
                M.SubPointer.get_array_field (|
                  M.get_constant (| "core::num::int_sqrt::U8_ISQRT_WITH_REMAINDER" |),
                  M.alloc (| M.rust_cast (M.read (| n |)) |)
                |),
                [
                  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 s := M.copy (| γ0_0 |) in
                      let r := M.copy (| γ0_1 |) in
                      let~ _ :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_function (| "core::hint::assert_unchecked", [] |),
                            [ BinOp.ne (| M.read (| s |), Value.Integer IntegerKind.U8 0 |) ]
                          |)
                        |) in
                      M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                ]
              |),
              [
                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 s := M.copy (| γ0_0 |) in
                    let r := M.copy (| γ0_1 |) in
                    M.match_operator (|
                      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 (|
                                                  BinOp.ne (|
                                                    M.read (| s |),
                                                    Value.Integer IntegerKind.U8 0
                                                  |)
                                                |)
                                              |)) in
                                          let _ :=
                                            M.is_constant_or_break_match (|
                                              M.read (| γ |),
                                              Value.Bool true
                                            |) in
                                          M.alloc (|
                                            M.never_to_any (|
                                              M.call_closure (|
                                                M.get_function (|
                                                  "core::panicking::panic_fmt",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path "core::fmt::Arguments",
                                                      "new_const",
                                                      []
                                                    |),
                                                    [
                                                      M.alloc (|
                                                        Value.Array
                                                          [
                                                            M.read (|
                                                              Value.String
                                                                "`$s` is  zero in `middle_stage!`."
                                                            |)
                                                          ]
                                                      |)
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            |)
                                          |)));
                                      fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |) in
                                M.alloc (| Value.Tuple [] |)));
                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                          ]
                        |) in
                      let~ n :=
                        M.alloc (|
                          M.rust_cast
                            (BinOp.Wrap.shr (|
                              M.read (| n |),
                              M.read (|
                                M.get_constant (| "core::num::int_sqrt::u128_stages::N_SHIFT'1" |)
                              |)
                            |))
                        |) in
                      let~ lo :=
                        M.alloc (|
                          BinOp.bit_and
                            (M.read (| n |))
                            (M.read (|
                              M.get_constant (|
                                "core::num::int_sqrt::u128_stages::LOWER_HALF_1_BITS"
                              |)
                            |))
                        |) in
                      let~ numerator :=
                        M.alloc (|
                          BinOp.bit_or
                            (BinOp.Wrap.shl (|
                              M.rust_cast (M.read (| r |)),
                              M.read (|
                                M.get_constant (|
                                  "core::num::int_sqrt::u128_stages::QUARTER_BITS"
                                |)
                              |)
                            |))
                            (BinOp.Wrap.shr (|
                              M.read (| lo |),
                              M.read (|
                                M.get_constant (|
                                  "core::num::int_sqrt::u128_stages::QUARTER_BITS"
                                |)
                              |)
                            |))
                        |) in
                      let~ denominator :=
                        M.alloc (|
                          BinOp.Wrap.shl (|
                            M.rust_cast (M.read (| s |)),
                            Value.Integer IntegerKind.I32 1
                          |)
                        |) in
                      let~ q :=
                        M.alloc (|
                          BinOp.Wrap.div (| M.read (| numerator |), M.read (| denominator |) |)
                        |) in
                      let~ u :=
                        M.alloc (|
                          BinOp.Wrap.rem (| M.read (| numerator |), M.read (| denominator |) |)
                        |) in
                      let~ s :=
                        M.alloc (|
                          BinOp.Wrap.add (|
                            M.rust_cast
                              (BinOp.Wrap.shl (|
                                M.read (| s |),
                                M.read (|
                                  M.get_constant (|
                                    "core::num::int_sqrt::u128_stages::QUARTER_BITS"
                                  |)
                                |)
                              |)),
                            M.read (| q |)
                          |)
                        |) in
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Ty.path "u16", "overflowing_sub", [] |),
                            [
                              BinOp.bit_or
                                (BinOp.Wrap.shl (|
                                  M.read (| u |),
                                  M.read (|
                                    M.get_constant (|
                                      "core::num::int_sqrt::u128_stages::QUARTER_BITS"
                                    |)
                                  |)
                                |))
                                (BinOp.bit_and
                                  (M.read (| lo |))
                                  (M.read (|
                                    M.get_constant (|
                                      "core::num::int_sqrt::u128_stages::LOWEST_QUARTER_1_BITS"
                                    |)
                                  |)));
                              BinOp.Wrap.mul (| M.read (| q |), M.read (| q |) |)
                            ]
                          |)
                        |),
                        [
                          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 r := M.copy (| γ0_0 |) in
                              let overflow := M.copy (| γ0_1 |) in
                              let~ _ :=
                                M.match_operator (|
                                  M.alloc (| Value.Tuple [] |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ := M.use overflow in
                                        let _ :=
                                          M.is_constant_or_break_match (|
                                            M.read (| γ |),
                                            Value.Bool true
                                          |) in
                                        let~ _ :=
                                          M.write (|
                                            r,
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.path "u16",
                                                "wrapping_add",
                                                []
                                              |),
                                              [
                                                M.read (| r |);
                                                BinOp.Wrap.sub (|
                                                  BinOp.Wrap.mul (|
                                                    Value.Integer IntegerKind.U16 2,
                                                    M.read (| s |)
                                                  |),
                                                  Value.Integer IntegerKind.U16 1
                                                |)
                                              ]
                                            |)
                                          |) in
                                        let~ _ :=
                                          let β := s in
                                          M.write (|
                                            β,
                                            BinOp.Wrap.sub (|
                                              M.read (| β |),
                                              Value.Integer IntegerKind.U16 1
                                            |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              let~ _ :=
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (| "core::hint::assert_unchecked", [] |),
                                    [ BinOp.ne (| M.read (| s |), Value.Integer IntegerKind.U16 0 |)
                                    ]
                                  |)
                                |) in
                              M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                        ]
                      |),
                      [
                        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 s := M.copy (| γ0_0 |) in
                            let r := M.copy (| γ0_1 |) in
                            M.match_operator (|
                              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 (|
                                                          BinOp.ne (|
                                                            M.read (| s |),
                                                            Value.Integer IntegerKind.U16 0
                                                          |)
                                                        |)
                                                      |)) in
                                                  let _ :=
                                                    M.is_constant_or_break_match (|
                                                      M.read (| γ |),
                                                      Value.Bool true
                                                    |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.call_closure (|
                                                        M.get_function (|
                                                          "core::panicking::panic_fmt",
                                                          []
                                                        |),
                                                        [
                                                          M.call_closure (|
                                                            M.get_associated_function (|
                                                              Ty.path "core::fmt::Arguments",
                                                              "new_const",
                                                              []
                                                            |),
                                                            [
                                                              M.alloc (|
                                                                Value.Array
                                                                  [
                                                                    M.read (|
                                                                      Value.String
                                                                        "`$s` is  zero in `middle_stage!`."
                                                                    |)
                                                                  ]
                                                              |)
                                                            ]
                                                          |)
                                                        ]
                                                      |)
                                                    |)
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                            ]
                                          |) in
                                        M.alloc (| Value.Tuple [] |)));
                                    fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              let~ n :=
                                M.alloc (|
                                  M.rust_cast
                                    (BinOp.Wrap.shr (|
                                      M.read (| n |),
                                      M.read (|
                                        M.get_constant (|
                                          "core::num::int_sqrt::u128_stages::N_SHIFT'2"
                                        |)
                                      |)
                                    |))
                                |) in
                              let~ lo :=
                                M.alloc (|
                                  BinOp.bit_and
                                    (M.read (| n |))
                                    (M.read (|
                                      M.get_constant (|
                                        "core::num::int_sqrt::u128_stages::LOWER_HALF_1_BITS'1"
                                      |)
                                    |))
                                |) in
                              let~ numerator :=
                                M.alloc (|
                                  BinOp.bit_or
                                    (BinOp.Wrap.shl (|
                                      M.rust_cast (M.read (| r |)),
                                      M.read (|
                                        M.get_constant (|
                                          "core::num::int_sqrt::u128_stages::QUARTER_BITS'1"
                                        |)
                                      |)
                                    |))
                                    (BinOp.Wrap.shr (|
                                      M.read (| lo |),
                                      M.read (|
                                        M.get_constant (|
                                          "core::num::int_sqrt::u128_stages::QUARTER_BITS'1"
                                        |)
                                      |)
                                    |))
                                |) in
                              let~ denominator :=
                                M.alloc (|
                                  BinOp.Wrap.shl (|
                                    M.rust_cast (M.read (| s |)),
                                    Value.Integer IntegerKind.I32 1
                                  |)
                                |) in
                              let~ q :=
                                M.alloc (|
                                  BinOp.Wrap.div (|
                                    M.read (| numerator |),
                                    M.read (| denominator |)
                                  |)
                                |) in
                              let~ u :=
                                M.alloc (|
                                  BinOp.Wrap.rem (|
                                    M.read (| numerator |),
                                    M.read (| denominator |)
                                  |)
                                |) in
                              let~ s :=
                                M.alloc (|
                                  BinOp.Wrap.add (|
                                    M.rust_cast
                                      (BinOp.Wrap.shl (|
                                        M.read (| s |),
                                        M.read (|
                                          M.get_constant (|
                                            "core::num::int_sqrt::u128_stages::QUARTER_BITS'1"
                                          |)
                                        |)
                                      |)),
                                    M.read (| q |)
                                  |)
                                |) in
                              M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "u32",
                                      "overflowing_sub",
                                      []
                                    |),
                                    [
                                      BinOp.bit_or
                                        (BinOp.Wrap.shl (|
                                          M.read (| u |),
                                          M.read (|
                                            M.get_constant (|
                                              "core::num::int_sqrt::u128_stages::QUARTER_BITS'1"
                                            |)
                                          |)
                                        |))
                                        (BinOp.bit_and
                                          (M.read (| lo |))
                                          (M.read (|
                                            M.get_constant (|
                                              "core::num::int_sqrt::u128_stages::LOWEST_QUARTER_1_BITS'1"
                                            |)
                                          |)));
                                      BinOp.Wrap.mul (| M.read (| q |), M.read (| q |) |)
                                    ]
                                  |)
                                |),
                                [
                                  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 r := M.copy (| γ0_0 |) in
                                      let overflow := M.copy (| γ0_1 |) in
                                      let~ _ :=
                                        M.match_operator (|
                                          M.alloc (| Value.Tuple [] |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let γ := M.use overflow in
                                                let _ :=
                                                  M.is_constant_or_break_match (|
                                                    M.read (| γ |),
                                                    Value.Bool true
                                                  |) in
                                                let~ _ :=
                                                  M.write (|
                                                    r,
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.path "u32",
                                                        "wrapping_add",
                                                        []
                                                      |),
                                                      [
                                                        M.read (| r |);
                                                        BinOp.Wrap.sub (|
                                                          BinOp.Wrap.mul (|
                                                            Value.Integer IntegerKind.U32 2,
                                                            M.read (| s |)
                                                          |),
                                                          Value.Integer IntegerKind.U32 1
                                                        |)
                                                      ]
                                                    |)
                                                  |) in
                                                let~ _ :=
                                                  let β := s in
                                                  M.write (|
                                                    β,
                                                    BinOp.Wrap.sub (|
                                                      M.read (| β |),
                                                      Value.Integer IntegerKind.U32 1
                                                    |)
                                                  |) in
                                                M.alloc (| Value.Tuple [] |)));
                                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                          ]
                                        |) in
                                      let~ _ :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_function (| "core::hint::assert_unchecked", [] |),
                                            [
                                              BinOp.ne (|
                                                M.read (| s |),
                                                Value.Integer IntegerKind.U32 0
                                              |)
                                            ]
                                          |)
                                        |) in
                                      M.alloc (| Value.Tuple [ M.read (| s |); M.read (| r |) ] |)))
                                ]
                              |),
                              [
                                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 s := M.copy (| γ0_0 |) in
                                    let r := M.copy (| γ0_1 |) in
                                    M.match_operator (|
                                      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 (|
                                                                  BinOp.ne (|
                                                                    M.read (| s |),
                                                                    Value.Integer IntegerKind.U32 0
                                                                  |)
                                                                |)
                                                              |)) in
                                                          let _ :=
                                                            M.is_constant_or_break_match (|
                                                              M.read (| γ |),
                                                              Value.Bool true
                                                            |) in
                                                          M.alloc (|
                                                            M.never_to_any (|
                                                              M.call_closure (|
                                                                M.get_function (|
                                                                  "core::panicking::panic_fmt",
                                                                  []
                                                                |),
                                                                [
                                                                  M.call_closure (|
                                                                    M.get_associated_function (|
                                                                      Ty.path
                                                                        "core::fmt::Arguments",
                                                                      "new_const",
                                                                      []
                                                                    |),
                                                                    [
                                                                      M.alloc (|
                                                                        Value.Array
                                                                          [
                                                                            M.read (|
                                                                              Value.String
                                                                                "`$s` is  zero in `middle_stage!`."
                                                                            |)
                                                                          ]
                                                                      |)
                                                                    ]
                                                                  |)
                                                                ]
                                                              |)
                                                            |)
                                                          |)));
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.alloc (| Value.Tuple [] |)))
                                                    ]
                                                  |) in
                                                M.alloc (| Value.Tuple [] |)));
                                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                          ]
                                        |) in
                                      let~ n :=
                                        M.alloc (|
                                          M.rust_cast
                                            (BinOp.Wrap.shr (|
                                              M.read (| n |),
                                              M.read (|
                                                M.get_constant (|
                                                  "core::num::int_sqrt::u128_stages::N_SHIFT'3"
                                                |)
                                              |)
                                            |))
                                        |) in
                                      let~ lo :=
                                        M.alloc (|
                                          BinOp.bit_and
                                            (M.read (| n |))
                                            (M.read (|
                                              M.get_constant (|
                                                "core::num::int_sqrt::u128_stages::LOWER_HALF_1_BITS'2"
                                              |)
                                            |))
                                        |) in
                                      let~ numerator :=
                                        M.alloc (|
                                          BinOp.bit_or
                                            (BinOp.Wrap.shl (|
                                              M.rust_cast (M.read (| r |)),
                                              M.read (|
                                                M.get_constant (|
                                                  "core::num::int_sqrt::u128_stages::QUARTER_BITS'2"
                                                |)
                                              |)
                                            |))
                                            (BinOp.Wrap.shr (|
                                              M.read (| lo |),
                                              M.read (|
                                                M.get_constant (|
                                                  "core::num::int_sqrt::u128_stages::QUARTER_BITS'2"
                                                |)
                                              |)
                                            |))
                                        |) in
                                      let~ denominator :=
                                        M.alloc (|
                                          BinOp.Wrap.shl (|
                                            M.rust_cast (M.read (| s |)),
                                            Value.Integer IntegerKind.I32 1
                                          |)
                                        |) in
                                      let~ q :=
                                        M.alloc (|
                                          BinOp.Wrap.div (|
                                            M.read (| numerator |),
                                            M.read (| denominator |)
                                          |)
                                        |) in
                                      let~ u :=
                                        M.alloc (|
                                          BinOp.Wrap.rem (|
                                            M.read (| numerator |),
                                            M.read (| denominator |)
                                          |)
                                        |) in
                                      let~ s :=
                                        M.alloc (|
                                          BinOp.Wrap.add (|
                                            M.rust_cast
                                              (BinOp.Wrap.shl (|
                                                M.read (| s |),
                                                M.read (|
                                                  M.get_constant (|
                                                    "core::num::int_sqrt::u128_stages::QUARTER_BITS'2"
                                                  |)
                                                |)
                                              |)),
                                            M.read (| q |)
                                          |)
                                        |) in
                                      M.match_operator (|
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.path "u64",
                                              "overflowing_sub",
                                              []
                                            |),
                                            [
                                              BinOp.bit_or
                                                (BinOp.Wrap.shl (|
                                                  M.read (| u |),
                                                  M.read (|
                                                    M.get_constant (|
                                                      "core::num::int_sqrt::u128_stages::QUARTER_BITS'2"
                                                    |)
                                                  |)
                                                |))
                                                (BinOp.bit_and
                                                  (M.read (| lo |))
                                                  (M.read (|
                                                    M.get_constant (|
                                                      "core::num::int_sqrt::u128_stages::LOWEST_QUARTER_1_BITS'2"
                                                    |)
                                                  |)));
                                              BinOp.Wrap.mul (| M.read (| q |), M.read (| q |) |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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 r := M.copy (| γ0_0 |) in
                                              let overflow := M.copy (| γ0_1 |) in
                                              let~ _ :=
                                                M.match_operator (|
                                                  M.alloc (| Value.Tuple [] |),
                                                  [
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (let γ := M.use overflow in
                                                        let _ :=
                                                          M.is_constant_or_break_match (|
                                                            M.read (| γ |),
                                                            Value.Bool true
                                                          |) in
                                                        let~ _ :=
                                                          M.write (|
                                                            r,
                                                            M.call_closure (|
                                                              M.get_associated_function (|
                                                                Ty.path "u64",
                                                                "wrapping_add",
                                                                []
                                                              |),
                                                              [
                                                                M.read (| r |);
                                                                BinOp.Wrap.sub (|
                                                                  BinOp.Wrap.mul (|
                                                                    Value.Integer IntegerKind.U64 2,
                                                                    M.read (| s |)
                                                                  |),
                                                                  Value.Integer IntegerKind.U64 1
                                                                |)
                                                              ]
                                                            |)
                                                          |) in
                                                        let~ _ :=
                                                          let β := s in
                                                          M.write (|
                                                            β,
                                                            BinOp.Wrap.sub (|
                                                              M.read (| β |),
                                                              Value.Integer IntegerKind.U64 1
                                                            |)
                                                          |) in
                                                        M.alloc (| Value.Tuple [] |)));
                                                    fun γ =>
                                                      ltac:(M.monadic
                                                        (M.alloc (| Value.Tuple [] |)))
                                                  ]
                                                |) in
                                              let~ _ :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_function (|
                                                      "core::hint::assert_unchecked",
                                                      []
                                                    |),
                                                    [
                                                      BinOp.ne (|
                                                        M.read (| s |),
                                                        Value.Integer IntegerKind.U64 0
                                                      |)
                                                    ]
                                                  |)
                                                |) in
                                              M.alloc (|
                                                Value.Tuple [ M.read (| s |); M.read (| r |) ]
                                              |)))
                                        ]
                                      |),
                                      [
                                        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 s := M.copy (| γ0_0 |) in
                                            let r := M.copy (| γ0_1 |) in
                                            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 (|
                                                                        BinOp.ne (|
                                                                          M.read (| s |),
                                                                          Value.Integer
                                                                            IntegerKind.U64
                                                                            0
                                                                        |)
                                                                      |)
                                                                    |)) in
                                                                let _ :=
                                                                  M.is_constant_or_break_match (|
                                                                    M.read (| γ |),
                                                                    Value.Bool true
                                                                  |) in
                                                                M.alloc (|
                                                                  M.never_to_any (|
                                                                    M.call_closure (|
                                                                      M.get_function (|
                                                                        "core::panicking::panic_fmt",
                                                                        []
                                                                      |),
                                                                      [
                                                                        M.call_closure (|
                                                                          M.get_associated_function (|
                                                                            Ty.path
                                                                              "core::fmt::Arguments",
                                                                            "new_const",
                                                                            []
                                                                          |),
                                                                          [
                                                                            M.alloc (|
                                                                              Value.Array
                                                                                [
                                                                                  M.read (|
                                                                                    Value.String
                                                                                      "`$s` is  zero in `last_stage!`."
                                                                                  |)
                                                                                ]
                                                                            |)
                                                                          ]
                                                                        |)
                                                                      ]
                                                                    |)
                                                                  |)
                                                                |)));
                                                            fun γ =>
                                                              ltac:(M.monadic
                                                                (M.alloc (| Value.Tuple [] |)))
                                                          ]
                                                        |) in
                                                      M.alloc (| Value.Tuple [] |)));
                                                  fun γ =>
                                                    ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                                ]
                                              |) in
                                            let~ lo :=
                                              M.alloc (|
                                                BinOp.bit_and
                                                  (M.read (| n |))
                                                  (M.read (|
                                                    M.get_constant (|
                                                      "core::num::int_sqrt::u128_stages::LOWER_HALF_1_BITS'3"
                                                    |)
                                                  |))
                                              |) in
                                            let~ numerator :=
                                              M.alloc (|
                                                BinOp.bit_or
                                                  (BinOp.Wrap.shl (|
                                                    M.rust_cast (M.read (| r |)),
                                                    M.read (|
                                                      M.get_constant (|
                                                        "core::num::int_sqrt::u128_stages::QUARTER_BITS'3"
                                                      |)
                                                    |)
                                                  |))
                                                  (BinOp.Wrap.shr (|
                                                    M.read (| lo |),
                                                    M.read (|
                                                      M.get_constant (|
                                                        "core::num::int_sqrt::u128_stages::QUARTER_BITS'3"
                                                      |)
                                                    |)
                                                  |))
                                              |) in
                                            let~ denominator :=
                                              M.alloc (|
                                                BinOp.Wrap.shl (|
                                                  M.rust_cast (M.read (| s |)),
                                                  Value.Integer IntegerKind.I32 1
                                                |)
                                              |) in
                                            let~ q :=
                                              M.alloc (|
                                                BinOp.Wrap.div (|
                                                  M.read (| numerator |),
                                                  M.read (| denominator |)
                                                |)
                                              |) in
                                            let~ s :=
                                              M.alloc (|
                                                BinOp.Wrap.add (|
                                                  M.rust_cast
                                                    (BinOp.Wrap.shl (|
                                                      M.read (| s |),
                                                      M.read (|
                                                        M.get_constant (|
                                                          "core::num::int_sqrt::u128_stages::QUARTER_BITS'3"
                                                        |)
                                                      |)
                                                    |)),
                                                  M.read (| q |)
                                                |)
                                              |) in
                                            M.match_operator (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.path "u128",
                                                    "overflowing_mul",
                                                    []
                                                  |),
                                                  [ M.read (| s |); M.read (| s |) ]
                                                |)
                                              |),
                                              [
                                                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 s_squared := M.copy (| γ0_0 |) in
                                                    let overflow := M.copy (| γ0_1 |) in
                                                    let~ _ :=
                                                      M.match_operator (|
                                                        M.alloc (| Value.Tuple [] |),
                                                        [
                                                          fun γ =>
                                                            ltac:(M.monadic
                                                              (let γ :=
                                                                M.use
                                                                  (M.alloc (|
                                                                    LogicalOp.or (|
                                                                      M.read (| overflow |),
                                                                      ltac:(M.monadic
                                                                        (BinOp.gt (|
                                                                          M.read (| s_squared |),
                                                                          M.read (| n |)
                                                                        |)))
                                                                    |)
                                                                  |)) in
                                                              let _ :=
                                                                M.is_constant_or_break_match (|
                                                                  M.read (| γ |),
                                                                  Value.Bool true
                                                                |) in
                                                              let~ _ :=
                                                                let β := s in
                                                                M.write (|
                                                                  β,
                                                                  BinOp.Wrap.sub (|
                                                                    M.read (| β |),
                                                                    Value.Integer IntegerKind.U128 1
                                                                  |)
                                                                |) in
                                                              M.alloc (| Value.Tuple [] |)));
                                                          fun γ =>
                                                            ltac:(M.monadic
                                                              (M.alloc (| Value.Tuple [] |)))
                                                        ]
                                                      |) in
                                                    s))
                                              ]
                                            |)))
                                      ]
                                    |)))
                              ]
                            |)))
                      ]
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u128_stages : M.IsFunction "core::num::int_sqrt::u128_stages" u128_stages.
    
    Module u128_stages.
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                Value.Integer IntegerKind.U32 128,
                Value.Integer IntegerKind.U32 8
              |)
            |))).
      
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                Value.Integer IntegerKind.U32 128,
                M.read (| M.get_constant (| "core::num::BITS" |) |)
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U16 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u128_stages::HALF_BITS" |) |)
                |),
                Value.Integer IntegerKind.U16 1
              |)
            |))).
      
      Definition value_LOWEST_QUARTER_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U16 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u128_stages::QUARTER_BITS" |) |)
                |),
                Value.Integer IntegerKind.U16 1
              |)
            |))).
      
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                Value.Integer IntegerKind.U32 128,
                M.read (| M.get_constant (| "core::num::BITS" |) |)
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U32 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u128_stages::HALF_BITS'1" |) |)
                |),
                Value.Integer IntegerKind.U32 1
              |)
            |))).
      
      Definition value_LOWEST_QUARTER_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U32 1,
                  M.read (|
                    M.get_constant (| "core::num::int_sqrt::u128_stages::QUARTER_BITS'1" |)
                  |)
                |),
                Value.Integer IntegerKind.U32 1
              |)
            |))).
      
      Definition value_N_SHIFT : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                Value.Integer IntegerKind.U32 128,
                M.read (| M.get_constant (| "core::num::BITS" |) |)
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U64 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u128_stages::HALF_BITS'2" |) |)
                |),
                Value.Integer IntegerKind.U64 1
              |)
            |))).
      
      Definition value_LOWEST_QUARTER_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U64 1,
                  M.read (|
                    M.get_constant (| "core::num::int_sqrt::u128_stages::QUARTER_BITS'2" |)
                  |)
                |),
                Value.Integer IntegerKind.U64 1
              |)
            |))).
      
      Definition value_HALF_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 1
              |)
            |))).
      
      Definition value_QUARTER_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.shr (|
                M.read (| M.get_constant (| "core::num::BITS" |) |),
                Value.Integer IntegerKind.I32 2
              |)
            |))).
      
      Definition value_LOWER_HALF_1_BITS : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              BinOp.Wrap.sub (|
                BinOp.Wrap.shl (|
                  Value.Integer IntegerKind.U128 1,
                  M.read (| M.get_constant (| "core::num::int_sqrt::u128_stages::HALF_BITS'3" |) |)
                |),
                Value.Integer IntegerKind.U128 1
              |)
            |))).
    End u128_stages.
    
    (*
            pub const fn $UnsignedT(mut n: $UnsignedT) -> $UnsignedT {
                if n <= <$HalfBitsT>::MAX as $UnsignedT {
                    $HalfBitsT(n as $HalfBitsT) as $UnsignedT
                } else {
                    // The normalization shift satisfies the Karatsuba square root
                    // algorithm precondition "a₃ ≥ b/4" where a₃ is the most
                    // significant quarter of `n`'s bits and b is the number of
                    // values that can be represented by that quarter of the bits.
                    //
                    // b/4 would then be all 0s except the second most significant
                    // bit (010...0) in binary. Since a₃ must be at least b/4, a₃'s
                    // most significant bit or its neighbor must be a 1. Since a₃'s
                    // most significant bits are `n`'s most significant bits, the
                    // same applies to `n`.
                    //
                    // The reason to shift by an even number of bits is because an
                    // even number of bits produces the square root shifted to the
                    // left by half of the normalization shift:
                    //
                    // sqrt(n << (2 * p))
                    // sqrt(2.pow(2 * p) * n)
                    // sqrt(2.pow(2 * p)) * sqrt(n)
                    // 2.pow(p) * sqrt(n)
                    // sqrt(n) << p
                    //
                    // Shifting by an odd number of bits leaves an ugly sqrt(2)
                    // multiplied in:
                    //
                    // sqrt(n << (2 * p + 1))
                    // sqrt(2.pow(2 * p + 1) * n)
                    // sqrt(2 * 2.pow(2 * p) * n)
                    // sqrt(2) * sqrt(2.pow(2 * p)) * sqrt(n)
                    // sqrt(2) * 2.pow(p) * sqrt(n)
                    // sqrt(2) * (sqrt(n) << p)
                    const EVEN_MAKING_BITMASK: u32 = !1;
                    let normalization_shift = n.leading_zeros() & EVEN_MAKING_BITMASK;
                    n <<= normalization_shift;
    
                    let s = $stages(n);
    
                    let denormalization_shift = normalization_shift >> 1;
                    s >> denormalization_shift
                }
            }
    *)
    Definition u16 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              M.alloc (| Value.Tuple [] |),
              [
                fun γ =>
                  ltac:(M.monadic
                    (let γ :=
                      M.use
                        (M.alloc (|
                          BinOp.le (|
                            M.read (| n |),
                            M.rust_cast (M.read (| M.get_constant (| "core::num::MAX" |) |))
                          |)
                        |)) in
                    let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u8", [] |),
                          [ M.rust_cast (M.read (| n |)) ]
                        |))
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let~ normalization_shift :=
                      M.alloc (|
                        BinOp.bit_and
                          (M.call_closure (|
                            M.get_associated_function (| Ty.path "u16", "leading_zeros", [] |),
                            [ M.read (| n |) ]
                          |))
                          (M.read (|
                            M.get_constant (| "core::num::int_sqrt::u16::EVEN_MAKING_BITMASK" |)
                          |))
                      |) in
                    let~ _ :=
                      let β := n in
                      M.write (|
                        β,
                        BinOp.Wrap.shl (| M.read (| β |), M.read (| normalization_shift |) |)
                      |) in
                    let~ s :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u16_stages", [] |),
                          [ M.read (| n |) ]
                        |)
                      |) in
                    let~ denormalization_shift :=
                      M.alloc (|
                        BinOp.Wrap.shr (|
                          M.read (| normalization_shift |),
                          Value.Integer IntegerKind.I32 1
                        |)
                      |) in
                    M.alloc (|
                      BinOp.Wrap.shr (| M.read (| s |), M.read (| denormalization_shift |) |)
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u16 : M.IsFunction "core::num::int_sqrt::u16" u16.
    
    Module u16.
      Definition value_EVEN_MAKING_BITMASK : Value.t :=
        M.run ltac:(M.monadic (M.alloc (| UnOp.not (| Value.Integer IntegerKind.U32 1 |) |))).
    End u16.
    
    (*
            pub const fn $UnsignedT(mut n: $UnsignedT) -> $UnsignedT {
                if n <= <$HalfBitsT>::MAX as $UnsignedT {
                    $HalfBitsT(n as $HalfBitsT) as $UnsignedT
                } else {
                    // The normalization shift satisfies the Karatsuba square root
                    // algorithm precondition "a₃ ≥ b/4" where a₃ is the most
                    // significant quarter of `n`'s bits and b is the number of
                    // values that can be represented by that quarter of the bits.
                    //
                    // b/4 would then be all 0s except the second most significant
                    // bit (010...0) in binary. Since a₃ must be at least b/4, a₃'s
                    // most significant bit or its neighbor must be a 1. Since a₃'s
                    // most significant bits are `n`'s most significant bits, the
                    // same applies to `n`.
                    //
                    // The reason to shift by an even number of bits is because an
                    // even number of bits produces the square root shifted to the
                    // left by half of the normalization shift:
                    //
                    // sqrt(n << (2 * p))
                    // sqrt(2.pow(2 * p) * n)
                    // sqrt(2.pow(2 * p)) * sqrt(n)
                    // 2.pow(p) * sqrt(n)
                    // sqrt(n) << p
                    //
                    // Shifting by an odd number of bits leaves an ugly sqrt(2)
                    // multiplied in:
                    //
                    // sqrt(n << (2 * p + 1))
                    // sqrt(2.pow(2 * p + 1) * n)
                    // sqrt(2 * 2.pow(2 * p) * n)
                    // sqrt(2) * sqrt(2.pow(2 * p)) * sqrt(n)
                    // sqrt(2) * 2.pow(p) * sqrt(n)
                    // sqrt(2) * (sqrt(n) << p)
                    const EVEN_MAKING_BITMASK: u32 = !1;
                    let normalization_shift = n.leading_zeros() & EVEN_MAKING_BITMASK;
                    n <<= normalization_shift;
    
                    let s = $stages(n);
    
                    let denormalization_shift = normalization_shift >> 1;
                    s >> denormalization_shift
                }
            }
    *)
    Definition u32 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              M.alloc (| Value.Tuple [] |),
              [
                fun γ =>
                  ltac:(M.monadic
                    (let γ :=
                      M.use
                        (M.alloc (|
                          BinOp.le (|
                            M.read (| n |),
                            M.rust_cast (M.read (| M.get_constant (| "core::num::MAX" |) |))
                          |)
                        |)) in
                    let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u16", [] |),
                          [ M.rust_cast (M.read (| n |)) ]
                        |))
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let~ normalization_shift :=
                      M.alloc (|
                        BinOp.bit_and
                          (M.call_closure (|
                            M.get_associated_function (| Ty.path "u32", "leading_zeros", [] |),
                            [ M.read (| n |) ]
                          |))
                          (M.read (|
                            M.get_constant (| "core::num::int_sqrt::u32::EVEN_MAKING_BITMASK" |)
                          |))
                      |) in
                    let~ _ :=
                      let β := n in
                      M.write (|
                        β,
                        BinOp.Wrap.shl (| M.read (| β |), M.read (| normalization_shift |) |)
                      |) in
                    let~ s :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u32_stages", [] |),
                          [ M.read (| n |) ]
                        |)
                      |) in
                    let~ denormalization_shift :=
                      M.alloc (|
                        BinOp.Wrap.shr (|
                          M.read (| normalization_shift |),
                          Value.Integer IntegerKind.I32 1
                        |)
                      |) in
                    M.alloc (|
                      BinOp.Wrap.shr (| M.read (| s |), M.read (| denormalization_shift |) |)
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u32 : M.IsFunction "core::num::int_sqrt::u32" u32.
    
    Module u32.
      Definition value_EVEN_MAKING_BITMASK : Value.t :=
        M.run ltac:(M.monadic (M.alloc (| UnOp.not (| Value.Integer IntegerKind.U32 1 |) |))).
    End u32.
    
    (*
            pub const fn $UnsignedT(mut n: $UnsignedT) -> $UnsignedT {
                if n <= <$HalfBitsT>::MAX as $UnsignedT {
                    $HalfBitsT(n as $HalfBitsT) as $UnsignedT
                } else {
                    // The normalization shift satisfies the Karatsuba square root
                    // algorithm precondition "a₃ ≥ b/4" where a₃ is the most
                    // significant quarter of `n`'s bits and b is the number of
                    // values that can be represented by that quarter of the bits.
                    //
                    // b/4 would then be all 0s except the second most significant
                    // bit (010...0) in binary. Since a₃ must be at least b/4, a₃'s
                    // most significant bit or its neighbor must be a 1. Since a₃'s
                    // most significant bits are `n`'s most significant bits, the
                    // same applies to `n`.
                    //
                    // The reason to shift by an even number of bits is because an
                    // even number of bits produces the square root shifted to the
                    // left by half of the normalization shift:
                    //
                    // sqrt(n << (2 * p))
                    // sqrt(2.pow(2 * p) * n)
                    // sqrt(2.pow(2 * p)) * sqrt(n)
                    // 2.pow(p) * sqrt(n)
                    // sqrt(n) << p
                    //
                    // Shifting by an odd number of bits leaves an ugly sqrt(2)
                    // multiplied in:
                    //
                    // sqrt(n << (2 * p + 1))
                    // sqrt(2.pow(2 * p + 1) * n)
                    // sqrt(2 * 2.pow(2 * p) * n)
                    // sqrt(2) * sqrt(2.pow(2 * p)) * sqrt(n)
                    // sqrt(2) * 2.pow(p) * sqrt(n)
                    // sqrt(2) * (sqrt(n) << p)
                    const EVEN_MAKING_BITMASK: u32 = !1;
                    let normalization_shift = n.leading_zeros() & EVEN_MAKING_BITMASK;
                    n <<= normalization_shift;
    
                    let s = $stages(n);
    
                    let denormalization_shift = normalization_shift >> 1;
                    s >> denormalization_shift
                }
            }
    *)
    Definition u64 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              M.alloc (| Value.Tuple [] |),
              [
                fun γ =>
                  ltac:(M.monadic
                    (let γ :=
                      M.use
                        (M.alloc (|
                          BinOp.le (|
                            M.read (| n |),
                            M.rust_cast (M.read (| M.get_constant (| "core::num::MAX" |) |))
                          |)
                        |)) in
                    let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u32", [] |),
                          [ M.rust_cast (M.read (| n |)) ]
                        |))
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let~ normalization_shift :=
                      M.alloc (|
                        BinOp.bit_and
                          (M.call_closure (|
                            M.get_associated_function (| Ty.path "u64", "leading_zeros", [] |),
                            [ M.read (| n |) ]
                          |))
                          (M.read (|
                            M.get_constant (| "core::num::int_sqrt::u64::EVEN_MAKING_BITMASK" |)
                          |))
                      |) in
                    let~ _ :=
                      let β := n in
                      M.write (|
                        β,
                        BinOp.Wrap.shl (| M.read (| β |), M.read (| normalization_shift |) |)
                      |) in
                    let~ s :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u64_stages", [] |),
                          [ M.read (| n |) ]
                        |)
                      |) in
                    let~ denormalization_shift :=
                      M.alloc (|
                        BinOp.Wrap.shr (|
                          M.read (| normalization_shift |),
                          Value.Integer IntegerKind.I32 1
                        |)
                      |) in
                    M.alloc (|
                      BinOp.Wrap.shr (| M.read (| s |), M.read (| denormalization_shift |) |)
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u64 : M.IsFunction "core::num::int_sqrt::u64" u64.
    
    Module u64.
      Definition value_EVEN_MAKING_BITMASK : Value.t :=
        M.run ltac:(M.monadic (M.alloc (| UnOp.not (| Value.Integer IntegerKind.U32 1 |) |))).
    End u64.
    
    (*
            pub const fn $UnsignedT(mut n: $UnsignedT) -> $UnsignedT {
                if n <= <$HalfBitsT>::MAX as $UnsignedT {
                    $HalfBitsT(n as $HalfBitsT) as $UnsignedT
                } else {
                    // The normalization shift satisfies the Karatsuba square root
                    // algorithm precondition "a₃ ≥ b/4" where a₃ is the most
                    // significant quarter of `n`'s bits and b is the number of
                    // values that can be represented by that quarter of the bits.
                    //
                    // b/4 would then be all 0s except the second most significant
                    // bit (010...0) in binary. Since a₃ must be at least b/4, a₃'s
                    // most significant bit or its neighbor must be a 1. Since a₃'s
                    // most significant bits are `n`'s most significant bits, the
                    // same applies to `n`.
                    //
                    // The reason to shift by an even number of bits is because an
                    // even number of bits produces the square root shifted to the
                    // left by half of the normalization shift:
                    //
                    // sqrt(n << (2 * p))
                    // sqrt(2.pow(2 * p) * n)
                    // sqrt(2.pow(2 * p)) * sqrt(n)
                    // 2.pow(p) * sqrt(n)
                    // sqrt(n) << p
                    //
                    // Shifting by an odd number of bits leaves an ugly sqrt(2)
                    // multiplied in:
                    //
                    // sqrt(n << (2 * p + 1))
                    // sqrt(2.pow(2 * p + 1) * n)
                    // sqrt(2 * 2.pow(2 * p) * n)
                    // sqrt(2) * sqrt(2.pow(2 * p)) * sqrt(n)
                    // sqrt(2) * 2.pow(p) * sqrt(n)
                    // sqrt(2) * (sqrt(n) << p)
                    const EVEN_MAKING_BITMASK: u32 = !1;
                    let normalization_shift = n.leading_zeros() & EVEN_MAKING_BITMASK;
                    n <<= normalization_shift;
    
                    let s = $stages(n);
    
                    let denormalization_shift = normalization_shift >> 1;
                    s >> denormalization_shift
                }
            }
    *)
    Definition u128 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ n ] =>
        ltac:(M.monadic
          (let n := M.alloc (| n |) in
          M.read (|
            M.match_operator (|
              M.alloc (| Value.Tuple [] |),
              [
                fun γ =>
                  ltac:(M.monadic
                    (let γ :=
                      M.use
                        (M.alloc (|
                          BinOp.le (|
                            M.read (| n |),
                            M.rust_cast (M.read (| M.get_constant (| "core::num::MAX" |) |))
                          |)
                        |)) in
                    let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u64", [] |),
                          [ M.rust_cast (M.read (| n |)) ]
                        |))
                    |)));
                fun γ =>
                  ltac:(M.monadic
                    (let~ normalization_shift :=
                      M.alloc (|
                        BinOp.bit_and
                          (M.call_closure (|
                            M.get_associated_function (| Ty.path "u128", "leading_zeros", [] |),
                            [ M.read (| n |) ]
                          |))
                          (M.read (|
                            M.get_constant (| "core::num::int_sqrt::u128::EVEN_MAKING_BITMASK" |)
                          |))
                      |) in
                    let~ _ :=
                      let β := n in
                      M.write (|
                        β,
                        BinOp.Wrap.shl (| M.read (| β |), M.read (| normalization_shift |) |)
                      |) in
                    let~ s :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_function (| "core::num::int_sqrt::u128_stages", [] |),
                          [ M.read (| n |) ]
                        |)
                      |) in
                    let~ denormalization_shift :=
                      M.alloc (|
                        BinOp.Wrap.shr (|
                          M.read (| normalization_shift |),
                          Value.Integer IntegerKind.I32 1
                        |)
                      |) in
                    M.alloc (|
                      BinOp.Wrap.shr (| M.read (| s |), M.read (| denormalization_shift |) |)
                    |)))
              ]
            |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_u128 : M.IsFunction "core::num::int_sqrt::u128" u128.
    
    Module u128.
      Definition value_EVEN_MAKING_BITMASK : Value.t :=
        M.run ltac:(M.monadic (M.alloc (| UnOp.not (| Value.Integer IntegerKind.U32 1 |) |))).
    End u128.
    
    (*
    pub const fn panic_for_negative_argument() -> ! {
        panic!("argument of integer square root cannot be negative")
    }
    *)
    Definition panic_for_negative_argument
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      match ε, τ, α with
      | [], [], [] =>
        ltac:(M.monadic
          (M.call_closure (|
            M.get_function (| "core::panicking::panic_fmt", [] |),
            [
              M.call_closure (|
                M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_const", [] |),
                [
                  M.alloc (|
                    Value.Array
                      [
                        M.read (|
                          Value.String "argument of integer square root cannot be negative"
                        |)
                      ]
                  |)
                ]
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Function_panic_for_negative_argument :
      M.IsFunction "core::num::int_sqrt::panic_for_negative_argument" panic_for_negative_argument.
  End int_sqrt.
End num.
