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

/* Variables and functions */
int /*<<< orphan*/ addRoundKey(int /*<<< orphan*/ *,
                               int /*<<< orphan*/ const *);
int /*<<< orphan*/ pLayer(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sBoxLayer(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void encrypt(uint64_t *X, const uint64_t *subkeys, const size_t nr) {
  static uint64_t Y[64];
  for (size_t i = 0; i < nr; i++) {
    addRoundKey(X, subkeys + (i * 64));
    sBoxLayer(Y, X);
    pLayer(X, Y);
  }
  addRoundKey(X, subkeys + (nr * 64));
}


x86 assembly (clang, -O0):
<encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11a7 <encrypt+0x77>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
shl    $0x6,%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <addRoundKey@plt>
mov    -0x8(%rbp),%rsi
lea    0x2ecf(%rip),%rdi
call   1030 <sBoxLayer@plt>
mov    -0x8(%rbp),%rdi
lea    0x2ebf(%rip),%rsi
call   1050 <pLayer@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114c <encrypt+0x1c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
shl    $0x6,%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <addRoundKey@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
test   %rdx,%rdx
je     118e <encrypt+0x5e>
lea    0x2f00(%rip),%r12
mov    %r14,%rbx
mov    %r15,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <addRoundKey@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <sBoxLayer@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <pLayer@plt>
add    $0x100,%rbx
add    $0xffffffffffffffff,%rbp
jne    1160 <encrypt+0x30>
shl    $0x8,%r15
add    %r15,%r14
mov    %r13,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <addRoundKey@plt>

LLVM IR (-O0):
@encrypt.Y = internal global [64 x i32] zeroinitializer
define void @encrypt(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %8
8: ; preds = %23, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %6
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i32*, i32** %4
%14 = load i32*, i32** %5
%15 = load i64, i64* %7
%16 = mul i64 %15, 64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = call i32 @addRoundKey(i32* %13, i32* %17)
%19 = load i32*, i32** %4
%20 = call i32 @sBoxLayer(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @encrypt.Y, i64 0, i64 0), i32* %19)
%21 = load i32*, i32** %4
%22 = call i32 @pLayer(i32* %21, i32* getelementptr inbounds ([64 x i32], [64 x i32]* @encrypt.Y, i64 0, i64 0))
br label %23
23: ; preds = %12
%24 = load i64, i64* %7
%25 = add i64 %24, 1
store i64 %25, i64* %7
br label %8
26: ; preds = %8
%27 = load i32*, i32** %4
%28 = load i32*, i32** %5
%29 = load i64, i64* %6
%30 = mul i64 %29, 64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = call i32 @addRoundKey(i32* %27, i32* %31)
ret void
}

LLVM IR (-O2):
@encrypt.Y = internal global [64 x i32] zeroinitializer
define void @encrypt(i32* %0, i32* %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %9
5: ; preds = %9, %3
%6 = shl i64 %2, 6
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = tail call i32 @addRoundKey(i32* %0, i32* %7)
ret void
9: ; preds = %3, %9
%10 = phi i64 [ %16, %9 ], [ 0, %3 ]
%11 = shl i64 %10, 6
%12 = getelementptr inbounds i32, i32* %1, i64 %11
%13 = tail call i32 @addRoundKey(i32* %0, i32* %12)
%14 = tail call i32 @sBoxLayer(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @encrypt.Y, i64 0, i64 0), i32* %0)
%15 = tail call i32 @pLayer(i32* %0, i32* getelementptr inbounds ([64 x i32], [64 x i32]* @encrypt.Y, i64 0, i64 0))
%16 = add nuw i64 %10, 1
%17 = icmp eq i64 %16, %2
br i1 %17, label %5, label %9
}