    {-# OPTIONS_GHC -fno-warn-orphans #-}

    module Futhark.IR.Mem.IxFunTests
      ( tests,
      )
    where

    import Data.Bifunctor
    import Data.Function ((&))
    import Data.List qualified as L
    import Data.Map qualified as M
    import Data.Text qualified as T
    import Futhark.Analysis.PrimExp.Convert
    import Futhark.IR.Mem.IxFun.Alg qualified as IxFunAlg
    import Futhark.IR.Mem.IxFunWrapper
    import Futhark.IR.Mem.IxFunWrapper qualified as IxFunWrap
    import Futhark.IR.Mem.LMAD qualified as IxFunLMAD
    import Futhark.IR.Prop
    import Futhark.IR.Syntax
    import Futhark.IR.Syntax.Core ()
    import Futhark.Util.IntegralExp qualified as IE
    import Futhark.Util.Pretty
    import Test.Tasty
    import Test.Tasty.HUnit
    import Prelude hiding (span)
    import Prelude qualified as P

    instance IE.IntegralExp Int where
      quot :: Int -> Int -> Int
    quot = Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    P.quot
      rem :: Int -> Int -> Int
    rem = Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    P.rem
      div :: Int -> Int -> Int
    div = Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    P.div
      mod :: Int -> Int -> Int
    mod = Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    P.mod
      pow :: Int -> Int -> Int
    pow = Int -> Int -> Int
    forall a b. (Num a, Integral b) => a -> b -> a
    (P.^)
      sgn :: Int -> Maybe Int
    sgn = Int -> Maybe Int
    forall a. a -> Maybe a
    Just (Int -> Maybe Int) -> (Int -> Int) -> Int -> Maybe Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> Int
    forall a. Num a => a -> a
    P.signum

    allPoints :: [Int] -> [[Int]]
    allPoints :: Shape Int -> [Shape Int]
    allPoints Shape Int
    dims =
      let total :: Int
    total = Shape Int -> Int
    forall a. Num a => [a] -> a
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    product Shape Int
    dims
          strides :: Shape Int
    strides = Int -> Shape Int -> Shape Int
    forall a. Int -> [a] -> [a]
    drop Int
    1 (Shape Int -> Shape Int) -> Shape Int -> Shape Int
    forall a b. (a -> b) -> a -> b
    $ Shape Int -> Shape Int
    forall a. [a] -> [a]
    L.reverse (Shape Int -> Shape Int) -> Shape Int -> Shape Int
    forall a b. (a -> b) -> a -> b
    $ (Int -> Int -> Int) -> Int -> Shape Int -> Shape Int
    forall b a. (b -> a -> b) -> b -> [a] -> [b]
    scanl Int -> Int -> Int
    forall a. Num a => a -> a -> a
    (*) Int
    1 (Shape Int -> Shape Int) -> Shape Int -> Shape Int
    forall a b. (a -> b) -> a -> b
    $ Shape Int -> Shape Int
    forall a. [a] -> [a]
    L.reverse Shape Int
    dims
       in (Int -> Shape Int) -> Shape Int -> [Shape Int]
    forall a b. (a -> b) -> [a] -> [b]
    map (Shape Int -> Int -> Shape Int
    unflatInd Shape Int
    strides) [Int
    0 .. Int
    total Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1]
      where
        unflatInd :: [Int] -> Int -> [Int]
        unflatInd :: Shape Int -> Int -> Shape Int
    unflatInd Shape Int
    strides Int
    x =
          (Shape Int, Int) -> Shape Int
    forall a b. (a, b) -> a
    fst ((Shape Int, Int) -> Shape Int) -> (Shape Int, Int) -> Shape Int
    forall a b. (a -> b) -> a -> b
    $
            ((Shape Int, Int) -> Int -> (Shape Int, Int))
    -> (Shape Int, Int) -> Shape Int -> (Shape Int, Int)
    forall b a. (b -> a -> b) -> b -> [a] -> b
    forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl
              ( \(Shape Int
    res, Int
    acc) Int
    span ->
                  (Shape Int
    res Shape Int -> Shape Int -> Shape Int
    forall a. [a] -> [a] -> [a]
    ++ [Int
    acc Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    span], Int
    acc Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.mod` Int
    span)
              )
              ([], Int
    x)
              Shape Int
    strides

    compareIxFuns :: Maybe (IxFunLMAD.LMAD Int) -> IxFunAlg.IxFun Int -> Assertion
    compareIxFuns :: Maybe (LMAD Int) -> IxFun Int -> Assertion
    compareIxFuns (Just LMAD Int
    ixfunLMAD) IxFun Int
    ixfunAlg =
      let lmadShape :: Shape Int
    lmadShape = LMAD Int -> Shape Int
    forall num. LMAD num -> Shape num
    IxFunLMAD.shape LMAD Int
    ixfunLMAD
          algShape :: Shape Int
    algShape = IxFun Int -> Shape Int
    forall num. IntegralExp num => IxFun num -> Shape num
    IxFunAlg.shape IxFun Int
    ixfunAlg
          points :: [Shape Int]
    points = Shape Int -> [Shape Int]
    allPoints Shape Int
    lmadShape
          resLMAD :: Shape Int
    resLMAD = (Shape Int -> Int) -> [Shape Int] -> Shape Int
    forall a b. (a -> b) -> [a] -> [b]
    map (LMAD Int -> Shape Int -> Int
    forall num.
    (IntegralExp num, Eq num) =>
    LMAD num -> Indices num -> num
    IxFunLMAD.index LMAD Int
    ixfunLMAD) [Shape Int]
    points
          resAlg :: Shape Int
    resAlg = (Shape Int -> Int) -> [Shape Int] -> Shape Int
    forall a b. (a -> b) -> [a] -> [b]
    map (IxFun Int -> Shape Int -> Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Indices num -> num
    IxFunAlg.index IxFun Int
    ixfunAlg) [Shape Int]
    points
          errorMessage :: String
    errorMessage =
            Text -> String
    T.unpack (Text -> String)
    -> (Doc (ZonkAny 7) -> Text) -> Doc (ZonkAny 7) -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Doc (ZonkAny 7) -> Text
    forall a. Doc a -> Text
    docText (Doc (ZonkAny 7) -> String) -> Doc (ZonkAny 7) -> String
    forall a b. (a -> b) -> a -> b
    $
              Doc (ZonkAny 7)
    "lmad ixfun:  "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> LMAD Int -> Doc (ZonkAny 7)
    forall a ann. Pretty a => a -> Doc ann
    forall ann. LMAD Int -> Doc ann
    pretty LMAD Int
    ixfunLMAD
                  Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 7)
    "alg ixfun:   "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> IxFun Int -> Doc (ZonkAny 7)
    forall a ann. Pretty a => a -> Doc ann
    forall ann. IxFun Int -> Doc ann
    pretty IxFun Int
    ixfunAlg
                  Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 7)
    "lmad shape:  "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> Shape Int -> Doc (ZonkAny 7)
    forall ann. Shape Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Shape Int
    lmadShape
                  Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 7)
    "alg shape:   "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> Shape Int -> Doc (ZonkAny 7)
    forall ann. Shape Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Shape Int
    algShape
                  Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 7)
    "lmad points length: "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> Int -> Doc (ZonkAny 7)
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Shape Int -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length Shape Int
    resLMAD)
                  Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 7)
    "alg points length:  "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> Int -> Doc (ZonkAny 7)
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Shape Int -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length Shape Int
    resAlg)
                  Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 7)
    "lmad points: "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> Shape Int -> Doc (ZonkAny 7)
    forall ann. Shape Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Shape Int
    resLMAD
                  Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 7)
    "alg points:  "
                Doc (ZonkAny 7) -> Doc (ZonkAny 7) -> Doc (ZonkAny 7)
    forall a. Semigroup a => a -> a -> a
    <> Shape Int -> Doc (ZonkAny 7)
    forall ann. Shape Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Shape Int
    resAlg
       in (Shape Int
    lmadShape Shape Int -> Shape Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Shape Int
    algShape Bool -> Bool -> Bool
    && Shape Int
    resLMAD Shape Int -> Shape Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Shape Int
    resAlg) Bool -> String -> Assertion
    forall t.
    (AssertionPredicable t, HasCallStack) =>
    t -> String -> Assertion
    @? String
    errorMessage
    compareIxFuns Maybe (LMAD Int)
    Nothing IxFun Int
    ixfunAlg =
      String -> Assertion
    forall a. HasCallStack => String -> IO a
    assertFailure (String -> Assertion) -> String -> Assertion
    forall a b. (a -> b) -> a -> b
    $
        [String] -> String
    unlines
          [ String
    "lmad ixfun: Nothing",
            String
    "alg ixfun:  " String -> String -> String
    forall a. Semigroup a => a -> a -> a
    <> IxFun Int -> String
    forall a. Pretty a => a -> String
    prettyString IxFun Int
    ixfunAlg
          ]

    compareOps :: IxFunWrap.IxFun Int -> Assertion
    compareOps :: IxFun Int -> Assertion
    compareOps (Maybe (LMAD Int)
    ixfunLMAD, IxFun Int
    ixfunAlg) = Maybe (LMAD Int) -> IxFun Int -> Assertion
    compareIxFuns Maybe (LMAD Int)
    ixfunLMAD IxFun Int
    ixfunAlg

    compareOpsFailure :: IxFunWrap.IxFun Int -> Assertion
    compareOpsFailure :: IxFun Int -> Assertion
    compareOpsFailure (Maybe (LMAD Int)
    Nothing, IxFun Int
    _) = () -> Assertion
    forall a. a -> IO a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ()
    compareOpsFailure (Just LMAD Int
    ixfunLMAD, IxFun Int
    ixfunAlg) =
      String -> Assertion
    forall a. HasCallStack => String -> IO a
    assertFailure (String -> Assertion)
    -> (Doc (ZonkAny 0) -> String) -> Doc (ZonkAny 0) -> Assertion
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> String
    T.unpack (Text -> String)
    -> (Doc (ZonkAny 0) -> Text) -> Doc (ZonkAny 0) -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Doc (ZonkAny 0) -> Text
    forall a. Doc a -> Text
    docText (Doc (ZonkAny 0) -> Assertion) -> Doc (ZonkAny 0) -> Assertion
    forall a b. (a -> b) -> a -> b
    $
        Doc (ZonkAny 0)
    "Not supposed to be representable as LMAD."
          Doc (ZonkAny 0) -> Doc (ZonkAny 0) -> Doc (ZonkAny 0)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 0)
    "lmad ixfun: "
          Doc (ZonkAny 0) -> Doc (ZonkAny 0) -> Doc (ZonkAny 0)
    forall a. Semigroup a => a -> a -> a
    <> LMAD Int -> Doc (ZonkAny 0)
    forall a ann. Pretty a => a -> Doc ann
    forall ann. LMAD Int -> Doc ann
    pretty LMAD Int
    ixfunLMAD
            Doc (ZonkAny 0) -> Doc (ZonkAny 0) -> Doc (ZonkAny 0)
    forall a. Doc a -> Doc a -> Doc a
    </> Doc (ZonkAny 0)
    "alg ixfun:  "
          Doc (ZonkAny 0) -> Doc (ZonkAny 0) -> Doc (ZonkAny 0)
    forall a. Semigroup a => a -> a -> a
    <> IxFun Int -> Doc (ZonkAny 0)
    forall a ann. Pretty a => a -> Doc ann
    forall ann. IxFun Int -> Doc ann
    pretty IxFun Int
    ixfunAlg

    -- XXX: Clean this up.
    n :: Int
    n :: Int
    n = Int
    19

    slice3 :: Slice Int
    slice3 :: Slice Int
    slice3 =
      [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice
        [ Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    2 (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    3) Int
    3,
          Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    2),
          Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    1 (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    2) Int
    2
        ]

    -- Actual tests.
    tests :: TestTree
    tests :: TestTree
    tests =
      String -> [TestTree] -> TestTree
    testGroup String
    "IxFunTests" ([TestTree] -> TestTree) -> [TestTree] -> TestTree
    forall a b. (a -> b) -> a -> b
    $
        [[TestTree]] -> [TestTree]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat
          [ [TestTree]
    test_iota,
            [TestTree]
    test_slice_iota,
            [TestTree]
    test_slice_reshape_iota1,
            [TestTree]
    test_permute_slice_iota,
            [TestTree]
    test_reshape_iota,
            [TestTree]
    test_reshape_permute_iota,
            [TestTree]
    test_slice_reshape_iota2,
            [TestTree]
    test_reshape_slice_iota3,
            [TestTree]
    test_flatten_strided,
            [TestTree]
    test_complex1,
            [TestTree]
    test_complex2,
            [TestTree]
    test_expand1,
            [TestTree]
    test_expand2,
            [TestTree]
    test_expand3,
            [TestTree]
    test_expand4,
            [TestTree]
    test_flatSlice_iota,
            [TestTree]
    test_slice_flatSlice_iota,
            [TestTree]
    test_flatSlice_flatSlice_iota,
            [TestTree]
    test_flatSlice_slice_iota,
            [TestTree]
    test_flatSlice_transpose_slice_iota
            -- TODO: Without z3, these tests fail. Ideally, our internal simplifier
            -- should be able to handle them:
            --
            -- test_disjoint3
          ]

    singleton :: TestTree -> [TestTree]
    singleton :: TestTree -> [TestTree]
    singleton = (TestTree -> [TestTree] -> [TestTree]
    forall a. a -> [a] -> [a]
    : [])

    test_iota :: [TestTree]
    test_iota :: [TestTree]
    test_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "iota" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n]

    test_slice_iota :: [TestTree]
    test_slice_iota :: [TestTree]
    test_slice_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "slice . iota" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n]) Slice Int
    slice3

    test_slice_reshape_iota1 :: [TestTree]
    test_slice_reshape_iota1 :: [TestTree]
    test_slice_reshape_iota1 =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "slice . reshape . iota 1" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (IxFun Int -> Shape Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Shape num -> IxFun num
    reshape (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n]) [Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    2, Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    3, Int
    1]) Slice Int
    slice3

    test_permute_slice_iota :: [TestTree]
    test_permute_slice_iota :: [TestTree]
    test_permute_slice_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "permute . slice . iota" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> Shape Int -> IxFun Int
    forall num. IxFun num -> Shape Int -> IxFun num
    permute (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n]) Slice Int
    slice3) [Int
    1, Int
    0]

    test_reshape_iota :: [TestTree]
    test_reshape_iota :: [TestTree]
    test_reshape_iota =
      -- This tests a pattern that occurs with ScalarSpace.
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "reshape . zeroslice . iota" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        let s :: Slice Int
    s = [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice [Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    0, Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1]
         in IxFun Int -> Shape Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Shape num -> IxFun num
    reshape (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n]) Slice Int
    s) [Int
    1, Int
    n, Int
    1, Int
    n]

    test_reshape_permute_iota :: [TestTree]
    test_reshape_permute_iota :: [TestTree]
    test_reshape_permute_iota =
      -- negative reshape test
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "reshape . permute . iota" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOpsFailure (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        let newdims :: Shape Int
    newdims = [Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n, Int
    n]
         in IxFun Int -> Shape Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Shape num -> IxFun num
    reshape (IxFun Int -> Shape Int -> IxFun Int
    forall num. IxFun num -> Shape Int -> IxFun num
    permute (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n]) [Int
    1, Int
    2, Int
    0]) Shape Int
    newdims

    test_slice_reshape_iota2 :: [TestTree]
    test_slice_reshape_iota2 :: [TestTree]
    test_slice_reshape_iota2 =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "slice . reshape . iota 2" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        let newdims :: Shape Int
    newdims = [Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n, Int
    n]
            slc :: Slice Int
    slc =
              [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice
                [ Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    2),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1
                ]
         in IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (IxFun Int -> Shape Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Shape num -> IxFun num
    reshape (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n, Int
    n]) Shape Int
    newdims) Slice Int
    slc

    test_reshape_slice_iota3 :: [TestTree]
    test_reshape_slice_iota3 :: [TestTree]
    test_reshape_slice_iota3 =
      -- negative reshape test
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "reshape . slice . iota 3" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOpsFailure (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        let newdims :: Shape Int
    newdims = [Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n, Int
    n]
            slc :: Slice Int
    slc =
              [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice
                [ Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    2),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1,
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    2) Int
    1,
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1
                ]
         in IxFun Int -> Shape Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Shape num -> IxFun num
    reshape (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n, Int
    n]) Slice Int
    slc) Shape Int
    newdims

    -- Tests flattening something that is strided - this can occur after
    -- memory expansion.
    test_flatten_strided :: [TestTree]
    test_flatten_strided :: [TestTree]
    test_flatten_strided =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "reshape . fix . iota 3d" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        let slc :: Slice Int
    slc = [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice [Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1, Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    2 Int
    1, Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix Int
    1]
         in IxFun Int -> Shape Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Shape num -> IxFun num
    reshape (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    2, Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n]) Slice Int
    slc) [Int
    2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    10]

    test_complex1 :: [TestTree]
    test_complex1 :: [TestTree]
    test_complex1 =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "permute . slice . permute . slice . iota 1" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        let slice33 :: Slice Int
    slice33 =
              [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice
                [ Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    3) (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1
                ]
            ixfun :: IxFun Int
    ixfun = IxFun Int -> Shape Int -> IxFun Int
    forall num. IxFun num -> Shape Int -> IxFun num
    permute (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n, Int
    n, Int
    n]) Slice Int
    slice33) [Int
    3, Int
    1, Int
    2, Int
    0]
            m :: Int
    m = Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    3
            slice1 :: Slice Int
    slice1 =
              [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice
                [ Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1,
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    1 (Int
    m Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    2) (-Int
    1)
                ]
            ixfun' :: IxFun Int
    ixfun' = IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice IxFun Int
    ixfun Slice Int
    slice1
         in IxFun Int
    ixfun'

    test_complex2 :: [TestTree]
    test_complex2 :: [TestTree]
    test_complex2 =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "permute . slice . permute . slice . iota 2" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        let slc2 :: Slice Int
    slc2 =
              [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice
                [ Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    2),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    3) (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1
                ]
            ixfun :: IxFun Int
    ixfun = IxFun Int -> Shape Int -> IxFun Int
    forall num. IxFun num -> Shape Int -> IxFun num
    permute (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n, Int
    n, Int
    n, Int
    n]) Slice Int
    slc2) [Int
    3, Int
    1, Int
    2, Int
    0]
            m :: Int
    m = Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `P.div` Int
    3
            slice1 :: Slice Int
    slice1 =
              [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice
                [ Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1,
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int
    n (-Int
    1),
                  Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    1 (Int
    m Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    2) (-Int
    1)
                ]
            ixfun' :: IxFun Int
    ixfun' = IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice IxFun Int
    ixfun Slice Int
    slice1
         in IxFun Int
    ixfun'

    -- Imitates a case from memory expansion.
    test_expand1 :: [TestTree]
    test_expand1 :: [TestTree]
    test_expand1 =
      [ String -> Assertion -> TestTree
    testCase String
    "expand . iota1d" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> TestTree) -> IxFun Int -> TestTree
    forall a b. (a -> b) -> a -> b
    $
          Int -> Int -> IxFun Int -> IxFun Int
    forall num. IntegralExp num => num -> num -> IxFun num -> IxFun num
    expand Int
    t Int
    nt (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n])
      ]
      where
        t :: Int
    t = Int
    3
        nt :: Int
    nt = Int
    7

    -- Imitates another case from memory expansion.
    test_expand2 :: [TestTree]
    test_expand2 :: [TestTree]
    test_expand2 =
      [ String -> Assertion -> TestTree
    testCase String
    "expand . iota2d" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> TestTree) -> IxFun Int -> TestTree
    forall a b. (a -> b) -> a -> b
    $
          Int -> Int -> IxFun Int -> IxFun Int
    forall num. IntegralExp num => num -> num -> IxFun num -> IxFun num
    expand Int
    t Int
    nt (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n])
      ]
      where
        t :: Int
    t = Int
    3
        nt :: Int
    nt = Int
    7

    test_expand3 :: [TestTree]
    test_expand3 :: [TestTree]
    test_expand3 =
      [ String -> Assertion -> TestTree
    testCase String
    "expand . permute . iota2d" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> TestTree) -> IxFun Int -> TestTree
    forall a b. (a -> b) -> a -> b
    $
          Int -> Int -> IxFun Int -> IxFun Int
    forall num. IntegralExp num => num -> num -> IxFun num -> IxFun num
    expand Int
    t Int
    nt (IxFun Int -> Shape Int -> IxFun Int
    forall num. IxFun num -> Shape Int -> IxFun num
    permute (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n, Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `div` Int
    2]) [Int
    1, Int
    0])
      ]
      where
        t :: Int
    t = Int
    3
        nt :: Int
    nt = Int
    7

    test_expand4 :: [TestTree]
    test_expand4 :: [TestTree]
    test_expand4 =
      [ String -> Assertion -> TestTree
    testCase String
    "expand . slice . iota1d" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> TestTree) -> IxFun Int -> TestTree
    forall a b. (a -> b) -> a -> b
    $
          Int -> Int -> IxFun Int -> IxFun Int
    forall num. IntegralExp num => num -> num -> IxFun num -> IxFun num
    expand Int
    t Int
    nt (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n]) ([DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice [Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `div` Int
    2) (Int
    n Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `div` Int
    2) Int
    1]))
      ]
      where
        t :: Int
    t = Int
    3
        nt :: Int
    nt = Int
    7

    test_flatSlice_iota :: [TestTree]
    test_flatSlice_iota :: [TestTree]
    test_flatSlice_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "flatSlice . iota" (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> FlatSlice Int -> IxFun Int
    forall num.
    IntegralExp num =>
    IxFun num -> FlatSlice num -> IxFun num
    flatSlice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n]) (FlatSlice Int -> IxFun Int) -> FlatSlice Int -> IxFun Int
    forall a b. (a -> b) -> a -> b
    $
          Int -> [FlatDimIndex Int] -> FlatSlice Int
    forall d. d -> [FlatDimIndex d] -> FlatSlice d
    FlatSlice Int
    2 [Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    2) Int
    4, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    n Int
    3, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    1 Int
    2]

    test_slice_flatSlice_iota :: [TestTree]
    test_slice_flatSlice_iota :: [TestTree]
    test_slice_flatSlice_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "slice . flatSlice . iota " (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (IxFun Int -> FlatSlice Int -> IxFun Int
    forall num.
    IntegralExp num =>
    IxFun num -> FlatSlice num -> IxFun num
    flatSlice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n]) FlatSlice Int
    flat_slice) (Slice Int -> IxFun Int) -> Slice Int -> IxFun Int
    forall a b. (a -> b) -> a -> b
    $
          [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice [Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix Int
    2, Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    n Int
    1, Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix Int
    0]
      where
        flat_slice :: FlatSlice Int
    flat_slice = Int -> [FlatDimIndex Int] -> FlatSlice Int
    forall d. d -> [FlatDimIndex d] -> FlatSlice d
    FlatSlice Int
    2 [Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex (Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    n) Int
    1, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    n Int
    1, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    1 Int
    1]

    test_flatSlice_flatSlice_iota :: [TestTree]
    test_flatSlice_flatSlice_iota :: [TestTree]
    test_flatSlice_flatSlice_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "flatSlice . flatSlice . iota " (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> FlatSlice Int -> IxFun Int
    forall num.
    IntegralExp num =>
    IxFun num -> FlatSlice num -> IxFun num
    flatSlice (IxFun Int -> FlatSlice Int -> IxFun Int
    forall num.
    IntegralExp num =>
    IxFun num -> FlatSlice num -> IxFun num
    flatSlice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    10 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    10]) FlatSlice Int
    flat_slice_1) FlatSlice Int
    flat_slice_2
      where
        flat_slice_1 :: FlatSlice Int
    flat_slice_1 = Int -> [FlatDimIndex Int] -> FlatSlice Int
    forall d. d -> [FlatDimIndex d] -> FlatSlice d
    FlatSlice Int
    17 [Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    3 Int
    27, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    3 Int
    10, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    3 Int
    1]
        flat_slice_2 :: FlatSlice Int
    flat_slice_2 = Int -> [FlatDimIndex Int] -> FlatSlice Int
    forall d. d -> [FlatDimIndex d] -> FlatSlice d
    FlatSlice Int
    2 [Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    2 (-Int
    2)]

    test_flatSlice_slice_iota :: [TestTree]
    test_flatSlice_slice_iota :: [TestTree]
    test_flatSlice_slice_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "flatSlice . slice . iota " (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> FlatSlice Int -> IxFun Int
    forall num.
    IntegralExp num =>
    IxFun num -> FlatSlice num -> IxFun num
    flatSlice (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    210, Int
    100]) (Slice Int -> IxFun Int) -> Slice Int -> IxFun Int
    forall a b. (a -> b) -> a -> b
    $ [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice [Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    10 Int
    100 Int
    2, Int -> DimIndex Int
    forall d. d -> DimIndex d
    DimFix Int
    10]) FlatSlice Int
    flat_slice_1
      where
        flat_slice_1 :: FlatSlice Int
    flat_slice_1 = Int -> [FlatDimIndex Int] -> FlatSlice Int
    forall d. d -> [FlatDimIndex d] -> FlatSlice d
    FlatSlice Int
    17 [Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    3 Int
    27, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    3 Int
    10, Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    3 Int
    1]

    test_flatSlice_transpose_slice_iota :: [TestTree]
    test_flatSlice_transpose_slice_iota :: [TestTree]
    test_flatSlice_transpose_slice_iota =
      TestTree -> [TestTree]
    singleton (TestTree -> [TestTree])
    -> (IxFun Int -> TestTree) -> IxFun Int -> [TestTree]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Assertion -> TestTree
    testCase String
    "flatSlice . transpose . slice . iota " (Assertion -> TestTree)
    -> (IxFun Int -> Assertion) -> IxFun Int -> TestTree
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IxFun Int -> Assertion
    compareOps (IxFun Int -> [TestTree]) -> IxFun Int -> [TestTree]
    forall a b. (a -> b) -> a -> b
    $
        IxFun Int -> FlatSlice Int -> IxFun Int
    forall num.
    IntegralExp num =>
    IxFun num -> FlatSlice num -> IxFun num
    flatSlice (IxFun Int -> Shape Int -> IxFun Int
    forall num. IxFun num -> Shape Int -> IxFun num
    permute (IxFun Int -> Slice Int -> IxFun Int
    forall num.
    (Eq num, IntegralExp num) =>
    IxFun num -> Slice num -> IxFun num
    slice (Shape Int -> IxFun Int
    forall num. IntegralExp num => Shape num -> IxFun num
    iota [Int
    20, Int
    20]) (Slice Int -> IxFun Int) -> Slice Int -> IxFun Int
    forall a b. (a -> b) -> a -> b
    $ [DimIndex Int] -> Slice Int
    forall d. [DimIndex d] -> Slice d
    Slice [Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    1 Int
    5 Int
    2, Int -> Int -> Int -> DimIndex Int
    forall d. d -> d -> d -> DimIndex d
    DimSlice Int
    0 Int
    5 Int
    2]) [Int
    1, Int
    0]) FlatSlice Int
    flat_slice_1
      where
        flat_slice_1 :: FlatSlice Int
    flat_slice_1 = Int -> [FlatDimIndex Int] -> FlatSlice Int
    forall d. d -> [FlatDimIndex d] -> FlatSlice d
    FlatSlice Int
    1 [Int -> Int -> FlatDimIndex Int
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex Int
    2 Int
    2]

    -- test_disjoint2 :: [TestTree]
    -- test_disjoint2 =
    --   let add_nw64 = (+)

    --       mul_nw64 = (*)

    --       sub64 = (-)

    --       vname s i = VName (nameFromString s) i
    --    in [ let gtid_8472 = TPrimExp $ LeafExp (vname "gtid" 8472) $ IntType Int64

    --             gtid_8473 = TPrimExp $ LeafExp (vname "gtid" 8473) $ IntType Int64

    --             gtid_8474 = TPrimExp $ LeafExp (vname "gtid" 8474) $ IntType Int64

    --             num_blocks_8284 = TPrimExp $ LeafExp (vname "num_blocks" 8284) $ IntType Int64

    --             nonnegs = freeIn [gtid_8472, gtid_8473, gtid_8474, num_blocks_8284]

    --             j_m_i_8287 :: TPrimExp Int64 VName
    --             j_m_i_8287 = num_blocks_8284 - 1

    --             lessthans :: [(VName, PrimExp VName)]
    --             lessthans =
    --               [ (head $ namesToList $ freeIn gtid_8472, untyped j_m_i_8287),
    --                 (head $ namesToList $ freeIn gtid_8473, untyped j_m_i_8287),
    --                 (head $ namesToList $ freeIn gtid_8474, untyped (16 :: TPrimExp Int64 VName))
    --               ]

    --             lm1 :: IxFunLMAD.LMAD (TPrimExp Int64 VName)
    --             lm1 =
    --               IxFunLMAD.LMAD
    --                 256
    --                 [ IxFunLMAD.LMADDim 256 0 (sub64 (num_blocks_8284) 1) 0 ,
    --                   IxFunLMAD.LMADDim 1 0 16 1 ,
    --                   IxFunLMAD.LMADDim 16 0 16 2
    --                 ]
    --             lm2 :: IxFunLMAD.LMAD (TPrimExp Int64 VName)
    --             lm2 =
    --               IxFunLMAD.LMAD
    --                 (add_nw64 (add_nw64 (add_nw64 (add_nw64 (mul_nw64 (256) (num_blocks_8284)) (256)) (mul_nw64 (gtid_8472) (mul_nw64 (256) (num_blocks_8284)))) (mul_nw64 (gtid_8473) (256))) (mul_nw64 (gtid_8474) (16)))
    --                 [IxFunLMAD.LMADDim 1 0 16 0 ]
    --          in testCase (pretty lm1 <> " and " <> pretty lm2) $ IxFunLMAD.disjoint2 lessthans nonnegs lm1 lm2 @? "Failed"
    --       ]

    -- test_lessThanish :: [TestTree]
    -- test_lessThanish =
    --   [testCase "0 < 1" $ IxFunLMAD.lessThanish mempty mempty 0 1 @? "Failed"]

    -- test_lessThanOrEqualish :: [TestTree]
    -- test_lessThanOrEqualish =
    --   [testCase "1 <= 1" $ IxFunLMAD.lessThanOrEqualish mempty mempty 1 1 @? "Failed"]

    _test_disjoint3 :: [TestTree]
    _test_disjoint3 :: [TestTree]
    _test_disjoint3 =
      let foo :: String -> Int -> VName
    foo String
    s = Name -> Int -> VName
    VName (String -> Name
    nameFromString String
    s)
          add_nw64 :: TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 = TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    (+)
          add64 :: TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 = TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    (+)
          mul_nw64 :: TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 = TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    (*)
          mul64 :: TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 = TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    (*)
          sub64 :: TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 = (-)
          sdiv64 :: TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sdiv64 = TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall e. IntegralExp e => e -> e -> e
    IE.div
          sub_nw64 :: TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub_nw64 = (-)
          disjointTester :: [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm1 LMAD (TPrimExp Int64 VName)
    lm2 =
            let nonnegs :: [PrimExp VName]
    nonnegs = (VName -> PrimExp VName) -> [VName] -> [PrimExp VName]
    forall a b. (a -> b) -> [a] -> [b]
    map (VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    `LeafExp` IntType -> PrimType
    IntType IntType
    Int64) ([VName] -> [PrimExp VName]) -> [VName] -> [PrimExp VName]
    forall a b. (a -> b) -> a -> b
    $ Names -> [VName]
    namesToList (Names -> [VName]) -> Names -> [VName]
    forall a b. (a -> b) -> a -> b
    $ LMAD (TPrimExp Int64 VName) -> Names
    forall a. FreeIn a => a -> Names
    freeIn LMAD (TPrimExp Int64 VName)
    lm1 Names -> Names -> Names
    forall a. Semigroup a => a -> a -> a
    <> LMAD (TPrimExp Int64 VName) -> Names
    forall a. FreeIn a => a -> Names
    freeIn LMAD (TPrimExp Int64 VName)
    lm2

                scmap :: Map VName (TypeBase shape u)
    scmap =
                  [(VName, TypeBase shape u)] -> Map VName (TypeBase shape u)
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList ([(VName, TypeBase shape u)] -> Map VName (TypeBase shape u))
    -> [(VName, TypeBase shape u)] -> Map VName (TypeBase shape u)
    forall a b. (a -> b) -> a -> b
    $
                    (VName -> (VName, TypeBase shape u))
    -> [VName] -> [(VName, TypeBase shape u)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\VName
    x -> (VName
    x, PrimType -> TypeBase shape u
    forall shape u. PrimType -> TypeBase shape u
    Prim (PrimType -> TypeBase shape u) -> PrimType -> TypeBase shape u
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64)) ([VName] -> [(VName, TypeBase shape u)])
    -> [VName] -> [(VName, TypeBase shape u)]
    forall a b. (a -> b) -> a -> b
    $
                      Names -> [VName]
    namesToList (Names -> [VName]) -> Names -> [VName]
    forall a b. (a -> b) -> a -> b
    $
                        LMAD (TPrimExp Int64 VName) -> Names
    forall a. FreeIn a => a -> Names
    freeIn LMAD (TPrimExp Int64 VName)
    lm1 Names -> Names -> Names
    forall a. Semigroup a => a -> a -> a
    <> LMAD (TPrimExp Int64 VName) -> Names
    forall a. FreeIn a => a -> Names
    freeIn LMAD (TPrimExp Int64 VName)
    lm2 Names -> Names -> Names
    forall a. Semigroup a => a -> a -> a
    <> [(VName, PrimExp VName)] -> Names
    forall a. FreeIn a => a -> Names
    freeIn [(VName, PrimExp VName)]
    lessthans Names -> Names -> Names
    forall a. Semigroup a => a -> a -> a
    <> [PrimExp VName] -> Names
    forall a. FreeIn a => a -> Names
    freeIn [PrimExp VName]
    asserts
             in Map VName Type
    -> [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> [PrimExp VName]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    IxFunLMAD.disjoint3 Map VName Type
    forall {shape} {u}. Map VName (TypeBase shape u)
    scmap [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans [PrimExp VName]
    nonnegs LMAD (TPrimExp Int64 VName)
    lm1 LMAD (TPrimExp Int64 VName)
    lm2
       in [ String -> Assertion -> TestTree
    testCase String
    "lm1 and lm2" (Assertion -> TestTree) -> Assertion -> TestTree
    forall a b. (a -> b) -> a -> b
    $
              let lessthans :: [(VName, PrimExp VName)]
    lessthans =
                    [ ( TPrimExp (ZonkAny 2) VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sdiv64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121
                      ),
                      (TPrimExp (ZonkAny 2) VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553, TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)
                    ]
                      [(TPrimExp (ZonkAny 2) VName, TPrimExp Int64 VName)]
    -> ([(TPrimExp (ZonkAny 2) VName, TPrimExp Int64 VName)]
        -> [(VName, PrimExp VName)])
    -> [(VName, PrimExp VName)]
    forall a b. a -> (a -> b) -> b
    & ((TPrimExp (ZonkAny 2) VName, TPrimExp Int64 VName)
     -> (VName, PrimExp VName))
    -> [(TPrimExp (ZonkAny 2) VName, TPrimExp Int64 VName)]
    -> [(VName, PrimExp VName)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(TPrimExp (ZonkAny 2) VName
    v, TPrimExp Int64 VName
    p) -> ([VName] -> VName
    forall a. HasCallStack => [a] -> a
    head ([VName] -> VName) -> [VName] -> VName
    forall a b. (a -> b) -> a -> b
    $ Names -> [VName]
    namesToList (Names -> [VName]) -> Names -> [VName]
    forall a b. (a -> b) -> a -> b
    $ TPrimExp (ZonkAny 2) VName -> Names
    forall a. FreeIn a => a -> Names
    freeIn TPrimExp (ZonkAny 2) VName
    v, TPrimExp Int64 VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped TPrimExp Int64 VName
    p))

                  asserts :: [PrimExp VName]
    asserts =
                    [ TPrimExp Bool VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped ((TPrimExp Int64 VName
    2 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 :: TPrimExp Int64 VName) TPrimExp Int64 VName -> TPrimExp Int64 VName -> TPrimExp Bool VName
    forall {k} v (t :: k).
    Eq v =>
    TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
    .<. TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab :: TPrimExp Bool VName),
                      TPrimExp Bool VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped ((TPrimExp Int64 VName
    3 :: TPrimExp Int64 VName) TPrimExp Int64 VName -> TPrimExp Int64 VName -> TPrimExp Bool VName
    forall {k} v (t :: k).
    Eq v =>
    TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
    .<. TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab :: TPrimExp Bool VName)
                    ]

                  block_size_12121 :: TPrimExp t VName
    block_size_12121 = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "block_size" Int
    12121) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64
                  i_12214 :: TPrimExp t VName
    i_12214 = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "i" Int
    12214) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64
                  n_blab :: TPrimExp t VName
    n_blab = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "n" Int
    1337) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64
                  gtid_12553 :: TPrimExp t VName
    gtid_12553 = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "gtid" Int
    12553) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64

                  lm1 :: LMAD (TPrimExp Int64 VName)
    lm1 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553 TPrimExp Int64 VName
    1) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)))
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553) TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    1)
                      ]

                  lm2 :: LMAD (TPrimExp Int64 VName)
    lm2 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)
                      ]

                  lm_w :: LMAD (TPrimExp Int64 VName)
    lm_w =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)))
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121
                      ]

                  lm_blocks :: LMAD (TPrimExp Int64 VName)
    lm_blocks =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    1)
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)) (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121
                      ]

                  lm_lower_per :: LMAD (TPrimExp Int64 VName)
    lm_lower_per =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)) (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    1)
                      ]

                  res1 :: Bool
    res1 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm1 LMAD (TPrimExp Int64 VName)
    lm_w
                  res2 :: Bool
    res2 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm2 LMAD (TPrimExp Int64 VName)
    lm_w
                  res3 :: Bool
    res3 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm_lower_per LMAD (TPrimExp Int64 VName)
    lm_blocks
               in Bool
    res1 Bool -> Bool -> Bool
    && Bool
    res2 Bool -> Bool -> Bool
    && Bool
    res3 Bool -> String -> Assertion
    forall t.
    (AssertionPredicable t, HasCallStack) =>
    t -> String -> Assertion
    @? String
    "Failed",
            String -> Assertion -> TestTree
    testCase String
    "nw second half" (Assertion -> TestTree) -> Assertion -> TestTree
    forall a b. (a -> b) -> a -> b
    $ do
              let lessthans :: [(VName, PrimExp VName)]
    lessthans =
                    [ ( TPrimExp (ZonkAny 4) VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sdiv64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121
                      ),
                      (TPrimExp (ZonkAny 4) VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553, TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)
                    ]
                      [(TPrimExp (ZonkAny 4) VName, TPrimExp Int64 VName)]
    -> ([(TPrimExp (ZonkAny 4) VName, TPrimExp Int64 VName)]
        -> [(VName, PrimExp VName)])
    -> [(VName, PrimExp VName)]
    forall a b. a -> (a -> b) -> b
    & ((TPrimExp (ZonkAny 4) VName, TPrimExp Int64 VName)
     -> (VName, PrimExp VName))
    -> [(TPrimExp (ZonkAny 4) VName, TPrimExp Int64 VName)]
    -> [(VName, PrimExp VName)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(TPrimExp (ZonkAny 4) VName
    v, TPrimExp Int64 VName
    p) -> ([VName] -> VName
    forall a. HasCallStack => [a] -> a
    head ([VName] -> VName) -> [VName] -> VName
    forall a b. (a -> b) -> a -> b
    $ Names -> [VName]
    namesToList (Names -> [VName]) -> Names -> [VName]
    forall a b. (a -> b) -> a -> b
    $ TPrimExp (ZonkAny 4) VName -> Names
    forall a. FreeIn a => a -> Names
    freeIn TPrimExp (ZonkAny 4) VName
    v, TPrimExp Int64 VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped TPrimExp Int64 VName
    p))

                  asserts :: [PrimExp VName]
    asserts =
                    [ TPrimExp Bool VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped ((TPrimExp Int64 VName
    2 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 :: TPrimExp Int64 VName) TPrimExp Int64 VName -> TPrimExp Int64 VName -> TPrimExp Bool VName
    forall {k} v (t :: k).
    Eq v =>
    TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
    .<. TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab :: TPrimExp Bool VName),
                      TPrimExp Bool VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped ((TPrimExp Int64 VName
    3 :: TPrimExp Int64 VName) TPrimExp Int64 VName -> TPrimExp Int64 VName -> TPrimExp Bool VName
    forall {k} v (t :: k).
    Eq v =>
    TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
    .<. TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab :: TPrimExp Bool VName)
                    ]

                  block_size_12121 :: TPrimExp t VName
    block_size_12121 = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "block_size" Int
    12121) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64
                  i_12214 :: TPrimExp t VName
    i_12214 = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "i" Int
    12214) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64
                  n_blab :: TPrimExp t VName
    n_blab = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "n" Int
    1337) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64
                  gtid_12553 :: TPrimExp t VName
    gtid_12553 = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "gtid" Int
    12553) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64

                  lm1 :: LMAD (TPrimExp Int64 VName)
    lm1 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)))) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121) TPrimExp Int64 VName
    1)) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553 TPrimExp Int64 VName
    1) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)))
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sdiv64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214) TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553) TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121
                      ]

                  lm2 :: LMAD (TPrimExp Int64 VName)
    lm2 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)))) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121) TPrimExp Int64 VName
    1) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553 TPrimExp Int64 VName
    1) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)))
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sdiv64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214) TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553) TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)
                      ]

                  lm3 :: LMAD (TPrimExp Int64 VName)
    lm3 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)))) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121) TPrimExp Int64 VName
    1))
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121
                      ]

                  lm4 :: LMAD (TPrimExp Int64 VName)
    lm4 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)))) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121) TPrimExp Int64 VName
    1)
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim
                          (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 (-TPrimExp Int64 VName
    1) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121))
                          TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim
                          TPrimExp Int64 VName
    1
                          (TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)
                      ]

                  lm_w :: LMAD (TPrimExp Int64 VName)
    lm_w =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add_nw64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    2 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    add64 TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    i_12214)))) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121) (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul_nw64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    gtid_12553 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    sub64 (TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    mul64 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab) TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121)))
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    n_blab TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    block_size_12121
                      ]

                  res1 :: Bool
    res1 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm1 LMAD (TPrimExp Int64 VName)
    lm_w
                  res2 :: Bool
    res2 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm2 LMAD (TPrimExp Int64 VName)
    lm_w
                  res3 :: Bool
    res3 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm3 LMAD (TPrimExp Int64 VName)
    lm_w
                  res4 :: Bool
    res4 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm4 LMAD (TPrimExp Int64 VName)
    lm_w
               in Bool
    res1 Bool -> Bool -> Bool
    && Bool
    res2 Bool -> Bool -> Bool
    && Bool
    res3 Bool -> Bool -> Bool
    && Bool
    res4 Bool -> String -> Assertion
    forall t.
    (AssertionPredicable t, HasCallStack) =>
    t -> String -> Assertion
    @? String
    "Failed " String -> String -> String
    forall a. Semigroup a => a -> a -> a
    <> [Bool] -> String
    forall a. Show a => a -> String
    show [Bool
    res1, Bool
    res2, Bool
    res3, Bool
    res4],
            String -> Assertion -> TestTree
    testCase String
    "lud long" (Assertion -> TestTree) -> Assertion -> TestTree
    forall a b. (a -> b) -> a -> b
    $
              let lessthans :: [(VName, PrimExp VName)]
    lessthans =
                    [ (TPrimExp (ZonkAny 6) VName -> VName)
    -> (TPrimExp Int64 VName -> PrimExp VName)
    -> (TPrimExp (ZonkAny 6) VName, TPrimExp Int64 VName)
    -> (VName, PrimExp VName)
    forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
    forall (p :: * -> * -> *) a b c d.
    Bifunctor p =>
    (a -> b) -> (c -> d) -> p a c -> p b d
    bimap
                        ([VName] -> VName
    forall a. HasCallStack => [a] -> a
    head ([VName] -> VName)
    -> (TPrimExp (ZonkAny 6) VName -> [VName])
    -> TPrimExp (ZonkAny 6) VName
    -> VName
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Names -> [VName]
    namesToList (Names -> [VName])
    -> (TPrimExp (ZonkAny 6) VName -> Names)
    -> TPrimExp (ZonkAny 6) VName
    -> [VName]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TPrimExp (ZonkAny 6) VName -> Names
    forall a. FreeIn a => a -> Names
    freeIn)
                        TPrimExp Int64 VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped
                        (TPrimExp (ZonkAny 6) VName
    forall {k} {t :: k}. TPrimExp t VName
    step, TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    - TPrimExp Int64 VName
    1 :: TPrimExp Int64 VName)
                    ]

                  step :: TPrimExp t VName
    step = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "step" Int
    1337) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64

                  num_blocks :: TPrimExp t VName
    num_blocks = PrimExp VName -> TPrimExp t VName
    forall {k} (t :: k) v. PrimExp v -> TPrimExp t v
    TPrimExp (PrimExp VName -> TPrimExp t VName)
    -> PrimExp VName -> TPrimExp t VName
    forall a b. (a -> b) -> a -> b
    $ VName -> PrimType -> PrimExp VName
    forall v. v -> PrimType -> PrimExp v
    LeafExp (String -> Int -> VName
    foo String
    "n" Int
    1338) (PrimType -> PrimExp VName) -> PrimType -> PrimExp VName
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    Int64

                  lm1 :: LMAD (TPrimExp Int64 VName)
    lm1 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * (TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step) TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step)
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks) (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    - TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    - TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    32 TPrimExp Int64 VName
    32,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    32
                      ]

                  lm_w1 :: LMAD (TPrimExp Int64 VName)
    lm_w1 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      (TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step)
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    32 TPrimExp Int64 VName
    32,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    32
                      ]

                  lm_w2 :: LMAD (TPrimExp Int64 VName)
    lm_w2 =
                    TPrimExp Int64 VName
    -> [LMADDim (TPrimExp Int64 VName)] -> LMAD (TPrimExp Int64 VName)
    forall num. num -> [LMADDim num] -> LMAD num
    IxFunLMAD.LMAD
                      ((TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step) TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + (TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    + TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step) TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    1024)
                      [ TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim (TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    * TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks) (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    - TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    - TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1024 (TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    - TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    step TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> TPrimExp Int64 VName
    forall a. Num a => a -> a -> a
    - TPrimExp Int64 VName
    1),
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1024 TPrimExp Int64 VName
    1,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    32 TPrimExp Int64 VName
    1,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    128 TPrimExp Int64 VName
    8,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    4 TPrimExp Int64 VName
    8,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    32 TPrimExp Int64 VName
    4,
                        TPrimExp Int64 VName
    -> TPrimExp Int64 VName -> LMADDim (TPrimExp Int64 VName)
    forall num. num -> num -> LMADDim num
    IxFunLMAD.LMADDim TPrimExp Int64 VName
    1 TPrimExp Int64 VName
    4
                      ]

                  asserts :: [PrimExp VName]
    asserts =
                    [ TPrimExp Bool VName -> PrimExp VName
    forall {k} (t :: k) v. TPrimExp t v -> PrimExp v
    untyped ((TPrimExp Int64 VName
    1 :: TPrimExp Int64 VName) TPrimExp Int64 VName -> TPrimExp Int64 VName -> TPrimExp Bool VName
    forall {k} v (t :: k).
    Eq v =>
    TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
    .<. TPrimExp Int64 VName
    forall {k} {t :: k}. TPrimExp t VName
    num_blocks :: TPrimExp Bool VName)
                    ]

                  res1 :: Bool
    res1 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm1 LMAD (TPrimExp Int64 VName)
    lm_w1
                  res2 :: Bool
    res2 = [PrimExp VName]
    -> [(VName, PrimExp VName)]
    -> LMAD (TPrimExp Int64 VName)
    -> LMAD (TPrimExp Int64 VName)
    -> Bool
    disjointTester [PrimExp VName]
    asserts [(VName, PrimExp VName)]
    lessthans LMAD (TPrimExp Int64 VName)
    lm1 LMAD (TPrimExp Int64 VName)
    lm_w2
               in Bool
    res1 Bool -> Bool -> Bool
    && Bool
    res2 Bool -> String -> Assertion
    forall t.
    (AssertionPredicable t, HasCallStack) =>
    t -> String -> Assertion
    @? String
    "Failed"
          ]