#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;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ AESAuthLengthSet(int, int);
int /*<<< orphan*/ AESDataRead(int, int *);
int /*<<< orphan*/ AESDataWrite(int, int *);
int /*<<< orphan*/ AESLengthSet(int, int /*<<< orphan*/);
int /*<<< orphan*/ AESTagRead(int, int *);
int /*<<< orphan*/ ASSERT(int);
bool AESDataProcessAuth(uint32_t ui32Base, uint32_t *pui32Src,
                        uint32_t *pui32Dest, uint32_t ui32Length,
                        uint32_t *pui32AuthSrc, uint32_t ui32AuthLength,
                        uint32_t *pui32Tag) {
  uint32_t ui32Count;
  ASSERT(ui32Base == 0x44036000);
  AESLengthSet(ui32Base, (uint64_t)ui32Length);
  AESAuthLengthSet(ui32Base, ui32AuthLength);
  for (ui32Count = 0; ui32Count < ui32AuthLength; ui32Count += 16) {
    AESDataWrite(ui32Base, pui32AuthSrc + (ui32Count / 4));
  }
  for (ui32Count = 0; ui32Count < ui32Length; ui32Count += 16) {
    AESDataWrite(ui32Base, pui32Src + (ui32Count / 4));
    AESDataRead(ui32Base, pui32Dest + (ui32Count / 4));
  }
  AESTagRead(ui32Base, pui32Tag);
  return (true);
}


