#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 unsigned long *)(0x400AF004))) = ((ui32Address) >> 6);
  (*((volatile unsigned long *)(0x400AF008))) = (((ui32Address) >> 2) & 0x0F);
  ui32Count /= 4;
  while (ui32Count) {
    *pui32Data = (*((volatile unsigned long *)(0x400AF014)));
    pui32Data++;
    ui32Count--;
    if (ui32Count && ((*((volatile unsigned long *)(0x400AF008))) == 0)) {
      (*((volatile unsigned long *)(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),%eax
sar    $0x6,%eax
movslq %eax,%rcx
mov    $0x400af004,%eax
mov    %rcx,(%rax)
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
and    $0xf,%eax
movslq %eax,%rcx
mov    $0x400af008,%eax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a5 <EEPROMRead+0xa5>
mov    $0x400af014,%eax
mov    (%rax),%rax
mov    %eax,%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     11a0 <EEPROMRead+0xa0>
mov    $0x400af008,%eax
mov    (%rax),%rax
cmp    $0x0,%rax
jne    11a0 <EEPROMRead+0xa0>
mov    $0x400af004,%eax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    $0x400af004,%eax
mov    %rcx,(%rax)
jmp    1141 <EEPROMRead+0x41>
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMRead>:
mov    %esi,%eax
sar    $0x6,%eax
cltq
mov    %rax,0x400af004
40
shr    $0x2,%esi
and    $0xf,%esi
mov    %rsi,0x400af008
40
lea    0x3(%rdx),%eax
cmp    $0x7,%eax
jb     1172 <EEPROMRead+0x72>
test   %edx,%edx
cmovns %edx,%eax
sar    $0x2,%eax
mov    0x400af014,%rcx
40
mov    %ecx,(%rdi)
mov    %eax,%ecx
add    $0xffffffff,%ecx
je     1172 <EEPROMRead+0x72>
test   $0x1,%cl
je     116a <EEPROMRead+0x6a>
add    $0x4,%rdi
cmpq   $0x0,0x400af008
jne    115b <EEPROMRead+0x5b>
addq   $0x1,0x400af004
40 01
mov    0x400af014,%rcx
40
mov    %ecx,(%rdi)
add    $0xfffffffe,%eax
mov    %eax,%ecx
and    $0xfffffffc,%edx
cmp    $0x8,%edx
jne    1173 <EEPROMRead+0x73>
ret
mov    %ecx,%eax
xor    %ecx,%ecx
jmp    1194 <EEPROMRead+0x94>
nopl   0x0(%rax)
mov    0x400af014,%rdx
40
mov    %edx,0x8(%rdi,%rcx,4)
add    $0x2,%rcx
cmp    %ecx,%eax
je     1172 <EEPROMRead+0x72>
cmpq   $0x0,0x400af008
jne    11a8 <EEPROMRead+0xa8>
addq   $0x1,0x400af004
40 01
mov    0x400af014,%rdx
40
mov    %edx,0x4(%rdi,%rcx,4)
cmpq   $0x0,0x400af008
jne    1180 <EEPROMRead+0x80>
addq   $0x1,0x400af004
40 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
%9 = sext i32 %8 to i64
store volatile i64 %9, i64* inttoptr (i64 1074458628 to i64*)
%10 = load i32, i32* %5
%11 = ashr i32 %10, 2
%12 = and i32 %11, 15
%13 = sext i32 %12 to i64
store volatile i64 %13, i64* inttoptr (i64 1074458632 to i64*)
%14 = load i32, i32* %6
%15 = sdiv i32 %14, 4
store i32 %15, i32* %6
br label %16
16: ; preds = %35, %3
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %36
19: ; preds = %16
%20 = load volatile i64, i64* inttoptr (i64 1074458644 to i64*)
%21 = trunc i64 %20 to i32
%22 = load i32*, i32** %4
store i32 %21, i32* %22
%23 = load i32*, i32** %4
%24 = getelementptr inbounds i32, i32* %23, i32 1
store i32* %24, i32** %4
%25 = load i32, i32* %6
%26 = add nsw i32 %25, -1
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %19
%30 = load volatile i64, i64* inttoptr (i64 1074458632 to i64*)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load volatile i64, i64* inttoptr (i64 1074458628 to i64*)
%34 = add i64 %33, 1
store volatile i64 %34, i64* inttoptr (i64 1074458628 to i64*)
br label %35
35: ; preds = %32, %29, %19
br label %16
36: ; preds = %16
ret void
}

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