#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 */

/* Variables and functions */
int RC4(int *, int *);
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int K[256];
  int S[256];
  int IV[3];
  int key[13] = {1, 2, 3, 4, 5, 66, 75, 123, 99, 100, 123, 43, 213};
  int seed[16];
  int N = 256;
  int i, j, k, t, x, A;
  int keystream, keybyte;
  int max_result, max_count;
  int results[256];
  int known_j, known_S;
  if (argc < 2) {
    printf("Usage: %s <keybyte to attack>\n", argv[0]);
    exit(0);
  }
  A = atoi(argv[1]);
  if ((A > 12) || (A < 0)) {
    printf("keybyte must be from 0 to 12.\n");
    exit(0);
  }
  for (k = 0; k < 256; k++)
    results[k] = 0;
  IV[0] = A + 3;
  IV[1] = N - 1;
  for (x = 0; x < 256; x++) {
    IV[2] = x;
    keystream = RC4(IV, key);
    printf("Using IV: (%d, %d, %d), first keystream byte is %u\n", IV[0], IV[1],
           IV[2], keystream);
    printf("Doing the first %d steps of KSA..  ", A + 3);
    for (k = 0; k < 3; k++)
      seed[k] = IV[k];
    for (k = 0; k < 13; k++)
      seed[k + 3] = key[k];
    for (k = 0; k < 256; k++) {
      S[k] = k;
      K[k] = seed[k % 16];
    }
    j = 0;
    for (i = 0; i < (A + 3); i++) {
      j = (j + S[i] + K[i]) % 256;
      t = S[i];
      S[i] = S[j];
      S[j] = t;
    }
    if (j < 2) {
      printf("S[0] or S[1] have been disturbed, discarding..\n");
    } else {
      known_j = j;
      known_S = S[A + 3];
      printf("at KSA iteration #%d, j=%d and S[%d]=%d\n", A + 3, known_j, A + 3,
             known_S);
      keybyte = keystream - known_j - known_S;
      while (keybyte < 0)
        keybyte = keybyte + 256;
      printf("key[%d] prediction = %d - %d - %d = %d\n", A, keystream, known_j,
             known_S, keybyte);
      results[keybyte] = results[keybyte] + 1;
    }
  }
  max_result = -1;
  max_count = 0;
  for (k = 0; k < 256; k++) {
    if (max_count < results[k]) {
      max_count = results[k];
      max_result = k;
    }
  }
  printf("\nFrequency table for key[%d] (* = most frequent)\n", A);
  for (k = 0; k < 32; k++) {
    for (i = 0; i < 8; i++) {
      t = k + i * 32;
      if (max_result == t)
        printf("%3d %2d*| ", t, results[t]);
      else
        printf("%3d %2d | ", t, results[t]);
    }
    printf("\n");
  }
  printf("\n[Actual Key] = (");
  for (k = 0; k < 12; k++)
    printf("%d, ", key[k]);
  printf("%d)\n", key[12]);
  printf("key[%d] is probably %d\n", A, max_result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xcd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x850(%rbp),%rdi
lea    0xe89(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
movl   $0x100,-0x894(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b1 <main+0x61>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x8ac(%rbp)
cmpl   $0xc,-0x8ac(%rbp)
jg     11de <main+0x8e>
cmpl   $0x0,-0x8ac(%rbp)
jge    11f3 <main+0xa3>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x8a0(%rbp)
cmpl   $0x100,-0x8a0(%rbp)
jge    1233 <main+0xe3>
movslq -0x8a0(%rbp),%rax
movl   $0x0,-0xcc0(%rbp,%rax,4)
mov    -0x8a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a0(%rbp)
jmp    11fd <main+0xad>
mov    -0x8ac(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x81c(%rbp)
mov    -0x894(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x818(%rbp)
movl   $0x0,-0x8a8(%rbp)
cmpl   $0x100,-0x8a8(%rbp)
jge    158d <main+0x43d>
mov    -0x8a8(%rbp),%eax
mov    %eax,-0x814(%rbp)
lea    -0x81c(%rbp),%rdi
lea    -0x850(%rbp),%rsi
call   1030 <RC4@plt>
mov    %eax,-0x8b0(%rbp)
mov    -0x81c(%rbp),%esi
mov    -0x818(%rbp),%edx
mov    -0x814(%rbp),%ecx
mov    -0x8b0(%rbp),%r8d
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8ac(%rbp),%esi
add    $0x3,%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8a0(%rbp)
cmpl   $0x3,-0x8a0(%rbp)
jge    1315 <main+0x1c5>
movslq -0x8a0(%rbp),%rax
mov    -0x81c(%rbp,%rax,4),%ecx
movslq -0x8a0(%rbp),%rax
mov    %ecx,-0x890(%rbp,%rax,4)
mov    -0x8a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a0(%rbp)
jmp    12d8 <main+0x188>
movl   $0x0,-0x8a0(%rbp)
cmpl   $0xd,-0x8a0(%rbp)
jge    1360 <main+0x210>
movslq -0x8a0(%rbp),%rax
mov    -0x850(%rbp,%rax,4),%ecx
mov    -0x8a0(%rbp),%eax
add    $0x3,%eax
cltq
mov    %ecx,-0x890(%rbp,%rax,4)
mov    -0x8a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a0(%rbp)
jmp    131f <main+0x1cf>
movl   $0x0,-0x8a0(%rbp)
cmpl   $0x100,-0x8a0(%rbp)
jge    13c8 <main+0x278>
mov    -0x8a0(%rbp),%ecx
movslq -0x8a0(%rbp),%rax
mov    %ecx,-0x810(%rbp,%rax,4)
mov    -0x8a0(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x890(%rbp,%rax,4),%ecx
movslq -0x8a0(%rbp),%rax
mov    %ecx,-0x410(%rbp,%rax,4)
mov    -0x8a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a0(%rbp)
jmp    136a <main+0x21a>
movl   $0x0,-0x89c(%rbp)
movl   $0x0,-0x898(%rbp)
mov    -0x898(%rbp),%eax
mov    -0x8ac(%rbp),%ecx
add    $0x3,%ecx
cmp    %ecx,%eax
jge    147b <main+0x32b>
mov    -0x89c(%rbp),%eax
movslq -0x898(%rbp),%rcx
add    -0x810(%rbp,%rcx,4),%eax
movslq -0x898(%rbp),%rcx
add    -0x410(%rbp,%rcx,4),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x89c(%rbp)
movslq -0x898(%rbp),%rax
mov    -0x810(%rbp,%rax,4),%eax
mov    %eax,-0x8a4(%rbp)
movslq -0x89c(%rbp),%rax
mov    -0x810(%rbp,%rax,4),%ecx
movslq -0x898(%rbp),%rax
mov    %ecx,-0x810(%rbp,%rax,4)
mov    -0x8a4(%rbp),%ecx
movslq -0x89c(%rbp),%rax
mov    %ecx,-0x810(%rbp,%rax,4)
mov    -0x898(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x898(%rbp)
jmp    13dc <main+0x28c>
cmpl   $0x2,-0x89c(%rbp)
jge    149b <main+0x34b>
lea    0xc3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1574 <main+0x424>
mov    -0x89c(%rbp),%eax
mov    %eax,-0xcc4(%rbp)
mov    -0x8ac(%rbp),%eax
add    $0x3,%eax
cltq
mov    -0x810(%rbp,%rax,4),%eax
mov    %eax,-0xcc8(%rbp)
mov    -0x8ac(%rbp),%esi
add    $0x3,%esi
mov    -0xcc4(%rbp),%edx
mov    -0x8ac(%rbp),%ecx
add    $0x3,%ecx
mov    -0xcc8(%rbp),%r8d
lea    0xc15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8b0(%rbp),%eax
sub    -0xcc4(%rbp),%eax
sub    -0xcc8(%rbp),%eax
mov    %eax,-0x8b4(%rbp)
cmpl   $0x0,-0x8b4(%rbp)
jge    1527 <main+0x3d7>
mov    -0x8b4(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x8b4(%rbp)
jmp    1504 <main+0x3b4>
mov    -0x8ac(%rbp),%esi
mov    -0x8b0(%rbp),%edx
mov    -0xcc4(%rbp),%ecx
mov    -0xcc8(%rbp),%r8d
mov    -0x8b4(%rbp),%r9d
lea    0xbd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x8b4(%rbp),%rax
mov    -0xcc0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
movslq -0x8b4(%rbp),%rax
mov    %ecx,-0xcc0(%rbp,%rax,4)
jmp    1579 <main+0x429>
mov    -0x8a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a8(%rbp)
jmp    125b <main+0x10b>
movl   $0xffffffff,-0x8b8(%rbp)
ff ff ff
movl   $0x0,-0x8bc(%rbp)
movl   $0x0,-0x8a0(%rbp)
cmpl   $0x100,-0x8a0(%rbp)
jge    160e <main+0x4be>
mov    -0x8bc(%rbp),%eax
movslq -0x8a0(%rbp),%rcx
cmp    -0xcc0(%rbp,%rcx,4),%eax
jge    15f5 <main+0x4a5>
movslq -0x8a0(%rbp),%rax
mov    -0xcc0(%rbp,%rax,4),%eax
mov    %eax,-0x8bc(%rbp)
mov    -0x8a0(%rbp),%eax
mov    %eax,-0x8b8(%rbp)
jmp    15fa <main+0x4aa>
mov    -0x8a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a0(%rbp)
jmp    15ab <main+0x45b>
mov    -0x8ac(%rbp),%esi
lea    0xb30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8a0(%rbp)
cmpl   $0x20,-0x8a0(%rbp)
jge    16fd <main+0x5ad>
movl   $0x0,-0x898(%rbp)
cmpl   $0x8,-0x898(%rbp)
jge    16db <main+0x58b>
mov    -0x8a0(%rbp),%eax
mov    -0x898(%rbp),%ecx
shl    $0x5,%ecx
add    %ecx,%eax
mov    %eax,-0x8a4(%rbp)
mov    -0x8b8(%rbp),%eax
cmp    -0x8a4(%rbp),%eax
jne    16a0 <main+0x550>
mov    -0x8a4(%rbp),%esi
movslq -0x8a4(%rbp),%rax
mov    -0xcc0(%rbp,%rax,4),%edx
lea    0xae9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16c2 <main+0x572>
mov    -0x8a4(%rbp),%esi
movslq -0x8a4(%rbp),%rax
mov    -0xcc0(%rbp,%rax,4),%edx
lea    0xacd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16c7 <main+0x577>
mov    -0x898(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x898(%rbp)
jmp    1643 <main+0x4f3>
lea    0xacb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a0(%rbp)
jmp    162c <main+0x4dc>
lea    0xa8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8a0(%rbp)
cmpl   $0xc,-0x8a0(%rbp)
jge    1752 <main+0x602>
movslq -0x8a0(%rbp),%rax
mov    -0x850(%rbp,%rax,4),%esi
lea    0xa6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a0(%rbp)
jmp    1715 <main+0x5c5>
mov    -0x820(%rbp),%esi
lea    0xa4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8ac(%rbp),%esi
mov    -0x8b8(%rbp),%edx
lea    0xa36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xcd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc98,%rsp
mov    0xea9(%rip),%eax
mov    %eax,0x40(%rsp)
movaps 0xe8e(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe72(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe56(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
cmp    $0x1,%edi
jle    1722 <main+0x5b2>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
cmp    $0xc,%eax
ja     173a <main+0x5ca>
mov    %eax,%ebx
lea    0x90(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    %ebx,(%rsp)
add    $0x3,%ebx
mov    %ebx,0x4(%rsp)
movl   $0xff,0x8(%rsp)
lea    0x5c(%rsp),%r12
lea    0x4(%rsp),%r13
xor    %ebp,%ebp
jmp    129f <main+0x12f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x490(%rsp,%rbx,4),%r12d
lea    0xe8c(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%r15,%r12,1),%eax
mov    %r14d,%r13d
sub    %eax,%r13d
test   %r13d,%r13d
mov    $0x0,%ecx
cmovle %ecx,%r13d
add    %eax,%r13d
sub    %r14d,%r13d
add    $0xff,%r13d
and    $0xffffff00,%r13d
add    %r14d,%r13d
sub    %eax,%r13d
lea    0xe6d(%rip),%rdi
mov    (%rsp),%esi
mov    %r14d,%edx
mov    %r15d,%ecx
mov    %r12d,%r8d
lea    0x5c(%rsp),%r12
mov    %r13d,%r9d
xor    %eax,%eax
call   1060 <printf@plt>
addl   $0x1,0x90(%rsp,%r13,4)
lea    0x4(%rsp),%r13
add    $0x1,%ebp
cmp    $0x100,%ebp
je     13db <main+0x26b>
mov    %ebp,0xc(%rsp)
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
call   1050 <RC4@plt>
mov    %eax,%r14d
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xd8d(%rip),%rdi
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdb0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%rax
mov    %rax,0x50(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x58(%rsp)
mov    0x40(%rsp),%eax
mov    %eax,0x30(%r12)
movaps 0x10(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
movaps 0x30(%rsp),%xmm2
movups %xmm2,0x20(%r12)
movups %xmm1,0x10(%r12)
movups %xmm0,(%r12)
xor    %eax,%eax
nopl   (%rax)
mov    %eax,0x490(%rsp,%rax,4)
mov    %eax,%ecx
and    $0xe,%ecx
mov    0x50(%rsp,%rcx,4),%ecx
mov    %ecx,0x890(%rsp,%rax,4)
lea    0x1(%rax),%rcx
mov    %ecx,0x494(%rsp,%rax,4)
and    $0xf,%ecx
mov    0x50(%rsp,%rcx,4),%ecx
mov    %ecx,0x894(%rsp,%rax,4)
add    $0x2,%rax
cmp    $0x100,%rax
jne    1320 <main+0x1b0>
xor    %eax,%eax
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x490(%rsp,%rax,4),%ecx
add    %ecx,%r15d
mov    0x890(%rsp,%rax,4),%edx
lea    (%rdx,%r15,1),%esi
add    $0xff,%esi
mov    %r15d,%edi
add    %edx,%edi
cmovns %edi,%esi
and    $0xffffff00,%esi
mov    %edi,%r15d
sub    %esi,%r15d
movslq %r15d,%rdx
mov    0x490(%rsp,%rdx,4),%esi
mov    %esi,0x490(%rsp,%rax,4)
mov    %ecx,0x490(%rsp,%rdx,4)
add    $0x1,%rax
cmp    %rax,%rbx
jne    1370 <main+0x200>
cmp    $0x1,%r15d
jg     1210 <main+0xa0>
lea    0xda7(%rip),%rdi
call   1040 <puts@plt>
jmp    1290 <main+0x120>
mov    $0xffffffff,%r13d
xor    %eax,%eax
xor    %ecx,%ecx
mov    (%rsp),%esi
jmp    13fe <main+0x28e>
nopw   0x0(%rax,%rax,1)
mov    %edi,%ecx
add    $0x4,%rax
cmp    $0x100,%rax
je     1455 <main+0x2e5>
mov    0x90(%rsp,%rax,4),%edi
cmp    %edi,%ecx
cmovl  %eax,%r13d
mov    0x94(%rsp,%rax,4),%edx
cmovl  %edi,%ecx
cmp    %edx,%ecx
jl     1420 <main+0x2b0>
mov    %ecx,%edx
jmp    1424 <main+0x2b4>
nopl   (%rax)
lea    0x1(%rax),%r13d
mov    0x98(%rsp,%rax,4),%edi
cmp    %edi,%edx
jl     1440 <main+0x2d0>
mov    %edx,%edi
jmp    1444 <main+0x2d4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x2(%rax),%r13d
mov    0x9c(%rsp,%rax,4),%ecx
cmp    %ecx,%edi
jge    13f0 <main+0x280>
lea    0x3(%rax),%r13d
jmp    13f2 <main+0x282>
lea    0xca0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13d,%r14d
lea    0xcc1(%rip),%r15
lea    0xcc5(%rip),%r12
xor    %ebx,%ebx
jmp    14b3 <main+0x343>
nopl   0x0(%rax,%rax,1)
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffff21,%rbp
mov    %rbp,%rbx
cmp    $0x20,%rbp
je     162b <main+0x4bb>
cmp    %rbx,%r14
jne    14d0 <main+0x360>
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
jmp    14dc <main+0x36c>
nopl   0x0(%rax,%rax,1)
mov    0x90(%rsp,%rbx,4),%edx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%rbx),%rbp
cmp    %r14,%rbp
jne    1500 <main+0x390>
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
jmp    150d <main+0x39d>
nopl   0x0(%rax)
mov    0x110(%rsp,%rbx,4),%edx
lea    0x20(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x20,%rbp
cmp    %r14,%rbp
jne    1530 <main+0x3c0>
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
jmp    153d <main+0x3cd>
nopl   (%rax)
mov    0x190(%rsp,%rbx,4),%edx
lea    0x40(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x20,%rbp
cmp    %r14,%rbp
jne    1560 <main+0x3f0>
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
jmp    156d <main+0x3fd>
nopl   (%rax)
mov    0x210(%rsp,%rbx,4),%edx
lea    0x60(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x20,%rbp
cmp    %r14,%rbp
jne    1590 <main+0x420>
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
jmp    15a0 <main+0x430>
nopl   (%rax)
mov    0x290(%rsp,%rbx,4),%edx
lea    0x80(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x20,%rbp
cmp    %r14,%rbp
jne    15c0 <main+0x450>
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
jmp    15d0 <main+0x460>
mov    0x310(%rsp,%rbx,4),%edx
lea    0xa0(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x20,%rbp
cmp    %r14,%rbp
jne    15f0 <main+0x480>
mov    0x90(%rsp,%r14,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
jmp    1600 <main+0x490>
mov    0x390(%rsp,%rbx,4),%edx
lea    0xc0(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x20,%rbp
cmp    %r14,%rbp
je     1480 <main+0x310>
mov    0x410(%rsp,%rbx,4),%edx
add    $0xe0,%ebx
mov    %r12,%rdi
mov    %ebx,%esi
jmp    148e <main+0x31e>
lea    0xb12(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xb12(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x40(%rsp),%esi
lea    0xa68(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xa5f(%rip),%rdi
mov    (%rsp),%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xc98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsi),%rsi
lea    0x908(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xa66(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@__const.main.key = [13 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 66, i32 75, i32 123, i32 99, i32 100, i32 123, i32 43, i32 213]
@.str = [31 x i8] c"Usage: %s <keybyte to attack>\0A\00"
@.str.1 = [31 x i8] c"keybyte must be from 0 to 12.\0A\00"
@.str.2 = [52 x i8] c"Using IV: (%d, %d, %d), first keystream byte is %u\0A\00"
@.str.3 = [36 x i8] c"Doing the first %d steps of KSA.. \00"
@.str.4 = [48 x i8] c"S[0] or S[1] have been disturbed, discarding..\0A\00"
@.str.5 = [41 x i8] c"at KSA iteration #%d, j=%d and S[%d]=%d\0A\00"
@.str.6 = [40 x i8] c"key[%d] prediction = %d - %d - %d = %d\0A\00"
@.str.7 = [50 x i8] c"\0AFrequency table for key[%d] (* = most frequent)\0A\00"
@.str.8 = [11 x i8] c"%3d %2d*| \00"
@.str.9 = [11 x i8] c"%3d %2d | \00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [18 x i8] c"\0A[Actual Key] = (\00"
@.str.12 = [5 x i8] c"%d, \00"
@.str.13 = [5 x i8] c"%d)\0A\00"
@.str.14 = [24 x i8] c"key[%d] is probably %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32]
%7 = alloca [256 x i32]
%8 = alloca [3 x i32]
%9 = alloca [13 x i32]
%10 = alloca [16 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca [256 x i32]
%23 = alloca i32
%24 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%25 = bitcast [13 x i32]* %9 to i8*
store i32 256, i32* %11
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 2
br i1 %27, label %28, label %34
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %2
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %17
%39 = load i32, i32* %17
%40 = icmp sgt i32 %39, 12
br i1 %40, label %44, label %41
41: ; preds = %34
%42 = load i32, i32* %17
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41, %34
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %41
store i32 0, i32* %14
br label %48
48: ; preds = %55, %47
%49 = load i32, i32* %14
%50 = icmp slt i32 %49, 256
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i32, i32* %14
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [256 x i32], [256 x i32]* %22, i64 0, i64 %53
store i32 0, i32* %54
br label %55
55: ; preds = %51
%56 = load i32, i32* %14
%57 = add nsw i32 %56, 1
store i32 %57, i32* %14
br label %48
58: ; preds = %48
%59 = load i32, i32* %17
%60 = add nsw i32 %59, 3
%61 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
store i32 %60, i32* %61
%62 = load i32, i32* %11
%63 = sub nsw i32 %62, 1
%64 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
store i32 %63, i32* %64
store i32 0, i32* %16
br label %65
65: ; preds = %218, %58
%66 = load i32, i32* %16
%67 = icmp slt i32 %66, 256
br i1 %67, label %68, label %221
68: ; preds = %65
%69 = load i32, i32* %16
%70 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
store i32 %69, i32* %70
%71 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%72 = getelementptr inbounds [13 x i32], [13 x i32]* %9, i64 0, i64 0
%73 = call i32 @RC4(i32* %71, i32* %72)
store i32 %73, i32* %18
%74 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%75 = load i32, i32* %74
%76 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
%77 = load i32, i32* %76
%78 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
%79 = load i32, i32* %78
%80 = load i32, i32* %18
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %75, i32 %77, i32 %79, i32 %80)
%82 = load i32, i32* %17
%83 = add nsw i32 %82, 3
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %83)
store i32 0, i32* %14
br label %85
85: ; preds = %96, %68
%86 = load i32, i32* %14
%87 = icmp slt i32 %86, 3
br i1 %87, label %88, label %99
88: ; preds = %85
%89 = load i32, i32* %14
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 %90
%92 = load i32, i32* %91
%93 = load i32, i32* %14
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %94
store i32 %92, i32* %95
br label %96
96: ; preds = %88
%97 = load i32, i32* %14
%98 = add nsw i32 %97, 1
store i32 %98, i32* %14
br label %85
99: ; preds = %85
store i32 0, i32* %14
br label %100
100: ; preds = %112, %99
%101 = load i32, i32* %14
%102 = icmp slt i32 %101, 13
br i1 %102, label %103, label %115
103: ; preds = %100
%104 = load i32, i32* %14
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [13 x i32], [13 x i32]* %9, i64 0, i64 %105
%107 = load i32, i32* %106
%108 = load i32, i32* %14
%109 = add nsw i32 %108, 3
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %110
store i32 %107, i32* %111
br label %112
112: ; preds = %103
%113 = load i32, i32* %14
%114 = add nsw i32 %113, 1
store i32 %114, i32* %14
br label %100
115: ; preds = %100
store i32 0, i32* %14
br label %116
116: ; preds = %132, %115
%117 = load i32, i32* %14
%118 = icmp slt i32 %117, 256
br i1 %118, label %119, label %135
119: ; preds = %116
%120 = load i32, i32* %14
%121 = load i32, i32* %14
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %122
store i32 %120, i32* %123
%124 = load i32, i32* %14
%125 = srem i32 %124, 16
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %126
%128 = load i32, i32* %127
%129 = load i32, i32* %14
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %130
store i32 %128, i32* %131
br label %132
132: ; preds = %119
%133 = load i32, i32* %14
%134 = add nsw i32 %133, 1
store i32 %134, i32* %14
br label %116
135: ; preds = %116
store i32 0, i32* %13
store i32 0, i32* %12
br label %136
136: ; preds = %169, %135
%137 = load i32, i32* %12
%138 = load i32, i32* %17
%139 = add nsw i32 %138, 3
%140 = icmp slt i32 %137, %139
br i1 %140, label %141, label %172
141: ; preds = %136
%142 = load i32, i32* %13
%143 = load i32, i32* %12
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %144
%146 = load i32, i32* %145
%147 = add nsw i32 %142, %146
%148 = load i32, i32* %12
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %149
%151 = load i32, i32* %150
%152 = add nsw i32 %147, %151
%153 = srem i32 %152, 256
store i32 %153, i32* %13
%154 = load i32, i32* %12
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %155
%157 = load i32, i32* %156
store i32 %157, i32* %15
%158 = load i32, i32* %13
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %159
%161 = load i32, i32* %160
%162 = load i32, i32* %12
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %163
store i32 %161, i32* %164
%165 = load i32, i32* %15
%166 = load i32, i32* %13
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %167
store i32 %165, i32* %168
br label %169
169: ; preds = %141
%170 = load i32, i32* %12
%171 = add nsw i32 %170, 1
store i32 %171, i32* %12
br label %136
172: ; preds = %136
%173 = load i32, i32* %13
%174 = icmp slt i32 %173, 2
br i1 %174, label %175, label %177
175: ; preds = %172
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %217
177: ; preds = %172
%178 = load i32, i32* %13
store i32 %178, i32* %23
%179 = load i32, i32* %17
%180 = add nsw i32 %179, 3
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %181
%183 = load i32, i32* %182
store i32 %183, i32* %24
%184 = load i32, i32* %17
%185 = add nsw i32 %184, 3
%186 = load i32, i32* %23
%187 = load i32, i32* %17
%188 = add nsw i32 %187, 3
%189 = load i32, i32* %24
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %185, i32 %186, i32 %188, i32 %189)
%191 = load i32, i32* %18
%192 = load i32, i32* %23
%193 = sub nsw i32 %191, %192
%194 = load i32, i32* %24
%195 = sub nsw i32 %193, %194
store i32 %195, i32* %19
br label %196
196: ; preds = %199, %177
%197 = load i32, i32* %19
%198 = icmp slt i32 %197, 0
br i1 %198, label %199, label %202
199: ; preds = %196
%200 = load i32, i32* %19
%201 = add nsw i32 %200, 256
store i32 %201, i32* %19
br label %196
202: ; preds = %196
%203 = load i32, i32* %17
%204 = load i32, i32* %18
%205 = load i32, i32* %23
%206 = load i32, i32* %24
%207 = load i32, i32* %19
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %203, i32 %204, i32 %205, i32 %206, i32 %207)
%209 = load i32, i32* %19
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds [256 x i32], [256 x i32]* %22, i64 0, i64 %210
%212 = load i32, i32* %211
%213 = add nsw i32 %212, 1
%214 = load i32, i32* %19
%215 = sext i32 %214 to i64
%216 = getelementptr inbounds [256 x i32], [256 x i32]* %22, i64 0, i64 %215
store i32 %213, i32* %216
br label %217
217: ; preds = %202, %175
br label %218
218: ; preds = %217
%219 = load i32, i32* %16
%220 = add nsw i32 %219, 1
store i32 %220, i32* %16
br label %65
221: ; preds = %65
store i32 -1, i32* %20
store i32 0, i32* %21
store i32 0, i32* %14
br label %222
222: ; preds = %239, %221
%223 = load i32, i32* %14
%224 = icmp slt i32 %223, 256
br i1 %224, label %225, label %242
225: ; preds = %222
%226 = load i32, i32* %21
%227 = load i32, i32* %14
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds [256 x i32], [256 x i32]* %22, i64 0, i64 %228
%230 = load i32, i32* %229
%231 = icmp slt i32 %226, %230
br i1 %231, label %232, label %238
232: ; preds = %225
%233 = load i32, i32* %14
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds [256 x i32], [256 x i32]* %22, i64 0, i64 %234
%236 = load i32, i32* %235
store i32 %236, i32* %21
%237 = load i32, i32* %14
store i32 %237, i32* %20
br label %238
238: ; preds = %232, %225
br label %239
239: ; preds = %238
%240 = load i32, i32* %14
%241 = add nsw i32 %240, 1
store i32 %241, i32* %14
br label %222
242: ; preds = %222
%243 = load i32, i32* %17
%244 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i32 %243)
store i32 0, i32* %14
br label %245
245: ; preds = %280, %242
%246 = load i32, i32* %14
%247 = icmp slt i32 %246, 32
br i1 %247, label %248, label %283
248: ; preds = %245
store i32 0, i32* %12
br label %249
249: ; preds = %275, %248
%250 = load i32, i32* %12
%251 = icmp slt i32 %250, 8
br i1 %251, label %252, label %278
252: ; preds = %249
%253 = load i32, i32* %14
%254 = load i32, i32* %12
%255 = mul nsw i32 %254, 32
%256 = add nsw i32 %253, %255
store i32 %256, i32* %15
%257 = load i32, i32* %20
%258 = load i32, i32* %15
%259 = icmp eq i32 %257, %258
br i1 %259, label %260, label %267
260: ; preds = %252
%261 = load i32, i32* %15
%262 = load i32, i32* %15
%263 = sext i32 %262 to i64
%264 = getelementptr inbounds [256 x i32], [256 x i32]* %22, i64 0, i64 %263
%265 = load i32, i32* %264
%266 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %261, i32 %265)
br label %274
267: ; preds = %252
%268 = load i32, i32* %15
%269 = load i32, i32* %15
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds [256 x i32], [256 x i32]* %22, i64 0, i64 %270
%272 = load i32, i32* %271
%273 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %268, i32 %272)
br label %274
274: ; preds = %267, %260
br label %275
275: ; preds = %274
%276 = load i32, i32* %12
%277 = add nsw i32 %276, 1
store i32 %277, i32* %12
br label %249
278: ; preds = %249
%279 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %280
280: ; preds = %278
%281 = load i32, i32* %14
%282 = add nsw i32 %281, 1
store i32 %282, i32* %14
br label %245
283: ; preds = %245
%284 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %14
br label %285
285: ; preds = %294, %283
%286 = load i32, i32* %14
%287 = icmp slt i32 %286, 12
br i1 %287, label %288, label %297
288: ; preds = %285
%289 = load i32, i32* %14
%290 = sext i32 %289 to i64
%291 = getelementptr inbounds [13 x i32], [13 x i32]* %9, i64 0, i64 %290
%292 = load i32, i32* %291
%293 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %292)
br label %294
294: ; preds = %288
%295 = load i32, i32* %14
%296 = add nsw i32 %295, 1
store i32 %296, i32* %14
br label %285
297: ; preds = %285
%298 = getelementptr inbounds [13 x i32], [13 x i32]* %9, i64 0, i64 12
%299 = load i32, i32* %298
%300 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %299)
%301 = load i32, i32* %17
%302 = load i32, i32* %20
%303 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i32 %301, i32 %302)
%304 = load i32, i32* %3
ret i32 %304
}

LLVM IR (-O2):
@__const.main.key = [13 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 66, i32 75, i32 123, i32 99, i32 100, i32 123, i32 43, i32 213]
@.str = [31 x i8] c"Usage: %s <keybyte to attack>\0A\00"
@.str.2 = [52 x i8] c"Using IV: (%d, %d, %d), first keystream byte is %u\0A\00"
@.str.3 = [36 x i8] c"Doing the first %d steps of KSA.. \00"
@.str.5 = [41 x i8] c"at KSA iteration #%d, j=%d and S[%d]=%d\0A\00"
@.str.6 = [40 x i8] c"key[%d] prediction = %d - %d - %d = %d\0A\00"
@.str.7 = [50 x i8] c"\0AFrequency table for key[%d] (* = most frequent)\0A\00"
@.str.8 = [11 x i8] c"%3d %2d*| \00"
@.str.9 = [11 x i8] c"%3d %2d | \00"
@.str.11 = [18 x i8] c"\0A[Actual Key] = (\00"
@.str.12 = [5 x i8] c"%d, \00"
@.str.13 = [5 x i8] c"%d)\0A\00"
@.str.14 = [24 x i8] c"key[%d] is probably %d\0A\00"
@str = [47 x i8] c"S[0] or S[1] have been disturbed, discarding..\00"
@str.15 = [30 x i8] c"keybyte must be from 0 to 12.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32]
%4 = alloca [256 x i32]
%5 = alloca [3 x i32]
%6 = bitcast [3 x i32]* %5 to i8*
%7 = alloca [13 x i32]
%8 = bitcast [13 x i32]* %7 to i8*
%9 = alloca [16 x i32]
%10 = bitcast [16 x i32]* %9 to i8*
%11 = alloca [256 x i32]
%12 = bitcast [256 x i32]* %11 to i8*
%13 = bitcast [256 x i32]* %3 to i8*
%14 = bitcast [256 x i32]* %4 to i8*
%15 = icmp slt i32 %0, 2
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8*, i8** %1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = icmp ugt i32 %23, 12
br i1 %24, label %36, label %25
25: ; preds = %20
%26 = add nuw nsw i32 %23, 3
%27 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
store i32 %26, i32* %27
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 1
store i32 255, i32* %28
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
%30 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 0
%31 = zext i32 %26 to i64
%32 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %31
%33 = getelementptr inbounds [16 x i32], [16 x i32]* %9, i64 0, i64 3
%34 = bitcast i32* %33 to i8*
%35 = zext i32 %26 to i64
br label %39
36: ; preds = %20
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.15, i64 0, i64 0))
%38 = tail call i32 @exit(i32 0)
unreachable
39: ; preds = %25, %101
%40 = phi i32 [ 0, %25 ], [ %102, %101 ]
store i32 %40, i32* %29
%41 = call i32 @RC4(i32* %27, i32* %30)
%42 = load i32, i32* %27
%43 = load i32, i32* %28
%44 = load i32, i32* %29
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %42, i32 %43, i32 %44, i32 %41)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %47
47: ; preds = %47, %39
%48 = phi i64 [ 0, %39 ], [ %62, %47 ]
%49 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %48
%50 = trunc i64 %48 to i32
store i32 %50, i32* %49
%51 = and i64 %48, 14
%52 = getelementptr inbounds [16 x i32], [16 x i32]* %9, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %48
store i32 %53, i32* %54
%55 = or i64 %48, 1
%56 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %55
%57 = trunc i64 %55 to i32
store i32 %57, i32* %56
%58 = and i64 %55, 15
%59 = getelementptr inbounds [16 x i32], [16 x i32]* %9, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %55
store i32 %60, i32* %61
%62 = add nuw nsw i64 %48, 2
%63 = icmp eq i64 %62, 256
br i1 %63, label %64, label %47
64: ; preds = %47, %64
%65 = phi i64 [ %77, %64 ], [ 0, %47 ]
%66 = phi i32 [ %73, %64 ], [ 0, %47 ]
%67 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %65
%68 = load i32, i32* %67
%69 = add nsw i32 %68, %66
%70 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %65
%71 = load i32, i32* %70
%72 = add nsw i32 %69, %71
%73 = srem i32 %72, 256
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %74
%76 = load i32, i32* %75
store i32 %76, i32* %67
store i32 %68, i32* %75
%77 = add nuw nsw i64 %65, 1
%78 = icmp eq i64 %77, %35
br i1 %78, label %79, label %64
79: ; preds = %64
%80 = icmp slt i32 %73, 2
br i1 %80, label %81, label %83
81: ; preds = %79
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %101
83: ; preds = %79
%84 = load i32, i32* %32
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %26, i32 %73, i32 %26, i32 %84)
%86 = add i32 %73, %84
%87 = sub i32 %41, %86
%88 = add nuw nsw i32 %73, 255
%89 = add i32 %88, %84
%90 = call i32 @llvm.smax.i32(i32 %87, i32 0)
%91 = add i32 %89, %90
%92 = sub i32 %91, %41
%93 = and i32 %92, -256
%94 = add i32 %41, %93
%95 = sub i32 %94, %86
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %23, i32 %41, i32 %73, i32 %84, i32 %95)
%97 = zext i32 %95 to i64
%98 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %97
%99 = load i32, i32* %98
%100 = add nsw i32 %99, 1
store i32 %100, i32* %98
br label %101
101: ; preds = %81, %83
%102 = add nuw nsw i32 %40, 1
%103 = icmp eq i32 %102, 256
br i1 %103, label %104, label %39
104: ; preds = %101, %104
%105 = phi i64 [ %135, %104 ], [ 0, %101 ]
%106 = phi i32 [ %134, %104 ], [ 0, %101 ]
%107 = phi i32 [ %133, %104 ], [ -1, %101 ]
%108 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %105
%109 = load i32, i32* %108
%110 = icmp slt i32 %106, %109
%111 = trunc i64 %105 to i32
%112 = select i1 %110, i32 %111, i32 %107
%113 = select i1 %110, i32 %109, i32 %106
%114 = or i64 %105, 1
%115 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %114
%116 = load i32, i32* %115
%117 = icmp slt i32 %113, %116
%118 = trunc i64 %114 to i32
%119 = select i1 %117, i32 %118, i32 %112
%120 = select i1 %117, i32 %116, i32 %113
%121 = or i64 %105, 2
%122 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %121
%123 = load i32, i32* %122
%124 = icmp slt i32 %120, %123
%125 = trunc i64 %121 to i32
%126 = select i1 %124, i32 %125, i32 %119
%127 = select i1 %124, i32 %123, i32 %120
%128 = or i64 %105, 3
%129 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %128
%130 = load i32, i32* %129
%131 = icmp slt i32 %127, %130
%132 = trunc i64 %128 to i32
%133 = select i1 %131, i32 %132, i32 %126
%134 = select i1 %131, i32 %130, i32 %127
%135 = add nuw nsw i64 %105, 4
%136 = icmp eq i64 %135, 256
br i1 %136, label %137, label %104
137: ; preds = %104
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i32 %23)
%139 = zext i32 %133 to i64
%140 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
%141 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
%142 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
%143 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
%144 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
%145 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
%146 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
%147 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %139
br label %148
148: ; preds = %137, %236
%149 = phi i64 [ 0, %137 ], [ %238, %236 ]
%150 = icmp eq i64 %149, %139
br i1 %150, label %151, label %154
151: ; preds = %148
%152 = load i32, i32* %140
%153 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %152)
br label %159
154: ; preds = %148
%155 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %149
%156 = load i32, i32* %155
%157 = trunc i64 %149 to i32
%158 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %157, i32 %156)
br label %159
159: ; preds = %151, %154
%160 = add nuw nsw i64 %149, 32
%161 = icmp eq i64 %160, %139
br i1 %161, label %167, label %162
162: ; preds = %159
%163 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %160
%164 = load i32, i32* %163
%165 = trunc i64 %160 to i32
%166 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %165, i32 %164)
br label %170
167: ; preds = %159
%168 = load i32, i32* %141
%169 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %168)
br label %170
170: ; preds = %167, %162
%171 = add nuw nsw i64 %149, 64
%172 = icmp eq i64 %171, %139
br i1 %172, label %178, label %173
173: ; preds = %170
%174 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %171
%175 = load i32, i32* %174
%176 = trunc i64 %171 to i32
%177 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %176, i32 %175)
br label %181
178: ; preds = %170
%179 = load i32, i32* %142
%180 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %179)
br label %181
181: ; preds = %178, %173
%182 = add nuw nsw i64 %149, 96
%183 = icmp eq i64 %182, %139
br i1 %183, label %189, label %184
184: ; preds = %181
%185 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %182
%186 = load i32, i32* %185
%187 = trunc i64 %182 to i32
%188 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %187, i32 %186)
br label %192
189: ; preds = %181
%190 = load i32, i32* %143
%191 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %190)
br label %192
192: ; preds = %189, %184
%193 = add nuw nsw i64 %149, 128
%194 = icmp eq i64 %193, %139
br i1 %194, label %200, label %195
195: ; preds = %192
%196 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %193
%197 = load i32, i32* %196
%198 = trunc i64 %193 to i32
%199 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %198, i32 %197)
br label %203
200: ; preds = %192
%201 = load i32, i32* %144
%202 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %201)
br label %203
203: ; preds = %200, %195
%204 = add nuw nsw i64 %149, 160
%205 = icmp eq i64 %204, %139
br i1 %205, label %211, label %206
206: ; preds = %203
%207 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %204
%208 = load i32, i32* %207
%209 = trunc i64 %204 to i32
%210 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %209, i32 %208)
br label %214
211: ; preds = %203
%212 = load i32, i32* %145
%213 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %212)
br label %214
214: ; preds = %211, %206
%215 = add nuw nsw i64 %149, 192
%216 = icmp eq i64 %215, %139
br i1 %216, label %222, label %217
217: ; preds = %214
%218 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %215
%219 = load i32, i32* %218
%220 = trunc i64 %215 to i32
%221 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %220, i32 %219)
br label %225
222: ; preds = %214
%223 = load i32, i32* %146
%224 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %223)
br label %225
225: ; preds = %222, %217
%226 = add nuw nsw i64 %149, 224
%227 = icmp eq i64 %226, %139
br i1 %227, label %233, label %228
228: ; preds = %225
%229 = getelementptr inbounds [256 x i32], [256 x i32]* %11, i64 0, i64 %226
%230 = load i32, i32* %229
%231 = trunc i64 %226 to i32
%232 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %231, i32 %230)
br label %236
233: ; preds = %225
%234 = load i32, i32* %147
%235 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %234)
br label %236
236: ; preds = %233, %228
%237 = call i32 @putchar(i32 10)
%238 = add nuw nsw i64 %149, 1
%239 = icmp eq i64 %238, 32
br i1 %239, label %240, label %148
240: ; preds = %236
%241 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%242 = load i32, i32* %30
%243 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %242)
%244 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 1
%245 = load i32, i32* %244
%246 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %245)
%247 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 2
%248 = load i32, i32* %247
%249 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %248)
%250 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 3
%251 = load i32, i32* %250
%252 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %251)
%253 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 4
%254 = load i32, i32* %253
%255 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %254)
%256 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 5
%257 = load i32, i32* %256
%258 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %257)
%259 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 6
%260 = load i32, i32* %259
%261 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %260)
%262 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 7
%263 = load i32, i32* %262
%264 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %263)
%265 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 8
%266 = load i32, i32* %265
%267 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %266)
%268 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 9
%269 = load i32, i32* %268
%270 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %269)
%271 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 10
%272 = load i32, i32* %271
%273 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %272)
%274 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 11
%275 = load i32, i32* %274
%276 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %275)
%277 = getelementptr inbounds [13 x i32], [13 x i32]* %7, i64 0, i64 12
%278 = load i32, i32* %277
%279 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %278)
%280 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i32 %23, i32 %133)
ret i32 0
}