#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 *);
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;
  ;
  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 (1);
}


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)
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    11c9 <AESDataProcessAuth+0x79>
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    118f <AESDataProcessAuth+0x3f>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122a <AESDataProcessAuth+0xda>
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    11d0 <AESDataProcessAuth+0x80>
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
mov    %ecx,%esi
call   1050 <AESLengthSet@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <AESAuthLengthSet@plt>
test   %ebx,%ebx
jle    11a4 <AESDataProcessAuth+0x54>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r14,%r13,1),%rsi
mov    %ebp,%edi
call   1060 <AESDataWrite@plt>
add    $0x10,%r14
cmp    %ebx,%r14d
jl     1190 <AESDataProcessAuth+0x40>
mov    0x40(%rsp),%r13
test   %r12d,%r12d
mov    (%rsp),%r14
jle    11df <AESDataProcessAuth+0x8f>
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     11c0 <AESDataProcessAuth+0x70>
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 = load i32, i32* %11
%18 = call i32 @AESLengthSet(i32 %16, i32 %17)
%19 = load i32, i32* %8
%20 = load i32, i32* %13
%21 = call i32 @AESAuthLengthSet(i32 %19, i32 %20)
store i32 0, i32* %15
br label %22
22: ; preds = %34, %7
%23 = load i32, i32* %15
%24 = load i32, i32* %13
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i32, i32* %8
%28 = load i32*, i32** %12
%29 = load i32, i32* %15
%30 = sdiv i32 %29, 4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %28, i64 %31
%33 = call i32 @AESDataWrite(i32 %27, i32* %32)
br label %34
34: ; preds = %26
%35 = load i32, i32* %15
%36 = add nsw i32 %35, 16
store i32 %36, i32* %15
br label %22
37: ; preds = %22
store i32 0, i32* %15
br label %38
38: ; preds = %57, %37
%39 = load i32, i32* %15
%40 = load i32, i32* %11
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %60
42: ; preds = %38
%43 = load i32, i32* %8
%44 = load i32*, i32** %9
%45 = load i32, i32* %15
%46 = sdiv i32 %45, 4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %44, i64 %47
%49 = call i32 @AESDataWrite(i32 %43, i32* %48)
%50 = load i32, i32* %8
%51 = load i32*, i32** %10
%52 = load i32, i32* %15
%53 = sdiv i32 %52, 4
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %51, i64 %54
%56 = call i32 @AESDataRead(i32 %50, i32* %55)
br label %57
57: ; preds = %42
%58 = load i32, i32* %15
%59 = add nsw i32 %58, 16
store i32 %59, i32* %15
br label %38
60: ; preds = %38
%61 = load i32, i32* %8
%62 = load i32*, i32** %14
%63 = call i32 @AESTagRead(i32 %61, i32* %62)
ret i32 1
}

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