#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_value;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const, ...);
int main(void) {
  volatile int *rc4 = (int *)0xFF240000;
  const char *key = "Key";
  size_t keylength = 3;
  printf("%02X %02X %02X\n", key[0], key[1], key[2]);
  (*rc4) |= 1 << 25;
  *rc4 = (1 << 24) | ((int)keylength);
  *rc4 = (1 << 24) | ((int)key[0]);
  *rc4 = (1 << 24) | ((int)key[1]);
  *rc4 = (1 << 24) | ((int)key[2]);
  int rc4_value;
  int count = 0;
  unsigned char wait;
  rc4_value = *rc4;
  printf("%08X\n", rc4_value);
  while (1) {
    if (count < 9) {
      (*rc4) |= 1 << 24;
      do {
        rc4_value = *rc4;
      } while (!((rc4_value) & (1 << 24)));
      printf("%08X\n", rc4_value);
      count = count + 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xff240000,%eax
mov    %rax,-0x10(%rbp)
lea    0xed1(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x3,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x18(%rbp),%rcx
movsbl 0x1(%rcx),%edx
mov    -0x18(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
lea    0xeac(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
or     $0x2000000,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
or     $0x1000000,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
or     $0x1000000,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%ecx
or     $0x1000000,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%ecx
or     $0x1000000,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
lea    0xe3d(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x9,-0x28(%rbp)
jge    1237 <main+0x127>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
or     $0x1000000,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
and    $0x1000000,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f9 <main+0xe9>
mov    -0x24(%rbp),%eax
lea    0xdf0(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e1 <main+0xd1>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xff240000,%ebx
lea    0xee0(%rip),%rdi
mov    $0x4b,%esi
mov    $0x65,%edx
mov    $0x79,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
orl    $0x2000000,(%rbx)
movl   $0x1000003,(%rbx)
movl   $0x100004b,(%rbx)
movl   $0x1000065,(%rbx)
movl   $0x1000079,(%rbx)
mov    (%rbx),%eax
movsbl %al,%esi
lea    0xeb0(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
cmp    $0x8,%ebp
ja     1170 <main+0x60>
orl    $0x1000000,(%rbx)
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%eax
test   $0x1000000,%eax
je     1180 <main+0x70>
movsbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
jmp    1170 <main+0x60>

LLVM IR (-O0):
@.str = [4 x i8] c"Key\00"
@.str.1 = [16 x i8] c"%02X %02X %02X\0A\00"
@.str.2 = [6 x i8] c"%08X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %1
store i32* inttoptr (i64 4280549376 to i32*), i32** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
store i64 3, i64* %4
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 signext %10, i32 %14, i32 %18)
%20 = load i32*, i32** %2
%21 = load volatile i32, i32* %20
%22 = or i32 %21, 33554432
store volatile i32 %22, i32* %20
%23 = load i64, i64* %4
%24 = trunc i64 %23 to i32
%25 = or i32 16777216, %24
%26 = load i32*, i32** %2
store volatile i32 %25, i32* %26
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = or i32 16777216, %30
%32 = load i32*, i32** %2
store volatile i32 %31, i32* %32
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = or i32 16777216, %36
%38 = load i32*, i32** %2
store volatile i32 %37, i32* %38
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = or i32 16777216, %42
%44 = load i32*, i32** %2
store volatile i32 %43, i32* %44
store i32 0, i32* %6
%45 = load i32*, i32** %2
%46 = load volatile i32, i32* %45
store i32 %46, i32* %5
%47 = load i32, i32* %5
%48 = trunc i32 %47 to i8
%49 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 signext %48)
br label %50
50: ; preds = %0, %71
%51 = load i32, i32* %6
%52 = icmp slt i32 %51, 9
br i1 %52, label %53, label %71
53: ; preds = %50
%54 = load i32*, i32** %2
%55 = load volatile i32, i32* %54
%56 = or i32 %55, 16777216
store volatile i32 %56, i32* %54
br label %57
57: ; preds = %60, %53
%58 = load i32*, i32** %2
%59 = load volatile i32, i32* %58
store i32 %59, i32* %5
br label %60
60: ; preds = %57
%61 = load i32, i32* %5
%62 = and i32 %61, 16777216
%63 = icmp ne i32 %62, 0
%64 = xor i1 %63, true
br i1 %64, label %57, label %65
65: ; preds = %60
%66 = load i32, i32* %5
%67 = trunc i32 %66 to i8
%68 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 signext %67)
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
br label %71
71: ; preds = %65, %50
br label %50
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"%02X %02X %02X\0A\00"
@.str.2 = [6 x i8] c"%08X\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 signext 75, i32 101, i32 121)
%2 = load volatile i32, i32* inttoptr (i64 4280549376 to i32*)
%3 = or i32 %2, 33554432
store volatile i32 %3, i32* inttoptr (i64 4280549376 to i32*)
store volatile i32 16777219, i32* inttoptr (i64 4280549376 to i32*)
store volatile i32 16777291, i32* inttoptr (i64 4280549376 to i32*)
store volatile i32 16777317, i32* inttoptr (i64 4280549376 to i32*)
store volatile i32 16777337, i32* inttoptr (i64 4280549376 to i32*)
%4 = load volatile i32, i32* inttoptr (i64 4280549376 to i32*)
%5 = trunc i32 %4 to i8
%6 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 signext %5)
br label %7
7: ; preds = %18, %0
%8 = phi i32 [ %21, %18 ], [ 0, %0 ]
%9 = icmp ult i32 %8, 9
br label %10
10: ; preds = %7, %10
br i1 %9, label %11, label %10
11: ; preds = %10
%12 = load volatile i32, i32* inttoptr (i64 4280549376 to i32*)
%13 = or i32 %12, 16777216
store volatile i32 %13, i32* inttoptr (i64 4280549376 to i32*)
br label %14
14: ; preds = %14, %11
%15 = load volatile i32, i32* inttoptr (i64 4280549376 to i32*)
%16 = and i32 %15, 16777216
%17 = icmp eq i32 %16, 0
br i1 %17, label %14, label %18
18: ; preds = %14
%19 = trunc i32 %15 to i8
%20 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 signext %19)
%21 = add nuw nsw i32 %8, 1
br label %7
}