    {-# LANGUAGE BangPatterns #-}
    {-# LANGUAGE CPP #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE MagicHash #-}
    {-# LANGUAGE StrictData #-}
    {-# LANGUAGE UnboxedTuples #-}
    {-# OPTIONS_GHC -funbox-strict-fields #-}

    -----------------------------------------------------------------------------
    ---- |
    ---- Module      :  Data.WideWord.Word256
    ----
    ---- Maintainer  :  erikd@mega-nerd.com
    ---- Stability   :  experimental
    ---- Portability :  non-portable (GHC extensions and primops)
    ----
    ---- This module provides an opaque unsigned 256 bit value with the usual set
    ---- of typeclass instances one would expect for a fixed width unsigned integer
    ---- type.
    ---- Operations like addition, subtraction and multiplication etc provide a
    ---- "modulo 2^256" result as one would expect from a fixed width unsigned word.
    -------------------------------------------------------------------------------

    module Data.WideWord.Word256
      ( Word256 (..)
      , showHexWord256
      , zeroWord256
      ) where

    import Control.DeepSeq (NFData (..))

    import Data.Bits (Bits (..), FiniteBits (..), shiftL)
    import Data.Data (Data)
    import Data.Ix (Ix)
    #if ! MIN_VERSION_base(4,11,0)
    import Data.Semigroup ((<>))
    #endif

    import Foreign.Ptr (Ptr, castPtr)
    import Foreign.Storable (Storable (..))

    import GHC.Base (Int (..))
    import GHC.Enum (predError, succError)
    import GHC.Exts ((*#), (+#), Int#, State#, ByteArray#, MutableByteArray#, Addr#)
    import GHC.Generics (Generic)
    import GHC.Real ((%))
    import GHC.Word (Word32, Word64)

    import Data.WideWord.Word64

    import Numeric (showHex)

    import Data.Primitive.Types (Prim (..), defaultSetByteArray#, defaultSetOffAddr#)
    import Data.Hashable (Hashable, hashWithSalt)
    import Data.Binary (Binary (get, put))

    {- HLINT ignore "Use guards" -}

    data Word256 = Word256
      { Word256 -> Word64
    word256hi :: !Word64
      , Word256 -> Word64
    word256m1 :: !Word64
      , Word256 -> Word64
    word256m0 :: !Word64
      , Word256 -> Word64
    word256lo :: !Word64
      }
      deriving (Word256 -> Word256 -> Bool
    (Word256 -> Word256 -> Bool)
    -> (Word256 -> Word256 -> Bool) -> Eq Word256
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Word256 -> Word256 -> Bool
    == :: Word256 -> Word256 -> Bool
    $c/= :: Word256 -> Word256 -> Bool
    /= :: Word256 -> Word256 -> Bool
    Eq, Typeable Word256
    Typeable Word256 =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Word256 -> c Word256)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Word256)
    -> (Word256 -> Constr)
    -> (Word256 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Word256))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word256))
    -> ((forall b. Data b => b -> b) -> Word256 -> Word256)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Word256 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Word256 -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Word256 -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Word256 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Word256 -> m Word256)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Word256 -> m Word256)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Word256 -> m Word256)
    -> Data Word256
    Word256 -> Constr
    Word256 -> DataType
    (forall b. Data b => b -> b) -> Word256 -> Word256
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Word256 -> u
    forall u. (forall d. Data d => d -> u) -> Word256 -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Word256 -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Word256 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Word256
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Word256 -> c Word256
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Word256)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word256)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Word256 -> c Word256
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Word256 -> c Word256
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Word256
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Word256
    $ctoConstr :: Word256 -> Constr
    toConstr :: Word256 -> Constr
    $cdataTypeOf :: Word256 -> DataType
    dataTypeOf :: Word256 -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Word256)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Word256)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word256)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word256)
    $cgmapT :: (forall b. Data b => b -> b) -> Word256 -> Word256
    gmapT :: (forall b. Data b => b -> b) -> Word256 -> Word256
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Word256 -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Word256 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Word256 -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Word256 -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Word256 -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Word256 -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Word256 -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Word256 -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Word256 -> m Word256
    Data, (forall x. Word256 -> Rep Word256 x)
    -> (forall x. Rep Word256 x -> Word256) -> Generic Word256
    forall x. Rep Word256 x -> Word256
    forall x. Word256 -> Rep Word256 x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Word256 -> Rep Word256 x
    from :: forall x. Word256 -> Rep Word256 x
    $cto :: forall x. Rep Word256 x -> Word256
    to :: forall x. Rep Word256 x -> Word256
    Generic, Ord Word256
    Ord Word256 =>
    ((Word256, Word256) -> [Word256])
    -> ((Word256, Word256) -> Word256 -> Int)
    -> ((Word256, Word256) -> Word256 -> Int)
    -> ((Word256, Word256) -> Word256 -> Bool)
    -> ((Word256, Word256) -> Int)
    -> ((Word256, Word256) -> Int)
    -> Ix Word256
    (Word256, Word256) -> Int
    (Word256, Word256) -> [Word256]
    (Word256, Word256) -> Word256 -> Bool
    (Word256, Word256) -> Word256 -> Int
    forall a.
    Ord a =>
    ((a, a) -> [a])
    -> ((a, a) -> a -> Int)
    -> ((a, a) -> a -> Int)
    -> ((a, a) -> a -> Bool)
    -> ((a, a) -> Int)
    -> ((a, a) -> Int)
    -> Ix a
    $crange :: (Word256, Word256) -> [Word256]
    range :: (Word256, Word256) -> [Word256]
    $cindex :: (Word256, Word256) -> Word256 -> Int
    index :: (Word256, Word256) -> Word256 -> Int
    $cunsafeIndex :: (Word256, Word256) -> Word256 -> Int
    unsafeIndex :: (Word256, Word256) -> Word256 -> Int
    $cinRange :: (Word256, Word256) -> Word256 -> Bool
    inRange :: (Word256, Word256) -> Word256 -> Bool
    $crangeSize :: (Word256, Word256) -> Int
    rangeSize :: (Word256, Word256) -> Int
    $cunsafeRangeSize :: (Word256, Word256) -> Int
    unsafeRangeSize :: (Word256, Word256) -> Int
    Ix)

    instance Hashable Word256 where
      hashWithSalt :: Int -> Word256 -> Int
    hashWithSalt Int
    s (Word256 Word64
    a1 Word64
    a2 Word64
    a3 Word64
    a4) =
        Int
    s Int -> Word64 -> Int
    forall a. Hashable a => Int -> a -> Int
    `hashWithSalt` Word64
    a1 Int -> Word64 -> Int
    forall a. Hashable a => Int -> a -> Int
    `hashWithSalt` Word64
    a2 Int -> Word64 -> Int
    forall a. Hashable a => Int -> a -> Int
    `hashWithSalt` Word64
    a3 Int -> Word64 -> Int
    forall a. Hashable a => Int -> a -> Int
    `hashWithSalt` Word64
    a4

    -- | @since 0.1.5.0
    instance Binary Word256 where
      put :: Word256 -> Put
    put (Word256 Word64
    a1 Word64
    a2 Word64
    a3 Word64
    a4) = Word64 -> Put
    forall t. Binary t => t -> Put
    put Word64
    a1 Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Word64 -> Put
    forall t. Binary t => t -> Put
    put Word64
    a2 Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Word64 -> Put
    forall t. Binary t => t -> Put
    put Word64
    a3 Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Word64 -> Put
    forall t. Binary t => t -> Put
    put Word64
    a4
      get :: Get Word256
    get = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256)
    -> Get Word64 -> Get (Word64 -> Word64 -> Word64 -> Word256)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Get Word64
    forall t. Binary t => Get t
    get Get (Word64 -> Word64 -> Word64 -> Word256)
    -> Get Word64 -> Get (Word64 -> Word64 -> Word256)
    forall a b. Get (a -> b) -> Get a -> Get b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Get Word64
    forall t. Binary t => Get t
    get Get (Word64 -> Word64 -> Word256)
    -> Get Word64 -> Get (Word64 -> Word256)
    forall a b. Get (a -> b) -> Get a -> Get b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Get Word64
    forall t. Binary t => Get t
    get Get (Word64 -> Word256) -> Get Word64 -> Get Word256
    forall a b. Get (a -> b) -> Get a -> Get b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Get Word64
    forall t. Binary t => Get t
    get

    showHexWord256 :: Word256 -> String
    showHexWord256 :: Word256 -> String
    showHexWord256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0)
      | Word64
    a3 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0 =
          if Word64
    a2 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0
            then if Word64
    a1 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0
              then Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a0 String
    ""
              else Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a1 String
    zeros0 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a0 String
    ""
            else Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a2 String
    zeros1 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a1 String
    zeros0 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a0 String
    ""
      | Bool
    otherwise =
             Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a3 String
    zeros2 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a2 String
    zeros1
          String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a1 String
    zeros0 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a0 String
    ""
      where
        h0 :: String
    h0 = Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a0 String
    ""
        h1 :: String
    h1 = Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a1 String
    ""
        h2 :: String
    h2 = Word64 -> ShowS
    forall a. Integral a => a -> ShowS
    showHex Word64
    a2 String
    ""
        zeros0 :: String
    zeros0 = Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate (Int
    16 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - String -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    h0) Char
    '0'
        zeros1 :: String
    zeros1 = Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate (Int
    16 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - String -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    h1) Char
    '0'
        zeros2 :: String
    zeros2 = Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate (Int
    16 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - String -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    h2) Char
    '0'

    instance Show Word256 where
      show :: Word256 -> String
    show = Integer -> String
    forall a. Show a => a -> String
    show (Integer -> String) -> (Word256 -> Integer) -> Word256 -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word256 -> Integer
    toInteger256

    instance Read Word256 where
      readsPrec :: Int -> ReadS Word256
    readsPrec Int
    p String
    s = [(Integer -> Word256
    fromInteger256 (Integer
    x :: Integer), String
    r) | (Integer
    x, String
    r) <- Int -> ReadS Integer
    forall a. Read a => Int -> ReadS a
    readsPrec Int
    p String
    s]

    instance Ord Word256 where
      compare :: Word256 -> Word256 -> Ordering
    compare = Word256 -> Word256 -> Ordering
    compare256

    instance Bounded Word256 where
      minBound :: Word256
    minBound = Word256
    zeroWord256
      maxBound :: Word256
    maxBound = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    forall a. Bounded a => a
    maxBound Word64
    forall a. Bounded a => a
    maxBound Word64
    forall a. Bounded a => a
    maxBound Word64
    forall a. Bounded a => a
    maxBound

    instance Enum Word256 where
      succ :: Word256 -> Word256
    succ = Word256 -> Word256
    succ256
      pred :: Word256 -> Word256
    pred = Word256 -> Word256
    pred256
      toEnum :: Int -> Word256
    toEnum = Int -> Word256
    toEnum256
      fromEnum :: Word256 -> Int
    fromEnum = Word256 -> Int
    fromEnum256

    instance Num Word256 where
      + :: Word256 -> Word256 -> Word256
    (+) = Word256 -> Word256 -> Word256
    plus256
      (-) = Word256 -> Word256 -> Word256
    minus256
      * :: Word256 -> Word256 -> Word256
    (*) = Word256 -> Word256 -> Word256
    times256
      negate :: Word256 -> Word256
    negate = Word256 -> Word256
    negate256
      abs :: Word256 -> Word256
    abs = Word256 -> Word256
    forall a. a -> a
    id
      signum :: Word256 -> Word256
    signum = Word256 -> Word256
    signum256
      fromInteger :: Integer -> Word256
    fromInteger = Integer -> Word256
    fromInteger256

    instance Bits Word256 where
      .&. :: Word256 -> Word256 -> Word256
    (.&.) = Word256 -> Word256 -> Word256
    and256
      .|. :: Word256 -> Word256 -> Word256
    (.|.) = Word256 -> Word256 -> Word256
    or256
      xor :: Word256 -> Word256 -> Word256
    xor = Word256 -> Word256 -> Word256
    xor256
      complement :: Word256 -> Word256
    complement = Word256 -> Word256
    complement256
      shiftL :: Word256 -> Int -> Word256
    shiftL = Word256 -> Int -> Word256
    shiftL256
      unsafeShiftL :: Word256 -> Int -> Word256
    unsafeShiftL = Word256 -> Int -> Word256
    shiftL256
      shiftR :: Word256 -> Int -> Word256
    shiftR = Word256 -> Int -> Word256
    shiftR256
      unsafeShiftR :: Word256 -> Int -> Word256
    unsafeShiftR = Word256 -> Int -> Word256
    shiftR256
      rotateL :: Word256 -> Int -> Word256
    rotateL = Word256 -> Int -> Word256
    rotateL256
      rotateR :: Word256 -> Int -> Word256
    rotateR = Word256 -> Int -> Word256
    rotateR256

      bitSize :: Word256 -> Int
    bitSize Word256
    _ = Int
    256
      bitSizeMaybe :: Word256 -> Maybe Int
    bitSizeMaybe Word256
    _ = Int -> Maybe Int
    forall a. a -> Maybe a
    Just Int
    256
      isSigned :: Word256 -> Bool
    isSigned Word256
    _ = Bool
    False

      testBit :: Word256 -> Int -> Bool
    testBit = Word256 -> Int -> Bool
    testBit256
      bit :: Int -> Word256
    bit = Int -> Word256
    bit256

      popCount :: Word256 -> Int
    popCount = Word256 -> Int
    popCount256

    instance FiniteBits Word256 where
      finiteBitSize :: Word256 -> Int
    finiteBitSize Word256
    _ = Int
    256
      countLeadingZeros :: Word256 -> Int
    countLeadingZeros = Word256 -> Int
    countLeadingZeros256
      countTrailingZeros :: Word256 -> Int
    countTrailingZeros = Word256 -> Int
    countTrailingZeros256

    instance Real Word256 where
      toRational :: Word256 -> Rational
    toRational Word256
    x = Word256 -> Integer
    toInteger256 Word256
    x Integer -> Integer -> Rational
    forall a. Integral a => a -> a -> Ratio a
    % Integer
    1

    -- For unsigned values, quotRem is the same as divMod.
    instance Integral Word256 where
      quot :: Word256 -> Word256 -> Word256
    quot Word256
    n Word256
    d = (Word256, Word256) -> Word256
    forall a b. (a, b) -> a
    fst (Word256 -> Word256 -> (Word256, Word256)
    quotRem256 Word256
    n Word256
    d)
      rem :: Word256 -> Word256 -> Word256
    rem Word256
    n Word256
    d = (Word256, Word256) -> Word256
    forall a b. (a, b) -> b
    snd (Word256 -> Word256 -> (Word256, Word256)
    quotRem256 Word256
    n Word256
    d)
      div :: Word256 -> Word256 -> Word256
    div Word256
    n Word256
    d = (Word256, Word256) -> Word256
    forall a b. (a, b) -> a
    fst (Word256 -> Word256 -> (Word256, Word256)
    quotRem256 Word256
    n Word256
    d)
      mod :: Word256 -> Word256 -> Word256
    mod Word256
    n Word256
    d = (Word256, Word256) -> Word256
    forall a b. (a, b) -> b
    snd (Word256 -> Word256 -> (Word256, Word256)
    quotRem256 Word256
    n Word256
    d)
      quotRem :: Word256 -> Word256 -> (Word256, Word256)
    quotRem = Word256 -> Word256 -> (Word256, Word256)
    quotRem256
      divMod :: Word256 -> Word256 -> (Word256, Word256)
    divMod = Word256 -> Word256 -> (Word256, Word256)
    quotRem256
      toInteger :: Word256 -> Integer
    toInteger = Word256 -> Integer
    toInteger256

    instance Storable Word256 where
      sizeOf :: Word256 -> Int
    sizeOf Word256
    w = Int# -> Int
    I# (Word256 -> Int#
    sizeOf256# Word256
    w)
      alignment :: Word256 -> Int
    alignment Word256
    w = Int# -> Int
    I# (Word256 -> Int#
    alignment256# Word256
    w)
      peek :: Ptr Word256 -> IO Word256
    peek = Ptr Word256 -> IO Word256
    peek256
      peekElemOff :: Ptr Word256 -> Int -> IO Word256
    peekElemOff = Ptr Word256 -> Int -> IO Word256
    peekElemOff256
      poke :: Ptr Word256 -> Word256 -> IO ()
    poke = Ptr Word256 -> Word256 -> IO ()
    poke256
      pokeElemOff :: Ptr Word256 -> Int -> Word256 -> IO ()
    pokeElemOff = Ptr Word256 -> Int -> Word256 -> IO ()
    pokeElemOff256

    instance NFData Word256 where
      -- The fields are already strict and unpacked, so do nothing.
      rnf :: Word256 -> ()
    rnf !Word256
    _ = ()

    instance Prim Word256 where
      sizeOf# :: Word256 -> Int#
    sizeOf#         = Word256 -> Int#
    sizeOf256#
      alignment# :: Word256 -> Int#
    alignment#      = Word256 -> Int#
    alignment256#
      indexByteArray# :: ByteArray# -> Int# -> Word256
    indexByteArray# = ByteArray# -> Int# -> Word256
    indexByteArray256#
      readByteArray# :: forall s.
    MutableByteArray# s -> Int# -> State# s -> (# State# s, Word256 #)
    readByteArray#  = MutableByteArray# s -> Int# -> State# s -> (# State# s, Word256 #)
    forall s.
    MutableByteArray# s -> Int# -> State# s -> (# State# s, Word256 #)
    readByteArray256#
      writeByteArray# :: forall s.
    MutableByteArray# s -> Int# -> Word256 -> State# s -> State# s
    writeByteArray# = MutableByteArray# s -> Int# -> Word256 -> State# s -> State# s
    forall s.
    MutableByteArray# s -> Int# -> Word256 -> State# s -> State# s
    writeByteArray256#
      setByteArray# :: forall s.
    MutableByteArray# s
    -> Int# -> Int# -> Word256 -> State# s -> State# s
    setByteArray#   = MutableByteArray# s
    -> Int# -> Int# -> Word256 -> State# s -> State# s
    forall s.
    MutableByteArray# s
    -> Int# -> Int# -> Word256 -> State# s -> State# s
    setByteArray256#
      indexOffAddr# :: Addr# -> Int# -> Word256
    indexOffAddr#   = Addr# -> Int# -> Word256
    indexOffAddr256#
      readOffAddr# :: forall s. Addr# -> Int# -> State# s -> (# State# s, Word256 #)
    readOffAddr#    = Addr# -> Int# -> State# s -> (# State# s, Word256 #)
    forall s. Addr# -> Int# -> State# s -> (# State# s, Word256 #)
    readOffAddr256#
      writeOffAddr# :: forall s. Addr# -> Int# -> Word256 -> State# s -> State# s
    writeOffAddr#   = Addr# -> Int# -> Word256 -> State# s -> State# s
    forall s. Addr# -> Int# -> Word256 -> State# s -> State# s
    writeOffAddr256#
      setOffAddr# :: forall s. Addr# -> Int# -> Int# -> Word256 -> State# s -> State# s
    setOffAddr#     = Addr# -> Int# -> Int# -> Word256 -> State# s -> State# s
    forall s. Addr# -> Int# -> Int# -> Word256 -> State# s -> State# s
    setOffAddr256#
      {-# INLINE sizeOf# #-}
      {-# INLINE alignment# #-}
      {-# INLINE indexByteArray# #-}
      {-# INLINE readByteArray# #-}
      {-# INLINE writeByteArray# #-}
      {-# INLINE setByteArray# #-}
      {-# INLINE indexOffAddr# #-}
      {-# INLINE readOffAddr# #-}
      {-# INLINE writeOffAddr# #-}
      {-# INLINE setOffAddr# #-}

    -- -----------------------------------------------------------------------------
    -- Rewrite rules.

    {-# RULES
    "fromIntegral :: Word256 -> Word256" fromIntegral = id :: Word256 -> Word256

    "fromIntegral :: Int -> Word256"     fromIntegral = fromInt
    "fromIntegral :: Word -> Word256"    fromIntegral = fromWord
    "fromIntegral :: Word32 -> Word256"  fromIntegral = fromWord32
    "fromIntegral :: Word64 -> Word256"  fromIntegral = Word256 0 0 0

    "fromIntegral :: Word256 -> Int"     fromIntegral = toInt
    "fromIntegral :: Word256 -> Word"    fromIntegral = toWord
    "fromIntegral :: Word256 -> Word32"  fromIntegral = toWord32
    "fromIntegral :: Word256 -> Word64"  fromIntegral = \(Word256 _ _ _ w) -> w
      #-}

    {-# INLINE fromInt #-}
    fromInt :: Int -> Word256
    fromInt :: Int -> Word256
    fromInt = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 (Word64 -> Word256) -> (Int -> Word64) -> Int -> Word256
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> Word64
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral

    {-# INLINE fromWord #-}
    fromWord :: Word -> Word256
    fromWord :: Word -> Word256
    fromWord = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 (Word64 -> Word256) -> (Word -> Word64) -> Word -> Word256
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Word64
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral

    {-# INLINE fromWord32 #-}
    fromWord32 :: Word32 -> Word256
    fromWord32 :: Word32 -> Word256
    fromWord32 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 (Word64 -> Word256) -> (Word32 -> Word64) -> Word32 -> Word256
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Word64
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral

    {-# INLINE toInt #-}
    toInt :: Word256 -> Int
    toInt :: Word256 -> Int
    toInt (Word256 Word64
    _ Word64
    _ Word64
    _ Word64
    w) = Word64 -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word64
    w

    {-# INLINE toWord #-}
    toWord :: Word256 -> Word
    toWord :: Word256 -> Word
    toWord (Word256 Word64
    _ Word64
    _ Word64
    _ Word64
    w) = Word64 -> Word
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word64
    w

    {-# INLINE toWord32 #-}
    toWord32 :: Word256 -> Word32
    toWord32 :: Word256 -> Word32
    toWord32 (Word256 Word64
    _ Word64
    _ Word64
    _ Word64
    w) = Word64 -> Word32
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word64
    w

    -- -----------------------------------------------------------------------------
    -- Functions for `Ord` instance.

    compare256 :: Word256 -> Word256 -> Ordering
    compare256 :: Word256 -> Word256 -> Ordering
    compare256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) (Word256 Word64
    b3 Word64
    b2 Word64
    b1 Word64
    b0) =
      Word64 -> Word64 -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Word64
    a3 Word64
    b3 Ordering -> Ordering -> Ordering
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Word64 -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Word64
    a2 Word64
    b2 Ordering -> Ordering -> Ordering
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Word64 -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Word64
    a1 Word64
    b1 Ordering -> Ordering -> Ordering
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Word64 -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Word64
    a0 Word64
    b0

    -- -----------------------------------------------------------------------------
    -- Functions for `Enum` instance.

    succ256 :: Word256 -> Word256
    succ256 :: Word256 -> Word256
    succ256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0)
      | Word64
    a0 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    forall a. Bounded a => a
    maxBound =
          if Word64
    a1 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    forall a. Bounded a => a
    maxBound
            then if Word64
    a2 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    forall a. Bounded a => a
    maxBound
              then if Word64
    a3 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    forall a. Bounded a => a
    maxBound
                then String -> Word256
    forall a. String -> a
    succError String
    "Word256"
                else Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    1) Word64
    0 Word64
    0 Word64
    0
              else Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a3 (Word64
    a2 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    1) Word64
    0 Word64
    0
            else Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a3 Word64
    a2 (Word64
    a1 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    1) Word64
    0
      | Bool
    otherwise = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a3 Word64
    a2 Word64
    a1 (Word64
    a0 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    1)

    pred256 :: Word256 -> Word256
    pred256 :: Word256 -> Word256
    pred256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0)
      | Word64
    a0 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0 =
          if Word64
    a1 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0
            then if Word64
    a2 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0
              then if Word64
    a3 Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0
                then String -> Word256
    forall a. String -> a
    predError String
    "Word256"
                else Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    - Word64
    1) Word64
    forall a. Bounded a => a
    maxBound Word64
    forall a. Bounded a => a
    maxBound Word64
    forall a. Bounded a => a
    maxBound
              else Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a3 (Word64
    a2 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    - Word64
    1) Word64
    forall a. Bounded a => a
    maxBound Word64
    forall a. Bounded a => a
    maxBound
            else Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a3 Word64
    a2 (Word64
    a1 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    - Word64
    1) Word64
    forall a. Bounded a => a
    maxBound
      | Bool
    otherwise = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a3 Word64
    a2 Word64
    a1 (Word64
    a0 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    - Word64
    1)

    {-# INLINABLE toEnum256 #-}
    toEnum256 :: Int -> Word256
    toEnum256 :: Int -> Word256
    toEnum256 Int
    i = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 (Int -> Word64
    forall a. Enum a => Int -> a
    toEnum Int
    i)

    {-# INLINABLE fromEnum256 #-}
    fromEnum256 :: Word256 -> Int
    fromEnum256 :: Word256 -> Int
    fromEnum256 (Word256 Word64
    _ Word64
    _ Word64
    _ Word64
    a0) = Word64 -> Int
    forall a. Enum a => a -> Int
    fromEnum Word64
    a0

    -- -----------------------------------------------------------------------------
    -- Functions for `Num` instance.

    {-# INLINABLE plus256 #-}
    plus256 :: Word256 -> Word256 -> Word256
    plus256 :: Word256 -> Word256 -> Word256
    plus256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) (Word256 Word64
    b3 Word64
    b2 Word64
    b1 Word64
    b0) =
        Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    s3 Word64
    s2 Word64
    s1 Word64
    s0
      where
        !(Word64
    c1, Word64
    s0) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    a0 Word64
    b0
        !(Word64
    c2a, Word64
    s1a) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    a1 Word64
    b1
        !(Word64
    c2b, Word64
    s1) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    s1a Word64
    c1
        !c2 :: Word64
    c2 = Word64
    c2a Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c2b
        !(Word64
    c3a, Word64
    s2a) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    a2 Word64
    b2
        !(Word64
    c3b, Word64
    s2) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    s2a Word64
    c2
        !c3 :: Word64
    c3 = Word64
    c3a Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3b
        !s3 :: Word64
    s3 = Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    b3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3

    {-# INLINABLE minus256 #-}
    minus256 :: Word256 -> Word256 -> Word256
    minus256 :: Word256 -> Word256 -> Word256
    minus256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) (Word256 Word64
    b3 Word64
    b2 Word64
    b1 Word64
    b0) =
        Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    d3 Word64
    d2 Word64
    d1 Word64
    d0
      where
        !(Word64
    c1, Word64
    d0) = Word64 -> Word64 -> (Word64, Word64)
    subCarryDiff Word64
    a0 Word64
    b0
        !(Word64
    c2a, Word64
    b1a) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    b1 Word64
    c1
        !(Word64
    c2b, Word64
    d1) = Word64 -> Word64 -> (Word64, Word64)
    subCarryDiff Word64
    a1 Word64
    b1a
        !c2 :: Word64
    c2 = Word64
    c2a Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c2b
        !(Word64
    c3a, Word64
    b2a) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    b2 Word64
    c2
        !(Word64
    c3b, Word64
    d2) = Word64 -> Word64 -> (Word64, Word64)
    subCarryDiff Word64
    a2 Word64
    b2a
        !c3 :: Word64
    c3 = Word64
    c3a Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3b
        !d3 :: Word64
    d3 = Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    - Word64
    b3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    - Word64
    c3

    times256 :: Word256 -> Word256 -> Word256
    times256 :: Word256 -> Word256 -> Word256
    times256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) (Word256 Word64
    b3 Word64
    b2 Word64
    b1 Word64
    b0) =
        Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    r3 Word64
    r2 Word64
    r1 Word64
    r0
      where
        !(Word64
    c00, Word64
    p00) = Word64 -> Word64 -> (Word64, Word64)
    timesCarryProd Word64
    a0 Word64
    b0
        !(Word64
    c01, Word64
    p01) = Word64 -> Word64 -> (Word64, Word64)
    timesCarryProd Word64
    a0 Word64
    b1
        !(Word64
    c02, Word64
    p02) = Word64 -> Word64 -> (Word64, Word64)
    timesCarryProd Word64
    a0 Word64
    b2
        !p03 :: Word64
    p03 = Word64
    a0 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    * Word64
    b3
        !(Word64
    c10, Word64
    p10) = Word64 -> Word64 -> (Word64, Word64)
    timesCarryProd Word64
    a1 Word64
    b0
        !(Word64
    c11, Word64
    p11) = Word64 -> Word64 -> (Word64, Word64)
    timesCarryProd Word64
    a1 Word64
    b1
        !p12 :: Word64
    p12 = Word64
    a1 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    * Word64
    b2
        !(Word64
    c20, Word64
    p20) = Word64 -> Word64 -> (Word64, Word64)
    timesCarryProd Word64
    a2 Word64
    b0
        !p21 :: Word64
    p21 = Word64
    a2 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    * Word64
    b1
        !p30 :: Word64
    p30 = Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    * Word64
    b0
        !r0 :: Word64
    r0 = Word64
    p00
        !c1 :: Word64
    c1 = Word64
    c00
        !(Word64
    c2x, Word64
    r1a) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    p01 Word64
    p10
        !(Word64
    c2y, Word64
    r1b) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    r1a Word64
    c1
        !(Word64
    c3w, Word64
    c2) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    c2x Word64
    c2y
        !r1 :: Word64
    r1 = Word64
    r1b
        !(Word64
    c3x, Word64
    r2a) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    p11 Word64
    p20
        !(Word64
    c3y, Word64
    r2b) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    p02 Word64
    r2a
        !(Word64
    c3z, Word64
    r2c) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    r2b Word64
    c2
        !(Word64
    c3s, Word64
    r2d) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    r2c Word64
    c01
        !(Word64
    c3t, Word64
    r2e) = Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum Word64
    r2d Word64
    c10
        !r2 :: Word64
    r2 = Word64
    r2e
        !r3 :: Word64
    r3 = Word64
    p30 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    p21 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    p12 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    p03 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3w Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3x Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    +
               Word64
    c3y Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3z Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3s Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3t Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c02 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c11 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c20

    {-# INLINABLE negate256 #-}
    negate256 :: Word256 -> Word256
    negate256 :: Word256 -> Word256
    negate256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) =
      case Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum (Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a0) Word64
    1 of
        (Word64
    c1, Word64
    s0) -> case Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum (Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a1) Word64
    c1 of
          (Word64
    c2, Word64
    s1) -> case Word64 -> Word64 -> (Word64, Word64)
    plusCarrySum (Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a2) Word64
    c2 of
            (Word64
    c3, Word64
    s2) -> case Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    c3 of
              Word64
    s3 -> Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    s3 Word64
    s2 Word64
    s1 Word64
    s0

    {-# INLINABLE signum256 #-}
    signum256 :: Word256 -> Word256
    signum256 :: Word256 -> Word256
    signum256 (Word256 Word64
    a Word64
    b Word64
    c Word64
    d) =
      if Word64
    a Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0 Bool -> Bool -> Bool
    && Word64
    b Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0 Bool -> Bool -> Bool
    && Word64
    c Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0 Bool -> Bool -> Bool
    && Word64
    d Word64 -> Word64 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word64
    0
        then Word256
    zeroWord256
        else Word256
    oneWord256

    fromInteger256 :: Integer -> Word256
    fromInteger256 :: Integer -> Word256
    fromInteger256 Integer
    i =
      Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256
        (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Word64) -> Integer -> Word64
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Int -> Integer
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    192) (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Word64) -> Integer -> Word64
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Int -> Integer
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    128)
        (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Word64) -> Integer -> Word64
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Int -> Integer
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    64) (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i)

    -- -----------------------------------------------------------------------------
    -- Functions for `Bits` instance.

    {-# INLINABLE and256 #-}
    and256 :: Word256 -> Word256 -> Word256
    and256 :: Word256 -> Word256 -> Word256
    and256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) (Word256 Word64
    b3 Word64
    b2 Word64
    b1 Word64
    b0) =
      Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .&. Word64
    b3) (Word64
    a2 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .&. Word64
    b2) (Word64
    a1 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .&. Word64
    b1) (Word64
    a0 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .&. Word64
    b0)

    {-# INLINABLE or256 #-}
    or256 :: Word256 -> Word256 -> Word256
    or256 :: Word256 -> Word256 -> Word256
    or256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) (Word256 Word64
    b3 Word64
    b2 Word64
    b1 Word64
    b0) =
      Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64
    a3 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .|. Word64
    b3) (Word64
    a2 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .|. Word64
    b2) (Word64
    a1 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .|. Word64
    b1) (Word64
    a0 Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    .|. Word64
    b0)

    {-# INLINABLE xor256 #-}
    xor256 :: Word256 -> Word256 -> Word256
    xor256 :: Word256 -> Word256 -> Word256
    xor256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) (Word256 Word64
    b3 Word64
    b2 Word64
    b1 Word64
    b0) =
      Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    xor Word64
    a3 Word64
    b3) (Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    xor Word64
    a2 Word64
    b2) (Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    xor Word64
    a1 Word64
    b1) (Word64 -> Word64 -> Word64
    forall a. Bits a => a -> a -> a
    xor Word64
    a0 Word64
    b0)

    {-# INLINABLE complement256 #-}
    complement256 :: Word256 -> Word256
    complement256 :: Word256 -> Word256
    complement256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) =
      Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a3) (Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a2) (Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a1) (Word64 -> Word64
    forall a. Bits a => a -> a
    complement Word64
    a0)

    -- Some of the following functions have quite complicated guard clauses, but we make them
    -- inlineable anyway so that if the things like the shift amount is a compile time constant
    -- most of the function can be dropped leaving only the needed bits inlined.

    {-# INLINABLE shiftL256 #-}
    shiftL256 :: Word256 -> Int -> Word256
    shiftL256 :: Word256 -> Int -> Word256
    shiftL256 w :: Word256
    w@(Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) Int
    s
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    0 = Word256
    w
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    forall a. Bounded a => a
    minBound = Word256
    zeroWord256
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    0 = Word256 -> Int -> Word256
    shiftR256 Word256
    w (Int -> Int
    forall a. Num a => a -> a
    negate Int
    s)
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    256 = Word256
    zeroWord256
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    192 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    192)) Word64
    0 Word64
    0 Word64
    0
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    192 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a0 Word64
    0 Word64
    0 Word64
    0
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    128 =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256
            (Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    128) Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    192 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    128)) Word64
    0 Word64
    0
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    128 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a1 Word64
    a0 Word64
    0 Word64
    0
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    64 =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256
            (Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64) Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    128 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64) Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    128 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64))
            Word64
    0
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    64 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a2 Word64
    a1 Word64
    a0 Word64
    0
      | Bool
    otherwise =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256
            (Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    s Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    s Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    s Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    s)

    {-# INLINABLE shiftR256 #-}
    shiftR256 :: Word256 -> Int -> Word256
    shiftR256 :: Word256 -> Int -> Word256
    shiftR256 w :: Word256
    w@(Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) Int
    s
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    0 = Word256
    w
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    forall a. Bounded a => a
    minBound = Word256
    zeroWord256
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    0 = Word256 -> Int -> Word256
    shiftL256 Word256
    w (Int -> Int
    forall a. Num a => a -> a
    negate Int
    s)
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    256 = Word256
    zeroWord256
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    192 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 (Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    192))
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    192 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 Word64
    a3
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    128 =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 (Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    128)) (Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    128) Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    192 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    128 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    a3 Word64
    a2
      | Int
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    64 =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 (Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64))
            (Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64) Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    128 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64) Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    128 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
      | Int
    s Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    64 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    a3 Word64
    a2 Word64
    a1
      | Bool
    otherwise =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256
            (Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    s)
            (Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    s Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    s Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))
            (Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    s Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    s))

    {-# INLINABLE rotateL256 #-}
    rotateL256 :: Word256 -> Int -> Word256
    rotateL256 :: Word256 -> Int -> Word256
    rotateL256 w :: Word256
    w@(Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) Int
    r
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    0 = Word256 -> Int -> Word256
    rotateR256 Word256
    w ((Int -> Int
    forall a. Num a => a -> a
    abs Int
    r) Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `mod` Int
    256)
      | Int
    r Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    0 = Word256
    w
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    256 = Word256 -> Int -> Word256
    rotateL256 Word256
    w (Int
    r Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `mod` Int
    256)
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    192 = Word256 -> Int -> Word256
    rotateL256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a0 Word64
    a3 Word64
    a2 Word64
    a1) (Int
    r Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    192)
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    128 = Word256 -> Int -> Word256
    rotateL256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a1 Word64
    a0 Word64
    a3 Word64
    a2) (Int
    r Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    128)
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    64 = Word256 -> Int -> Word256
    rotateL256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a2 Word64
    a1 Word64
    a0 Word64
    a3) (Int
    r Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64)
      | Bool
    otherwise =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256
            (Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r))
            (Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r))
            (Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r))
            (Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r))

    {-# INLINABLE rotateR256 #-}
    rotateR256 :: Word256 -> Int -> Word256
    rotateR256 :: Word256 -> Int -> Word256
    rotateR256 w :: Word256
    w@(Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) Int
    r
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    0 = Word256 -> Int -> Word256
    rotateL256 Word256
    w ((Int -> Int
    forall a. Num a => a -> a
    abs Int
    r) Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `mod` Int
    256)
      | Int
    r Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    0 = Word256
    w
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    256 = Word256 -> Int -> Word256
    rotateR256 Word256
    w (Int
    r Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `mod` Int
    256)
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    192 = Word256 -> Int -> Word256
    rotateR256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a2 Word64
    a1 Word64
    a0 Word64
    a3) (Int
    r Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    192)
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    128 = Word256 -> Int -> Word256
    rotateR256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a1 Word64
    a0 Word64
    a3 Word64
    a2) (Int
    r Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    128)
      | Int
    r Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    64 = Word256 -> Int -> Word256
    rotateR256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    a0 Word64
    a3 Word64
    a2 Word64
    a1) (Int
    r Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64)
      | Bool
    otherwise =
          Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256
            (Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r)) (Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a3 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r))
            (Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a2 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r)) (Word64
    a0 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftR` Int
    r Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    a1 Word64 -> Int -> Word64
    forall a. Bits a => a -> Int -> a
    `shiftL` (Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    r))

    {-# INLINABLE testBit256 #-}
    testBit256 :: Word256 -> Int -> Bool
    testBit256 :: Word256 -> Int -> Bool
    testBit256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) Int
    i
      | Int
    i Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    0 = Bool
    False
      | Int
    i Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    256 = Bool
    False
      | Int
    i Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    192 = Word64 -> Int -> Bool
    forall a. Bits a => a -> Int -> Bool
    testBit Word64
    a3 (Int
    i Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    192)
      | Int
    i Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    128 = Word64 -> Int -> Bool
    forall a. Bits a => a -> Int -> Bool
    testBit Word64
    a2 (Int
    i Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    128)
      | Int
    i Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    64 = Word64 -> Int -> Bool
    forall a. Bits a => a -> Int -> Bool
    testBit Word64
    a1 (Int
    i Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    64)
      | Bool
    otherwise = Word64 -> Int -> Bool
    forall a. Bits a => a -> Int -> Bool
    testBit Word64
    a0 Int
    i

    {-# INLINABLE bit256 #-}
    bit256 :: Int -> Word256
    bit256 :: Int -> Word256
    bit256 Int
    indx
      | Int
    indx Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    0 = Word256
    zeroWord256
      | Int
    indx Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    256 = Word256
    zeroWord256
      | Bool
    otherwise = Word256 -> Int -> Word256
    shiftL256 Word256
    oneWord256 Int
    indx

    {-# INLINABLE popCount256 #-}
    popCount256 :: Word256 -> Int
    popCount256 :: Word256 -> Int
    popCount256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) =
      Word64 -> Int
    forall a. Bits a => a -> Int
    popCount Word64
    a3 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Word64 -> Int
    forall a. Bits a => a -> Int
    popCount Word64
    a2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Word64 -> Int
    forall a. Bits a => a -> Int
    popCount Word64
    a1 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Word64 -> Int
    forall a. Bits a => a -> Int
    popCount Word64
    a0

    -- -----------------------------------------------------------------------------
    -- Functions for `FiniteBits` instance.

    {-# INLINABLE countLeadingZeros256 #-}
    countLeadingZeros256 :: Word256 -> Int
    countLeadingZeros256 :: Word256 -> Int
    countLeadingZeros256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) =
      case Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countLeadingZeros Word64
    a3 of
        Int
    64 -> case Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countLeadingZeros Word64
    a2 of
          Int
    64 -> case Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countLeadingZeros Word64
    a1 of
            Int
    64 -> Int
    192 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countLeadingZeros Word64
    a0
            Int
    res -> Int
    128 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    res
          Int
    res -> Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    res
        Int
    res -> Int
    res

    {-# INLINABLE countTrailingZeros256 #-}
    countTrailingZeros256 :: Word256 -> Int
    countTrailingZeros256 :: Word256 -> Int
    countTrailingZeros256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) =
      case Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countTrailingZeros Word64
    a0 of
        Int
    64 -> case Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countTrailingZeros Word64
    a1 of
          Int
    64 -> case Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countTrailingZeros Word64
    a2 of
            Int
    64 -> Int
    192 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Word64 -> Int
    forall b. FiniteBits b => b -> Int
    countTrailingZeros Word64
    a3
            Int
    res -> Int
    128 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    res
          Int
    res -> Int
    64 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    res
        Int
    res -> Int
    res

    -- -----------------------------------------------------------------------------
    -- Functions for `Integral` instance.

    -- TODO: This is inefficient, but the better version is rather
    -- tedious to write out.
    quotRem256 :: Word256 -> Word256 -> (Word256, Word256)
    quotRem256 :: Word256 -> Word256 -> (Word256, Word256)
    quotRem256 Word256
    a Word256
    b =
      let (Integer
    x,Integer
    y) = Integer -> Integer -> (Integer, Integer)
    forall a. Integral a => a -> a -> (a, a)
    quotRem (Word256 -> Integer
    toInteger256 Word256
    a) (Word256 -> Integer
    toInteger256 Word256
    b)
       in (Integer -> Word256
    fromInteger256 Integer
    x, Integer -> Word256
    fromInteger256 Integer
    y)

    toInteger256 :: Word256 -> Integer
    toInteger256 :: Word256 -> Integer
    toInteger256 (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) =
      (Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word64
    a3 Integer -> Int -> Integer
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    192)
        Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + (Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word64
    a2 Integer -> Int -> Integer
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    128)
        Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + (Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word64
    a1 Integer -> Int -> Integer
    forall a. Bits a => a -> Int -> a
    `shiftL` Int
    64)
        Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word64
    a0

    -- -----------------------------------------------------------------------------
    -- Functions for `Storable` instance.

    peek256 :: Ptr Word256 -> IO Word256
    peek256 :: Ptr Word256 -> IO Word256
    peek256 Ptr Word256
    ptr =
      Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256)
    -> IO Word64 -> IO (Word64 -> Word64 -> Word64 -> Word256)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index3 IO (Word64 -> Word64 -> Word64 -> Word256)
    -> IO Word64 -> IO (Word64 -> Word64 -> Word256)
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index2
        IO (Word64 -> Word64 -> Word256)
    -> IO Word64 -> IO (Word64 -> Word256)
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index1 IO (Word64 -> Word256) -> IO Word64 -> IO Word256
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index0

    peekElemOff256 :: Ptr Word256 -> Int -> IO Word256
    peekElemOff256 :: Ptr Word256 -> Int -> IO Word256
    peekElemOff256 Ptr Word256
    ptr Int
    idx =
      Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64 -> Word64 -> Word64 -> Word64 -> Word256)
    -> IO Word64 -> IO (Word64 -> Word64 -> Word64 -> Word256)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index3)
        IO (Word64 -> Word64 -> Word64 -> Word256)
    -> IO Word64 -> IO (Word64 -> Word64 -> Word256)
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index2)
        IO (Word64 -> Word64 -> Word256)
    -> IO Word64 -> IO (Word64 -> Word256)
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index1)
        IO (Word64 -> Word256) -> IO Word64 -> IO Word256
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Ptr Word64 -> Int -> IO Word64
    forall a. Storable a => Ptr a -> Int -> IO a
    peekElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index0)
      where
        idx2 :: Int
    idx2 = Int
    4 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    idx

    poke256 :: Ptr Word256 -> Word256 -> IO ()
    poke256 :: Ptr Word256 -> Word256 -> IO ()
    poke256 Ptr Word256
    ptr (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) = do
      Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index3 Word64
    a3
      Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index2 Word64
    a2
      Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index1 Word64
    a1
      Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) Int
    index0 Word64
    a0

    pokeElemOff256 :: Ptr Word256 -> Int -> Word256 -> IO ()
    pokeElemOff256 :: Ptr Word256 -> Int -> Word256 -> IO ()
    pokeElemOff256 Ptr Word256
    ptr Int
    idx (Word256 Word64
    a3 Word64
    a2 Word64
    a1 Word64
    a0) = do
        Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index0) Word64
    a0
        Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index1) Word64
    a1
        Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index2) Word64
    a2
        Ptr Word64 -> Int -> Word64 -> IO ()
    forall a. Storable a => Ptr a -> Int -> a -> IO ()
    pokeElemOff (Ptr Word256 -> Ptr Word64
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word256
    ptr) (Int
    idx2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    index3) Word64
    a3
      where
        idx2 :: Int
    idx2 = Int
    4 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    idx

    -- -----------------------------------------------------------------------------
    -- Functions for `Prim` instance.

    {-# INLINE sizeOf256# #-}
    sizeOf256# :: Word256 -> Int#
    sizeOf256# :: Word256 -> Int#
    sizeOf256# Word256
    _ = Int#
    4# Int# -> Int# -> Int#
    *# Word64 -> Int#
    forall a. Prim a => a -> Int#
    sizeOf# (Word64
    0 :: Word64)

    {-# INLINE alignment256# #-}
    alignment256# :: Word256 -> Int#
    alignment256# :: Word256 -> Int#
    alignment256# Word256
    _ = Int#
    4# Int# -> Int# -> Int#
    *# Word64 -> Int#
    forall a. Prim a => a -> Int#
    alignment# (Word64
    0 :: Word64)

    {-# INLINE indexByteArray256# #-}
    indexByteArray256# :: ByteArray# -> Int# -> Word256
    indexByteArray256# :: ByteArray# -> Int# -> Word256
    indexByteArray256# ByteArray#
    arr# Int#
    i# =
      let i2# :: Int#
    i2# = Int#
    4# Int# -> Int# -> Int#
    *# Int#
    i#
          w :: Word64
    w = ByteArray# -> Int# -> Word64
    forall a. Prim a => ByteArray# -> Int# -> a
    indexByteArray# ByteArray#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index3)
          x :: Word64
    x = ByteArray# -> Int# -> Word64
    forall a. Prim a => ByteArray# -> Int# -> a
    indexByteArray# ByteArray#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index2)
          y :: Word64
    y = ByteArray# -> Int# -> Word64
    forall a. Prim a => ByteArray# -> Int# -> a
    indexByteArray# ByteArray#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index1)
          z :: Word64
    z = ByteArray# -> Int# -> Word64
    forall a. Prim a => ByteArray# -> Int# -> a
    indexByteArray# ByteArray#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index0)
      in Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    w Word64
    x Word64
    y Word64
    z

    {-# INLINE readByteArray256# #-}
    readByteArray256# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word256 #)
    readByteArray256# :: forall s.
    MutableByteArray# s -> Int# -> State# s -> (# State# s, Word256 #)
    readByteArray256# MutableByteArray# s
    arr# Int#
    i# =
      \State# s
    s0 -> case MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall s.
    MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> State# s -> (# State# s, a #)
    readByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index3) State# s
    s0 of
        (# State# s
    s1, Word64
    w #) -> case MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall s.
    MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> State# s -> (# State# s, a #)
    readByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index2) State# s
    s1 of
          (# State# s
    s2, Word64
    x #) -> case MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall s.
    MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> State# s -> (# State# s, a #)
    readByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index1) State# s
    s2 of
            (# State# s
    s3, Word64
    y #) -> case MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall s.
    MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> State# s -> (# State# s, a #)
    readByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index0) State# s
    s3 of
              (# State# s
    s4, Word64
    z #) -> (# State# s
    s4, Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    w Word64
    x Word64
    y Word64
    z #)
      where i2# :: Int#
    i2# = Int#
    4# Int# -> Int# -> Int#
    *# Int#
    i#

    {-# INLINE writeByteArray256# #-}
    writeByteArray256# :: MutableByteArray# s -> Int# -> Word256 -> State# s -> State# s
    writeByteArray256# :: forall s.
    MutableByteArray# s -> Int# -> Word256 -> State# s -> State# s
    writeByteArray256# MutableByteArray# s
    arr# Int#
    i# (Word256 Word64
    a Word64
    b Word64
    c Word64
    d) =
      \State# s
    s0 -> case MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall s.
    MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> a -> State# s -> State# s
    writeByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index3) Word64
    a State# s
    s0 of
        State# s
    s1 -> case MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall s.
    MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> a -> State# s -> State# s
    writeByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index2) Word64
    b State# s
    s1 of
          State# s
    s2 -> case MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall s.
    MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> a -> State# s -> State# s
    writeByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index1) Word64
    c State# s
    s2 of
            State# s
    s3 -> case MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall s.
    MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> a -> State# s -> State# s
    writeByteArray# MutableByteArray# s
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index0) Word64
    d State# s
    s3 of
              State# s
    s4 -> State# s
    s4
      where i2# :: Int#
    i2# = Int#
    4# Int# -> Int# -> Int#
    *# Int#
    i#

    {-# INLINE setByteArray256# #-}
    setByteArray256# :: MutableByteArray# s -> Int# -> Int# -> Word256 -> State# s -> State# s
    setByteArray256# :: forall s.
    MutableByteArray# s
    -> Int# -> Int# -> Word256 -> State# s -> State# s
    setByteArray256# = MutableByteArray# s
    -> Int# -> Int# -> Word256 -> State# s -> State# s
    forall a s.
    Prim a =>
    MutableByteArray# s -> Int# -> Int# -> a -> State# s -> State# s
    defaultSetByteArray#

    {-# INLINE indexOffAddr256# #-}
    indexOffAddr256# :: Addr# -> Int# -> Word256
    indexOffAddr256# :: Addr# -> Int# -> Word256
    indexOffAddr256# Addr#
    arr# Int#
    i# =
      let i2# :: Int#
    i2# = Int#
    4# Int# -> Int# -> Int#
    *# Int#
    i#
          w :: Word64
    w = Addr# -> Int# -> Word64
    forall a. Prim a => Addr# -> Int# -> a
    indexOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index3)
          x :: Word64
    x = Addr# -> Int# -> Word64
    forall a. Prim a => Addr# -> Int# -> a
    indexOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index2)
          y :: Word64
    y = Addr# -> Int# -> Word64
    forall a. Prim a => Addr# -> Int# -> a
    indexOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index1)
          z :: Word64
    z = Addr# -> Int# -> Word64
    forall a. Prim a => Addr# -> Int# -> a
    indexOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index0)
      in Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    w Word64
    x Word64
    y Word64
    z

    {-# INLINE readOffAddr256# #-}
    readOffAddr256# :: Addr# -> Int# -> State# s -> (# State# s, Word256 #)
    readOffAddr256# :: forall s. Addr# -> Int# -> State# s -> (# State# s, Word256 #)
    readOffAddr256# Addr#
    arr# Int#
    i# =
      \State# s
    s0 -> case Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall s. Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    Addr# -> Int# -> State# s -> (# State# s, a #)
    readOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index3) State# s
    s0 of
        (# State# s
    s1, Word64
    w #) -> case Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall s. Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    Addr# -> Int# -> State# s -> (# State# s, a #)
    readOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index2) State# s
    s1 of
          (# State# s
    s2, Word64
    x #) -> case Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall s. Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    Addr# -> Int# -> State# s -> (# State# s, a #)
    readOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index1) State# s
    s2 of
            (# State# s
    s3, Word64
    y #) -> case Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall s. Addr# -> Int# -> State# s -> (# State# s, Word64 #)
    forall a s.
    Prim a =>
    Addr# -> Int# -> State# s -> (# State# s, a #)
    readOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index0) State# s
    s3 of
              (# State# s
    s4, Word64
    z #) -> (# State# s
    s4, Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    w Word64
    x Word64
    y Word64
    z #)
      where i2# :: Int#
    i2# = Int#
    4# Int# -> Int# -> Int#
    *# Int#
    i#

    {-# INLINE writeOffAddr256# #-}
    writeOffAddr256# :: Addr# -> Int# -> Word256 -> State# s -> State# s
    writeOffAddr256# :: forall s. Addr# -> Int# -> Word256 -> State# s -> State# s
    writeOffAddr256# Addr#
    arr# Int#
    i# (Word256 Word64
    a Word64
    b Word64
    c Word64
    d) =
      \State# s
    s0 -> case Addr# -> Int# -> Word64 -> State# s -> State# s
    forall s. Addr# -> Int# -> Word64 -> State# s -> State# s
    forall a s. Prim a => Addr# -> Int# -> a -> State# s -> State# s
    writeOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index3) Word64
    a State# s
    s0 of
        State# s
    s1 -> case Addr# -> Int# -> Word64 -> State# s -> State# s
    forall s. Addr# -> Int# -> Word64 -> State# s -> State# s
    forall a s. Prim a => Addr# -> Int# -> a -> State# s -> State# s
    writeOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index2) Word64
    b State# s
    s1 of
          State# s
    s2 -> case Addr# -> Int# -> Word64 -> State# s -> State# s
    forall s. Addr# -> Int# -> Word64 -> State# s -> State# s
    forall a s. Prim a => Addr# -> Int# -> a -> State# s -> State# s
    writeOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index1) Word64
    c State# s
    s2 of
            State# s
    s3 -> case Addr# -> Int# -> Word64 -> State# s -> State# s
    forall s. Addr# -> Int# -> Word64 -> State# s -> State# s
    forall a s. Prim a => Addr# -> Int# -> a -> State# s -> State# s
    writeOffAddr# Addr#
    arr# (Int#
    i2# Int# -> Int# -> Int#
    +# Int -> Int#
    unInt Int
    index0) Word64
    d State# s
    s3 of
              State# s
    s4 -> State# s
    s4
      where i2# :: Int#
    i2# = Int#
    4# Int# -> Int# -> Int#
    *# Int#
    i#

    {-# INLINE setOffAddr256# #-}
    setOffAddr256# :: Addr# -> Int# -> Int# -> Word256 -> State# s -> State# s
    setOffAddr256# :: forall s. Addr# -> Int# -> Int# -> Word256 -> State# s -> State# s
    setOffAddr256# = Addr# -> Int# -> Int# -> Word256 -> State# s -> State# s
    forall a s.
    Prim a =>
    Addr# -> Int# -> Int# -> a -> State# s -> State# s
    defaultSetOffAddr#

    -- -----------------------------------------------------------------------------
    -- Constants.

    zeroWord256 :: Word256
    zeroWord256 :: Word256
    zeroWord256 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 Word64
    0

    oneWord256 :: Word256
    oneWord256 :: Word256
    oneWord256 = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 Word64
    0 Word64
    0 Word64
    0 Word64
    1

    unInt :: Int -> Int#
    unInt :: Int -> Int#
    unInt (I# Int#
    i#) = Int#
    i#

    -- Use these indices to get the peek/poke ordering endian correct.
    index0, index1, index2, index3 :: Int
    #if WORDS_BIGENDIAN
    index0 = 3
    index1 = 2
    index2 = 1
    index3 = 0
    #else
    index0 :: Int
    index0 = Int
    0
    index1 :: Int
    index1 = Int
    1
    index2 :: Int
    index2 = Int
    2
    index3 :: Int
    index3 = Int
    3
    #endif