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

/* Variables and functions */
int /*<<< orphan*/ RC4(int /*<<< orphan*/ *, size_t, unsigned char *,
                       unsigned char *);
int /*<<< orphan*/ RC4_set_key(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, size_t);
int /*<<< orphan*/ strlen(char *);
void info_rc4_cipher(unsigned char *data, unsigned char *key, size_t len) {
  RC4_KEY rc4_key;
  unsigned char tmp[len + 1];
  RC4_set_key(&rc4_key, strlen((char *)key), key);
  tmp[len] = '\0';
  memcpy(tmp, data, len);
  RC4(&rc4_key, len, tmp, data);
}


x86 assembly (clang, -O0):
<info_rc4_cipher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
lea    -0x1c(%rbp),%rdi
call   1060 <RC4_set_key@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rax
movb   $0x0,(%rdi,%rax,1)
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
call   1040 <RC4@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<info_rc4_cipher>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,-0x30(%rbp)
mov    %rsp,%rbx
lea    0x10(%rdx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsi,%rdi
call   1030 <strlen@plt>
lea    -0x34(%rbp),%r13
mov    %r13,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1060 <RC4_set_key@plt>
movb   $0x0,(%r12,%rbx,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <RC4@plt>
mov    -0x30(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @info_rc4_cipher(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%10 = load i64, i64* %6
%11 = add i64 %10, 1
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %8
%13 = alloca i8, i64 %11
store i64 %11, i64* %9
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
%16 = load i8*, i8** %5
%17 = call i32 @RC4_set_key(i32* %7, i32 %15, i8* %16)
%18 = load i64, i64* %6
%19 = getelementptr inbounds i8, i8* %13, i64 %18
store i8 0, i8* %19
%20 = load i8*, i8** %4
%21 = load i64, i64* %6
%22 = call i32 @memcpy(i8* %13, i8* %20, i64 %21)
%23 = load i64, i64* %6
%24 = load i8*, i8** %4
%25 = call i32 @RC4(i32* %7, i64 %23, i8* %13, i8* %24)
%26 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
define void @info_rc4_cipher(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = add i64 %2, 1
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = tail call i32 @strlen(i8* %1)
%10 = call i32 @RC4_set_key(i32* %4, i32 %9, i8* %1)
%11 = getelementptr inbounds i8, i8* %8, i64 %2
store i8 0, i8* %11
%12 = call i32 @memcpy(i8* %8, i8* %0, i64 %2)
%13 = call i32 @RC4(i32* %4, i64 %2, i8* %8, i8* %0)
ret void
}