#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 */
void itm_rc4_init(unsigned char *box, int *x, int *y, const unsigned char *key,
                  int keylen) {
  int X, Y, i, j, k, a;
  if (keylen <= 0 || key == NULL) {
    X = -1;
    Y = -1;
  } else {
    X = Y = 0;
    j = k = 0;
    for (i = 0; i < 256; i++) {
      box[i] = (unsigned char)i;
    }
    for (i = 0; i < 256; i++) {
      a = box[i];
      j = (unsigned char)(j + a + key[k]);
      box[i] = box[j];
      box[j] = a;
      if (++k >= keylen)
        k = 0;
    }
  }
  x[0] = X;
  y[0] = Y;
}


x86 assembly (clang, -O0):
<itm_rc4_init>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    112d <itm_rc4_init+0x2d>
cmpq   $0x0,-0x20(%rbp)
jne    1140 <itm_rc4_init+0x40>
movl   $0xffffffff,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
jmp    1222 <itm_rc4_init+0x122>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x100,-0x30(%rbp)
jge    118e <itm_rc4_init+0x8e>
mov    -0x30(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1163 <itm_rc4_init+0x63>
movl   $0x0,-0x30(%rbp)
cmpl   $0x100,-0x30(%rbp)
jge    121d <itm_rc4_init+0x11d>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x38(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmp    -0x24(%rbp),%eax
jl     120a <itm_rc4_init+0x10a>
movl   $0x0,-0x38(%rbp)
jmp    120f <itm_rc4_init+0x10f>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1195 <itm_rc4_init+0x95>
jmp    1222 <itm_rc4_init+0x122>
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<itm_rc4_init>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%r9d
test   %rcx,%rcx
je     1225 <itm_rc4_init+0x125>
test   %r8d,%r8d
jle    1225 <itm_rc4_init+0x125>
movaps 0xedd(%rip),%xmm0
movups %xmm0,(%rdi)
movaps 0xee3(%rip),%xmm0
movups %xmm0,0x10(%rdi)
movaps 0xee8(%rip),%xmm0
movups %xmm0,0x20(%rdi)
movaps 0xeed(%rip),%xmm0
movups %xmm0,0x30(%rdi)
movaps 0xef2(%rip),%xmm0
movups %xmm0,0x40(%rdi)
movaps 0xef7(%rip),%xmm0
movups %xmm0,0x50(%rdi)
movaps 0xefc(%rip),%xmm0
movups %xmm0,0x60(%rdi)
movaps 0xf01(%rip),%xmm0
movups %xmm0,0x70(%rdi)
movaps 0xf06(%rip),%xmm0
movups %xmm0,0x80(%rdi)
movaps 0xf08(%rip),%xmm0
movups %xmm0,0x90(%rdi)
movaps 0xf0a(%rip),%xmm0
movups %xmm0,0xa0(%rdi)
movaps 0xf0c(%rip),%xmm0
movups %xmm0,0xb0(%rdi)
movaps 0xf0e(%rip),%xmm0
movups %xmm0,0xc0(%rdi)
movaps 0xf10(%rip),%xmm0
movups %xmm0,0xd0(%rdi)
movaps 0xf12(%rip),%xmm0
movups %xmm0,0xe0(%rdi)
movaps 0xf14(%rip),%xmm0
movups %xmm0,0xf0(%rdi)
xor    %r9d,%r9d
xor    %r10d,%r10d
xor    %eax,%eax
xor    %r11d,%r11d
xchg   %ax,%ax
movzbl (%rdi,%r10,1),%r14d
add    %r14b,%r11b
cltq
add    (%rcx,%rax,1),%r11b
movzbl %r11b,%ebp
movzbl (%rdi,%rbp,1),%ebx
mov    %bl,(%rdi,%r10,1)
mov    %r14b,(%rdi,%rbp,1)
add    $0x1,%eax
cmp    %r8d,%eax
cmovge %r9d,%eax
add    $0x1,%r10
cmp    $0x100,%r10
jne    11f0 <itm_rc4_init+0xf0>
mov    %r9d,(%rsi)
mov    %r9d,(%rdx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @itm_rc4_init(i8* %0, i32* %1, i32* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%17 = load i32, i32* %10
%18 = icmp sle i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %5
%20 = load i8*, i8** %9
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %23
22: ; preds = %19, %5
store i32 -1, i32* %11
store i32 -1, i32* %12
br label %85
23: ; preds = %19
store i32 0, i32* %12
store i32 0, i32* %11
store i32 0, i32* %15
store i32 0, i32* %14
store i32 0, i32* %13
br label %24
24: ; preds = %34, %23
%25 = load i32, i32* %13
%26 = icmp slt i32 %25, 256
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i32, i32* %13
%29 = trunc i32 %28 to i8
%30 = load i8*, i8** %6
%31 = load i32, i32* %13
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 %29, i8* %33
br label %34
34: ; preds = %27
%35 = load i32, i32* %13
%36 = add nsw i32 %35, 1
store i32 %36, i32* %13
br label %24
37: ; preds = %24
store i32 0, i32* %13
br label %38
38: ; preds = %81, %37
%39 = load i32, i32* %13
%40 = icmp slt i32 %39, 256
br i1 %40, label %41, label %84
41: ; preds = %38
%42 = load i8*, i8** %6
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
store i32 %47, i32* %16
%48 = load i32, i32* %14
%49 = load i32, i32* %16
%50 = add nsw i32 %48, %49
%51 = load i8*, i8** %9
%52 = load i32, i32* %15
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = add nsw i32 %50, %56
%58 = trunc i32 %57 to i8
%59 = zext i8 %58 to i32
store i32 %59, i32* %14
%60 = load i8*, i8** %6
%61 = load i32, i32* %14
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = load i8*, i8** %6
%66 = load i32, i32* %13
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
store i8 %64, i8* %68
%69 = load i32, i32* %16
%70 = trunc i32 %69 to i8
%71 = load i8*, i8** %6
%72 = load i32, i32* %14
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
store i8 %70, i8* %74
%75 = load i32, i32* %15
%76 = add nsw i32 %75, 1
store i32 %76, i32* %15
%77 = load i32, i32* %10
%78 = icmp sge i32 %76, %77
br i1 %78, label %79, label %80
79: ; preds = %41
store i32 0, i32* %15
br label %80
80: ; preds = %79, %41
br label %81
81: ; preds = %80
%82 = load i32, i32* %13
%83 = add nsw i32 %82, 1
store i32 %83, i32* %13
br label %38
84: ; preds = %38
br label %85
85: ; preds = %84, %22
%86 = load i32, i32* %11
%87 = load i32*, i32** %7
%88 = getelementptr inbounds i32, i32* %87, i64 0
store i32 %86, i32* %88
%89 = load i32, i32* %12
%90 = load i32*, i32** %8
%91 = getelementptr inbounds i32, i32* %90, i64 0
store i32 %89, i32* %91
ret void
}

LLVM IR (-O2):
define void @itm_rc4_init(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i8* %3, i32 %4) {
%6 = icmp slt i32 %4, 1
%7 = icmp eq i8* %3, null
%8 = or i1 %7, %6
br i1 %8, label %60, label %9
9: ; preds = %5
%10 = bitcast i8* %0 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %10
%11 = getelementptr inbounds i8, i8* %0, i64 16
%12 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %12
%13 = getelementptr inbounds i8, i8* %0, i64 32
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %14
%15 = getelementptr inbounds i8, i8* %0, i64 48
%16 = bitcast i8* %15 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %16
%17 = getelementptr inbounds i8, i8* %0, i64 64
%18 = bitcast i8* %17 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %18
%19 = getelementptr inbounds i8, i8* %0, i64 80
%20 = bitcast i8* %19 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %20
%21 = getelementptr inbounds i8, i8* %0, i64 96
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %22
%23 = getelementptr inbounds i8, i8* %0, i64 112
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %24
%25 = getelementptr inbounds i8, i8* %0, i64 128
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %26
%27 = getelementptr inbounds i8, i8* %0, i64 144
%28 = bitcast i8* %27 to <16 x i8>*
store <16 x i8> <i8 -112, i8 -111, i8 -110, i8 -109, i8 -108, i8 -107, i8 -106, i8 -105, i8 -104, i8 -103, i8 -102, i8 -101, i8 -100, i8 -99, i8 -98, i8 -97>, <16 x i8>* %28
%29 = getelementptr inbounds i8, i8* %0, i64 160
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> <i8 -96, i8 -95, i8 -94, i8 -93, i8 -92, i8 -91, i8 -90, i8 -89, i8 -88, i8 -87, i8 -86, i8 -85, i8 -84, i8 -83, i8 -82, i8 -81>, <16 x i8>* %30
%31 = getelementptr inbounds i8, i8* %0, i64 176
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> <i8 -80, i8 -79, i8 -78, i8 -77, i8 -76, i8 -75, i8 -74, i8 -73, i8 -72, i8 -71, i8 -70, i8 -69, i8 -68, i8 -67, i8 -66, i8 -65>, <16 x i8>* %32
%33 = getelementptr inbounds i8, i8* %0, i64 192
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> <i8 -64, i8 -63, i8 -62, i8 -61, i8 -60, i8 -59, i8 -58, i8 -57, i8 -56, i8 -55, i8 -54, i8 -53, i8 -52, i8 -51, i8 -50, i8 -49>, <16 x i8>* %34
%35 = getelementptr inbounds i8, i8* %0, i64 208
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> <i8 -48, i8 -47, i8 -46, i8 -45, i8 -44, i8 -43, i8 -42, i8 -41, i8 -40, i8 -39, i8 -38, i8 -37, i8 -36, i8 -35, i8 -34, i8 -33>, <16 x i8>* %36
%37 = getelementptr inbounds i8, i8* %0, i64 224
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> <i8 -32, i8 -31, i8 -30, i8 -29, i8 -28, i8 -27, i8 -26, i8 -25, i8 -24, i8 -23, i8 -22, i8 -21, i8 -20, i8 -19, i8 -18, i8 -17>, <16 x i8>* %38
%39 = getelementptr inbounds i8, i8* %0, i64 240
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> <i8 -16, i8 -15, i8 -14, i8 -13, i8 -12, i8 -11, i8 -10, i8 -9, i8 -8, i8 -7, i8 -6, i8 -5, i8 -4, i8 -3, i8 -2, i8 -1>, <16 x i8>* %40
br label %41
41: ; preds = %9, %41
%42 = phi i64 [ %58, %41 ], [ 0, %9 ]
%43 = phi i32 [ %57, %41 ], [ 0, %9 ]
%44 = phi i8 [ %51, %41 ], [ 0, %9 ]
%45 = getelementptr inbounds i8, i8* %0, i64 %42
%46 = load i8, i8* %45
%47 = add i8 %46, %44
%48 = sext i32 %43 to i64
%49 = getelementptr inbounds i8, i8* %3, i64 %48
%50 = load i8, i8* %49
%51 = add i8 %47, %50
%52 = zext i8 %51 to i64
%53 = getelementptr inbounds i8, i8* %0, i64 %52
%54 = load i8, i8* %53
store i8 %54, i8* %45
store i8 %46, i8* %53
%55 = add nsw i32 %43, 1
%56 = icmp slt i32 %55, %4
%57 = select i1 %56, i32 %55, i32 0
%58 = add nuw nsw i64 %42, 1
%59 = icmp eq i64 %58, 256
br i1 %59, label %60, label %41
60: ; preds = %41, %5
%61 = phi i32 [ -1, %5 ], [ 0, %41 ]
store i32 %61, i32* %1
store i32 %61, i32* %2
ret void
}