x86 assembly (clang, -O0):
<AESDataProcessAuth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x44036000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <ASSERT@plt>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1050 <AESLengthSet@plt>
mov    -0x4(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1070 <AESAuthLengthSet@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11ed <AESDataProcessAuth+0x8d>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1060 <AESDataWrite@plt>
mov    -0x30(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x30(%rbp)
jmp    11b3 <AESDataProcessAuth+0x53>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    124e <AESDataProcessAuth+0xee>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1060 <AESDataWrite@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <AESDataRead@plt>
mov    -0x30(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x30(%rbp)
jmp    11f4 <AESDataProcessAuth+0x94>
mov    -0x4(%rbp),%edi
mov    0x10(%rbp),%rsi
call   1040 <AESTagRead@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AESDataProcessAuth>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8,%r13
mov    %ecx,%r12d
mov    %rdx,(%rsp)
mov    %rsi,%r15
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x44036000,%ebp
sete   %dil
call   1080 <ASSERT@plt>
mov    %ebp,%edi
mov    %r12d,%esi
call   1050 <AESLengthSet@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <AESAuthLengthSet@plt>
test   %ebx,%ebx
jle    11c4 <AESDataProcessAuth+0x64>
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
lea    (%r14,%r13,1),%rsi
mov    %ebp,%edi
call   1060 <AESDataWrite@plt>
add    $0x10,%r14
cmp    %ebx,%r14d
jl     11b0 <AESDataProcessAuth+0x50>
mov    0x40(%rsp),%r13
test   %r12d,%r12d
mov    (%rsp),%r14
jle    11ff <AESDataProcessAuth+0x9f>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r15,%rbx,1),%rsi
mov    %ebp,%edi
call   1060 <AESDataWrite@plt>
lea    (%r14,%rbx,1),%rsi
mov    %ebp,%edi
call   1030 <AESDataRead@plt>
add    $0x10,%rbx
cmp    %r12d,%ebx
jl     11e0 <AESDataProcessAuth+0x80>
mov    %ebp,%edi
mov    %r13,%rsi
call   1040 <AESTagRead@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @AESDataProcessAuth(i32 %0, i32* %1, i32* %2, i32 %3, i32* %4, i32 %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
store i32 %0, i32* %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32 %3, i32* %11
store i32* %4, i32** %12
store i32 %5, i32* %13
store i32* %6, i32** %14
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 1141071872
%18 = zext i1 %17 to i32
%19 = call i32 @ASSERT(i32 %18)
%20 = load i32, i32* %8
%21 = load i32, i32* %11
%22 = call i32 @AESLengthSet(i32 %20, i32 %21)
%23 = load i32, i32* %8
%24 = load i32, i32* %13
%25 = call i32 @AESAuthLengthSet(i32 %23, i32 %24)
store i32 0, i32* %15
br label %26
26: ; preds = %38, %7
%27 = load i32, i32* %15
%28 = load i32, i32* %13
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %41
30: ; preds = %26
%31 = load i32, i32* %8
%32 = load i32*, i32** %12
%33 = load i32, i32* %15
%34 = sdiv i32 %33, 4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %32, i64 %35
%37 = call i32 @AESDataWrite(i32 %31, i32* %36)
br label %38
38: ; preds = %30
%39 = load i32, i32* %15
%40 = add nsw i32 %39, 16
store i32 %40, i32* %15
br label %26
41: ; preds = %26
store i32 0, i32* %15
br label %42
42: ; preds = %61, %41
%43 = load i32, i32* %15
%44 = load i32, i32* %11
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %64
46: ; preds = %42
%47 = load i32, i32* %8
%48 = load i32*, i32** %9
%49 = load i32, i32* %15
%50 = sdiv i32 %49, 4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %48, i64 %51
%53 = call i32 @AESDataWrite(i32 %47, i32* %52)
%54 = load i32, i32* %8
%55 = load i32*, i32** %10
%56 = load i32, i32* %15
%57 = sdiv i32 %56, 4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %55, i64 %58
%60 = call i32 @AESDataRead(i32 %54, i32* %59)
br label %61
61: ; preds = %46
%62 = load i32, i32* %15
%63 = add nsw i32 %62, 16
store i32 %63, i32* %15
br label %42
64: ; preds = %42
%65 = load i32, i32* %8
%66 = load i32*, i32** %14
%67 = call i32 @AESTagRead(i32 %65, i32* %66)
ret i32 1
}

LLVM IR (-O2):
define i32 @AESDataProcessAuth(i32 %0, i32* %1, i32* %2, i32 %3, i32* %4, i32 %5, i32* %6) {
%8 = icmp eq i32 %0, 1141071872
%9 = zext i1 %8 to i32
%10 = tail call i32 @ASSERT(i32 %9)
%11 = tail call i32 @AESLengthSet(i32 %0, i32 %3)
%12 = tail call i32 @AESAuthLengthSet(i32 %0, i32 %5)
%13 = icmp sgt i32 %5, 0
br i1 %13, label %16, label %14
14: ; preds = %16, %7
%15 = icmp sgt i32 %3, 0
br i1 %15, label %24, label %34
16: ; preds = %7, %16
%17 = phi i64 [ %21, %16 ], [ 0, %7 ]
%18 = lshr exact i64 %17, 2
%19 = getelementptr inbounds i32, i32* %4, i64 %18
%20 = tail call i32 @AESDataWrite(i32 %0, i32* %19)
%21 = add nuw i64 %17, 16
%22 = trunc i64 %21 to i32
%23 = icmp slt i32 %22, %5
br i1 %23, label %16, label %14
24: ; preds = %14, %24
%25 = phi i64 [ %31, %24 ], [ 0, %14 ]
%26 = lshr exact i64 %25, 2
%27 = getelementptr inbounds i32, i32* %1, i64 %26
%28 = tail call i32 @AESDataWrite(i32 %0, i32* %27)
%29 = getelementptr inbounds i32, i32* %2, i64 %26
%30 = tail call i32 @AESDataRead(i32 %0, i32* %29)
%31 = add nuw i64 %25, 16
%32 = trunc i64 %31 to i32
%33 = icmp slt i32 %32, %3
br i1 %33, label %24, label %34
34: ; preds = %24, %14
%35 = tail call i32 @AESTagRead(i32 %0, i32* %6)
ret i32 1
}