Commit e2777978 authored by pcapriotti's avatar pcapriotti
Browse files

Add test case for #5900

parent 1c595c00
import Data.Bits
import Data.Word
import Debug.Trace
fl :: Word64 -> Word64 -> Word64
fl fin sk =
let (x1, x2) = w64tow32 fin in
let (k1, k2) = w64tow32 sk in
let y2 = x2 `xor` ((x1 .&. k1) `rotateL` 1) in
let y1 = x1 `xor` (y2 .|. k2) in
trace (show fin ++ " " ++ show sk ++ " -> " ++ show (w32tow64 (y1, y2))) $ w32tow64 (y1, y2)
w64tow32 :: Word64 -> (Word32, Word32)
w64tow32 w = (fromIntegral (w `shiftR` 32), fromIntegral (w .&. 0xffffffff))
w32tow64 :: (Word32, Word32) -> Word64
w32tow64 (x1, x2) = ((fromIntegral x1) `shiftL` 32) .|. (fromIntegral x2)
a, b :: Word64
a = 1238988323332265734
b = 11185553392205053542
main :: IO ()
main =
putStrLn $ "fl " ++ show a ++ " " ++ show b ++ " -> " ++ show (fl a b)
1238988323332265734 11185553392205053542 -> 18360184157246690566
fl 1238988323332265734 11185553392205053542 -> 18360184157246690566
......@@ -92,4 +92,4 @@ test('5785', normal, compile_and_run, [''])
test('setByteArray', normal, compile_and_run, [''])
test('6146', normal, compile_and_run, [''])
test('T5900', normal, compile_and_run, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment