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

/* Variables and functions */
void EEPROMRead(uint32_t *pui32Data, uint32_t ui32Address, uint32_t ui32Count) {
  ;
  ;

  ;
  ;
  ;
  (*((volatile uint32_t *)(0x400AF004))) = ((ui32Address) >> 6);
  (*((volatile uint32_t *)(0x400AF008))) = (((ui32Address) >> 2) & 0x0F);
  ui32Count /= 4;
  while (ui32Count) {
    *pui32Data = (*((volatile uint32_t *)(0x400AF014)));
    pui32Data++;
    ui32Count--;
    if (ui32Count && ((*((volatile uint32_t *)(0x400AF008))) == 0)) {
      (*((volatile uint32_t *)(0x400AF004))) += 1;
    }
  }
}


x86 assembly (clang, -O0):
<EEPROMRead>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x6,%ecx
mov    $0x400af004,%eax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x2,%ecx
and    $0xf,%ecx
mov    $0x400af008,%eax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1195 <EEPROMRead+0x95>
mov    $0x400af014,%eax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1190 <EEPROMRead+0x90>
mov    $0x400af008,%eax
mov    (%rax),%eax
cmp    $0x0,%eax
jne    1190 <EEPROMRead+0x90>
mov    $0x400af004,%eax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    $0x400af004,%eax
mov    %ecx,(%rax)
jmp    1139 <EEPROMRead+0x39>
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMRead>:
mov    %esi,%eax
sar    $0x6,%eax
mov    %eax,0x400af004
shr    $0x2,%esi
and    $0xf,%esi
mov    %esi,0x400af008
lea    0x3(%rdx),%eax
cmp    $0x7,%eax
jb     116a <EEPROMRead+0x6a>
test   %edx,%edx
cmovns %edx,%eax
sar    $0x2,%eax
mov    0x400af014,%ecx
mov    %ecx,(%rdi)
mov    %eax,%ecx
add    $0xffffffff,%ecx
je     116a <EEPROMRead+0x6a>
test   $0x1,%cl
je     1162 <EEPROMRead+0x62>
add    $0x4,%rdi
cmpl   $0x0,0x400af008
jne    1154 <EEPROMRead+0x54>
addl   $0x1,0x400af004
01
mov    0x400af014,%ecx
mov    %ecx,(%rdi)
add    $0xfffffffe,%eax
mov    %eax,%ecx
and    $0xfffffffc,%edx
cmp    $0x8,%edx
jne    116b <EEPROMRead+0x6b>
ret
mov    %ecx,%eax
xor    %ecx,%ecx
jmp    1193 <EEPROMRead+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x400af014,%edx
mov    %edx,0x8(%rdi,%rcx,4)
add    $0x2,%rcx
cmp    %ecx,%eax
je     116a <EEPROMRead+0x6a>
cmpl   $0x0,0x400af008
jne    11a5 <EEPROMRead+0xa5>
addl   $0x1,0x400af004
01
mov    0x400af014,%edx
mov    %edx,0x4(%rdi,%rcx,4)
cmpl   $0x0,0x400af008
jne    1180 <EEPROMRead+0x80>
addl   $0x1,0x400af004
01
jmp    1180 <EEPROMRead+0x80>

LLVM IR (-O0):
define void @EEPROMRead(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = ashr i32 %7, 6
store volatile i32 %8, i32* inttoptr (i64 1074458628 to i32*)
%9 = load i32, i32* %5
%10 = ashr i32 %9, 2
%11 = and i32 %10, 15
store volatile i32 %11, i32* inttoptr (i64 1074458632 to i32*)
%12 = load i32, i32* %6
%13 = sdiv i32 %12, 4
store i32 %13, i32* %6
br label %14
14: ; preds = %32, %3
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = load volatile i32, i32* inttoptr (i64 1074458644 to i32*)
%19 = load i32*, i32** %4
store i32 %18, i32* %19
%20 = load i32*, i32** %4
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %4
%22 = load i32, i32* %6
%23 = add nsw i32 %22, -1
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %17
%27 = load volatile i32, i32* inttoptr (i64 1074458632 to i32*)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load volatile i32, i32* inttoptr (i64 1074458628 to i32*)
%31 = add nsw i32 %30, 1
store volatile i32 %31, i32* inttoptr (i64 1074458628 to i32*)
br label %32
32: ; preds = %29, %26, %17
br label %14
33: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @EEPROMRead(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = ashr i32 %1, 6
store volatile i32 %4, i32* inttoptr (i64 1074458628 to i32*)
%5 = lshr i32 %1, 2
%6 = and i32 %5, 15
store volatile i32 %6, i32* inttoptr (i64 1074458632 to i32*)
%7 = add i32 %2, 3
%8 = icmp ult i32 %7, 7
br i1 %8, label %53, label %9
9: ; preds = %3
%10 = sdiv i32 %2, 4
%11 = load volatile i32, i32* inttoptr (i64 1074458644 to i32*)
store i32 %11, i32* %0
%12 = add nsw i32 %10, -1
%13 = icmp eq i32 %12, 0
br i1 %13, label %53, label %14
14: ; preds = %9
%15 = and i32 %12, 1
%16 = icmp eq i32 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %14
%18 = getelementptr inbounds i32, i32* %0, i64 1
%19 = load volatile i32, i32* inttoptr (i64 1074458632 to i32*)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load volatile i32, i32* inttoptr (i64 1074458628 to i32*)
%23 = add nsw i32 %22, 1
store volatile i32 %23, i32* inttoptr (i64 1074458628 to i32*)
br label %24
24: ; preds = %21, %17
%25 = load volatile i32, i32* inttoptr (i64 1074458644 to i32*)
store i32 %25, i32* %18
%26 = add nsw i32 %10, -2
br label %27
27: ; preds = %24, %14
%28 = phi i32 [ %12, %14 ], [ %26, %24 ]
%29 = phi i32* [ %0, %14 ], [ %18, %24 ]
%30 = and i32 %2, -4
%31 = icmp eq i32 %30, 8
br i1 %31, label %53, label %32
32: ; preds = %27, %49
%33 = phi i32 [ %51, %49 ], [ %28, %27 ]
%34 = phi i32* [ %43, %49 ], [ %29, %27 ]
%35 = getelementptr inbounds i32, i32* %34, i64 1
%36 = load volatile i32, i32* inttoptr (i64 1074458632 to i32*)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %32
%39 = load volatile i32, i32* inttoptr (i64 1074458628 to i32*)
%40 = add nsw i32 %39, 1
store volatile i32 %40, i32* inttoptr (i64 1074458628 to i32*)
br label %41
41: ; preds = %38, %32
%42 = load volatile i32, i32* inttoptr (i64 1074458644 to i32*)
store i32 %42, i32* %35
%43 = getelementptr inbounds i32, i32* %34, i64 2
%44 = load volatile i32, i32* inttoptr (i64 1074458632 to i32*)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load volatile i32, i32* inttoptr (i64 1074458628 to i32*)
%48 = add nsw i32 %47, 1
store volatile i32 %48, i32* inttoptr (i64 1074458628 to i32*)
br label %49
49: ; preds = %46, %41
%50 = load volatile i32, i32* inttoptr (i64 1074458644 to i32*)
store i32 %50, i32* %43
%51 = add nsw i32 %33, -2
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %32
53: ; preds = %27, %49, %9, %3
ret void
}