#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*/ BlockDecrypt(unsigned char *);
int /*<<< orphan*/ XorBytes(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, unsigned int);
void AES_Decrypt(unsigned char *pPlainText, const unsigned char *pCipherText,
                 unsigned int nDataLen, const unsigned char *pIV) {
  unsigned int i;
  if (pPlainText != pCipherText) {
    memcpy(pPlainText, pCipherText, nDataLen);
  }
  pPlainText += nDataLen - 4 * 4;
  for (i = nDataLen / (4 * 4); i > 0; i--, pPlainText -= 4 * 4) {
    BlockDecrypt(pPlainText);
    if (i == 1) {
      XorBytes(pPlainText, pIV, 4 * 4);
    } else {
      XorBytes(pPlainText, pPlainText - 4 * 4, 4 * 4);
    }
  }
}


x86 assembly (clang, -O0):
<AES_Decrypt>:
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_Decrypt+0x35>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x14(%rbp),%ecx
sub    $0x10,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jbe    11ea <AES_Decrypt+0xba>
mov    -0x8(%rbp),%rdi
call   1030 <BlockDecrypt@plt>
cmpl   $0x1,-0x24(%rbp)
jne    11b5 <AES_Decrypt+0x85>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1050 <XorBytes@plt>
jmp    11cb <AES_Decrypt+0x9b>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0xfffffffffffffff0,%rsi
mov    $0x10,%edx
call   1050 <XorBytes@plt>
jmp    11d0 <AES_Decrypt+0xa0>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
add    $0xfffffffffffffff0,%rax
mov    %rax,-0x8(%rbp)
jmp    1181 <AES_Decrypt+0x51>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES_Decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rdi,%r12
cmp    %rsi,%rdi
je     1151 <AES_Decrypt+0x21>
mov    %r12,%rdi
mov    %r15d,%edx
call   1040 <memcpy@plt>
cmp    $0x10,%r15d
jae    1160 <AES_Decrypt+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,%ebp
shr    $0x4,%ebp
add    $0xfffffff0,%r15d
add    %r15,%r12
mov    %r12,%rdi
call   1030 <BlockDecrypt@plt>
cmp    $0x1,%ebp
jne    117f <AES_Decrypt+0x4f>
mov    %r12,%rbx
jmp    11b5 <AES_Decrypt+0x85>
add    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x10(%r12),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <XorBytes@plt>
mov    %rbx,%rdi
call   1030 <BlockDecrypt@plt>
mov    %rbx,%r12
add    $0xffffffff,%ebp
jne    1190 <AES_Decrypt+0x60>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <XorBytes@plt>

LLVM IR (-O0):
define void @AES_Decrypt(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** %5
%15 = load i8*, i8** %6
%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 = sub i32 %19, 16
%21 = load i8*, i8** %5
%22 = zext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8* %23, i8** %5
%24 = load i32, i32* %7
%25 = udiv i32 %24, 16
store i32 %25, i32* %9
br label %26
26: ; preds = %44, %18
%27 = load i32, i32* %9
%28 = icmp ugt i32 %27, 0
br i1 %28, label %29, label %49
29: ; preds = %26
%30 = load i8*, i8** %5
%31 = call i32 @BlockDecrypt(i8* %30)
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = load i8*, i8** %8
%37 = call i32 @XorBytes(i8* %35, i8* %36, i32 16)
br label %43
38: ; preds = %29
%39 = load i8*, i8** %5
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 -16
%42 = call i32 @XorBytes(i8* %39, i8* %41, i32 16)
br label %43
43: ; preds = %38, %34
br label %44
44: ; preds = %43
%45 = load i32, i32* %9
%46 = add i32 %45, -1
store i32 %46, i32* %9
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i64 -16
store i8* %48, i8** %5
br label %26
49: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @AES_Decrypt(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* %0, i8* %1, i32 %2)
br label %8
8: ; preds = %6, %4
%9 = icmp ult i32 %2, 16
br i1 %9, label %29, label %10
10: ; preds = %8
%11 = lshr i32 %2, 4
%12 = add i32 %2, -16
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = tail call i32 @BlockDecrypt(i8* %14)
%16 = icmp eq i32 %11, 1
br i1 %16, label %26, label %17
17: ; preds = %10, %17
%18 = phi i8* [ %23, %17 ], [ %14, %10 ]
%19 = phi i32 [ %22, %17 ], [ %11, %10 ]
%20 = getelementptr inbounds i8, i8* %18, i64 -16
%21 = tail call i32 @XorBytes(i8* %18, i8* %20, i32 16)
%22 = add nsw i32 %19, -1
%23 = getelementptr inbounds i8, i8* %18, i64 -16
%24 = tail call i32 @BlockDecrypt(i8* %23)
%25 = icmp eq i32 %22, 1
br i1 %25, label %26, label %17
26: ; preds = %17, %10
%27 = phi i8* [ %14, %10 ], [ %23, %17 ]
%28 = tail call i32 @XorBytes(i8* %27, i8* %3, i32 16)
br label %29
29: ; preds = %26, %8
ret void
}