#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
void RunEncryptionKeySchedule(uint8_t *key, uint8_t *roundKeys) {
  uint8_t i;
  uint32_t *Key = (uint32_t *)key;
  uint32_t *RoundKeys = (uint32_t *)roundKeys;
  for (i = 0; i < 2; i++) {
    RoundKeys[i] = Key[i];
    RoundKeys[i + 4] = Key[i + 2];
  }
  RoundKeys[2] = ((Key[1] << 31) & 0x80000000) ^ (Key[0] >> 1) ^
                 ((Key[1] >> 31) & 0x00000001);
  RoundKeys[3] = ((Key[0] << 31) & 0x80000000) ^ (Key[1] >> 1);
}


x86 assembly (clang, -O0):
<RunEncryptionKeySchedule>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    1171 <RunEncryptionKeySchedule+0x71>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x28(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <RunEncryptionKeySchedule+0x23>
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
shl    $0x1f,%ecx
and    $0x80000000,%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
sar    $0x1,%eax
xor    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
sar    $0x1f,%eax
and    $0x1,%eax
xor    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
shl    $0x1f,%ecx
and    $0x80000000,%ecx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
sar    $0x1,%eax
xor    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0xc(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<RunEncryptionKeySchedule>:
mov    (%rdi),%eax
mov    %eax,(%rsi)
mov    0x8(%rdi),%eax
mov    %eax,0x10(%rsi)
mov    0x4(%rdi),%eax
mov    %eax,0x4(%rsi)
mov    0xc(%rdi),%eax
mov    %eax,0x14(%rsi)
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
sar    %eax
bswap  %ecx
mov    %ecx,%edx
and    $0xf0f0f0f,%edx
shl    $0x4,%edx
shr    $0x4,%ecx
and    $0xf0f0f0f,%ecx
or     %edx,%ecx
mov    %ecx,%edx
and    $0x33333333,%edx
shr    $0x2,%ecx
and    $0x33333333,%ecx
lea    (%rcx,%rdx,4),%ecx
lea    (%rcx,%rcx,1),%edx
shr    %ecx
or     %edx,%ecx
and    $0x80000001,%ecx
xor    %eax,%ecx
mov    %ecx,0x8(%rsi)
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
shl    $0x1f,%eax
sar    %ecx
xor    %eax,%ecx
mov    %ecx,0xc(%rsi)
ret

LLVM IR (-O0):
define void @RunEncryptionKeySchedule(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%8 = load i32*, i32** %3
store i32* %8, i32** %6
%9 = load i32*, i32** %4
store i32* %9, i32** %7
store i32 0, i32* %5
br label %10
10: ; preds = %34, %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %37
13: ; preds = %10
%14 = load i32*, i32** %6
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = load i32*, i32** %7
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
%23 = load i32*, i32** %6
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %23, i64 %26
%28 = load i32, i32* %27
%29 = load i32*, i32** %7
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %29, i64 %32
store i32 %28, i32* %33
br label %34
34: ; preds = %13
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %10
37: ; preds = %10
%38 = load i32*, i32** %6
%39 = getelementptr inbounds i32, i32* %38, i64 1
%40 = load i32, i32* %39
%41 = shl i32 %40, 31
%42 = and i32 %41, -2147483648
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i64 0
%45 = load i32, i32* %44
%46 = ashr i32 %45, 1
%47 = xor i32 %42, %46
%48 = load i32*, i32** %6
%49 = getelementptr inbounds i32, i32* %48, i64 1
%50 = load i32, i32* %49
%51 = ashr i32 %50, 31
%52 = and i32 %51, 1
%53 = xor i32 %47, %52
%54 = load i32*, i32** %7
%55 = getelementptr inbounds i32, i32* %54, i64 2
store i32 %53, i32* %55
%56 = load i32*, i32** %6
%57 = getelementptr inbounds i32, i32* %56, i64 0
%58 = load i32, i32* %57
%59 = shl i32 %58, 31
%60 = and i32 %59, -2147483648
%61 = load i32*, i32** %6
%62 = getelementptr inbounds i32, i32* %61, i64 1
%63 = load i32, i32* %62
%64 = ashr i32 %63, 1
%65 = xor i32 %60, %64
%66 = load i32*, i32** %7
%67 = getelementptr inbounds i32, i32* %66, i64 3
store i32 %65, i32* %67
ret void
}

LLVM IR (-O2):
define void @RunEncryptionKeySchedule(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = load i32, i32* %0
store i32 %3, i32* %1
%4 = getelementptr inbounds i32, i32* %0, i64 2
%5 = load i32, i32* %4
%6 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %5, i32* %6
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %8, i32* %9
%10 = getelementptr inbounds i32, i32* %0, i64 3
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %11, i32* %12
%13 = load i32, i32* %7
%14 = load i32, i32* %0
%15 = ashr i32 %14, 1
%16 = call i32 @llvm.bitreverse.i32(i32 %13)
%17 = and i32 %16, -2147483647
%18 = xor i32 %17, %15
%19 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %18, i32* %19
%20 = load i32, i32* %0
%21 = shl i32 %20, 31
%22 = load i32, i32* %7
%23 = ashr i32 %22, 1
%24 = xor i32 %23, %21
%25 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %24, i32* %25
ret void
}