#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ p3;
typedef int /*<<< orphan*/ p2;
typedef int /*<<< orphan*/ p1;
typedef int /*<<< orphan*/ k3;
typedef int /*<<< orphan*/ k2;
typedef int /*<<< orphan*/ k1;

/* Variables and functions */
int /*<<< orphan*/ rc4_TestOne(unsigned char *, int, unsigned char *, int,
                               unsigned char *);
int rc4_SelfTest(void) {
  unsigned char p1[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  unsigned char k1[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
  unsigned char c1[] = {0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79};
  unsigned char p2[] = {0xdc, 0xee, 0x4c, 0xf9, 0x2c};
  unsigned char k2[] = {0x61, 0x8a, 0x63, 0xd2, 0xfb};
  unsigned char c2[] = {0xf1, 0x38, 0x29, 0xc9, 0xde};
  unsigned char p3[] = {
      0x52, 0x75, 0x69, 0x73, 0x6c, 0x69, 0x6e, 0x6e, 0x75, 0x6e, 0x20, 0x6c,
      0x61, 0x75, 0x6c, 0x75, 0x20, 0x6b, 0x6f, 0x72, 0x76, 0x69, 0x73, 0x73,
      0x73, 0x61, 0x6e, 0x69, 0x2c, 0x20, 0x74, 0xe4, 0x68, 0x6b, 0xe4, 0x70,
      0xe4, 0x69, 0x64, 0x65, 0x6e, 0x20, 0x70, 0xe4, 0xe4, 0x6c, 0x6c, 0xe4,
      0x20, 0x74, 0xe4, 0x79, 0x73, 0x69, 0x6b, 0x75, 0x75, 0x2e, 0x20, 0x4b,
      0x65, 0x73, 0xe4, 0x79, 0xf6, 0x6e, 0x20, 0x6f, 0x6e, 0x20, 0x6f, 0x6e,
      0x6e, 0x69, 0x20, 0x6f, 0x6d, 0x61, 0x6e, 0x61, 0x6e, 0x69, 0x2c, 0x20,
      0x6b, 0x61, 0x73, 0x6b, 0x69, 0x73, 0x61, 0x76, 0x75, 0x75, 0x6e, 0x20,
      0x6c, 0x61, 0x61, 0x6b, 0x73, 0x6f, 0x74, 0x20, 0x76, 0x65, 0x72, 0x68,
      0x6f, 0x75, 0x75, 0x2e, 0x20, 0x45, 0x6e, 0x20, 0x6d, 0x61, 0x20, 0x69,
      0x6c, 0x6f, 0x69, 0x74, 0x73, 0x65, 0x2c, 0x20, 0x73, 0x75, 0x72, 0x65,
      0x20, 0x68, 0x75, 0x6f, 0x6b, 0x61, 0x61, 0x2c, 0x20, 0x6d, 0x75, 0x74,
      0x74, 0x61, 0x20, 0x6d, 0x65, 0x74, 0x73, 0xe4, 0x6e, 0x20, 0x74, 0x75,
      0x6d, 0x6d, 0x75, 0x75, 0x73, 0x20, 0x6d, 0x75, 0x6c, 0x6c, 0x65, 0x20,
      0x74, 0x75, 0x6f, 0x6b, 0x61, 0x61, 0x2e, 0x20, 0x50, 0x75, 0x75, 0x6e,
      0x74, 0x6f, 0x20, 0x70, 0x69, 0x6c, 0x76, 0x65, 0x6e, 0x2c, 0x20, 0x6d,
      0x69, 0x20, 0x68, 0x75, 0x6b, 0x6b, 0x75, 0x75, 0x2c, 0x20, 0x73, 0x69,
      0x69, 0x6e, 0x74, 0x6f, 0x20, 0x76, 0x61, 0x72, 0x61, 0x6e, 0x20, 0x74,
      0x75, 0x75, 0x6c, 0x69, 0x73, 0x65, 0x6e, 0x2c, 0x20, 0x6d, 0x69, 0x20,
      0x6e, 0x75, 0x6b, 0x6b, 0x75, 0x75, 0x2e, 0x20, 0x54, 0x75, 0x6f, 0x6b,
      0x73, 0x75, 0x74, 0x20, 0x76, 0x61, 0x6e, 0x61, 0x6d, 0x6f, 0x6e, 0x20,
      0x6a, 0x61, 0x20, 0x76, 0x61, 0x72, 0x6a, 0x6f, 0x74, 0x20, 0x76, 0x65,
      0x65, 0x6e, 0x2c, 0x20, 0x6e, 0x69, 0x69, 0x73, 0x74, 0xe4, 0x20, 0x73,
      0x79, 0x64, 0xe4, 0x6d, 0x65, 0x6e, 0x69, 0x20, 0x6c, 0x61, 0x75, 0x6c,
      0x75, 0x6e, 0x20, 0x74, 0x65, 0x65, 0x6e, 0x2e, 0x20, 0x2d, 0x20, 0x45,
      0x69, 0x6e, 0x6f, 0x20, 0x4c, 0x65, 0x69, 0x6e, 0x6f};
  unsigned char k3[] = {0x29, 0x04, 0x19, 0x72, 0xfb, 0x42, 0xba, 0x5f,
                        0xc7, 0x12, 0x77, 0x12, 0xf1, 0x38, 0x29, 0xc9};
  unsigned char c3[] = {
      0x35, 0x81, 0x86, 0x99, 0x90, 0x01, 0xe6, 0xb5, 0xda, 0xf0, 0x5e, 0xce,
      0xeb, 0x7e, 0xee, 0x21, 0xe0, 0x68, 0x9c, 0x1f, 0x00, 0xee, 0xa8, 0x1f,
      0x7d, 0xd2, 0xca, 0xae, 0xe1, 0xd2, 0x76, 0x3e, 0x68, 0xaf, 0x0e, 0xad,
      0x33, 0xd6, 0x6c, 0x26, 0x8b, 0xc9, 0x46, 0xc4, 0x84, 0xfb, 0xe9, 0x4c,
      0x5f, 0x5e, 0x0b, 0x86, 0xa5, 0x92, 0x79, 0xe4, 0xf8, 0x24, 0xe7, 0xa6,
      0x40, 0xbd, 0x22, 0x32, 0x10, 0xb0, 0xa6, 0x11, 0x60, 0xb7, 0xbc, 0xe9,
      0x86, 0xea, 0x65, 0x68, 0x80, 0x03, 0x59, 0x6b, 0x63, 0x0a, 0x6b, 0x90,
      0xf8, 0xe0, 0xca, 0xf6, 0x91, 0x2a, 0x98, 0xeb, 0x87, 0x21, 0x76, 0xe8,
      0x3c, 0x20, 0x2c, 0xaa, 0x64, 0x16, 0x6d, 0x2c, 0xce, 0x57, 0xff, 0x1b,
      0xca, 0x57, 0xb2, 0x13, 0xf0, 0xed, 0x1a, 0xa7, 0x2f, 0xb8, 0xea, 0x52,
      0xb0, 0xbe, 0x01, 0xcd, 0x1e, 0x41, 0x28, 0x67, 0x72, 0x0b, 0x32, 0x6e,
      0xb3, 0x89, 0xd0, 0x11, 0xbd, 0x70, 0xd8, 0xaf, 0x03, 0x5f, 0xb0, 0xd8,
      0x58, 0x9d, 0xbc, 0xe3, 0xc6, 0x66, 0xf5, 0xea, 0x8d, 0x4c, 0x79, 0x54,
      0xc5, 0x0c, 0x3f, 0x34, 0x0b, 0x04, 0x67, 0xf8, 0x1b, 0x42, 0x59, 0x61,
      0xc1, 0x18, 0x43, 0x07, 0x4d, 0xf6, 0x20, 0xf2, 0x08, 0x40, 0x4b, 0x39,
      0x4c, 0xf9, 0xd3, 0x7f, 0xf5, 0x4b, 0x5f, 0x1a, 0xd8, 0xf6, 0xea, 0x7d,
      0xa3, 0xc5, 0x61, 0xdf, 0xa7, 0x28, 0x1f, 0x96, 0x44, 0x63, 0xd2, 0xcc,
      0x35, 0xa4, 0xd1, 0xb0, 0x34, 0x90, 0xde, 0xc5, 0x1b, 0x07, 0x11, 0xfb,
      0xd6, 0xf5, 0x5f, 0x79, 0x23, 0x4d, 0x5b, 0x7c, 0x76, 0x66, 0x22, 0xa6,
      0x6d, 0xe9, 0x2b, 0xe9, 0x96, 0x46, 0x1d, 0x5e, 0x4d, 0xc8, 0x78, 0xef,
      0x9b, 0xca, 0x03, 0x05, 0x21, 0xe8, 0x35, 0x1e, 0x4b, 0xae, 0xd2, 0xfd,
      0x04, 0xf9, 0x46, 0x73, 0x68, 0xc4, 0xad, 0x6a, 0xc1, 0x86, 0xd0, 0x82,
      0x45, 0xb2, 0x63, 0xa2, 0x66, 0x6d, 0x1f, 0x6c, 0x54, 0x20, 0xf1, 0x59,
      0x9d, 0xfd, 0x9f, 0x43, 0x89, 0x21, 0xc2, 0xf5, 0xa4, 0x63, 0x93, 0x8c,
      0xe0, 0x98, 0x22, 0x65, 0xee, 0xf7, 0x01, 0x79, 0xbc, 0x55, 0x3f, 0x33,
      0x9e, 0xb1, 0xa4, 0xc1, 0xaf, 0x5f, 0x6a, 0x54, 0x7f};
  rc4_TestOne(k1, sizeof(k1), p1, sizeof(p1), c1);
  rc4_TestOne(k2, sizeof(k2), p2, sizeof(p2), c2);
  rc4_TestOne(k3, sizeof(k3), p3, sizeof(p3), c3);
  return 0;
}


x86 assembly (clang, -O0):
<rc4_SelfTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2b0,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0xeae(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea9(%rip),%eax
mov    %eax,-0x1d(%rbp)
mov    0xea4(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xe9c(%rip),%eax
mov    %eax,-0x22(%rbp)
mov    0xe97(%rip),%al
mov    %al,-0x1e(%rbp)
mov    0xe8f(%rip),%eax
mov    %eax,-0x27(%rbp)
mov    0xe8a(%rip),%al
mov    %al,-0x23(%rbp)
lea    -0x160(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x135,%edx
call   1040 <memcpy@plt>
mov    0x10ea(%rip),%rax
mov    %rax,-0x170(%rbp)
mov    0x10e4(%rip),%rax
mov    %rax,-0x168(%rbp)
lea    -0x2b0(%rbp),%rdi
lea    0xf87(%rip),%rsi
mov    $0x135,%edx
call   1040 <memcpy@plt>
lea    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rdx
lea    -0x18(%rbp),%r8
mov    $0x8,%ecx
mov    %ecx,%esi
call   1050 <rc4_TestOne@plt>
lea    -0x22(%rbp),%rdi
lea    -0x1d(%rbp),%rdx
lea    -0x27(%rbp),%r8
mov    $0x5,%ecx
mov    %ecx,%esi
call   1050 <rc4_TestOne@plt>
lea    -0x170(%rbp),%rdi
lea    -0x160(%rbp),%rdx
lea    -0x2b0(%rbp),%r8
mov    $0x10,%esi
mov    $0x135,%ecx
call   1050 <rc4_TestOne@plt>
xor    %eax,%eax
add    $0x2b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rc4_SelfTest>:
push   %r14
push   %rbx
sub    $0x2b8,%rsp
movq   $0x0,0x28(%rsp)
movabs $0xefcdab8967452301,%rax
ab cd ef
mov    %rax,0x20(%rsp)
movabs $0x79084b10e7c29474,%rax
4b 08 79
mov    %rax,0x18(%rsp)
movb   $0x2c,0x14(%rsp)
movl   $0xf94ceedc,0x10(%rsp)
f9
movb   $0xfb,0xc(%rsp)
movl   $0xd2638a61,0x8(%rsp)
d2
movb   $0xde,0x4(%rsp)
movl   $0xc92938f1,(%rsp)
lea    0xe92(%rip),%rsi
lea    0x180(%rsp),%r14
mov    $0x135,%edx
mov    %r14,%rdi
call   1030 <memcpy@plt>
movaps 0x10f6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xfaa(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    $0x135,%edx
mov    %rbx,%rdi
call   1030 <memcpy@plt>
lea    0x20(%rsp),%rdi
lea    0x28(%rsp),%rdx
lea    0x18(%rsp),%r8
mov    $0x8,%esi
mov    $0x8,%ecx
call   1040 <rc4_TestOne@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    %rsp,%r8
mov    $0x5,%esi
mov    $0x5,%ecx
call   1040 <rc4_TestOne@plt>
lea    0x30(%rsp),%rdi
mov    $0x10,%esi
mov    %r14,%rdx
mov    $0x135,%ecx
mov    %rbx,%r8
call   1040 <rc4_TestOne@plt>
xor    %eax,%eax
add    $0x2b8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.rc4_SelfTest.k1 = [8 x i8] c"\01#Eg\89\AB\CD\EF"
@__const.rc4_SelfTest.c1 = [8 x i8] c"t\94\C2\E7\10K\08y"
@__const.rc4_SelfTest.p2 = [5 x i8] c"\DC\EEL\F9,"
@__const.rc4_SelfTest.k2 = [5 x i8] c"a\8Ac\D2\FB"
@__const.rc4_SelfTest.c2 = [5 x i8] c"\F18)\C9\DE"
@__const.rc4_SelfTest.p3 = [309 x i8] c"Ruislinnun laulu korvisssani, t\E4hk\E4p\E4iden p\E4\E4ll\E4 t\E4ysikuu. Kes\E4y\F6n on onni omanani, kaskisavuun laaksot verhouu. En ma iloitse, sure huokaa, mutta mets\E4n tummuus mulle tuokaa. Puunto pilven, mi hukkuu, siinto varan tuulisen, mi nukkuu. Tuoksut vanamon ja varjot veen, niist\E4 syd\E4meni laulun teen. - Eino Leino"
@__const.rc4_SelfTest.k3 = [16 x i8] c")\04\19r\FBB\BA_\C7\12w\12\F18)\C9"
@__const.rc4_SelfTest.c3 = [309 x i8] c"5\81\86\99\90\01\E6\B5\DA\F0^\CE\EB~\EE!\E0h\9C\1F\00\EE\A8\1F}\D2\CA\AE\E1\D2v>h\AF\0E\AD3\D6l&\8B\C9F\C4\84\FB\E9L_^\0B\86\A5\92y\E4\F8$\E7\A6@\BD\222\10\B0\A6\11`\B7\BC\E9\86\EAeh\80\03Ykc\0Ak\90\F8\E0\CA\F6\91*\98\EB\87!v\E8< ,\AAd\16m,\CEW\FF\1B\CAW\B2\13\F0\ED\1A\A7/\B8\EAR\B0\BE\01\CD\1EA(gr\0B2n\B3\89\D0\11\BDp\D8\AF\03_\B0\D8X\9D\BC\E3\C6f\F5\EA\8DLyT\C5\0C?4\0B\04g\F8\1BBYa\C1\18C\07M\F6 \F2\08@K9L\F9\D3\7F\F5K_\1A\D8\F6\EA}\A3\C5a\DF\A7(\1F\96Dc\D2\CC5\A4\D1\B04\90\DE\C5\1B\07\11\FB\D6\F5_y#M[|vf\22\A6m\E9+\E9\96F\1D^M\C8x\EF\9B\CA\03\05!\E85\1EK\AE\D2\FD\04\F9Fsh\C4\ADj\C1\86\D0\82E\B2c\A2fm\1FlT \F1Y\9D\FD\9FC\89!\C2\F5\A4c\93\8C\E0\98\22e\EE\F7\01y\BCU?3\9E\B1\A4\C1\AF_jT\7F"
define i32 @rc4_SelfTest() {
%1 = alloca [8 x i8]
%2 = alloca [8 x i8]
%3 = alloca [8 x i8]
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
%6 = alloca [5 x i8]
%7 = alloca [309 x i8]
%8 = alloca [16 x i8]
%9 = alloca [309 x i8]
%10 = bitcast [8 x i8]* %1 to i8*
%11 = bitcast [8 x i8]* %2 to i8*
%12 = bitcast [8 x i8]* %3 to i8*
%13 = bitcast [5 x i8]* %4 to i8*
%14 = bitcast [5 x i8]* %5 to i8*
%15 = bitcast [5 x i8]* %6 to i8*
%16 = bitcast [309 x i8]* %7 to i8*
%17 = bitcast [16 x i8]* %8 to i8*
%18 = bitcast [309 x i8]* %9 to i8*
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%22 = call i32 @rc4_TestOne(i8* %19, i32 8, i8* %20, i32 8, i8* %21)
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%26 = call i32 @rc4_TestOne(i8* %23, i32 5, i8* %24, i32 5, i8* %25)
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%28 = getelementptr inbounds [309 x i8], [309 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [309 x i8], [309 x i8]* %9, i64 0, i64 0
%30 = call i32 @rc4_TestOne(i8* %27, i32 16, i8* %28, i32 309, i8* %29)
ret i32 0
}

LLVM IR (-O2):
@__const.rc4_SelfTest.p2 = [5 x i8] c"\DC\EEL\F9,"
@__const.rc4_SelfTest.k2 = [5 x i8] c"a\8Ac\D2\FB"
@__const.rc4_SelfTest.c2 = [5 x i8] c"\F18)\C9\DE"
@__const.rc4_SelfTest.p3 = [309 x i8] c"Ruislinnun laulu korvisssani, t\E4hk\E4p\E4iden p\E4\E4ll\E4 t\E4ysikuu. Kes\E4y\F6n on onni omanani, kaskisavuun laaksot verhouu. En ma iloitse, sure huokaa, mutta mets\E4n tummuus mulle tuokaa. Puunto pilven, mi hukkuu, siinto varan tuulisen, mi nukkuu. Tuoksut vanamon ja varjot veen, niist\E4 syd\E4meni laulun teen. - Eino Leino"
@__const.rc4_SelfTest.k3 = [16 x i8] c")\04\19r\FBB\BA_\C7\12w\12\F18)\C9"
@__const.rc4_SelfTest.c3 = [309 x i8] c"5\81\86\99\90\01\E6\B5\DA\F0^\CE\EB~\EE!\E0h\9C\1F\00\EE\A8\1F}\D2\CA\AE\E1\D2v>h\AF\0E\AD3\D6l&\8B\C9F\C4\84\FB\E9L_^\0B\86\A5\92y\E4\F8$\E7\A6@\BD\222\10\B0\A6\11`\B7\BC\E9\86\EAeh\80\03Ykc\0Ak\90\F8\E0\CA\F6\91*\98\EB\87!v\E8< ,\AAd\16m,\CEW\FF\1B\CAW\B2\13\F0\ED\1A\A7/\B8\EAR\B0\BE\01\CD\1EA(gr\0B2n\B3\89\D0\11\BDp\D8\AF\03_\B0\D8X\9D\BC\E3\C6f\F5\EA\8DLyT\C5\0C?4\0B\04g\F8\1BBYa\C1\18C\07M\F6 \F2\08@K9L\F9\D3\7F\F5K_\1A\D8\F6\EA}\A3\C5a\DF\A7(\1F\96Dc\D2\CC5\A4\D1\B04\90\DE\C5\1B\07\11\FB\D6\F5_y#M[|vf\22\A6m\E9+\E9\96F\1D^M\C8x\EF\9B\CA\03\05!\E85\1EK\AE\D2\FD\04\F9Fsh\C4\ADj\C1\86\D0\82E\B2c\A2fm\1FlT \F1Y\9D\FD\9FC\89!\C2\F5\A4c\93\8C\E0\98\22e\EE\F7\01y\BCU?3\9E\B1\A4\C1\AF_jT\7F"
define i32 @rc4_SelfTest() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
%6 = alloca [5 x i8]
%7 = alloca [309 x i8]
%8 = alloca [16 x i8]
%9 = alloca [309 x i8]
%10 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%11 = bitcast i64* %2 to i8*
store i64 -1167088121787636991, i64* %2
%12 = bitcast i64* %3 to i8*
store i64 8721303214382814324, i64* %3
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [309 x i8], [309 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [309 x i8], [309 x i8]* %9, i64 0, i64 0
%19 = call i32 @rc4_TestOne(i8* %11, i32 8, i8* %10, i32 8, i8* %12)
%20 = call i32 @rc4_TestOne(i8* %14, i32 5, i8* %13, i32 5, i8* %15)
%21 = call i32 @rc4_TestOne(i8* %17, i32 16, i8* %16, i32 309, i8* %18)
ret i32 0
}