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

/* Variables and functions */
int rot32l3(int);
int rot32r8(int);
void RunEncryptionKeySchedule(uint8_t *key, uint8_t *roundKeys) {
  uint32_t *key32 = (uint32_t *)key;
  uint32_t *roundKeys32 = (uint32_t *)roundKeys;
  uint32_t y = key32[0];
  uint32_t x = key32[1];
  uint32_t key2 = key32[2];
  uint32_t key3 = key32[3];
  uint32_t tmp;
  uint8_t i = 0;
  while (1) {
    roundKeys32[i] = y;
    if (i == 27 - 1)
      break;
    x = (rot32r8(x) + y) ^ i++;
    y = rot32l3(y) ^ x;
    tmp = x;
    x = key2;
    key2 = key3;
    key3 = tmp;
  }
}


x86 assembly (clang, -O0):
<RunEncryptionKeySchedule>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x30(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
cmpq   $0x1a,-0x40(%rbp)
jne    118d <RunEncryptionKeySchedule+0x6d>
jmp    11da <RunEncryptionKeySchedule+0xba>
mov    -0x28(%rbp),%edi
call   1030 <rot32r8@plt>
add    -0x24(%rbp),%eax
cltq
mov    -0x40(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x40(%rbp)
xor    %rcx,%rax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <rot32l3@plt>
xor    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    116f <RunEncryptionKeySchedule+0x4f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RunEncryptionKeySchedule>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rax
mov    (%rdi),%ebp
mov    0x4(%rdi),%edi
mov    0x8(%rax),%r15d
mov    0xc(%rax),%ebx
mov    %rsi,(%rsp)
mov    %ebp,(%rsi)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%r13d
mov    %ebx,%r15d
call   1030 <rot32r8@plt>
add    %ebp,%eax
lea    0x1(%r12),%r14
mov    %r12d,%ebx
xor    %eax,%ebx
mov    %ebp,%edi
call   1040 <rot32l3@plt>
mov    %eax,%ebp
xor    %ebx,%ebp
mov    (%rsp),%rax
mov    %ebp,0x4(%rax,%r12,4)
mov    %r14,%r12
mov    %r13d,%edi
cmp    $0x1a,%r14
jne    1150 <RunEncryptionKeySchedule+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @RunEncryptionKeySchedule(i64* nocapture %0, i64* nocapture writeonly %1) {
%3 = bitcast i64* %0 to i32*
%4 = bitcast i64* %1 to i32*
%5 = load i32, i32* %3
%6 = getelementptr inbounds i32, i32* %3, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds i64, i64* %0, i64 1
%9 = bitcast i64* %8 to i32*
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %3, i64 3
%12 = load i32, i32* %11
store i32 %5, i32* %4
br label %13
13: ; preds = %2, %13
%14 = phi i64 [ 0, %2 ], [ %21, %13 ]
%15 = phi i32 [ %5, %2 ], [ %25, %13 ]
%16 = phi i32 [ %12, %2 ], [ %23, %13 ]
%17 = phi i32 [ %10, %2 ], [ %16, %13 ]
%18 = phi i32 [ %7, %2 ], [ %17, %13 ]
%19 = tail call i32 @rot32r8(i32 %18)
%20 = add nsw i32 %19, %15
%21 = add nuw nsw i64 %14, 1
%22 = trunc i64 %14 to i32
%23 = xor i32 %20, %22
%24 = tail call i32 @rot32l3(i32 %15)
%25 = xor i32 %23, %24
%26 = getelementptr inbounds i32, i32* %4, i64 %21
store i32 %25, i32* %26
%27 = icmp eq i64 %21, 26
br i1 %27, label %28, label %13
28: ; preds = %13
ret void
}