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

/* Variables and functions */
void RunEncryptionKeySchedule(uint8_t *key, uint8_t *roundKeys) {
  uint8_t i;
  for (i = 0; i < 20; i++) {
    if (i % 2) {
      roundKeys[i] = key[i >> 1] & 0xF;
    } else {
      roundKeys[i] = (key[i >> 1] >> 4) & 0xF;
    }
  }
}


x86 assembly (clang, -O0):
<RunEncryptionKeySchedule>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    1188 <RunEncryptionKeySchedule+0x88>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1154 <RunEncryptionKeySchedule+0x54>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sar    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
and    $0xf,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1175 <RunEncryptionKeySchedule+0x75>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sar    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
sar    $0x4,%edx
and    $0xf,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    117a <RunEncryptionKeySchedule+0x7a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <RunEncryptionKeySchedule+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<RunEncryptionKeySchedule>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rdi,%rax,2),%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
mov    %ecx,(%rsi,%rax,4)
mov    (%rdi,%rax,2),%ecx
and    $0xf,%ecx
mov    %ecx,0x4(%rsi,%rax,4)
add    $0x2,%rax
cmp    $0x14,%rax
jne    1110 <RunEncryptionKeySchedule+0x10>
ret

LLVM IR (-O0):
define void @RunEncryptionKeySchedule(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %39, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %42
9: ; preds = %6
%10 = load i32, i32* %5
%11 = srem i32 %10, 2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i32*, i32** %3
%15 = load i32, i32* %5
%16 = ashr i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %14, i64 %17
%19 = load i32, i32* %18
%20 = and i32 %19, 15
%21 = load i32*, i32** %4
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
br label %38
25: ; preds = %9
%26 = load i32*, i32** %3
%27 = load i32, i32* %5
%28 = ashr i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %26, i64 %29
%31 = load i32, i32* %30
%32 = ashr i32 %31, 4
%33 = and i32 %32, 15
%34 = load i32*, i32** %4
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
br label %38
38: ; preds = %25, %13
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %6
42: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @RunEncryptionKeySchedule(i32* nocapture %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %17, %3 ]
%5 = lshr exact i64 %4, 1
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = load i32, i32* %6
%8 = lshr i32 %7, 4
%9 = and i32 %8, 15
%10 = getelementptr inbounds i32, i32* %1, i64 %4
store i32 %9, i32* %10
%11 = or i64 %4, 1
%12 = lshr exact i64 %4, 1
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = and i32 %14, 15
%16 = getelementptr inbounds i32, i32* %1, i64 %11
store i32 %15, i32* %16
%17 = add nuw nsw i64 %4, 2
%18 = icmp eq i64 %17, 20
br i1 %18, label %19, label %3
19: ; preds = %3
ret void
}