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

/* Variables and functions */
int /*<<< orphan*/ BlockEncrypt(unsigned char *);
int /*<<< orphan*/ XorBytes(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, unsigned int);
void AES_Encrypt(const unsigned char *pPlainText, unsigned char *pCipherText,
                 unsigned int nDataLen, const unsigned char *pIV) {
  unsigned int i;
  if (pPlainText != pCipherText) {
    memcpy(pCipherText, pPlainText, nDataLen);
  }
  for (i = nDataLen / (4 * 4); i > 0; i--, pCipherText += 4 * 4) {
    XorBytes(pCipherText, pIV, 4 * 4);
    BlockEncrypt(pCipherText);
    pIV = pCipherText;
  }
}


x86 assembly (clang, -O0):
<AES_Encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1165 <AES_Encrypt+0x35>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x14(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jbe    11b5 <AES_Encrypt+0x85>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1050 <XorBytes@plt>
mov    -0x10(%rbp),%rdi
call   1030 <BlockEncrypt@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    116e <AES_Encrypt+0x3e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES_Encrypt>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rbx
cmp    %rsi,%rdi
je     114e <AES_Encrypt+0x1e>
mov    %rdi,%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1040 <memcpy@plt>
cmp    $0x10,%ebp
jb     1184 <AES_Encrypt+0x54>
shr    $0x4,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1050 <XorBytes@plt>
mov    %rbx,%rdi
call   1030 <BlockEncrypt@plt>
mov    %rbx,%r14
add    $0x10,%rbx
add    $0xffffffff,%ebp
jne    1160 <AES_Encrypt+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @AES_Encrypt(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = icmp ne i8* %10, %11
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load i8*, i8** %5
%16 = load i32, i32* %7
%17 = call i32 @memcpy(i8* %14, i8* %15, i32 %16)
br label %18
18: ; preds = %13, %4
%19 = load i32, i32* %7
%20 = udiv i32 %19, 16
store i32 %20, i32* %9
br label %21
21: ; preds = %31, %18
%22 = load i32, i32* %9
%23 = icmp ugt i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = load i8*, i8** %6
%26 = load i8*, i8** %8
%27 = call i32 @XorBytes(i8* %25, i8* %26, i32 16)
%28 = load i8*, i8** %6
%29 = call i32 @BlockEncrypt(i8* %28)
%30 = load i8*, i8** %6
store i8* %30, i8** %8
br label %31
31: ; preds = %24
%32 = load i32, i32* %9
%33 = add i32 %32, -1
store i32 %33, i32* %9
%34 = load i8*, i8** %6
%35 = getelementptr inbounds i8, i8* %34, i64 16
store i8* %35, i8** %6
br label %21
36: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @AES_Encrypt(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = icmp eq i8* %0, %1
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %2)
br label %8
8: ; preds = %6, %4
%9 = icmp ult i32 %2, 16
br i1 %9, label %21, label %10
10: ; preds = %8
%11 = lshr i32 %2, 4
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %18, %12 ], [ %11, %10 ]
%14 = phi i8* [ %15, %12 ], [ %3, %10 ]
%15 = phi i8* [ %19, %12 ], [ %1, %10 ]
%16 = tail call i32 @XorBytes(i8* %15, i8* %14, i32 16)
%17 = tail call i32 @BlockEncrypt(i8* %15)
%18 = add nsw i32 %13, -1
%19 = getelementptr inbounds i8, i8* %15, i64 16
%20 = icmp eq i32 %18, 0
br i1 %20, label %21, label %12
21: ; preds = %12, %8
ret void
}