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

/* Variables and functions */
int computeEncryptionRound(int, int, int);
int finalPermutation(int);
int generateCD(int);
int generatePerRoundKey(int);
int initialPermutation(int);
int rotateCD(int, int);
uint64_t DESEncrypt(uint64_t input, uint64_t key) {
  input = initialPermutation(input);
  uint64_t keys[16];
  uint64_t CD = generateCD(key);
  for (int i = 0; i < 16; i++) {
    CD = rotateCD(i, CD);
    keys[i] = generatePerRoundKey(CD);
  }
  for (int round_num = 0; round_num < 16; round_num++) {
    input = computeEncryptionRound(round_num, input, keys[round_num]);
  }
  input = (input >> 32) | (input << 32);
  uint64_t output = finalPermutation(input);
  return output;
}


x86 assembly (clang, -O0):
<DESEncrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <initialPermutation@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <generateCD@plt>
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x10,-0x58(%rbp)
jge    11c3 <DESEncrypt+0x63>
mov    -0x58(%rbp),%edi
mov    -0x54(%rbp),%esi
call   1080 <rotateCD@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,%ecx
movslq -0x58(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    118b <DESEncrypt+0x2b>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x10,-0x5c(%rbp)
jge    11f8 <DESEncrypt+0x98>
mov    -0x5c(%rbp),%edi
mov    -0x4(%rbp),%esi
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
call   1060 <computeEncryptionRound@plt>
mov    %eax,-0x4(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11ca <DESEncrypt+0x6a>
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    -0x4(%rbp),%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <finalPermutation@plt>
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DESEncrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebx
call   1040 <initialPermutation@plt>
mov    %eax,0x34(%rsp)
mov    %ebx,%edi
call   1050 <generateCD@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x30(%rsp)
mov    $0x1,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x2c(%rsp)
mov    $0x2,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x28(%rsp)
mov    $0x3,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x24(%rsp)
mov    $0x4,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x20(%rsp)
mov    $0x5,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x1c(%rsp)
mov    $0x6,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x18(%rsp)
mov    $0x7,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x14(%rsp)
mov    $0x8,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0x10(%rsp)
mov    $0x9,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,0xc(%rsp)
mov    $0xa,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,%ebp
mov    $0xb,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,%r14d
mov    $0xc,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,%r15d
mov    $0xd,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,%r12d
mov    $0xe,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,%r13d
mov    $0xf,%edi
mov    %ebx,%esi
call   1080 <rotateCD@plt>
mov    %eax,%edi
call   1030 <generatePerRoundKey@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    0x34(%rsp),%esi
mov    0x30(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x1,%edi
mov    %eax,%esi
mov    0x2c(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x2,%edi
mov    %eax,%esi
mov    0x28(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x3,%edi
mov    %eax,%esi
mov    0x24(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x4,%edi
mov    %eax,%esi
mov    0x20(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x5,%edi
mov    %eax,%esi
mov    0x1c(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x6,%edi
mov    %eax,%esi
mov    0x18(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x7,%edi
mov    %eax,%esi
mov    0x14(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x8,%edi
mov    %eax,%esi
mov    0x10(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0x9,%edi
mov    %eax,%esi
mov    0xc(%rsp),%edx
call   1060 <computeEncryptionRound@plt>
mov    $0xa,%edi
mov    %eax,%esi
mov    %ebp,%edx
call   1060 <computeEncryptionRound@plt>
mov    $0xb,%edi
mov    %eax,%esi
mov    %r14d,%edx
call   1060 <computeEncryptionRound@plt>
mov    $0xc,%edi
mov    %eax,%esi
mov    %r15d,%edx
call   1060 <computeEncryptionRound@plt>
mov    $0xd,%edi
mov    %eax,%esi
mov    %r12d,%edx
call   1060 <computeEncryptionRound@plt>
mov    $0xe,%edi
mov    %eax,%esi
mov    %r13d,%edx
call   1060 <computeEncryptionRound@plt>
mov    $0xf,%edi
mov    %eax,%esi
mov    %ebx,%edx
call   1060 <computeEncryptionRound@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <finalPermutation@plt>

LLVM IR (-O0):
define i32 @DESEncrypt(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [16 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = call i32 @initialPermutation(i32 %10)
store i32 %11, i32* %3
%12 = load i32, i32* %4
%13 = call i32 @generateCD(i32 %12)
store i32 %13, i32* %6
store i32 0, i32* %7
br label %14
14: ; preds = %26, %2
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 16
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = call i32 @rotateCD(i32 %18, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = call i32 @generatePerRoundKey(i32 %21)
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %24
store i32 %22, i32* %25
br label %26
26: ; preds = %17
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %14
29: ; preds = %14
store i32 0, i32* %8
br label %30
30: ; preds = %41, %29
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 16
br i1 %32, label %33, label %44
33: ; preds = %30
%34 = load i32, i32* %8
%35 = load i32, i32* %3
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 @computeEncryptionRound(i32 %34, i32 %35, i32 %39)
store i32 %40, i32* %3
br label %41
41: ; preds = %33
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %30
44: ; preds = %30
%45 = load i32, i32* %3
%46 = ashr i32 %45, 32
%47 = load i32, i32* %3
%48 = shl i32 %47, 32
%49 = or i32 %46, %48
store i32 %49, i32* %3
%50 = load i32, i32* %3
%51 = call i32 @finalPermutation(i32 %50)
store i32 %51, i32* %9
%52 = load i32, i32* %9
ret i32 %52
}

LLVM IR (-O2):
define i32 @DESEncrypt(i32 %0, i32 %1) {
%3 = tail call i32 @initialPermutation(i32 %0)
%4 = tail call i32 @generateCD(i32 %1)
%5 = tail call i32 @rotateCD(i32 0, i32 %4)
%6 = tail call i32 @generatePerRoundKey(i32 %5)
%7 = tail call i32 @rotateCD(i32 1, i32 %5)
%8 = tail call i32 @generatePerRoundKey(i32 %7)
%9 = tail call i32 @rotateCD(i32 2, i32 %7)
%10 = tail call i32 @generatePerRoundKey(i32 %9)
%11 = tail call i32 @rotateCD(i32 3, i32 %9)
%12 = tail call i32 @generatePerRoundKey(i32 %11)
%13 = tail call i32 @rotateCD(i32 4, i32 %11)
%14 = tail call i32 @generatePerRoundKey(i32 %13)
%15 = tail call i32 @rotateCD(i32 5, i32 %13)
%16 = tail call i32 @generatePerRoundKey(i32 %15)
%17 = tail call i32 @rotateCD(i32 6, i32 %15)
%18 = tail call i32 @generatePerRoundKey(i32 %17)
%19 = tail call i32 @rotateCD(i32 7, i32 %17)
%20 = tail call i32 @generatePerRoundKey(i32 %19)
%21 = tail call i32 @rotateCD(i32 8, i32 %19)
%22 = tail call i32 @generatePerRoundKey(i32 %21)
%23 = tail call i32 @rotateCD(i32 9, i32 %21)
%24 = tail call i32 @generatePerRoundKey(i32 %23)
%25 = tail call i32 @rotateCD(i32 10, i32 %23)
%26 = tail call i32 @generatePerRoundKey(i32 %25)
%27 = tail call i32 @rotateCD(i32 11, i32 %25)
%28 = tail call i32 @generatePerRoundKey(i32 %27)
%29 = tail call i32 @rotateCD(i32 12, i32 %27)
%30 = tail call i32 @generatePerRoundKey(i32 %29)
%31 = tail call i32 @rotateCD(i32 13, i32 %29)
%32 = tail call i32 @generatePerRoundKey(i32 %31)
%33 = tail call i32 @rotateCD(i32 14, i32 %31)
%34 = tail call i32 @generatePerRoundKey(i32 %33)
%35 = tail call i32 @rotateCD(i32 15, i32 %33)
%36 = tail call i32 @generatePerRoundKey(i32 %35)
%37 = tail call i32 @computeEncryptionRound(i32 0, i32 %3, i32 %6)
%38 = tail call i32 @computeEncryptionRound(i32 1, i32 %37, i32 %8)
%39 = tail call i32 @computeEncryptionRound(i32 2, i32 %38, i32 %10)
%40 = tail call i32 @computeEncryptionRound(i32 3, i32 %39, i32 %12)
%41 = tail call i32 @computeEncryptionRound(i32 4, i32 %40, i32 %14)
%42 = tail call i32 @computeEncryptionRound(i32 5, i32 %41, i32 %16)
%43 = tail call i32 @computeEncryptionRound(i32 6, i32 %42, i32 %18)
%44 = tail call i32 @computeEncryptionRound(i32 7, i32 %43, i32 %20)
%45 = tail call i32 @computeEncryptionRound(i32 8, i32 %44, i32 %22)
%46 = tail call i32 @computeEncryptionRound(i32 9, i32 %45, i32 %24)
%47 = tail call i32 @computeEncryptionRound(i32 10, i32 %46, i32 %26)
%48 = tail call i32 @computeEncryptionRound(i32 11, i32 %47, i32 %28)
%49 = tail call i32 @computeEncryptionRound(i32 12, i32 %48, i32 %30)
%50 = tail call i32 @computeEncryptionRound(i32 13, i32 %49, i32 %32)
%51 = tail call i32 @computeEncryptionRound(i32 14, i32 %50, i32 %34)
%52 = tail call i32 @computeEncryptionRound(i32 15, i32 %51, i32 %36)
%53 = tail call i32 @finalPermutation(i32 poison)
ret i32 %53
}