Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created February 7, 2023 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpickering/de8663e906f2ec4c6f4071194246b77d to your computer and use it in GitHub Desktop.
Save mpickering/de8663e906f2ec4c6f4071194246b77d to your computer and use it in GitHub Desktop.
-- RHS size: {terms: 111, types: 79, coercions: 0, joins: 1/4}
scanr [InlPrag=INLINE (sat-args=2)]
:: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString
[GblId,
Arity=3,
Str=<LC(S,C(1,L))><1L><1!P(L,L,L)>,
Unf=Unf{Src=StableUser, TopLvl=True,
Value=True, ConLike=True, WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False)
Tmpl= \ (f_advQ [Occ=OnceL1!] :: Word8 -> Word8 -> Word8)
(v_advR [Occ=Once1!] :: Word8)
(ds_dfFm [Occ=Once1!] :: ByteString) ->
case ds_dfFm of
{ BS bx_dfTL [Occ=OnceL1] bx1_dfTM [Occ=OnceL1] bx2_dfTN ->
GHC.Magic.runRW#
@GHC.Types.LiftedRep
@ByteString
(\ (s_ib4I [Occ=Once1, OS=OneShot]
:: GHC.Prim.State# GHC.Prim.RealWorld) ->
let {
x_ib4K :: GHC.Prim.Int#
[LclId]
x_ib4K = GHC.Prim.+# bx2_dfTN 1# } in
case GHC.Prim.<# x_ib4K 0# of {
__DEFAULT ->
case GHC.Prim.newPinnedByteArray# @GHC.Prim.RealWorld x_ib4K s_ib4I
of
{ (# ipv_ib4P [Occ=Once1], ipv1_ib4Q #) ->
let {
ipv2_ib4O :: GHC.Prim.Addr#
[LclId]
ipv2_ib4O
= GHC.Prim.mutableByteArrayContents#
@GHC.Prim.RealWorld ipv1_ib4Q } in
let {
ipv3_ib4S :: GHC.ForeignPtr.ForeignPtrContents
[LclId, Unf=OtherCon []]
ipv3_ib4S = GHC.ForeignPtr.PlainPtr ipv1_ib4Q } in
case v_advR of wild2_afXO [Occ=Once1] { W8# x1_afXP [Occ=Once1] ->
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_ib4O bx2_dfTN)
0#
x1_afXP
ipv_ib4P
of s2_afXR [Occ=Once1]
{ __DEFAULT ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_ib4S
s2_afXR
of s'_ifXC [Occ=Once1]
{ __DEFAULT ->
letrec {
scanr__aeBD [Occ=LoopBreaker] :: Word8 -> Int -> IO ()
[LclId, Arity=3, Unf=OtherCon []]
scanr__aeBD
= \ (z_advZ [Occ=Once1!] :: Word8) (n_adw0 [Occ=Once1!] :: Int) ->
case z_advZ of z1_X5 [Occ=Once1] { W8# _ [Occ=Dead] ->
case n_adw0 of n1_X6 [Occ=Once1] { GHC.Types.I# ipv5_sghu ->
case GHC.Classes.ltInt n1_X6 (GHC.Types.I# 0#) of {
False ->
(\ (s1_a7EQ [Occ=Once1]
:: GHC.Prim.State# GHC.Prim.RealWorld) ->
case GHC.Prim.readWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# bx_dfTL ipv5_sghu)
0#
s1_a7EQ
of
{ (# ipv6_acPv [Occ=Once1], ipv7_acPw [Occ=Once1] #) ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
bx1_dfTM
ipv6_acPv
of s'1_ifXe [Occ=Once1]
{ __DEFAULT ->
case f_advQ (GHC.Word.W8# ipv7_acPw) z1_X5
of wild3_X9 [Occ=Once1]
{ W8# x2_Xa [Occ=Once1] ->
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_ib4O ipv5_sghu)
0#
x2_Xa
s'1_ifXe
of s3_Xb [Occ=Once1]
{ __DEFAULT ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_ib4S
s3_Xb
of s'2_Xc [Occ=Once1]
{ __DEFAULT ->
((scanr__aeBD
wild3_X9 (GHC.Types.I# (GHC.Prim.-# ipv5_sghu 1#)))
`cast` (GHC.Types.N:IO[0] <()>_R
:: IO ()
~R# (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld,
() #))))
s'2_Xc
}
}
}
}
})
`cast` (Sym (GHC.Types.N:IO[0] <()>_R)
:: (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld, () #))
~R# IO ());
True ->
(\ (s1_a7Fc [Occ=Once1]
:: GHC.Prim.State# GHC.Prim.RealWorld) ->
(# s1_a7Fc, GHC.Tuple.Prim.() #))
`cast` (Sym (GHC.Types.N:IO[0] <()>_R)
:: (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld, () #))
~R# IO ())
}
}
}; } in
case ((scanr__aeBD
wild2_afXO (GHC.Types.I# (GHC.Prim.-# bx2_dfTN 1#)))
`cast` (GHC.Types.N:IO[0] <()>_R
:: IO ()
~R# (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld, () #))))
s'_ifXC
of
{ (# _ [Occ=Dead], _ [Occ=Dead] #) ->
GHC.Magic.lazy
@ByteString
(Data.ByteString.Internal.Type.BS ipv2_ib4O ipv3_ib4S x_ib4K)
}
}
}
}
};
1# -> case GHC.ForeignPtr.mallocPlainForeignPtrBytes2 of { }
})
}}]
scanr
= \ (f_advQ :: Word8 -> Word8 -> Word8)
(v_advR :: Word8)
(ds_dfFm :: ByteString) ->
case ds_dfFm of { BS bx_dfTL bx1_dfTM bx2_dfTN ->
GHC.Magic.runRW#
@GHC.Types.LiftedRep
@ByteString
(\ (s_ib4I [OS=OneShot] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
let {
x_sgCF :: GHC.Prim.Int#
[LclId]
x_sgCF = GHC.Prim.+# bx2_dfTN 1# } in
case GHC.Prim.<# x_sgCF 0# of {
__DEFAULT ->
case GHC.Prim.newPinnedByteArray# @GHC.Prim.RealWorld x_sgCF s_ib4I
of
{ (# ipv_ib4P, ipv1_ib4Q #) ->
case v_advR of wild2_afXO { W8# x1_afXP ->
let {
ipv2_sgCH :: GHC.Prim.Addr#
[LclId]
ipv2_sgCH
= GHC.Prim.mutableByteArrayContents#
@GHC.Prim.RealWorld ipv1_ib4Q } in
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_sgCH bx2_dfTN)
0#
x1_afXP
ipv_ib4P
of s2_afXR
{ __DEFAULT ->
let {
ipv3_sgCJ :: GHC.ForeignPtr.ForeignPtrContents
[LclId, Unf=OtherCon []]
ipv3_sgCJ = GHC.ForeignPtr.PlainPtr ipv1_ib4Q } in
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_sgCJ
s2_afXR
of s'_ifXC
{ __DEFAULT ->
joinrec {
$wscanr__shhC [InlPrag=[2], Occ=LoopBreaker, Dmd=SC(S,C(1,C(1,L)))]
:: Word8
-> GHC.Prim.Int#
-> GHC.Prim.State# GHC.Prim.RealWorld
-> ByteString
[LclId[JoinId(3)(Just [!])],
Arity=3,
Str=<1L><L><L>,
Unf=OtherCon []]
$wscanr__shhC (z_shhv :: Word8)
(ww_shhy :: GHC.Prim.Int#)
(eta_shhA [OS=OneShot] :: GHC.Prim.State# GHC.Prim.RealWorld)
= case z_shhv of z1_X5 { W8# ipv4_sghn ->
case GHC.Prim.<# ww_shhy 0# of {
__DEFAULT ->
case GHC.Prim.readWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# bx_dfTL ww_shhy)
0#
eta_shhA
of
{ (# ipv5_acPv, ipv6_acPw #) ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
bx1_dfTM
ipv5_acPv
of s'1_ifXe
{ __DEFAULT ->
case f_advQ (GHC.Word.W8# ipv6_acPw) z1_X5 of wild1_X9
{ W8# x2_Xa ->
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_sgCH ww_shhy)
0#
x2_Xa
s'1_ifXe
of s1_Xb
{ __DEFAULT ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_sgCJ
s1_Xb
of s'2_Xc
{ __DEFAULT ->
jump $wscanr__shhC wild1_X9 (GHC.Prim.-# ww_shhy 1#) s'2_Xc
}
}
}
}
};
1# ->
GHC.Magic.lazy
@ByteString
(Data.ByteString.Internal.Type.BS ipv2_sgCH ipv3_sgCJ x_sgCF)
}
}; } in
jump $wscanr__shhC wild2_afXO (GHC.Prim.-# bx2_dfTN 1#) s'_ifXC
}
}
}
};
1# ->
case GHC.ForeignPtr.mallocPlainForeignPtrBytes2 of wild1_00 { }
})
}
-- RHS size: {terms: 113, types: 80, coercions: 0, joins: 2/5}
scanr [InlPrag=INLINE (sat-args=2)]
:: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString
[GblId,
Arity=3,
Str=<LC(S,C(1,L))><1L><1!P(L,L,L)>,
Unf=Unf{Src=StableUser, TopLvl=True,
Value=True, ConLike=True, WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False)
Tmpl= \ (f_adxn [Occ=OnceL1!] :: Word8 -> Word8 -> Word8)
(v_adxo [Occ=Once1!] :: Word8)
(ds_dfGT [Occ=Once1!] :: ByteString) ->
case ds_dfGT of
{ BS bx_dfVi [Occ=OnceL1] bx1_dfVj [Occ=OnceL1] bx2_dfVk ->
GHC.Magic.runRW#
@GHC.Types.LiftedRep
@ByteString
(\ (s_ib67 [Occ=Once1, OS=OneShot]
:: GHC.Prim.State# GHC.Prim.RealWorld) ->
let {
x_ib69 :: GHC.Prim.Int#
[LclId]
x_ib69 = GHC.Prim.+# bx2_dfVk 1# } in
case GHC.Prim.<# x_ib69 0# of {
__DEFAULT ->
case GHC.Prim.newPinnedByteArray# @GHC.Prim.RealWorld x_ib69 s_ib67
of
{ (# ipv_ib6e [Occ=Once1], ipv1_ib6f #) ->
let {
ipv2_ib6d :: GHC.Prim.Addr#
[LclId]
ipv2_ib6d
= GHC.Prim.mutableByteArrayContents#
@GHC.Prim.RealWorld ipv1_ib6f } in
let {
ipv3_ib6h :: GHC.ForeignPtr.ForeignPtrContents
[LclId, Unf=OtherCon []]
ipv3_ib6h = GHC.ForeignPtr.PlainPtr ipv1_ib6f } in
case v_adxo of wild2_afZl [Occ=Once1] { W8# x1_afZm [Occ=Once1] ->
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_ib6d bx2_dfVk)
0#
x1_afZm
ipv_ib6e
of s2_afZo [Occ=Once1]
{ __DEFAULT ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_ib6h
s2_afZo
of s'_ifZ9 [Occ=Once1]
{ __DEFAULT ->
letrec {
scanr__aeDa [Occ=LoopBreaker] :: Word8 -> Int -> IO ()
[LclId, Arity=3, Unf=OtherCon []]
scanr__aeDa
= \ (z_adxw [Occ=Once1!] :: Word8) (n_adxx [Occ=Once1!] :: Int) ->
case z_adxw of z1_X5 [Occ=Once1] { W8# _ [Occ=Dead] ->
case n_adxx of n1_X6 [Occ=Once1] { GHC.Types.I# ipv5_sgj1 ->
case GHC.Classes.ltInt n1_X6 (GHC.Types.I# 0#) of {
False ->
(\ (s1_a7F3 [Occ=Once1]
:: GHC.Prim.State# GHC.Prim.RealWorld) ->
case GHC.Prim.readWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# bx_dfVi ipv5_sgj1)
0#
s1_a7F3
of
{ (# ipv6_acR2 [Occ=Once1], ipv7_acR3 [Occ=Once1] #) ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
bx1_dfVj
ipv6_acR2
of s'1_ifYL [Occ=Once1]
{ __DEFAULT ->
case f_adxn (GHC.Word.W8# ipv7_acR3) z1_X5
of wild3_X9 [Occ=Once1]
{ W8# x2_Xa [Occ=Once1] ->
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_ib6d ipv5_sgj1)
0#
x2_Xa
s'1_ifYL
of s3_Xb [Occ=Once1]
{ __DEFAULT ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_ib6h
s3_Xb
of s'2_Xc [Occ=Once1]
{ __DEFAULT ->
((scanr__aeDa
wild3_X9 (GHC.Types.I# (GHC.Prim.-# ipv5_sgj1 1#)))
`cast` (GHC.Types.N:IO[0] <()>_R
:: IO ()
~R# (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld,
() #))))
s'2_Xc
}
}
}
}
})
`cast` (Sym (GHC.Types.N:IO[0] <()>_R)
:: (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld, () #))
~R# IO ());
True ->
(\ (s1_a7Fp [Occ=Once1]
:: GHC.Prim.State# GHC.Prim.RealWorld) ->
(# s1_a7Fp, GHC.Tuple.Prim.() #))
`cast` (Sym (GHC.Types.N:IO[0] <()>_R)
:: (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld, () #))
~R# IO ())
}
}
}; } in
case ((scanr__aeDa
wild2_afZl (GHC.Types.I# (GHC.Prim.-# bx2_dfVk 1#)))
`cast` (GHC.Types.N:IO[0] <()>_R
:: IO ()
~R# (GHC.Prim.State# GHC.Prim.RealWorld
-> (# GHC.Prim.State# GHC.Prim.RealWorld, () #))))
s'_ifZ9
of
{ (# _ [Occ=Dead], _ [Occ=Dead] #) ->
GHC.Magic.lazy
@ByteString
(Data.ByteString.Internal.Type.BS ipv2_ib6d ipv3_ib6h x_ib69)
}
}
}
}
};
1# -> case GHC.ForeignPtr.mallocPlainForeignPtrBytes2 of { }
})
}}]
scanr
= \ (f_adxn :: Word8 -> Word8 -> Word8)
(v_adxo :: Word8)
(ds_dfGT :: ByteString) ->
case ds_dfGT of { BS bx_dfVi bx1_dfVj bx2_dfVk ->
GHC.Magic.runRW#
@GHC.Types.LiftedRep
@ByteString
(\ (s_ib67 [OS=OneShot] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
let {
x_sgEc :: GHC.Prim.Int#
[LclId]
x_sgEc = GHC.Prim.+# bx2_dfVk 1# } in
case GHC.Prim.<# x_sgEc 0# of {
__DEFAULT ->
case GHC.Prim.newPinnedByteArray# @GHC.Prim.RealWorld x_sgEc s_ib67
of
{ (# ipv_ib6e, ipv1_ib6f #) ->
case v_adxo of wild2_afZl { W8# x1_afZm ->
let {
ipv2_sgEe :: GHC.Prim.Addr#
[LclId]
ipv2_sgEe
= GHC.Prim.mutableByteArrayContents#
@GHC.Prim.RealWorld ipv1_ib6f } in
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_sgEe bx2_dfVk)
0#
x1_afZm
ipv_ib6e
of s2_afZo
{ __DEFAULT ->
let {
ipv3_sgEg :: GHC.ForeignPtr.ForeignPtrContents
[LclId, Unf=OtherCon []]
ipv3_sgEg = GHC.ForeignPtr.PlainPtr ipv1_ib6f } in
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_sgEg
s2_afZo
of s'_ifZ9
{ __DEFAULT ->
join {
$w$j_shjx [InlPrag=[2], Dmd=SL] :: ByteString
[LclId[JoinId(0)(Nothing)]]
$w$j_shjx
= GHC.Magic.lazy
@ByteString
(Data.ByteString.Internal.Type.BS ipv2_sgEe ipv3_sgEg x_sgEc) } in
joinrec {
$wscanr__shjG [InlPrag=[2], Occ=LoopBreaker, Dmd=SC(S,C(1,C(1,L)))]
:: Word8
-> GHC.Prim.Int#
-> GHC.Prim.State# GHC.Prim.RealWorld
-> ByteString
[LclId[JoinId(3)(Just [!])],
Arity=3,
Str=<1L><L><L>,
Unf=OtherCon []]
$wscanr__shjG (z_shjz :: Word8)
(ww_shjC :: GHC.Prim.Int#)
(eta_shjE [OS=OneShot] :: GHC.Prim.State# GHC.Prim.RealWorld)
= case z_shjz of z1_X5 { W8# ipv4_sgiU ->
case GHC.Prim.<# ww_shjC 0# of {
__DEFAULT ->
case GHC.Prim.readWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# bx_dfVi ww_shjC)
0#
eta_shjE
of
{ (# ipv5_acR2, ipv6_acR3 #) ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
bx1_dfVj
ipv5_acR2
of s'1_ifYL
{ __DEFAULT ->
case f_adxn (GHC.Word.W8# ipv6_acR3) z1_X5 of wild1_X9
{ W8# x2_Xa ->
case GHC.Prim.writeWord8OffAddr#
@GHC.Prim.RealWorld
(GHC.Prim.plusAddr# ipv2_sgEe ww_shjC)
0#
x2_Xa
s'1_ifYL
of s1_Xb
{ __DEFAULT ->
case GHC.Prim.touch#
@GHC.Types.Lifted
@GHC.ForeignPtr.ForeignPtrContents
ipv3_sgEg
s1_Xb
of s'2_Xc
{ __DEFAULT ->
jump $wscanr__shjG wild1_X9 (GHC.Prim.-# ww_shjC 1#) s'2_Xc
}
}
}
}
};
1# -> jump $w$j_shjx
}
}; } in
jump $wscanr__shjG wild2_afZl (GHC.Prim.-# bx2_dfVk 1#) s'_ifZ9
}
}
}
};
1# ->
case GHC.ForeignPtr.mallocPlainForeignPtrBytes2 of wild1_00 { }
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment