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

/* Variables and functions */
int /*<<< orphan*/ READ_ROUND_KEY_DOUBLE_WORD(int /*<<< orphan*/);
int /*<<< orphan*/ doubleRound(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/, int /*<<< orphan*/);
void Encrypt(uint8_t *block, uint8_t *roundKeys) {
  uint8_t i;
  uint32_t *rk = (uint32_t *)roundKeys;
  uint32_t *rightPtr = (uint32_t *)block;
  uint32_t *leftPtr = (rightPtr + 1);
  uint32_t rk2i;
  uint32_t rk2ip1;
  for (i = 0; i < 42 / 2; ++i) {
    rk2i = READ_ROUND_KEY_DOUBLE_WORD(rk[2 * i]);
    rk2ip1 = READ_ROUND_KEY_DOUBLE_WORD(rk[2 * i + 1]);
    doubleRound(leftPtr, rightPtr, rk2i, rk2ip1);
  }
}


x86 assembly (clang, -O0):
<Encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x15,-0x14(%rbp)
jge    11b1 <Encrypt+0x91>
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <READ_ROUND_KEY_DOUBLE_WORD@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <READ_ROUND_KEY_DOUBLE_WORD@plt>
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
call   1030 <doubleRound@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <Encrypt+0x33>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x4(%rdi),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12,%rbx,8),%edi
call   1040 <READ_ROUND_KEY_DOUBLE_WORD@plt>
mov    %eax,%ebp
mov    0x4(%r12,%rbx,8),%edi
call   1040 <READ_ROUND_KEY_DOUBLE_WORD@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <doubleRound@plt>
add    $0x1,%rbx
cmp    $0x15,%rbx
jne    1140 <Encrypt+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @Encrypt(i32* %0, i32* nocapture %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 1
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %15, %4 ]
%6 = shl nuw nsw i64 %5, 1
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = load i32, i32* %7
%9 = tail call i32 @READ_ROUND_KEY_DOUBLE_WORD(i32 %8)
%10 = or i64 %6, 1
%11 = getelementptr inbounds i32, i32* %1, i64 %10
%12 = load i32, i32* %11
%13 = tail call i32 @READ_ROUND_KEY_DOUBLE_WORD(i32 %12)
%14 = tail call i32 @doubleRound(i32* %3, i32* %0, i32 %9, i32 %13)
%15 = add nuw nsw i64 %5, 1
%16 = icmp eq i64 %15, 21
br i1 %16, label %17, label %4
17: ; preds = %4
ret void
}