#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*/ AESDataWrite(int, int *);
int /*<<< orphan*/ AESLengthSet(int, int /*<<< orphan*/);
int /*<<< orphan*/ AESTagRead(int, int *);
int /*<<< orphan*/ ASSERT(int);
bool AESDataAuth(uint32_t ui32Base, uint32_t *pui32Src, uint32_t ui32Length,
                 uint32_t *pui32Tag) {
  uint32_t ui32Count;
  ASSERT(ui32Base == 0x44036000);
  AESLengthSet(ui32Base, (uint64_t)ui32Length);
  for (ui32Count = 0; ui32Count < ui32Length; ui32Count += 16) {
    AESDataWrite(ui32Base, pui32Src + (ui32Count / 4));
  }
  AESTagRead(ui32Base, pui32Tag);
  return (true);
}


x86 assembly (clang, -O0):
<AESDataAuth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x44036000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <ASSERT@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <AESLengthSet@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b6 <AESDataAuth+0x76>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1050 <AESDataWrite@plt>
mov    -0x24(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x24(%rbp)
jmp    117c <AESDataAuth+0x3c>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <AESTagRead@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AESDataAuth>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rsi,%r15
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x44036000,%ebp
sete   %dil
call   1060 <ASSERT@plt>
mov    %ebp,%edi
mov    %r12d,%esi
call   1040 <AESLengthSet@plt>
test   %r12d,%r12d
jle    1194 <AESDataAuth+0x54>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r15,%rbx,1),%rsi
mov    %ebp,%edi
call   1050 <AESDataWrite@plt>
add    $0x10,%rbx
cmp    %r12d,%ebx
jl     1180 <AESDataAuth+0x40>
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <AESTagRead@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @AESDataAuth(i32 %0, i32* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 1141071872
%12 = zext i1 %11 to i32
%13 = call i32 @ASSERT(i32 %12)
%14 = load i32, i32* %5
%15 = load i32, i32* %7
%16 = call i32 @AESLengthSet(i32 %14, i32 %15)
store i32 0, i32* %9
br label %17
17: ; preds = %29, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i32, i32* %5
%23 = load i32*, i32** %6
%24 = load i32, i32* %9
%25 = sdiv i32 %24, 4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %23, i64 %26
%28 = call i32 @AESDataWrite(i32 %22, i32* %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 16
store i32 %31, i32* %9
br label %17
32: ; preds = %17
%33 = load i32, i32* %5
%34 = load i32*, i32** %8
%35 = call i32 @AESTagRead(i32 %33, i32* %34)
ret i32 1
}

LLVM IR (-O2):
define i32 @AESDataAuth(i32 %0, i32* %1, i32 %2, i32* %3) {
%5 = icmp eq i32 %0, 1141071872
%6 = zext i1 %5 to i32
%7 = tail call i32 @ASSERT(i32 %6)
%8 = tail call i32 @AESLengthSet(i32 %0, i32 %2)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %18
10: ; preds = %4, %10
%11 = phi i64 [ %15, %10 ], [ 0, %4 ]
%12 = lshr exact i64 %11, 2
%13 = getelementptr inbounds i32, i32* %1, i64 %12
%14 = tail call i32 @AESDataWrite(i32 %0, i32* %13)
%15 = add nuw i64 %11, 16
%16 = trunc i64 %15 to i32
%17 = icmp slt i32 %16, %2
br i1 %17, label %10, label %18
18: ; preds = %10, %4
%19 = tail call i32 @AESTagRead(i32 %0, i32* %3)
ret i32 1
}