xref: /freebsd/crypto/openssl/crypto/aes/asm/aes-ppc.pl (revision 7bded2db17780f5b59bc532689d8a9541f06901e)
11f13597dSJung-uk Kim#!/usr/bin/env perl
21f13597dSJung-uk Kim
31f13597dSJung-uk Kim# ====================================================================
41f13597dSJung-uk Kim# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
51f13597dSJung-uk Kim# project. The module is, however, dual licensed under OpenSSL and
61f13597dSJung-uk Kim# CRYPTOGAMS licenses depending on where you obtain it. For further
71f13597dSJung-uk Kim# details see http://www.openssl.org/~appro/cryptogams/.
81f13597dSJung-uk Kim# ====================================================================
91f13597dSJung-uk Kim
101f13597dSJung-uk Kim# Needs more work: key setup, CBC routine...
111f13597dSJung-uk Kim#
121f13597dSJung-uk Kim# ppc_AES_[en|de]crypt perform at 18 cycles per byte processed with
131f13597dSJung-uk Kim# 128-bit key, which is ~40% better than 64-bit code generated by gcc
141f13597dSJung-uk Kim# 4.0. But these are not the ones currently used! Their "compact"
151f13597dSJung-uk Kim# counterparts are, for security reason. ppc_AES_encrypt_compact runs
161f13597dSJung-uk Kim# at 1/2 of ppc_AES_encrypt speed, while ppc_AES_decrypt_compact -
171f13597dSJung-uk Kim# at 1/3 of ppc_AES_decrypt.
181f13597dSJung-uk Kim
191f13597dSJung-uk Kim# February 2010
201f13597dSJung-uk Kim#
211f13597dSJung-uk Kim# Rescheduling instructions to favour Power6 pipeline gave 10%
221f13597dSJung-uk Kim# performance improvement on the platfrom in question (and marginal
231f13597dSJung-uk Kim# improvement even on others). It should be noted that Power6 fails
241f13597dSJung-uk Kim# to process byte in 18 cycles, only in 23, because it fails to issue
251f13597dSJung-uk Kim# 4 load instructions in two cycles, only in 3. As result non-compact
261f13597dSJung-uk Kim# block subroutines are 25% slower than one would expect. Compact
271f13597dSJung-uk Kim# functions scale better, because they have pure computational part,
281f13597dSJung-uk Kim# which scales perfectly with clock frequency. To be specific
291f13597dSJung-uk Kim# ppc_AES_encrypt_compact operates at 42 cycles per byte, while
301f13597dSJung-uk Kim# ppc_AES_decrypt_compact - at 55 (in 64-bit build).
311f13597dSJung-uk Kim
321f13597dSJung-uk Kim$flavour = shift;
331f13597dSJung-uk Kim
341f13597dSJung-uk Kimif ($flavour =~ /64/) {
351f13597dSJung-uk Kim	$SIZE_T	=8;
361f13597dSJung-uk Kim	$LRSAVE	=2*$SIZE_T;
371f13597dSJung-uk Kim	$STU	="stdu";
381f13597dSJung-uk Kim	$POP	="ld";
391f13597dSJung-uk Kim	$PUSH	="std";
401f13597dSJung-uk Kim} elsif ($flavour =~ /32/) {
411f13597dSJung-uk Kim	$SIZE_T	=4;
421f13597dSJung-uk Kim	$LRSAVE	=$SIZE_T;
431f13597dSJung-uk Kim	$STU	="stwu";
441f13597dSJung-uk Kim	$POP	="lwz";
451f13597dSJung-uk Kim	$PUSH	="stw";
461f13597dSJung-uk Kim} else { die "nonsense $flavour"; }
471f13597dSJung-uk Kim
48*7bded2dbSJung-uk Kim$LITTLE_ENDIAN = ($flavour=~/le$/) ? $SIZE_T : 0;
49*7bded2dbSJung-uk Kim
501f13597dSJung-uk Kim$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
511f13597dSJung-uk Kim( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
521f13597dSJung-uk Kim( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
531f13597dSJung-uk Kimdie "can't locate ppc-xlate.pl";
541f13597dSJung-uk Kim
551f13597dSJung-uk Kimopen STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
561f13597dSJung-uk Kim
571f13597dSJung-uk Kim$FRAME=32*$SIZE_T;
581f13597dSJung-uk Kim
591f13597dSJung-uk Kimsub _data_word()
601f13597dSJung-uk Kim{ my $i;
611f13597dSJung-uk Kim    while(defined($i=shift)) { $code.=sprintf"\t.long\t0x%08x,0x%08x\n",$i,$i; }
621f13597dSJung-uk Kim}
631f13597dSJung-uk Kim
641f13597dSJung-uk Kim$sp="r1";
651f13597dSJung-uk Kim$toc="r2";
661f13597dSJung-uk Kim$inp="r3";
671f13597dSJung-uk Kim$out="r4";
681f13597dSJung-uk Kim$key="r5";
691f13597dSJung-uk Kim
701f13597dSJung-uk Kim$Tbl0="r3";
711f13597dSJung-uk Kim$Tbl1="r6";
721f13597dSJung-uk Kim$Tbl2="r7";
73*7bded2dbSJung-uk Kim$Tbl3=$out;	# stay away from "r2"; $out is offloaded to stack
741f13597dSJung-uk Kim
751f13597dSJung-uk Kim$s0="r8";
761f13597dSJung-uk Kim$s1="r9";
771f13597dSJung-uk Kim$s2="r10";
781f13597dSJung-uk Kim$s3="r11";
791f13597dSJung-uk Kim
801f13597dSJung-uk Kim$t0="r12";
81*7bded2dbSJung-uk Kim$t1="r0";	# stay away from "r13";
821f13597dSJung-uk Kim$t2="r14";
831f13597dSJung-uk Kim$t3="r15";
841f13597dSJung-uk Kim
851f13597dSJung-uk Kim$acc00="r16";
861f13597dSJung-uk Kim$acc01="r17";
871f13597dSJung-uk Kim$acc02="r18";
881f13597dSJung-uk Kim$acc03="r19";
891f13597dSJung-uk Kim
901f13597dSJung-uk Kim$acc04="r20";
911f13597dSJung-uk Kim$acc05="r21";
921f13597dSJung-uk Kim$acc06="r22";
931f13597dSJung-uk Kim$acc07="r23";
941f13597dSJung-uk Kim
951f13597dSJung-uk Kim$acc08="r24";
961f13597dSJung-uk Kim$acc09="r25";
971f13597dSJung-uk Kim$acc10="r26";
981f13597dSJung-uk Kim$acc11="r27";
991f13597dSJung-uk Kim
1001f13597dSJung-uk Kim$acc12="r28";
1011f13597dSJung-uk Kim$acc13="r29";
1021f13597dSJung-uk Kim$acc14="r30";
1031f13597dSJung-uk Kim$acc15="r31";
1041f13597dSJung-uk Kim
1051f13597dSJung-uk Kim$mask80=$Tbl2;
1061f13597dSJung-uk Kim$mask1b=$Tbl3;
1071f13597dSJung-uk Kim
1081f13597dSJung-uk Kim$code.=<<___;
1091f13597dSJung-uk Kim.machine	"any"
1101f13597dSJung-uk Kim.text
1111f13597dSJung-uk Kim
1121f13597dSJung-uk Kim.align	7
1131f13597dSJung-uk KimLAES_Te:
1141f13597dSJung-uk Kim	mflr	r0
1151f13597dSJung-uk Kim	bcl	20,31,\$+4
1161f13597dSJung-uk Kim	mflr	$Tbl0	;    vvvvv "distance" between . and 1st data entry
1171f13597dSJung-uk Kim	addi	$Tbl0,$Tbl0,`128-8`
1181f13597dSJung-uk Kim	mtlr	r0
1191f13597dSJung-uk Kim	blr
1201f13597dSJung-uk Kim	.long	0
1211f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
1221f13597dSJung-uk Kim	.space	`64-9*4`
1231f13597dSJung-uk KimLAES_Td:
1241f13597dSJung-uk Kim	mflr	r0
1251f13597dSJung-uk Kim	bcl	20,31,\$+4
1261f13597dSJung-uk Kim	mflr	$Tbl0	;    vvvvvvvv "distance" between . and 1st data entry
1271f13597dSJung-uk Kim	addi	$Tbl0,$Tbl0,`128-64-8+2048+256`
1281f13597dSJung-uk Kim	mtlr	r0
1291f13597dSJung-uk Kim	blr
1301f13597dSJung-uk Kim	.long	0
1311f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
1321f13597dSJung-uk Kim	.space	`128-64-9*4`
1331f13597dSJung-uk Kim___
1341f13597dSJung-uk Kim&_data_word(
1351f13597dSJung-uk Kim	0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d,
1361f13597dSJung-uk Kim	0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
1371f13597dSJung-uk Kim	0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d,
1381f13597dSJung-uk Kim	0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a,
1391f13597dSJung-uk Kim	0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87,
1401f13597dSJung-uk Kim	0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b,
1411f13597dSJung-uk Kim	0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea,
1421f13597dSJung-uk Kim	0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b,
1431f13597dSJung-uk Kim	0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a,
1441f13597dSJung-uk Kim	0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f,
1451f13597dSJung-uk Kim	0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108,
1461f13597dSJung-uk Kim	0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f,
1471f13597dSJung-uk Kim	0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e,
1481f13597dSJung-uk Kim	0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5,
1491f13597dSJung-uk Kim	0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d,
1501f13597dSJung-uk Kim	0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f,
1511f13597dSJung-uk Kim	0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e,
1521f13597dSJung-uk Kim	0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb,
1531f13597dSJung-uk Kim	0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce,
1541f13597dSJung-uk Kim	0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497,
1551f13597dSJung-uk Kim	0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c,
1561f13597dSJung-uk Kim	0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed,
1571f13597dSJung-uk Kim	0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b,
1581f13597dSJung-uk Kim	0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a,
1591f13597dSJung-uk Kim	0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16,
1601f13597dSJung-uk Kim	0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594,
1611f13597dSJung-uk Kim	0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81,
1621f13597dSJung-uk Kim	0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3,
1631f13597dSJung-uk Kim	0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a,
1641f13597dSJung-uk Kim	0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504,
1651f13597dSJung-uk Kim	0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163,
1661f13597dSJung-uk Kim	0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d,
1671f13597dSJung-uk Kim	0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f,
1681f13597dSJung-uk Kim	0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739,
1691f13597dSJung-uk Kim	0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47,
1701f13597dSJung-uk Kim	0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395,
1711f13597dSJung-uk Kim	0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f,
1721f13597dSJung-uk Kim	0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883,
1731f13597dSJung-uk Kim	0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c,
1741f13597dSJung-uk Kim	0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76,
1751f13597dSJung-uk Kim	0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e,
1761f13597dSJung-uk Kim	0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4,
1771f13597dSJung-uk Kim	0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6,
1781f13597dSJung-uk Kim	0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b,
1791f13597dSJung-uk Kim	0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7,
1801f13597dSJung-uk Kim	0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0,
1811f13597dSJung-uk Kim	0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25,
1821f13597dSJung-uk Kim	0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818,
1831f13597dSJung-uk Kim	0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72,
1841f13597dSJung-uk Kim	0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651,
1851f13597dSJung-uk Kim	0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21,
1861f13597dSJung-uk Kim	0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85,
1871f13597dSJung-uk Kim	0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa,
1881f13597dSJung-uk Kim	0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12,
1891f13597dSJung-uk Kim	0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0,
1901f13597dSJung-uk Kim	0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9,
1911f13597dSJung-uk Kim	0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133,
1921f13597dSJung-uk Kim	0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7,
1931f13597dSJung-uk Kim	0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920,
1941f13597dSJung-uk Kim	0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a,
1951f13597dSJung-uk Kim	0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17,
1961f13597dSJung-uk Kim	0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8,
1971f13597dSJung-uk Kim	0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11,
1981f13597dSJung-uk Kim	0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a);
1991f13597dSJung-uk Kim$code.=<<___;
2001f13597dSJung-uk Kim.byte	0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5
2011f13597dSJung-uk Kim.byte	0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76
2021f13597dSJung-uk Kim.byte	0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0
2031f13597dSJung-uk Kim.byte	0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0
2041f13597dSJung-uk Kim.byte	0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc
2051f13597dSJung-uk Kim.byte	0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15
2061f13597dSJung-uk Kim.byte	0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a
2071f13597dSJung-uk Kim.byte	0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75
2081f13597dSJung-uk Kim.byte	0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0
2091f13597dSJung-uk Kim.byte	0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84
2101f13597dSJung-uk Kim.byte	0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b
2111f13597dSJung-uk Kim.byte	0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf
2121f13597dSJung-uk Kim.byte	0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85
2131f13597dSJung-uk Kim.byte	0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8
2141f13597dSJung-uk Kim.byte	0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5
2151f13597dSJung-uk Kim.byte	0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2
2161f13597dSJung-uk Kim.byte	0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17
2171f13597dSJung-uk Kim.byte	0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73
2181f13597dSJung-uk Kim.byte	0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88
2191f13597dSJung-uk Kim.byte	0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb
2201f13597dSJung-uk Kim.byte	0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c
2211f13597dSJung-uk Kim.byte	0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79
2221f13597dSJung-uk Kim.byte	0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9
2231f13597dSJung-uk Kim.byte	0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08
2241f13597dSJung-uk Kim.byte	0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6
2251f13597dSJung-uk Kim.byte	0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a
2261f13597dSJung-uk Kim.byte	0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e
2271f13597dSJung-uk Kim.byte	0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e
2281f13597dSJung-uk Kim.byte	0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94
2291f13597dSJung-uk Kim.byte	0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf
2301f13597dSJung-uk Kim.byte	0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68
2311f13597dSJung-uk Kim.byte	0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
2321f13597dSJung-uk Kim___
2331f13597dSJung-uk Kim&_data_word(
2341f13597dSJung-uk Kim	0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96,
2351f13597dSJung-uk Kim	0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
2361f13597dSJung-uk Kim	0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25,
2371f13597dSJung-uk Kim	0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f,
2381f13597dSJung-uk Kim	0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1,
2391f13597dSJung-uk Kim	0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6,
2401f13597dSJung-uk Kim	0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da,
2411f13597dSJung-uk Kim	0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844,
2421f13597dSJung-uk Kim	0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd,
2431f13597dSJung-uk Kim	0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4,
2441f13597dSJung-uk Kim	0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45,
2451f13597dSJung-uk Kim	0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94,
2461f13597dSJung-uk Kim	0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7,
2471f13597dSJung-uk Kim	0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a,
2481f13597dSJung-uk Kim	0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5,
2491f13597dSJung-uk Kim	0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c,
2501f13597dSJung-uk Kim	0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1,
2511f13597dSJung-uk Kim	0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a,
2521f13597dSJung-uk Kim	0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75,
2531f13597dSJung-uk Kim	0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051,
2541f13597dSJung-uk Kim	0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46,
2551f13597dSJung-uk Kim	0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff,
2561f13597dSJung-uk Kim	0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77,
2571f13597dSJung-uk Kim	0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb,
2581f13597dSJung-uk Kim	0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000,
2591f13597dSJung-uk Kim	0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e,
2601f13597dSJung-uk Kim	0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927,
2611f13597dSJung-uk Kim	0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a,
2621f13597dSJung-uk Kim	0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e,
2631f13597dSJung-uk Kim	0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16,
2641f13597dSJung-uk Kim	0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d,
2651f13597dSJung-uk Kim	0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8,
2661f13597dSJung-uk Kim	0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd,
2671f13597dSJung-uk Kim	0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34,
2681f13597dSJung-uk Kim	0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163,
2691f13597dSJung-uk Kim	0xd731dcca, 0x42638510, 0x13972240, 0x84c61120,
2701f13597dSJung-uk Kim	0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d,
2711f13597dSJung-uk Kim	0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0,
2721f13597dSJung-uk Kim	0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422,
2731f13597dSJung-uk Kim	0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef,
2741f13597dSJung-uk Kim	0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36,
2751f13597dSJung-uk Kim	0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4,
2761f13597dSJung-uk Kim	0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662,
2771f13597dSJung-uk Kim	0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5,
2781f13597dSJung-uk Kim	0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3,
2791f13597dSJung-uk Kim	0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b,
2801f13597dSJung-uk Kim	0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8,
2811f13597dSJung-uk Kim	0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6,
2821f13597dSJung-uk Kim	0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6,
2831f13597dSJung-uk Kim	0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0,
2841f13597dSJung-uk Kim	0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815,
2851f13597dSJung-uk Kim	0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f,
2861f13597dSJung-uk Kim	0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df,
2871f13597dSJung-uk Kim	0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f,
2881f13597dSJung-uk Kim	0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e,
2891f13597dSJung-uk Kim	0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713,
2901f13597dSJung-uk Kim	0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89,
2911f13597dSJung-uk Kim	0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c,
2921f13597dSJung-uk Kim	0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf,
2931f13597dSJung-uk Kim	0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86,
2941f13597dSJung-uk Kim	0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f,
2951f13597dSJung-uk Kim	0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541,
2961f13597dSJung-uk Kim	0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190,
2971f13597dSJung-uk Kim	0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742);
2981f13597dSJung-uk Kim$code.=<<___;
2991f13597dSJung-uk Kim.byte	0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38
3001f13597dSJung-uk Kim.byte	0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb
3011f13597dSJung-uk Kim.byte	0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87
3021f13597dSJung-uk Kim.byte	0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb
3031f13597dSJung-uk Kim.byte	0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d
3041f13597dSJung-uk Kim.byte	0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e
3051f13597dSJung-uk Kim.byte	0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2
3061f13597dSJung-uk Kim.byte	0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25
3071f13597dSJung-uk Kim.byte	0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16
3081f13597dSJung-uk Kim.byte	0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92
3091f13597dSJung-uk Kim.byte	0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda
3101f13597dSJung-uk Kim.byte	0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84
3111f13597dSJung-uk Kim.byte	0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a
3121f13597dSJung-uk Kim.byte	0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06
3131f13597dSJung-uk Kim.byte	0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02
3141f13597dSJung-uk Kim.byte	0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b
3151f13597dSJung-uk Kim.byte	0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea
3161f13597dSJung-uk Kim.byte	0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73
3171f13597dSJung-uk Kim.byte	0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85
3181f13597dSJung-uk Kim.byte	0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e
3191f13597dSJung-uk Kim.byte	0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89
3201f13597dSJung-uk Kim.byte	0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b
3211f13597dSJung-uk Kim.byte	0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20
3221f13597dSJung-uk Kim.byte	0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4
3231f13597dSJung-uk Kim.byte	0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31
3241f13597dSJung-uk Kim.byte	0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f
3251f13597dSJung-uk Kim.byte	0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d
3261f13597dSJung-uk Kim.byte	0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef
3271f13597dSJung-uk Kim.byte	0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0
3281f13597dSJung-uk Kim.byte	0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61
3291f13597dSJung-uk Kim.byte	0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26
3301f13597dSJung-uk Kim.byte	0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
3311f13597dSJung-uk Kim
3321f13597dSJung-uk Kim
3331f13597dSJung-uk Kim.globl	.AES_encrypt
3341f13597dSJung-uk Kim.align	7
3351f13597dSJung-uk Kim.AES_encrypt:
3361f13597dSJung-uk Kim	$STU	$sp,-$FRAME($sp)
3371f13597dSJung-uk Kim	mflr	r0
3381f13597dSJung-uk Kim
339*7bded2dbSJung-uk Kim	$PUSH	$out,`$FRAME-$SIZE_T*19`($sp)
3401f13597dSJung-uk Kim	$PUSH	r14,`$FRAME-$SIZE_T*18`($sp)
3411f13597dSJung-uk Kim	$PUSH	r15,`$FRAME-$SIZE_T*17`($sp)
3421f13597dSJung-uk Kim	$PUSH	r16,`$FRAME-$SIZE_T*16`($sp)
3431f13597dSJung-uk Kim	$PUSH	r17,`$FRAME-$SIZE_T*15`($sp)
3441f13597dSJung-uk Kim	$PUSH	r18,`$FRAME-$SIZE_T*14`($sp)
3451f13597dSJung-uk Kim	$PUSH	r19,`$FRAME-$SIZE_T*13`($sp)
3461f13597dSJung-uk Kim	$PUSH	r20,`$FRAME-$SIZE_T*12`($sp)
3471f13597dSJung-uk Kim	$PUSH	r21,`$FRAME-$SIZE_T*11`($sp)
3481f13597dSJung-uk Kim	$PUSH	r22,`$FRAME-$SIZE_T*10`($sp)
3491f13597dSJung-uk Kim	$PUSH	r23,`$FRAME-$SIZE_T*9`($sp)
3501f13597dSJung-uk Kim	$PUSH	r24,`$FRAME-$SIZE_T*8`($sp)
3511f13597dSJung-uk Kim	$PUSH	r25,`$FRAME-$SIZE_T*7`($sp)
3521f13597dSJung-uk Kim	$PUSH	r26,`$FRAME-$SIZE_T*6`($sp)
3531f13597dSJung-uk Kim	$PUSH	r27,`$FRAME-$SIZE_T*5`($sp)
3541f13597dSJung-uk Kim	$PUSH	r28,`$FRAME-$SIZE_T*4`($sp)
3551f13597dSJung-uk Kim	$PUSH	r29,`$FRAME-$SIZE_T*3`($sp)
3561f13597dSJung-uk Kim	$PUSH	r30,`$FRAME-$SIZE_T*2`($sp)
3571f13597dSJung-uk Kim	$PUSH	r31,`$FRAME-$SIZE_T*1`($sp)
3581f13597dSJung-uk Kim	$PUSH	r0,`$FRAME+$LRSAVE`($sp)
3591f13597dSJung-uk Kim
3601f13597dSJung-uk Kim	andi.	$t0,$inp,3
3611f13597dSJung-uk Kim	andi.	$t1,$out,3
3621f13597dSJung-uk Kim	or.	$t0,$t0,$t1
3631f13597dSJung-uk Kim	bne	Lenc_unaligned
3641f13597dSJung-uk Kim
3651f13597dSJung-uk KimLenc_unaligned_ok:
366*7bded2dbSJung-uk Kim___
367*7bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
3681f13597dSJung-uk Kim	lwz	$s0,0($inp)
3691f13597dSJung-uk Kim	lwz	$s1,4($inp)
3701f13597dSJung-uk Kim	lwz	$s2,8($inp)
3711f13597dSJung-uk Kim	lwz	$s3,12($inp)
372*7bded2dbSJung-uk Kim___
373*7bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
374*7bded2dbSJung-uk Kim	lwz	$t0,0($inp)
375*7bded2dbSJung-uk Kim	lwz	$t1,4($inp)
376*7bded2dbSJung-uk Kim	lwz	$t2,8($inp)
377*7bded2dbSJung-uk Kim	lwz	$t3,12($inp)
378*7bded2dbSJung-uk Kim	rotlwi	$s0,$t0,8
379*7bded2dbSJung-uk Kim	rotlwi	$s1,$t1,8
380*7bded2dbSJung-uk Kim	rotlwi	$s2,$t2,8
381*7bded2dbSJung-uk Kim	rotlwi	$s3,$t3,8
382*7bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,0,7
383*7bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,0,7
384*7bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,0,7
385*7bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,0,7
386*7bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,16,23
387*7bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,16,23
388*7bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,16,23
389*7bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,16,23
390*7bded2dbSJung-uk Kim___
391*7bded2dbSJung-uk Kim$code.=<<___;
3921f13597dSJung-uk Kim	bl	LAES_Te
3931f13597dSJung-uk Kim	bl	Lppc_AES_encrypt_compact
394*7bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
395*7bded2dbSJung-uk Kim___
396*7bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
397*7bded2dbSJung-uk Kim	rotlwi	$t0,$s0,8
398*7bded2dbSJung-uk Kim	rotlwi	$t1,$s1,8
399*7bded2dbSJung-uk Kim	rotlwi	$t2,$s2,8
400*7bded2dbSJung-uk Kim	rotlwi	$t3,$s3,8
401*7bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,0,7
402*7bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,0,7
403*7bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,0,7
404*7bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,0,7
405*7bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,16,23
406*7bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,16,23
407*7bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,16,23
408*7bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,16,23
409*7bded2dbSJung-uk Kim	stw	$t0,0($out)
410*7bded2dbSJung-uk Kim	stw	$t1,4($out)
411*7bded2dbSJung-uk Kim	stw	$t2,8($out)
412*7bded2dbSJung-uk Kim	stw	$t3,12($out)
413*7bded2dbSJung-uk Kim___
414*7bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
4151f13597dSJung-uk Kim	stw	$s0,0($out)
4161f13597dSJung-uk Kim	stw	$s1,4($out)
4171f13597dSJung-uk Kim	stw	$s2,8($out)
4181f13597dSJung-uk Kim	stw	$s3,12($out)
419*7bded2dbSJung-uk Kim___
420*7bded2dbSJung-uk Kim$code.=<<___;
4211f13597dSJung-uk Kim	b	Lenc_done
4221f13597dSJung-uk Kim
4231f13597dSJung-uk KimLenc_unaligned:
4241f13597dSJung-uk Kim	subfic	$t0,$inp,4096
4251f13597dSJung-uk Kim	subfic	$t1,$out,4096
4261f13597dSJung-uk Kim	andi.	$t0,$t0,4096-16
4271f13597dSJung-uk Kim	beq	Lenc_xpage
4281f13597dSJung-uk Kim	andi.	$t1,$t1,4096-16
4291f13597dSJung-uk Kim	bne	Lenc_unaligned_ok
4301f13597dSJung-uk Kim
4311f13597dSJung-uk KimLenc_xpage:
4321f13597dSJung-uk Kim	lbz	$acc00,0($inp)
4331f13597dSJung-uk Kim	lbz	$acc01,1($inp)
4341f13597dSJung-uk Kim	lbz	$acc02,2($inp)
4351f13597dSJung-uk Kim	lbz	$s0,3($inp)
4361f13597dSJung-uk Kim	lbz	$acc04,4($inp)
4371f13597dSJung-uk Kim	lbz	$acc05,5($inp)
4381f13597dSJung-uk Kim	lbz	$acc06,6($inp)
4391f13597dSJung-uk Kim	lbz	$s1,7($inp)
4401f13597dSJung-uk Kim	lbz	$acc08,8($inp)
4411f13597dSJung-uk Kim	lbz	$acc09,9($inp)
4421f13597dSJung-uk Kim	lbz	$acc10,10($inp)
4431f13597dSJung-uk Kim	insrwi	$s0,$acc00,8,0
4441f13597dSJung-uk Kim	lbz	$s2,11($inp)
4451f13597dSJung-uk Kim	insrwi	$s1,$acc04,8,0
4461f13597dSJung-uk Kim	lbz	$acc12,12($inp)
4471f13597dSJung-uk Kim	insrwi	$s0,$acc01,8,8
4481f13597dSJung-uk Kim	lbz	$acc13,13($inp)
4491f13597dSJung-uk Kim	insrwi	$s1,$acc05,8,8
4501f13597dSJung-uk Kim	lbz	$acc14,14($inp)
4511f13597dSJung-uk Kim	insrwi	$s0,$acc02,8,16
4521f13597dSJung-uk Kim	lbz	$s3,15($inp)
4531f13597dSJung-uk Kim	insrwi	$s1,$acc06,8,16
4541f13597dSJung-uk Kim	insrwi	$s2,$acc08,8,0
4551f13597dSJung-uk Kim	insrwi	$s3,$acc12,8,0
4561f13597dSJung-uk Kim	insrwi	$s2,$acc09,8,8
4571f13597dSJung-uk Kim	insrwi	$s3,$acc13,8,8
4581f13597dSJung-uk Kim	insrwi	$s2,$acc10,8,16
4591f13597dSJung-uk Kim	insrwi	$s3,$acc14,8,16
4601f13597dSJung-uk Kim
4611f13597dSJung-uk Kim	bl	LAES_Te
4621f13597dSJung-uk Kim	bl	Lppc_AES_encrypt_compact
463*7bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
4641f13597dSJung-uk Kim
4651f13597dSJung-uk Kim	extrwi	$acc00,$s0,8,0
4661f13597dSJung-uk Kim	extrwi	$acc01,$s0,8,8
4671f13597dSJung-uk Kim	stb	$acc00,0($out)
4681f13597dSJung-uk Kim	extrwi	$acc02,$s0,8,16
4691f13597dSJung-uk Kim	stb	$acc01,1($out)
4701f13597dSJung-uk Kim	stb	$acc02,2($out)
4711f13597dSJung-uk Kim	extrwi	$acc04,$s1,8,0
4721f13597dSJung-uk Kim	stb	$s0,3($out)
4731f13597dSJung-uk Kim	extrwi	$acc05,$s1,8,8
4741f13597dSJung-uk Kim	stb	$acc04,4($out)
4751f13597dSJung-uk Kim	extrwi	$acc06,$s1,8,16
4761f13597dSJung-uk Kim	stb	$acc05,5($out)
4771f13597dSJung-uk Kim	stb	$acc06,6($out)
4781f13597dSJung-uk Kim	extrwi	$acc08,$s2,8,0
4791f13597dSJung-uk Kim	stb	$s1,7($out)
4801f13597dSJung-uk Kim	extrwi	$acc09,$s2,8,8
4811f13597dSJung-uk Kim	stb	$acc08,8($out)
4821f13597dSJung-uk Kim	extrwi	$acc10,$s2,8,16
4831f13597dSJung-uk Kim	stb	$acc09,9($out)
4841f13597dSJung-uk Kim	stb	$acc10,10($out)
4851f13597dSJung-uk Kim	extrwi	$acc12,$s3,8,0
4861f13597dSJung-uk Kim	stb	$s2,11($out)
4871f13597dSJung-uk Kim	extrwi	$acc13,$s3,8,8
4881f13597dSJung-uk Kim	stb	$acc12,12($out)
4891f13597dSJung-uk Kim	extrwi	$acc14,$s3,8,16
4901f13597dSJung-uk Kim	stb	$acc13,13($out)
4911f13597dSJung-uk Kim	stb	$acc14,14($out)
4921f13597dSJung-uk Kim	stb	$s3,15($out)
4931f13597dSJung-uk Kim
4941f13597dSJung-uk KimLenc_done:
4951f13597dSJung-uk Kim	$POP	r0,`$FRAME+$LRSAVE`($sp)
4961f13597dSJung-uk Kim	$POP	r14,`$FRAME-$SIZE_T*18`($sp)
4971f13597dSJung-uk Kim	$POP	r15,`$FRAME-$SIZE_T*17`($sp)
4981f13597dSJung-uk Kim	$POP	r16,`$FRAME-$SIZE_T*16`($sp)
4991f13597dSJung-uk Kim	$POP	r17,`$FRAME-$SIZE_T*15`($sp)
5001f13597dSJung-uk Kim	$POP	r18,`$FRAME-$SIZE_T*14`($sp)
5011f13597dSJung-uk Kim	$POP	r19,`$FRAME-$SIZE_T*13`($sp)
5021f13597dSJung-uk Kim	$POP	r20,`$FRAME-$SIZE_T*12`($sp)
5031f13597dSJung-uk Kim	$POP	r21,`$FRAME-$SIZE_T*11`($sp)
5041f13597dSJung-uk Kim	$POP	r22,`$FRAME-$SIZE_T*10`($sp)
5051f13597dSJung-uk Kim	$POP	r23,`$FRAME-$SIZE_T*9`($sp)
5061f13597dSJung-uk Kim	$POP	r24,`$FRAME-$SIZE_T*8`($sp)
5071f13597dSJung-uk Kim	$POP	r25,`$FRAME-$SIZE_T*7`($sp)
5081f13597dSJung-uk Kim	$POP	r26,`$FRAME-$SIZE_T*6`($sp)
5091f13597dSJung-uk Kim	$POP	r27,`$FRAME-$SIZE_T*5`($sp)
5101f13597dSJung-uk Kim	$POP	r28,`$FRAME-$SIZE_T*4`($sp)
5111f13597dSJung-uk Kim	$POP	r29,`$FRAME-$SIZE_T*3`($sp)
5121f13597dSJung-uk Kim	$POP	r30,`$FRAME-$SIZE_T*2`($sp)
5131f13597dSJung-uk Kim	$POP	r31,`$FRAME-$SIZE_T*1`($sp)
5141f13597dSJung-uk Kim	mtlr	r0
5151f13597dSJung-uk Kim	addi	$sp,$sp,$FRAME
5161f13597dSJung-uk Kim	blr
5171f13597dSJung-uk Kim	.long	0
5181f13597dSJung-uk Kim	.byte	0,12,4,1,0x80,18,3,0
5191f13597dSJung-uk Kim	.long	0
5201f13597dSJung-uk Kim
5211f13597dSJung-uk Kim.align	5
5221f13597dSJung-uk KimLppc_AES_encrypt:
5231f13597dSJung-uk Kim	lwz	$acc00,240($key)
5241f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,3
5251f13597dSJung-uk Kim	lwz	$t0,0($key)
5261f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2
5271f13597dSJung-uk Kim	lwz	$t1,4($key)
5281f13597dSJung-uk Kim	addi	$Tbl3,$Tbl0,1
5291f13597dSJung-uk Kim	lwz	$t2,8($key)
5301f13597dSJung-uk Kim	addi	$acc00,$acc00,-1
5311f13597dSJung-uk Kim	lwz	$t3,12($key)
5321f13597dSJung-uk Kim	addi	$key,$key,16
5331f13597dSJung-uk Kim	xor	$s0,$s0,$t0
5341f13597dSJung-uk Kim	xor	$s1,$s1,$t1
5351f13597dSJung-uk Kim	xor	$s2,$s2,$t2
5361f13597dSJung-uk Kim	xor	$s3,$s3,$t3
5371f13597dSJung-uk Kim	mtctr	$acc00
5381f13597dSJung-uk Kim.align	4
5391f13597dSJung-uk KimLenc_loop:
5401f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24+3`,21,28
5411f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24+3`,21,28
5421f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24+3`,21,28
5431f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24+3`,21,28
5441f13597dSJung-uk Kim	lwz	$t0,0($key)
5451f13597dSJung-uk Kim	rlwinm	$acc04,$s1,`32-16+3`,21,28
5461f13597dSJung-uk Kim	lwz	$t1,4($key)
5471f13597dSJung-uk Kim	rlwinm	$acc05,$s2,`32-16+3`,21,28
5481f13597dSJung-uk Kim	lwz	$t2,8($key)
5491f13597dSJung-uk Kim	rlwinm	$acc06,$s3,`32-16+3`,21,28
5501f13597dSJung-uk Kim	lwz	$t3,12($key)
5511f13597dSJung-uk Kim	rlwinm	$acc07,$s0,`32-16+3`,21,28
5521f13597dSJung-uk Kim	lwzx	$acc00,$Tbl0,$acc00
5531f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8+3`,21,28
5541f13597dSJung-uk Kim	lwzx	$acc01,$Tbl0,$acc01
5551f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8+3`,21,28
5561f13597dSJung-uk Kim	lwzx	$acc02,$Tbl0,$acc02
5571f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8+3`,21,28
5581f13597dSJung-uk Kim	lwzx	$acc03,$Tbl0,$acc03
5591f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8+3`,21,28
5601f13597dSJung-uk Kim	lwzx	$acc04,$Tbl1,$acc04
5611f13597dSJung-uk Kim	rlwinm	$acc12,$s3,`0+3`,21,28
5621f13597dSJung-uk Kim	lwzx	$acc05,$Tbl1,$acc05
5631f13597dSJung-uk Kim	rlwinm	$acc13,$s0,`0+3`,21,28
5641f13597dSJung-uk Kim	lwzx	$acc06,$Tbl1,$acc06
5651f13597dSJung-uk Kim	rlwinm	$acc14,$s1,`0+3`,21,28
5661f13597dSJung-uk Kim	lwzx	$acc07,$Tbl1,$acc07
5671f13597dSJung-uk Kim	rlwinm	$acc15,$s2,`0+3`,21,28
5681f13597dSJung-uk Kim	lwzx	$acc08,$Tbl2,$acc08
5691f13597dSJung-uk Kim	xor	$t0,$t0,$acc00
5701f13597dSJung-uk Kim	lwzx	$acc09,$Tbl2,$acc09
5711f13597dSJung-uk Kim	xor	$t1,$t1,$acc01
5721f13597dSJung-uk Kim	lwzx	$acc10,$Tbl2,$acc10
5731f13597dSJung-uk Kim	xor	$t2,$t2,$acc02
5741f13597dSJung-uk Kim	lwzx	$acc11,$Tbl2,$acc11
5751f13597dSJung-uk Kim	xor	$t3,$t3,$acc03
5761f13597dSJung-uk Kim	lwzx	$acc12,$Tbl3,$acc12
5771f13597dSJung-uk Kim	xor	$t0,$t0,$acc04
5781f13597dSJung-uk Kim	lwzx	$acc13,$Tbl3,$acc13
5791f13597dSJung-uk Kim	xor	$t1,$t1,$acc05
5801f13597dSJung-uk Kim	lwzx	$acc14,$Tbl3,$acc14
5811f13597dSJung-uk Kim	xor	$t2,$t2,$acc06
5821f13597dSJung-uk Kim	lwzx	$acc15,$Tbl3,$acc15
5831f13597dSJung-uk Kim	xor	$t3,$t3,$acc07
5841f13597dSJung-uk Kim	xor	$t0,$t0,$acc08
5851f13597dSJung-uk Kim	xor	$t1,$t1,$acc09
5861f13597dSJung-uk Kim	xor	$t2,$t2,$acc10
5871f13597dSJung-uk Kim	xor	$t3,$t3,$acc11
5881f13597dSJung-uk Kim	xor	$s0,$t0,$acc12
5891f13597dSJung-uk Kim	xor	$s1,$t1,$acc13
5901f13597dSJung-uk Kim	xor	$s2,$t2,$acc14
5911f13597dSJung-uk Kim	xor	$s3,$t3,$acc15
5921f13597dSJung-uk Kim	addi	$key,$key,16
5931f13597dSJung-uk Kim	bdnz-	Lenc_loop
5941f13597dSJung-uk Kim
5951f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2048
5961f13597dSJung-uk Kim	nop
5971f13597dSJung-uk Kim	lwz	$t0,0($key)
5981f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
5991f13597dSJung-uk Kim	lwz	$t1,4($key)
6001f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
6011f13597dSJung-uk Kim	lwz	$t2,8($key)
6021f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
6031f13597dSJung-uk Kim	lwz	$t3,12($key)
6041f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
6051f13597dSJung-uk Kim	lwz	$acc08,`2048+0`($Tbl0)	! prefetch Te4
6061f13597dSJung-uk Kim	rlwinm	$acc04,$s1,`32-16`,24,31
6071f13597dSJung-uk Kim	lwz	$acc09,`2048+32`($Tbl0)
6081f13597dSJung-uk Kim	rlwinm	$acc05,$s2,`32-16`,24,31
6091f13597dSJung-uk Kim	lwz	$acc10,`2048+64`($Tbl0)
6101f13597dSJung-uk Kim	rlwinm	$acc06,$s3,`32-16`,24,31
6111f13597dSJung-uk Kim	lwz	$acc11,`2048+96`($Tbl0)
6121f13597dSJung-uk Kim	rlwinm	$acc07,$s0,`32-16`,24,31
6131f13597dSJung-uk Kim	lwz	$acc12,`2048+128`($Tbl0)
6141f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
6151f13597dSJung-uk Kim	lwz	$acc13,`2048+160`($Tbl0)
6161f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
6171f13597dSJung-uk Kim	lwz	$acc14,`2048+192`($Tbl0)
6181f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
6191f13597dSJung-uk Kim	lwz	$acc15,`2048+224`($Tbl0)
6201f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
6211f13597dSJung-uk Kim	lbzx	$acc00,$Tbl2,$acc00
6221f13597dSJung-uk Kim	rlwinm	$acc12,$s3,`0`,24,31
6231f13597dSJung-uk Kim	lbzx	$acc01,$Tbl2,$acc01
6241f13597dSJung-uk Kim	rlwinm	$acc13,$s0,`0`,24,31
6251f13597dSJung-uk Kim	lbzx	$acc02,$Tbl2,$acc02
6261f13597dSJung-uk Kim	rlwinm	$acc14,$s1,`0`,24,31
6271f13597dSJung-uk Kim	lbzx	$acc03,$Tbl2,$acc03
6281f13597dSJung-uk Kim	rlwinm	$acc15,$s2,`0`,24,31
6291f13597dSJung-uk Kim	lbzx	$acc04,$Tbl2,$acc04
6301f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
6311f13597dSJung-uk Kim	lbzx	$acc05,$Tbl2,$acc05
6321f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
6331f13597dSJung-uk Kim	lbzx	$acc06,$Tbl2,$acc06
6341f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
6351f13597dSJung-uk Kim	lbzx	$acc07,$Tbl2,$acc07
6361f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
6371f13597dSJung-uk Kim	lbzx	$acc08,$Tbl2,$acc08
6381f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
6391f13597dSJung-uk Kim	lbzx	$acc09,$Tbl2,$acc09
6401f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
6411f13597dSJung-uk Kim	lbzx	$acc10,$Tbl2,$acc10
6421f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
6431f13597dSJung-uk Kim	lbzx	$acc11,$Tbl2,$acc11
6441f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
6451f13597dSJung-uk Kim	lbzx	$acc12,$Tbl2,$acc12
6461f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
6471f13597dSJung-uk Kim	lbzx	$acc13,$Tbl2,$acc13
6481f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
6491f13597dSJung-uk Kim	lbzx	$acc14,$Tbl2,$acc14
6501f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
6511f13597dSJung-uk Kim	lbzx	$acc15,$Tbl2,$acc15
6521f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
6531f13597dSJung-uk Kim	or	$s0,$s0,$acc12
6541f13597dSJung-uk Kim	or	$s1,$s1,$acc13
6551f13597dSJung-uk Kim	or	$s2,$s2,$acc14
6561f13597dSJung-uk Kim	or	$s3,$s3,$acc15
6571f13597dSJung-uk Kim	xor	$s0,$s0,$t0
6581f13597dSJung-uk Kim	xor	$s1,$s1,$t1
6591f13597dSJung-uk Kim	xor	$s2,$s2,$t2
6601f13597dSJung-uk Kim	xor	$s3,$s3,$t3
6611f13597dSJung-uk Kim	blr
6621f13597dSJung-uk Kim	.long	0
6631f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
6641f13597dSJung-uk Kim
6651f13597dSJung-uk Kim.align	4
6661f13597dSJung-uk KimLppc_AES_encrypt_compact:
6671f13597dSJung-uk Kim	lwz	$acc00,240($key)
6681f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,2048
6691f13597dSJung-uk Kim	lwz	$t0,0($key)
6701f13597dSJung-uk Kim	lis	$mask80,0x8080
6711f13597dSJung-uk Kim	lwz	$t1,4($key)
6721f13597dSJung-uk Kim	lis	$mask1b,0x1b1b
6731f13597dSJung-uk Kim	lwz	$t2,8($key)
6741f13597dSJung-uk Kim	ori	$mask80,$mask80,0x8080
6751f13597dSJung-uk Kim	lwz	$t3,12($key)
6761f13597dSJung-uk Kim	ori	$mask1b,$mask1b,0x1b1b
6771f13597dSJung-uk Kim	addi	$key,$key,16
6781f13597dSJung-uk Kim	mtctr	$acc00
6791f13597dSJung-uk Kim.align	4
6801f13597dSJung-uk KimLenc_compact_loop:
6811f13597dSJung-uk Kim	xor	$s0,$s0,$t0
6821f13597dSJung-uk Kim	xor	$s1,$s1,$t1
6831f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
6841f13597dSJung-uk Kim	xor	$s2,$s2,$t2
6851f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
6861f13597dSJung-uk Kim	xor	$s3,$s3,$t3
6871f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
6881f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
6891f13597dSJung-uk Kim	rlwinm	$acc04,$s1,`32-16`,24,31
6901f13597dSJung-uk Kim	rlwinm	$acc05,$s2,`32-16`,24,31
6911f13597dSJung-uk Kim	rlwinm	$acc06,$s3,`32-16`,24,31
6921f13597dSJung-uk Kim	rlwinm	$acc07,$s0,`32-16`,24,31
6931f13597dSJung-uk Kim	lbzx	$acc00,$Tbl1,$acc00
6941f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
6951f13597dSJung-uk Kim	lbzx	$acc01,$Tbl1,$acc01
6961f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
6971f13597dSJung-uk Kim	lbzx	$acc02,$Tbl1,$acc02
6981f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
6991f13597dSJung-uk Kim	lbzx	$acc03,$Tbl1,$acc03
7001f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
7011f13597dSJung-uk Kim	lbzx	$acc04,$Tbl1,$acc04
7021f13597dSJung-uk Kim	rlwinm	$acc12,$s3,`0`,24,31
7031f13597dSJung-uk Kim	lbzx	$acc05,$Tbl1,$acc05
7041f13597dSJung-uk Kim	rlwinm	$acc13,$s0,`0`,24,31
7051f13597dSJung-uk Kim	lbzx	$acc06,$Tbl1,$acc06
7061f13597dSJung-uk Kim	rlwinm	$acc14,$s1,`0`,24,31
7071f13597dSJung-uk Kim	lbzx	$acc07,$Tbl1,$acc07
7081f13597dSJung-uk Kim	rlwinm	$acc15,$s2,`0`,24,31
7091f13597dSJung-uk Kim	lbzx	$acc08,$Tbl1,$acc08
7101f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
7111f13597dSJung-uk Kim	lbzx	$acc09,$Tbl1,$acc09
7121f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
7131f13597dSJung-uk Kim	lbzx	$acc10,$Tbl1,$acc10
7141f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
7151f13597dSJung-uk Kim	lbzx	$acc11,$Tbl1,$acc11
7161f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
7171f13597dSJung-uk Kim	lbzx	$acc12,$Tbl1,$acc12
7181f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
7191f13597dSJung-uk Kim	lbzx	$acc13,$Tbl1,$acc13
7201f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
7211f13597dSJung-uk Kim	lbzx	$acc14,$Tbl1,$acc14
7221f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
7231f13597dSJung-uk Kim	lbzx	$acc15,$Tbl1,$acc15
7241f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
7251f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
7261f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
7271f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
7281f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
7291f13597dSJung-uk Kim	lwz	$t0,0($key)
7301f13597dSJung-uk Kim	or	$s0,$s0,$acc12
7311f13597dSJung-uk Kim	lwz	$t1,4($key)
7321f13597dSJung-uk Kim	or	$s1,$s1,$acc13
7331f13597dSJung-uk Kim	lwz	$t2,8($key)
7341f13597dSJung-uk Kim	or	$s2,$s2,$acc14
7351f13597dSJung-uk Kim	lwz	$t3,12($key)
7361f13597dSJung-uk Kim	or	$s3,$s3,$acc15
7371f13597dSJung-uk Kim
7381f13597dSJung-uk Kim	addi	$key,$key,16
7391f13597dSJung-uk Kim	bdz	Lenc_compact_done
7401f13597dSJung-uk Kim
7411f13597dSJung-uk Kim	and	$acc00,$s0,$mask80	# r1=r0&0x80808080
7421f13597dSJung-uk Kim	and	$acc01,$s1,$mask80
7431f13597dSJung-uk Kim	and	$acc02,$s2,$mask80
7441f13597dSJung-uk Kim	and	$acc03,$s3,$mask80
7451f13597dSJung-uk Kim	srwi	$acc04,$acc00,7		# r1>>7
7461f13597dSJung-uk Kim	andc	$acc08,$s0,$mask80	# r0&0x7f7f7f7f
7471f13597dSJung-uk Kim	srwi	$acc05,$acc01,7
7481f13597dSJung-uk Kim	andc	$acc09,$s1,$mask80
7491f13597dSJung-uk Kim	srwi	$acc06,$acc02,7
7501f13597dSJung-uk Kim	andc	$acc10,$s2,$mask80
7511f13597dSJung-uk Kim	srwi	$acc07,$acc03,7
7521f13597dSJung-uk Kim	andc	$acc11,$s3,$mask80
7531f13597dSJung-uk Kim	sub	$acc00,$acc00,$acc04	# r1-(r1>>7)
7541f13597dSJung-uk Kim	sub	$acc01,$acc01,$acc05
7551f13597dSJung-uk Kim	sub	$acc02,$acc02,$acc06
7561f13597dSJung-uk Kim	sub	$acc03,$acc03,$acc07
7571f13597dSJung-uk Kim	add	$acc08,$acc08,$acc08	# (r0&0x7f7f7f7f)<<1
7581f13597dSJung-uk Kim	add	$acc09,$acc09,$acc09
7591f13597dSJung-uk Kim	add	$acc10,$acc10,$acc10
7601f13597dSJung-uk Kim	add	$acc11,$acc11,$acc11
7611f13597dSJung-uk Kim	and	$acc00,$acc00,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
7621f13597dSJung-uk Kim	and	$acc01,$acc01,$mask1b
7631f13597dSJung-uk Kim	and	$acc02,$acc02,$mask1b
7641f13597dSJung-uk Kim	and	$acc03,$acc03,$mask1b
7651f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08	# r2
7661f13597dSJung-uk Kim	xor	$acc01,$acc01,$acc09
7671f13597dSJung-uk Kim	 rotlwi	$acc12,$s0,16		# ROTATE(r0,16)
7681f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
7691f13597dSJung-uk Kim	 rotlwi	$acc13,$s1,16
7701f13597dSJung-uk Kim	xor	$acc03,$acc03,$acc11
7711f13597dSJung-uk Kim	 rotlwi	$acc14,$s2,16
7721f13597dSJung-uk Kim
7731f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# r0^r2
7741f13597dSJung-uk Kim	rotlwi	$acc15,$s3,16
7751f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
7761f13597dSJung-uk Kim	rotrwi	$s0,$s0,24		# ROTATE(r2^r0,24)
7771f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
7781f13597dSJung-uk Kim	rotrwi	$s1,$s1,24
7791f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
7801f13597dSJung-uk Kim	rotrwi	$s2,$s2,24
7811f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# ROTATE(r2^r0,24)^r2
7821f13597dSJung-uk Kim	rotrwi	$s3,$s3,24
7831f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
7841f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
7851f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
7861f13597dSJung-uk Kim	rotlwi	$acc08,$acc12,8		# ROTATE(r0,24)
7871f13597dSJung-uk Kim	xor	$s0,$s0,$acc12		#
7881f13597dSJung-uk Kim	rotlwi	$acc09,$acc13,8
7891f13597dSJung-uk Kim	xor	$s1,$s1,$acc13
7901f13597dSJung-uk Kim	rotlwi	$acc10,$acc14,8
7911f13597dSJung-uk Kim	xor	$s2,$s2,$acc14
7921f13597dSJung-uk Kim	rotlwi	$acc11,$acc15,8
7931f13597dSJung-uk Kim	xor	$s3,$s3,$acc15
7941f13597dSJung-uk Kim	xor	$s0,$s0,$acc08		#
7951f13597dSJung-uk Kim	xor	$s1,$s1,$acc09
7961f13597dSJung-uk Kim	xor	$s2,$s2,$acc10
7971f13597dSJung-uk Kim	xor	$s3,$s3,$acc11
7981f13597dSJung-uk Kim
7991f13597dSJung-uk Kim	b	Lenc_compact_loop
8001f13597dSJung-uk Kim.align	4
8011f13597dSJung-uk KimLenc_compact_done:
8021f13597dSJung-uk Kim	xor	$s0,$s0,$t0
8031f13597dSJung-uk Kim	xor	$s1,$s1,$t1
8041f13597dSJung-uk Kim	xor	$s2,$s2,$t2
8051f13597dSJung-uk Kim	xor	$s3,$s3,$t3
8061f13597dSJung-uk Kim	blr
8071f13597dSJung-uk Kim	.long	0
8081f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
809*7bded2dbSJung-uk Kim.size	.AES_encrypt,.-.AES_encrypt
8101f13597dSJung-uk Kim
8111f13597dSJung-uk Kim.globl	.AES_decrypt
8121f13597dSJung-uk Kim.align	7
8131f13597dSJung-uk Kim.AES_decrypt:
8141f13597dSJung-uk Kim	$STU	$sp,-$FRAME($sp)
8151f13597dSJung-uk Kim	mflr	r0
8161f13597dSJung-uk Kim
817*7bded2dbSJung-uk Kim	$PUSH	$out,`$FRAME-$SIZE_T*19`($sp)
8181f13597dSJung-uk Kim	$PUSH	r14,`$FRAME-$SIZE_T*18`($sp)
8191f13597dSJung-uk Kim	$PUSH	r15,`$FRAME-$SIZE_T*17`($sp)
8201f13597dSJung-uk Kim	$PUSH	r16,`$FRAME-$SIZE_T*16`($sp)
8211f13597dSJung-uk Kim	$PUSH	r17,`$FRAME-$SIZE_T*15`($sp)
8221f13597dSJung-uk Kim	$PUSH	r18,`$FRAME-$SIZE_T*14`($sp)
8231f13597dSJung-uk Kim	$PUSH	r19,`$FRAME-$SIZE_T*13`($sp)
8241f13597dSJung-uk Kim	$PUSH	r20,`$FRAME-$SIZE_T*12`($sp)
8251f13597dSJung-uk Kim	$PUSH	r21,`$FRAME-$SIZE_T*11`($sp)
8261f13597dSJung-uk Kim	$PUSH	r22,`$FRAME-$SIZE_T*10`($sp)
8271f13597dSJung-uk Kim	$PUSH	r23,`$FRAME-$SIZE_T*9`($sp)
8281f13597dSJung-uk Kim	$PUSH	r24,`$FRAME-$SIZE_T*8`($sp)
8291f13597dSJung-uk Kim	$PUSH	r25,`$FRAME-$SIZE_T*7`($sp)
8301f13597dSJung-uk Kim	$PUSH	r26,`$FRAME-$SIZE_T*6`($sp)
8311f13597dSJung-uk Kim	$PUSH	r27,`$FRAME-$SIZE_T*5`($sp)
8321f13597dSJung-uk Kim	$PUSH	r28,`$FRAME-$SIZE_T*4`($sp)
8331f13597dSJung-uk Kim	$PUSH	r29,`$FRAME-$SIZE_T*3`($sp)
8341f13597dSJung-uk Kim	$PUSH	r30,`$FRAME-$SIZE_T*2`($sp)
8351f13597dSJung-uk Kim	$PUSH	r31,`$FRAME-$SIZE_T*1`($sp)
8361f13597dSJung-uk Kim	$PUSH	r0,`$FRAME+$LRSAVE`($sp)
8371f13597dSJung-uk Kim
8381f13597dSJung-uk Kim	andi.	$t0,$inp,3
8391f13597dSJung-uk Kim	andi.	$t1,$out,3
8401f13597dSJung-uk Kim	or.	$t0,$t0,$t1
8411f13597dSJung-uk Kim	bne	Ldec_unaligned
8421f13597dSJung-uk Kim
8431f13597dSJung-uk KimLdec_unaligned_ok:
844*7bded2dbSJung-uk Kim___
845*7bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
8461f13597dSJung-uk Kim	lwz	$s0,0($inp)
8471f13597dSJung-uk Kim	lwz	$s1,4($inp)
8481f13597dSJung-uk Kim	lwz	$s2,8($inp)
8491f13597dSJung-uk Kim	lwz	$s3,12($inp)
850*7bded2dbSJung-uk Kim___
851*7bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
852*7bded2dbSJung-uk Kim	lwz	$t0,0($inp)
853*7bded2dbSJung-uk Kim	lwz	$t1,4($inp)
854*7bded2dbSJung-uk Kim	lwz	$t2,8($inp)
855*7bded2dbSJung-uk Kim	lwz	$t3,12($inp)
856*7bded2dbSJung-uk Kim	rotlwi	$s0,$t0,8
857*7bded2dbSJung-uk Kim	rotlwi	$s1,$t1,8
858*7bded2dbSJung-uk Kim	rotlwi	$s2,$t2,8
859*7bded2dbSJung-uk Kim	rotlwi	$s3,$t3,8
860*7bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,0,7
861*7bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,0,7
862*7bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,0,7
863*7bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,0,7
864*7bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,16,23
865*7bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,16,23
866*7bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,16,23
867*7bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,16,23
868*7bded2dbSJung-uk Kim___
869*7bded2dbSJung-uk Kim$code.=<<___;
8701f13597dSJung-uk Kim	bl	LAES_Td
8711f13597dSJung-uk Kim	bl	Lppc_AES_decrypt_compact
872*7bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
873*7bded2dbSJung-uk Kim___
874*7bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
875*7bded2dbSJung-uk Kim	rotlwi	$t0,$s0,8
876*7bded2dbSJung-uk Kim	rotlwi	$t1,$s1,8
877*7bded2dbSJung-uk Kim	rotlwi	$t2,$s2,8
878*7bded2dbSJung-uk Kim	rotlwi	$t3,$s3,8
879*7bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,0,7
880*7bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,0,7
881*7bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,0,7
882*7bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,0,7
883*7bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,16,23
884*7bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,16,23
885*7bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,16,23
886*7bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,16,23
887*7bded2dbSJung-uk Kim	stw	$t0,0($out)
888*7bded2dbSJung-uk Kim	stw	$t1,4($out)
889*7bded2dbSJung-uk Kim	stw	$t2,8($out)
890*7bded2dbSJung-uk Kim	stw	$t3,12($out)
891*7bded2dbSJung-uk Kim___
892*7bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
8931f13597dSJung-uk Kim	stw	$s0,0($out)
8941f13597dSJung-uk Kim	stw	$s1,4($out)
8951f13597dSJung-uk Kim	stw	$s2,8($out)
8961f13597dSJung-uk Kim	stw	$s3,12($out)
897*7bded2dbSJung-uk Kim___
898*7bded2dbSJung-uk Kim$code.=<<___;
8991f13597dSJung-uk Kim	b	Ldec_done
9001f13597dSJung-uk Kim
9011f13597dSJung-uk KimLdec_unaligned:
9021f13597dSJung-uk Kim	subfic	$t0,$inp,4096
9031f13597dSJung-uk Kim	subfic	$t1,$out,4096
9041f13597dSJung-uk Kim	andi.	$t0,$t0,4096-16
9051f13597dSJung-uk Kim	beq	Ldec_xpage
9061f13597dSJung-uk Kim	andi.	$t1,$t1,4096-16
9071f13597dSJung-uk Kim	bne	Ldec_unaligned_ok
9081f13597dSJung-uk Kim
9091f13597dSJung-uk KimLdec_xpage:
9101f13597dSJung-uk Kim	lbz	$acc00,0($inp)
9111f13597dSJung-uk Kim	lbz	$acc01,1($inp)
9121f13597dSJung-uk Kim	lbz	$acc02,2($inp)
9131f13597dSJung-uk Kim	lbz	$s0,3($inp)
9141f13597dSJung-uk Kim	lbz	$acc04,4($inp)
9151f13597dSJung-uk Kim	lbz	$acc05,5($inp)
9161f13597dSJung-uk Kim	lbz	$acc06,6($inp)
9171f13597dSJung-uk Kim	lbz	$s1,7($inp)
9181f13597dSJung-uk Kim	lbz	$acc08,8($inp)
9191f13597dSJung-uk Kim	lbz	$acc09,9($inp)
9201f13597dSJung-uk Kim	lbz	$acc10,10($inp)
9211f13597dSJung-uk Kim	insrwi	$s0,$acc00,8,0
9221f13597dSJung-uk Kim	lbz	$s2,11($inp)
9231f13597dSJung-uk Kim	insrwi	$s1,$acc04,8,0
9241f13597dSJung-uk Kim	lbz	$acc12,12($inp)
9251f13597dSJung-uk Kim	insrwi	$s0,$acc01,8,8
9261f13597dSJung-uk Kim	lbz	$acc13,13($inp)
9271f13597dSJung-uk Kim	insrwi	$s1,$acc05,8,8
9281f13597dSJung-uk Kim	lbz	$acc14,14($inp)
9291f13597dSJung-uk Kim	insrwi	$s0,$acc02,8,16
9301f13597dSJung-uk Kim	lbz	$s3,15($inp)
9311f13597dSJung-uk Kim	insrwi	$s1,$acc06,8,16
9321f13597dSJung-uk Kim	insrwi	$s2,$acc08,8,0
9331f13597dSJung-uk Kim	insrwi	$s3,$acc12,8,0
9341f13597dSJung-uk Kim	insrwi	$s2,$acc09,8,8
9351f13597dSJung-uk Kim	insrwi	$s3,$acc13,8,8
9361f13597dSJung-uk Kim	insrwi	$s2,$acc10,8,16
9371f13597dSJung-uk Kim	insrwi	$s3,$acc14,8,16
9381f13597dSJung-uk Kim
9391f13597dSJung-uk Kim	bl	LAES_Td
9401f13597dSJung-uk Kim	bl	Lppc_AES_decrypt_compact
941*7bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
9421f13597dSJung-uk Kim
9431f13597dSJung-uk Kim	extrwi	$acc00,$s0,8,0
9441f13597dSJung-uk Kim	extrwi	$acc01,$s0,8,8
9451f13597dSJung-uk Kim	stb	$acc00,0($out)
9461f13597dSJung-uk Kim	extrwi	$acc02,$s0,8,16
9471f13597dSJung-uk Kim	stb	$acc01,1($out)
9481f13597dSJung-uk Kim	stb	$acc02,2($out)
9491f13597dSJung-uk Kim	extrwi	$acc04,$s1,8,0
9501f13597dSJung-uk Kim	stb	$s0,3($out)
9511f13597dSJung-uk Kim	extrwi	$acc05,$s1,8,8
9521f13597dSJung-uk Kim	stb	$acc04,4($out)
9531f13597dSJung-uk Kim	extrwi	$acc06,$s1,8,16
9541f13597dSJung-uk Kim	stb	$acc05,5($out)
9551f13597dSJung-uk Kim	stb	$acc06,6($out)
9561f13597dSJung-uk Kim	extrwi	$acc08,$s2,8,0
9571f13597dSJung-uk Kim	stb	$s1,7($out)
9581f13597dSJung-uk Kim	extrwi	$acc09,$s2,8,8
9591f13597dSJung-uk Kim	stb	$acc08,8($out)
9601f13597dSJung-uk Kim	extrwi	$acc10,$s2,8,16
9611f13597dSJung-uk Kim	stb	$acc09,9($out)
9621f13597dSJung-uk Kim	stb	$acc10,10($out)
9631f13597dSJung-uk Kim	extrwi	$acc12,$s3,8,0
9641f13597dSJung-uk Kim	stb	$s2,11($out)
9651f13597dSJung-uk Kim	extrwi	$acc13,$s3,8,8
9661f13597dSJung-uk Kim	stb	$acc12,12($out)
9671f13597dSJung-uk Kim	extrwi	$acc14,$s3,8,16
9681f13597dSJung-uk Kim	stb	$acc13,13($out)
9691f13597dSJung-uk Kim	stb	$acc14,14($out)
9701f13597dSJung-uk Kim	stb	$s3,15($out)
9711f13597dSJung-uk Kim
9721f13597dSJung-uk KimLdec_done:
9731f13597dSJung-uk Kim	$POP	r0,`$FRAME+$LRSAVE`($sp)
9741f13597dSJung-uk Kim	$POP	r14,`$FRAME-$SIZE_T*18`($sp)
9751f13597dSJung-uk Kim	$POP	r15,`$FRAME-$SIZE_T*17`($sp)
9761f13597dSJung-uk Kim	$POP	r16,`$FRAME-$SIZE_T*16`($sp)
9771f13597dSJung-uk Kim	$POP	r17,`$FRAME-$SIZE_T*15`($sp)
9781f13597dSJung-uk Kim	$POP	r18,`$FRAME-$SIZE_T*14`($sp)
9791f13597dSJung-uk Kim	$POP	r19,`$FRAME-$SIZE_T*13`($sp)
9801f13597dSJung-uk Kim	$POP	r20,`$FRAME-$SIZE_T*12`($sp)
9811f13597dSJung-uk Kim	$POP	r21,`$FRAME-$SIZE_T*11`($sp)
9821f13597dSJung-uk Kim	$POP	r22,`$FRAME-$SIZE_T*10`($sp)
9831f13597dSJung-uk Kim	$POP	r23,`$FRAME-$SIZE_T*9`($sp)
9841f13597dSJung-uk Kim	$POP	r24,`$FRAME-$SIZE_T*8`($sp)
9851f13597dSJung-uk Kim	$POP	r25,`$FRAME-$SIZE_T*7`($sp)
9861f13597dSJung-uk Kim	$POP	r26,`$FRAME-$SIZE_T*6`($sp)
9871f13597dSJung-uk Kim	$POP	r27,`$FRAME-$SIZE_T*5`($sp)
9881f13597dSJung-uk Kim	$POP	r28,`$FRAME-$SIZE_T*4`($sp)
9891f13597dSJung-uk Kim	$POP	r29,`$FRAME-$SIZE_T*3`($sp)
9901f13597dSJung-uk Kim	$POP	r30,`$FRAME-$SIZE_T*2`($sp)
9911f13597dSJung-uk Kim	$POP	r31,`$FRAME-$SIZE_T*1`($sp)
9921f13597dSJung-uk Kim	mtlr	r0
9931f13597dSJung-uk Kim	addi	$sp,$sp,$FRAME
9941f13597dSJung-uk Kim	blr
9951f13597dSJung-uk Kim	.long	0
9961f13597dSJung-uk Kim	.byte	0,12,4,1,0x80,18,3,0
9971f13597dSJung-uk Kim	.long	0
9981f13597dSJung-uk Kim
9991f13597dSJung-uk Kim.align	5
10001f13597dSJung-uk KimLppc_AES_decrypt:
10011f13597dSJung-uk Kim	lwz	$acc00,240($key)
10021f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,3
10031f13597dSJung-uk Kim	lwz	$t0,0($key)
10041f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2
10051f13597dSJung-uk Kim	lwz	$t1,4($key)
10061f13597dSJung-uk Kim	addi	$Tbl3,$Tbl0,1
10071f13597dSJung-uk Kim	lwz	$t2,8($key)
10081f13597dSJung-uk Kim	addi	$acc00,$acc00,-1
10091f13597dSJung-uk Kim	lwz	$t3,12($key)
10101f13597dSJung-uk Kim	addi	$key,$key,16
10111f13597dSJung-uk Kim	xor	$s0,$s0,$t0
10121f13597dSJung-uk Kim	xor	$s1,$s1,$t1
10131f13597dSJung-uk Kim	xor	$s2,$s2,$t2
10141f13597dSJung-uk Kim	xor	$s3,$s3,$t3
10151f13597dSJung-uk Kim	mtctr	$acc00
10161f13597dSJung-uk Kim.align	4
10171f13597dSJung-uk KimLdec_loop:
10181f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24+3`,21,28
10191f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24+3`,21,28
10201f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24+3`,21,28
10211f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24+3`,21,28
10221f13597dSJung-uk Kim	lwz	$t0,0($key)
10231f13597dSJung-uk Kim	rlwinm	$acc04,$s3,`32-16+3`,21,28
10241f13597dSJung-uk Kim	lwz	$t1,4($key)
10251f13597dSJung-uk Kim	rlwinm	$acc05,$s0,`32-16+3`,21,28
10261f13597dSJung-uk Kim	lwz	$t2,8($key)
10271f13597dSJung-uk Kim	rlwinm	$acc06,$s1,`32-16+3`,21,28
10281f13597dSJung-uk Kim	lwz	$t3,12($key)
10291f13597dSJung-uk Kim	rlwinm	$acc07,$s2,`32-16+3`,21,28
10301f13597dSJung-uk Kim	lwzx	$acc00,$Tbl0,$acc00
10311f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8+3`,21,28
10321f13597dSJung-uk Kim	lwzx	$acc01,$Tbl0,$acc01
10331f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8+3`,21,28
10341f13597dSJung-uk Kim	lwzx	$acc02,$Tbl0,$acc02
10351f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8+3`,21,28
10361f13597dSJung-uk Kim	lwzx	$acc03,$Tbl0,$acc03
10371f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8+3`,21,28
10381f13597dSJung-uk Kim	lwzx	$acc04,$Tbl1,$acc04
10391f13597dSJung-uk Kim	rlwinm	$acc12,$s1,`0+3`,21,28
10401f13597dSJung-uk Kim	lwzx	$acc05,$Tbl1,$acc05
10411f13597dSJung-uk Kim	rlwinm	$acc13,$s2,`0+3`,21,28
10421f13597dSJung-uk Kim	lwzx	$acc06,$Tbl1,$acc06
10431f13597dSJung-uk Kim	rlwinm	$acc14,$s3,`0+3`,21,28
10441f13597dSJung-uk Kim	lwzx	$acc07,$Tbl1,$acc07
10451f13597dSJung-uk Kim	rlwinm	$acc15,$s0,`0+3`,21,28
10461f13597dSJung-uk Kim	lwzx	$acc08,$Tbl2,$acc08
10471f13597dSJung-uk Kim	xor	$t0,$t0,$acc00
10481f13597dSJung-uk Kim	lwzx	$acc09,$Tbl2,$acc09
10491f13597dSJung-uk Kim	xor	$t1,$t1,$acc01
10501f13597dSJung-uk Kim	lwzx	$acc10,$Tbl2,$acc10
10511f13597dSJung-uk Kim	xor	$t2,$t2,$acc02
10521f13597dSJung-uk Kim	lwzx	$acc11,$Tbl2,$acc11
10531f13597dSJung-uk Kim	xor	$t3,$t3,$acc03
10541f13597dSJung-uk Kim	lwzx	$acc12,$Tbl3,$acc12
10551f13597dSJung-uk Kim	xor	$t0,$t0,$acc04
10561f13597dSJung-uk Kim	lwzx	$acc13,$Tbl3,$acc13
10571f13597dSJung-uk Kim	xor	$t1,$t1,$acc05
10581f13597dSJung-uk Kim	lwzx	$acc14,$Tbl3,$acc14
10591f13597dSJung-uk Kim	xor	$t2,$t2,$acc06
10601f13597dSJung-uk Kim	lwzx	$acc15,$Tbl3,$acc15
10611f13597dSJung-uk Kim	xor	$t3,$t3,$acc07
10621f13597dSJung-uk Kim	xor	$t0,$t0,$acc08
10631f13597dSJung-uk Kim	xor	$t1,$t1,$acc09
10641f13597dSJung-uk Kim	xor	$t2,$t2,$acc10
10651f13597dSJung-uk Kim	xor	$t3,$t3,$acc11
10661f13597dSJung-uk Kim	xor	$s0,$t0,$acc12
10671f13597dSJung-uk Kim	xor	$s1,$t1,$acc13
10681f13597dSJung-uk Kim	xor	$s2,$t2,$acc14
10691f13597dSJung-uk Kim	xor	$s3,$t3,$acc15
10701f13597dSJung-uk Kim	addi	$key,$key,16
10711f13597dSJung-uk Kim	bdnz-	Ldec_loop
10721f13597dSJung-uk Kim
10731f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2048
10741f13597dSJung-uk Kim	nop
10751f13597dSJung-uk Kim	lwz	$t0,0($key)
10761f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
10771f13597dSJung-uk Kim	lwz	$t1,4($key)
10781f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
10791f13597dSJung-uk Kim	lwz	$t2,8($key)
10801f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
10811f13597dSJung-uk Kim	lwz	$t3,12($key)
10821f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
10831f13597dSJung-uk Kim	lwz	$acc08,`2048+0`($Tbl0)	! prefetch Td4
10841f13597dSJung-uk Kim	rlwinm	$acc04,$s3,`32-16`,24,31
10851f13597dSJung-uk Kim	lwz	$acc09,`2048+32`($Tbl0)
10861f13597dSJung-uk Kim	rlwinm	$acc05,$s0,`32-16`,24,31
10871f13597dSJung-uk Kim	lwz	$acc10,`2048+64`($Tbl0)
10881f13597dSJung-uk Kim	lbzx	$acc00,$Tbl2,$acc00
10891f13597dSJung-uk Kim	lwz	$acc11,`2048+96`($Tbl0)
10901f13597dSJung-uk Kim	lbzx	$acc01,$Tbl2,$acc01
10911f13597dSJung-uk Kim	lwz	$acc12,`2048+128`($Tbl0)
10921f13597dSJung-uk Kim	rlwinm	$acc06,$s1,`32-16`,24,31
10931f13597dSJung-uk Kim	lwz	$acc13,`2048+160`($Tbl0)
10941f13597dSJung-uk Kim	rlwinm	$acc07,$s2,`32-16`,24,31
10951f13597dSJung-uk Kim	lwz	$acc14,`2048+192`($Tbl0)
10961f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
10971f13597dSJung-uk Kim	lwz	$acc15,`2048+224`($Tbl0)
10981f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
10991f13597dSJung-uk Kim	lbzx	$acc02,$Tbl2,$acc02
11001f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
11011f13597dSJung-uk Kim	lbzx	$acc03,$Tbl2,$acc03
11021f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
11031f13597dSJung-uk Kim	lbzx	$acc04,$Tbl2,$acc04
11041f13597dSJung-uk Kim	rlwinm	$acc12,$s1,`0`,24,31
11051f13597dSJung-uk Kim	lbzx	$acc05,$Tbl2,$acc05
11061f13597dSJung-uk Kim	rlwinm	$acc13,$s2,`0`,24,31
11071f13597dSJung-uk Kim	lbzx	$acc06,$Tbl2,$acc06
11081f13597dSJung-uk Kim	rlwinm	$acc14,$s3,`0`,24,31
11091f13597dSJung-uk Kim	lbzx	$acc07,$Tbl2,$acc07
11101f13597dSJung-uk Kim	rlwinm	$acc15,$s0,`0`,24,31
11111f13597dSJung-uk Kim	lbzx	$acc08,$Tbl2,$acc08
11121f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
11131f13597dSJung-uk Kim	lbzx	$acc09,$Tbl2,$acc09
11141f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
11151f13597dSJung-uk Kim	lbzx	$acc10,$Tbl2,$acc10
11161f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
11171f13597dSJung-uk Kim	lbzx	$acc11,$Tbl2,$acc11
11181f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
11191f13597dSJung-uk Kim	lbzx	$acc12,$Tbl2,$acc12
11201f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
11211f13597dSJung-uk Kim	lbzx	$acc13,$Tbl2,$acc13
11221f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
11231f13597dSJung-uk Kim	lbzx	$acc14,$Tbl2,$acc14
11241f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
11251f13597dSJung-uk Kim	lbzx	$acc15,$Tbl2,$acc15
11261f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
11271f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
11281f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
11291f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
11301f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
11311f13597dSJung-uk Kim	or	$s0,$s0,$acc12
11321f13597dSJung-uk Kim	or	$s1,$s1,$acc13
11331f13597dSJung-uk Kim	or	$s2,$s2,$acc14
11341f13597dSJung-uk Kim	or	$s3,$s3,$acc15
11351f13597dSJung-uk Kim	xor	$s0,$s0,$t0
11361f13597dSJung-uk Kim	xor	$s1,$s1,$t1
11371f13597dSJung-uk Kim	xor	$s2,$s2,$t2
11381f13597dSJung-uk Kim	xor	$s3,$s3,$t3
11391f13597dSJung-uk Kim	blr
11401f13597dSJung-uk Kim	.long	0
11411f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
11421f13597dSJung-uk Kim
11431f13597dSJung-uk Kim.align	4
11441f13597dSJung-uk KimLppc_AES_decrypt_compact:
11451f13597dSJung-uk Kim	lwz	$acc00,240($key)
11461f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,2048
11471f13597dSJung-uk Kim	lwz	$t0,0($key)
11481f13597dSJung-uk Kim	lis	$mask80,0x8080
11491f13597dSJung-uk Kim	lwz	$t1,4($key)
11501f13597dSJung-uk Kim	lis	$mask1b,0x1b1b
11511f13597dSJung-uk Kim	lwz	$t2,8($key)
11521f13597dSJung-uk Kim	ori	$mask80,$mask80,0x8080
11531f13597dSJung-uk Kim	lwz	$t3,12($key)
11541f13597dSJung-uk Kim	ori	$mask1b,$mask1b,0x1b1b
11551f13597dSJung-uk Kim	addi	$key,$key,16
11561f13597dSJung-uk Kim___
11571f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==8);
11581f13597dSJung-uk Kim	insrdi	$mask80,$mask80,32,0
11591f13597dSJung-uk Kim	insrdi	$mask1b,$mask1b,32,0
11601f13597dSJung-uk Kim___
11611f13597dSJung-uk Kim$code.=<<___;
11621f13597dSJung-uk Kim	mtctr	$acc00
11631f13597dSJung-uk Kim.align	4
11641f13597dSJung-uk KimLdec_compact_loop:
11651f13597dSJung-uk Kim	xor	$s0,$s0,$t0
11661f13597dSJung-uk Kim	xor	$s1,$s1,$t1
11671f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
11681f13597dSJung-uk Kim	xor	$s2,$s2,$t2
11691f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
11701f13597dSJung-uk Kim	xor	$s3,$s3,$t3
11711f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
11721f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
11731f13597dSJung-uk Kim	rlwinm	$acc04,$s3,`32-16`,24,31
11741f13597dSJung-uk Kim	rlwinm	$acc05,$s0,`32-16`,24,31
11751f13597dSJung-uk Kim	rlwinm	$acc06,$s1,`32-16`,24,31
11761f13597dSJung-uk Kim	rlwinm	$acc07,$s2,`32-16`,24,31
11771f13597dSJung-uk Kim	lbzx	$acc00,$Tbl1,$acc00
11781f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
11791f13597dSJung-uk Kim	lbzx	$acc01,$Tbl1,$acc01
11801f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
11811f13597dSJung-uk Kim	lbzx	$acc02,$Tbl1,$acc02
11821f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
11831f13597dSJung-uk Kim	lbzx	$acc03,$Tbl1,$acc03
11841f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
11851f13597dSJung-uk Kim	lbzx	$acc04,$Tbl1,$acc04
11861f13597dSJung-uk Kim	rlwinm	$acc12,$s1,`0`,24,31
11871f13597dSJung-uk Kim	lbzx	$acc05,$Tbl1,$acc05
11881f13597dSJung-uk Kim	rlwinm	$acc13,$s2,`0`,24,31
11891f13597dSJung-uk Kim	lbzx	$acc06,$Tbl1,$acc06
11901f13597dSJung-uk Kim	rlwinm	$acc14,$s3,`0`,24,31
11911f13597dSJung-uk Kim	lbzx	$acc07,$Tbl1,$acc07
11921f13597dSJung-uk Kim	rlwinm	$acc15,$s0,`0`,24,31
11931f13597dSJung-uk Kim	lbzx	$acc08,$Tbl1,$acc08
11941f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
11951f13597dSJung-uk Kim	lbzx	$acc09,$Tbl1,$acc09
11961f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
11971f13597dSJung-uk Kim	lbzx	$acc10,$Tbl1,$acc10
11981f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
11991f13597dSJung-uk Kim	lbzx	$acc11,$Tbl1,$acc11
12001f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
12011f13597dSJung-uk Kim	lbzx	$acc12,$Tbl1,$acc12
12021f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
12031f13597dSJung-uk Kim	lbzx	$acc13,$Tbl1,$acc13
12041f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
12051f13597dSJung-uk Kim	lbzx	$acc14,$Tbl1,$acc14
12061f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
12071f13597dSJung-uk Kim	lbzx	$acc15,$Tbl1,$acc15
12081f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
12091f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
12101f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
12111f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
12121f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
12131f13597dSJung-uk Kim	lwz	$t0,0($key)
12141f13597dSJung-uk Kim	or	$s0,$s0,$acc12
12151f13597dSJung-uk Kim	lwz	$t1,4($key)
12161f13597dSJung-uk Kim	or	$s1,$s1,$acc13
12171f13597dSJung-uk Kim	lwz	$t2,8($key)
12181f13597dSJung-uk Kim	or	$s2,$s2,$acc14
12191f13597dSJung-uk Kim	lwz	$t3,12($key)
12201f13597dSJung-uk Kim	or	$s3,$s3,$acc15
12211f13597dSJung-uk Kim
12221f13597dSJung-uk Kim	addi	$key,$key,16
12231f13597dSJung-uk Kim	bdz	Ldec_compact_done
12241f13597dSJung-uk Kim___
12251f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==8);
12261f13597dSJung-uk Kim	# vectorized permutation improves decrypt performance by 10%
12271f13597dSJung-uk Kim	insrdi	$s0,$s1,32,0
12281f13597dSJung-uk Kim	insrdi	$s2,$s3,32,0
12291f13597dSJung-uk Kim
12301f13597dSJung-uk Kim	and	$acc00,$s0,$mask80	# r1=r0&0x80808080
12311f13597dSJung-uk Kim	and	$acc02,$s2,$mask80
12321f13597dSJung-uk Kim	srdi	$acc04,$acc00,7		# r1>>7
12331f13597dSJung-uk Kim	srdi	$acc06,$acc02,7
12341f13597dSJung-uk Kim	andc	$acc08,$s0,$mask80	# r0&0x7f7f7f7f
12351f13597dSJung-uk Kim	andc	$acc10,$s2,$mask80
12361f13597dSJung-uk Kim	sub	$acc00,$acc00,$acc04	# r1-(r1>>7)
12371f13597dSJung-uk Kim	sub	$acc02,$acc02,$acc06
12381f13597dSJung-uk Kim	add	$acc08,$acc08,$acc08	# (r0&0x7f7f7f7f)<<1
12391f13597dSJung-uk Kim	add	$acc10,$acc10,$acc10
12401f13597dSJung-uk Kim	and	$acc00,$acc00,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
12411f13597dSJung-uk Kim	and	$acc02,$acc02,$mask1b
12421f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08	# r2
12431f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
12441f13597dSJung-uk Kim
12451f13597dSJung-uk Kim	and	$acc04,$acc00,$mask80	# r1=r2&0x80808080
12461f13597dSJung-uk Kim	and	$acc06,$acc02,$mask80
12471f13597dSJung-uk Kim	srdi	$acc08,$acc04,7		# r1>>7
12481f13597dSJung-uk Kim	srdi	$acc10,$acc06,7
12491f13597dSJung-uk Kim	andc	$acc12,$acc00,$mask80	# r2&0x7f7f7f7f
12501f13597dSJung-uk Kim	andc	$acc14,$acc02,$mask80
12511f13597dSJung-uk Kim	sub	$acc04,$acc04,$acc08	# r1-(r1>>7)
12521f13597dSJung-uk Kim	sub	$acc06,$acc06,$acc10
12531f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r2&0x7f7f7f7f)<<1
12541f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
12551f13597dSJung-uk Kim	and	$acc04,$acc04,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
12561f13597dSJung-uk Kim	and	$acc06,$acc06,$mask1b
12571f13597dSJung-uk Kim	xor	$acc04,$acc04,$acc12	# r4
12581f13597dSJung-uk Kim	xor	$acc06,$acc06,$acc14
12591f13597dSJung-uk Kim
12601f13597dSJung-uk Kim	and	$acc08,$acc04,$mask80	# r1=r4&0x80808080
12611f13597dSJung-uk Kim	and	$acc10,$acc06,$mask80
12621f13597dSJung-uk Kim	srdi	$acc12,$acc08,7		# r1>>7
12631f13597dSJung-uk Kim	srdi	$acc14,$acc10,7
12641f13597dSJung-uk Kim	sub	$acc08,$acc08,$acc12	# r1-(r1>>7)
12651f13597dSJung-uk Kim	sub	$acc10,$acc10,$acc14
12661f13597dSJung-uk Kim	andc	$acc12,$acc04,$mask80	# r4&0x7f7f7f7f
12671f13597dSJung-uk Kim	andc	$acc14,$acc06,$mask80
12681f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r4&0x7f7f7f7f)<<1
12691f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
12701f13597dSJung-uk Kim	and	$acc08,$acc08,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
12711f13597dSJung-uk Kim	and	$acc10,$acc10,$mask1b
12721f13597dSJung-uk Kim	xor	$acc08,$acc08,$acc12	# r8
12731f13597dSJung-uk Kim	xor	$acc10,$acc10,$acc14
12741f13597dSJung-uk Kim
12751f13597dSJung-uk Kim	xor	$acc00,$acc00,$s0	# r2^r0
12761f13597dSJung-uk Kim	xor	$acc02,$acc02,$s2
12771f13597dSJung-uk Kim	xor	$acc04,$acc04,$s0	# r4^r0
12781f13597dSJung-uk Kim	xor	$acc06,$acc06,$s2
12791f13597dSJung-uk Kim
12801f13597dSJung-uk Kim	extrdi	$acc01,$acc00,32,0
12811f13597dSJung-uk Kim	extrdi	$acc03,$acc02,32,0
12821f13597dSJung-uk Kim	extrdi	$acc05,$acc04,32,0
12831f13597dSJung-uk Kim	extrdi	$acc07,$acc06,32,0
12841f13597dSJung-uk Kim	extrdi	$acc09,$acc08,32,0
12851f13597dSJung-uk Kim	extrdi	$acc11,$acc10,32,0
12861f13597dSJung-uk Kim___
12871f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==4);
12881f13597dSJung-uk Kim	and	$acc00,$s0,$mask80	# r1=r0&0x80808080
12891f13597dSJung-uk Kim	and	$acc01,$s1,$mask80
12901f13597dSJung-uk Kim	and	$acc02,$s2,$mask80
12911f13597dSJung-uk Kim	and	$acc03,$s3,$mask80
12921f13597dSJung-uk Kim	srwi	$acc04,$acc00,7		# r1>>7
12931f13597dSJung-uk Kim	andc	$acc08,$s0,$mask80	# r0&0x7f7f7f7f
12941f13597dSJung-uk Kim	srwi	$acc05,$acc01,7
12951f13597dSJung-uk Kim	andc	$acc09,$s1,$mask80
12961f13597dSJung-uk Kim	srwi	$acc06,$acc02,7
12971f13597dSJung-uk Kim	andc	$acc10,$s2,$mask80
12981f13597dSJung-uk Kim	srwi	$acc07,$acc03,7
12991f13597dSJung-uk Kim	andc	$acc11,$s3,$mask80
13001f13597dSJung-uk Kim	sub	$acc00,$acc00,$acc04	# r1-(r1>>7)
13011f13597dSJung-uk Kim	sub	$acc01,$acc01,$acc05
13021f13597dSJung-uk Kim	sub	$acc02,$acc02,$acc06
13031f13597dSJung-uk Kim	sub	$acc03,$acc03,$acc07
13041f13597dSJung-uk Kim	add	$acc08,$acc08,$acc08	# (r0&0x7f7f7f7f)<<1
13051f13597dSJung-uk Kim	add	$acc09,$acc09,$acc09
13061f13597dSJung-uk Kim	add	$acc10,$acc10,$acc10
13071f13597dSJung-uk Kim	add	$acc11,$acc11,$acc11
13081f13597dSJung-uk Kim	and	$acc00,$acc00,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
13091f13597dSJung-uk Kim	and	$acc01,$acc01,$mask1b
13101f13597dSJung-uk Kim	and	$acc02,$acc02,$mask1b
13111f13597dSJung-uk Kim	and	$acc03,$acc03,$mask1b
13121f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08	# r2
13131f13597dSJung-uk Kim	xor	$acc01,$acc01,$acc09
13141f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
13151f13597dSJung-uk Kim	xor	$acc03,$acc03,$acc11
13161f13597dSJung-uk Kim
13171f13597dSJung-uk Kim	and	$acc04,$acc00,$mask80	# r1=r2&0x80808080
13181f13597dSJung-uk Kim	and	$acc05,$acc01,$mask80
13191f13597dSJung-uk Kim	and	$acc06,$acc02,$mask80
13201f13597dSJung-uk Kim	and	$acc07,$acc03,$mask80
13211f13597dSJung-uk Kim	srwi	$acc08,$acc04,7		# r1>>7
13221f13597dSJung-uk Kim	andc	$acc12,$acc00,$mask80	# r2&0x7f7f7f7f
13231f13597dSJung-uk Kim	srwi	$acc09,$acc05,7
13241f13597dSJung-uk Kim	andc	$acc13,$acc01,$mask80
13251f13597dSJung-uk Kim	srwi	$acc10,$acc06,7
13261f13597dSJung-uk Kim	andc	$acc14,$acc02,$mask80
13271f13597dSJung-uk Kim	srwi	$acc11,$acc07,7
13281f13597dSJung-uk Kim	andc	$acc15,$acc03,$mask80
13291f13597dSJung-uk Kim	sub	$acc04,$acc04,$acc08	# r1-(r1>>7)
13301f13597dSJung-uk Kim	sub	$acc05,$acc05,$acc09
13311f13597dSJung-uk Kim	sub	$acc06,$acc06,$acc10
13321f13597dSJung-uk Kim	sub	$acc07,$acc07,$acc11
13331f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r2&0x7f7f7f7f)<<1
13341f13597dSJung-uk Kim	add	$acc13,$acc13,$acc13
13351f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
13361f13597dSJung-uk Kim	add	$acc15,$acc15,$acc15
13371f13597dSJung-uk Kim	and	$acc04,$acc04,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
13381f13597dSJung-uk Kim	and	$acc05,$acc05,$mask1b
13391f13597dSJung-uk Kim	and	$acc06,$acc06,$mask1b
13401f13597dSJung-uk Kim	and	$acc07,$acc07,$mask1b
13411f13597dSJung-uk Kim	xor	$acc04,$acc04,$acc12	# r4
13421f13597dSJung-uk Kim	xor	$acc05,$acc05,$acc13
13431f13597dSJung-uk Kim	xor	$acc06,$acc06,$acc14
13441f13597dSJung-uk Kim	xor	$acc07,$acc07,$acc15
13451f13597dSJung-uk Kim
13461f13597dSJung-uk Kim	and	$acc08,$acc04,$mask80	# r1=r4&0x80808080
13471f13597dSJung-uk Kim	and	$acc09,$acc05,$mask80
13481f13597dSJung-uk Kim	srwi	$acc12,$acc08,7		# r1>>7
13491f13597dSJung-uk Kim	and	$acc10,$acc06,$mask80
13501f13597dSJung-uk Kim	srwi	$acc13,$acc09,7
13511f13597dSJung-uk Kim	and	$acc11,$acc07,$mask80
13521f13597dSJung-uk Kim	srwi	$acc14,$acc10,7
13531f13597dSJung-uk Kim	sub	$acc08,$acc08,$acc12	# r1-(r1>>7)
13541f13597dSJung-uk Kim	srwi	$acc15,$acc11,7
13551f13597dSJung-uk Kim	sub	$acc09,$acc09,$acc13
13561f13597dSJung-uk Kim	sub	$acc10,$acc10,$acc14
13571f13597dSJung-uk Kim	sub	$acc11,$acc11,$acc15
13581f13597dSJung-uk Kim	andc	$acc12,$acc04,$mask80	# r4&0x7f7f7f7f
13591f13597dSJung-uk Kim	andc	$acc13,$acc05,$mask80
13601f13597dSJung-uk Kim	andc	$acc14,$acc06,$mask80
13611f13597dSJung-uk Kim	andc	$acc15,$acc07,$mask80
13621f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r4&0x7f7f7f7f)<<1
13631f13597dSJung-uk Kim	add	$acc13,$acc13,$acc13
13641f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
13651f13597dSJung-uk Kim	add	$acc15,$acc15,$acc15
13661f13597dSJung-uk Kim	and	$acc08,$acc08,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
13671f13597dSJung-uk Kim	and	$acc09,$acc09,$mask1b
13681f13597dSJung-uk Kim	and	$acc10,$acc10,$mask1b
13691f13597dSJung-uk Kim	and	$acc11,$acc11,$mask1b
13701f13597dSJung-uk Kim	xor	$acc08,$acc08,$acc12	# r8
13711f13597dSJung-uk Kim	xor	$acc09,$acc09,$acc13
13721f13597dSJung-uk Kim	xor	$acc10,$acc10,$acc14
13731f13597dSJung-uk Kim	xor	$acc11,$acc11,$acc15
13741f13597dSJung-uk Kim
13751f13597dSJung-uk Kim	xor	$acc00,$acc00,$s0	# r2^r0
13761f13597dSJung-uk Kim	xor	$acc01,$acc01,$s1
13771f13597dSJung-uk Kim	xor	$acc02,$acc02,$s2
13781f13597dSJung-uk Kim	xor	$acc03,$acc03,$s3
13791f13597dSJung-uk Kim	xor	$acc04,$acc04,$s0	# r4^r0
13801f13597dSJung-uk Kim	xor	$acc05,$acc05,$s1
13811f13597dSJung-uk Kim	xor	$acc06,$acc06,$s2
13821f13597dSJung-uk Kim	xor	$acc07,$acc07,$s3
13831f13597dSJung-uk Kim___
13841f13597dSJung-uk Kim$code.=<<___;
13851f13597dSJung-uk Kim	rotrwi	$s0,$s0,8		# = ROTATE(r0,8)
13861f13597dSJung-uk Kim	rotrwi	$s1,$s1,8
13871f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# ^= r2^r0
13881f13597dSJung-uk Kim	rotrwi	$s2,$s2,8
13891f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
13901f13597dSJung-uk Kim	rotrwi	$s3,$s3,8
13911f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
13921f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
13931f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08
13941f13597dSJung-uk Kim	xor	$acc01,$acc01,$acc09
13951f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
13961f13597dSJung-uk Kim	xor	$acc03,$acc03,$acc11
13971f13597dSJung-uk Kim	xor	$s0,$s0,$acc04		# ^= r4^r0
13981f13597dSJung-uk Kim	rotrwi	$acc00,$acc00,24
13991f13597dSJung-uk Kim	xor	$s1,$s1,$acc05
14001f13597dSJung-uk Kim	rotrwi	$acc01,$acc01,24
14011f13597dSJung-uk Kim	xor	$s2,$s2,$acc06
14021f13597dSJung-uk Kim	rotrwi	$acc02,$acc02,24
14031f13597dSJung-uk Kim	xor	$s3,$s3,$acc07
14041f13597dSJung-uk Kim	rotrwi	$acc03,$acc03,24
14051f13597dSJung-uk Kim	xor	$acc04,$acc04,$acc08
14061f13597dSJung-uk Kim	xor	$acc05,$acc05,$acc09
14071f13597dSJung-uk Kim	xor	$acc06,$acc06,$acc10
14081f13597dSJung-uk Kim	xor	$acc07,$acc07,$acc11
14091f13597dSJung-uk Kim	xor	$s0,$s0,$acc08		# ^= r8 [^((r4^r0)^(r2^r0)=r4^r2)]
14101f13597dSJung-uk Kim	rotrwi	$acc04,$acc04,16
14111f13597dSJung-uk Kim	xor	$s1,$s1,$acc09
14121f13597dSJung-uk Kim	rotrwi	$acc05,$acc05,16
14131f13597dSJung-uk Kim	xor	$s2,$s2,$acc10
14141f13597dSJung-uk Kim	rotrwi	$acc06,$acc06,16
14151f13597dSJung-uk Kim	xor	$s3,$s3,$acc11
14161f13597dSJung-uk Kim	rotrwi	$acc07,$acc07,16
14171f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# ^= ROTATE(r8^r2^r0,24)
14181f13597dSJung-uk Kim	rotrwi	$acc08,$acc08,8
14191f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
14201f13597dSJung-uk Kim	rotrwi	$acc09,$acc09,8
14211f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
14221f13597dSJung-uk Kim	rotrwi	$acc10,$acc10,8
14231f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
14241f13597dSJung-uk Kim	rotrwi	$acc11,$acc11,8
14251f13597dSJung-uk Kim	xor	$s0,$s0,$acc04		# ^= ROTATE(r8^r4^r0,16)
14261f13597dSJung-uk Kim	xor	$s1,$s1,$acc05
14271f13597dSJung-uk Kim	xor	$s2,$s2,$acc06
14281f13597dSJung-uk Kim	xor	$s3,$s3,$acc07
14291f13597dSJung-uk Kim	xor	$s0,$s0,$acc08		# ^= ROTATE(r8,8)
14301f13597dSJung-uk Kim	xor	$s1,$s1,$acc09
14311f13597dSJung-uk Kim	xor	$s2,$s2,$acc10
14321f13597dSJung-uk Kim	xor	$s3,$s3,$acc11
14331f13597dSJung-uk Kim
14341f13597dSJung-uk Kim	b	Ldec_compact_loop
14351f13597dSJung-uk Kim.align	4
14361f13597dSJung-uk KimLdec_compact_done:
14371f13597dSJung-uk Kim	xor	$s0,$s0,$t0
14381f13597dSJung-uk Kim	xor	$s1,$s1,$t1
14391f13597dSJung-uk Kim	xor	$s2,$s2,$t2
14401f13597dSJung-uk Kim	xor	$s3,$s3,$t3
14411f13597dSJung-uk Kim	blr
14421f13597dSJung-uk Kim	.long	0
14431f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
1444*7bded2dbSJung-uk Kim.size	.AES_decrypt,.-.AES_decrypt
14451f13597dSJung-uk Kim
14461f13597dSJung-uk Kim.asciz	"AES for PPC, CRYPTOGAMS by <appro\@openssl.org>"
14471f13597dSJung-uk Kim.align	7
14481f13597dSJung-uk Kim___
14491f13597dSJung-uk Kim
14501f13597dSJung-uk Kim$code =~ s/\`([^\`]*)\`/eval $1/gem;
14511f13597dSJung-uk Kimprint $code;
14521f13597dSJung-uk Kimclose STDOUT;
1453