#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 */
int /*<<< orphan*/ _EEPROMSectorMaskClear();
int /*<<< orphan*/ _EEPROMSectorMaskSet(int);
uint32_t EEPROMProgram(uint32_t *pui32Data, uint32_t ui32Address,
                       uint32_t ui32Count) {
  uint32_t ui32Status;
  ;
  ;

  ;
  ;
  ;
  do {
    ui32Status = (*((volatile uint32_t *)(0x400AF018)));
  } while (ui32Status & 0x00000001);
  (*((volatile uint32_t *)(0x400AF004))) = ((ui32Address) >> 6);
  (*((volatile uint32_t *)(0x400AF008))) = (((ui32Address) >> 2) & 0x0F);
  ui32Count /= 4;
  while (ui32Count) {
    if ((((*((volatile uint32_t *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) ==
         (0x10000000 | 0x00050000)) &&
        (((*((volatile uint32_t *)(0x400FE000))) & (0x0000FF00 | 0x000000FF)) ==
         (0x00000000 | 0x00000000))) {
      _EEPROMSectorMaskSet(ui32Address);
    }
    (*((volatile uint32_t *)(0x400AF014))) = *pui32Data;
    do {
      ui32Status = (*((volatile uint32_t *)(0x400AF018)));
    } while (ui32Status & 0x00000001);
    if (ui32Status & (0x00000010 | 0x00000100)) {
      if ((((*((volatile uint32_t *)(0x400FE000))) &
            (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) &&
          (((*((volatile uint32_t *)(0x400FE000))) &
            (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
        _EEPROMSectorMaskClear();
      }
      return (ui32Status);
    }
    pui32Data++;
    ui32Count--;
    if (ui32Count && ((*((volatile uint32_t *)(0x400AF008))) == 0)) {
      (*((volatile uint32_t *)(0x400AF004))) += 1;
    }
  }
  if ((((*((volatile uint32_t *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) ==
       (0x10000000 | 0x00050000)) &&
      (((*((volatile uint32_t *)(0x400FE000))) & (0x0000FF00 | 0x000000FF)) ==
       (0x00000000 | 0x00000000))) {
    _EEPROMSectorMaskClear();
  }
  return ((*((volatile uint32_t *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    $0x400af018,%eax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1132 <EEPROMProgram+0x12>
mov    -0x14(%rbp),%ecx
sar    $0x6,%ecx
mov    $0x400af004,%eax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
sar    $0x2,%ecx
and    $0xf,%ecx
mov    $0x400af008,%eax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     126e <EEPROMProgram+0x14e>
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    11b4 <EEPROMProgram+0x94>
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0xffff,%eax
cmp    $0x0,%eax
jne    11b4 <EEPROMProgram+0x94>
mov    -0x14(%rbp),%edi
call   1040 <_EEPROMSectorMaskSet@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    $0x400af014,%eax
mov    %ecx,(%rax)
mov    $0x400af018,%eax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11c1 <EEPROMProgram+0xa1>
mov    -0x1c(%rbp),%eax
and    $0x110,%eax
cmp    $0x0,%eax
je     1229 <EEPROMProgram+0x109>
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    121e <EEPROMProgram+0xfe>
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0xffff,%eax
cmp    $0x0,%eax
jne    121e <EEPROMProgram+0xfe>
mov    $0x0,%al
call   1030 <_EEPROMSectorMaskClear@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12ab <EEPROMProgram+0x18b>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1269 <EEPROMProgram+0x149>
mov    $0x400af008,%eax
mov    (%rax),%eax
cmp    $0x0,%eax
jne    1269 <EEPROMProgram+0x149>
mov    $0x400af004,%eax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    $0x400af004,%eax
mov    %ecx,(%rax)
jmp    1176 <EEPROMProgram+0x56>
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    12a1 <EEPROMProgram+0x181>
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0xffff,%eax
cmp    $0x0,%eax
jne    12a1 <EEPROMProgram+0x181>
mov    $0x0,%al
call   1030 <_EEPROMSectorMaskClear@plt>
mov    $0x400af018,%eax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMProgram>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r15
xchg   %ax,%ax
mov    0x400af018,%eax
test   $0x1,%al
jne    1130 <EEPROMProgram+0x10>
mov    %r14d,%eax
sar    $0x6,%eax
mov    %eax,0x400af004
mov    %r14d,%eax
shr    $0x2,%eax
and    $0xf,%eax
mov    %eax,0x400af008
lea    0x3(%rdx),%ebx
cmp    $0x7,%ebx
jae    1198 <EEPROMProgram+0x78>
mov    $0x70ff0000,%eax
and    0x400fe000,%eax
cmp    $0x10050000,%eax
jne    1186 <EEPROMProgram+0x66>
mov    0x400fe000,%eax
test   %ax,%ax
jne    1186 <EEPROMProgram+0x66>
xor    %eax,%eax
call   1030 <_EEPROMSectorMaskClear@plt>
mov    0x400af018,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
test   %edx,%edx
cmovns %edx,%ebx
sar    $0x2,%ebx
mov    $0x70ff0000,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    0x400fe000,%eax
and    %r12d,%eax
cmp    $0x10050000,%eax
jne    11e0 <EEPROMProgram+0xc0>
mov    0x400fe000,%eax
test   %ax,%ax
jne    11e0 <EEPROMProgram+0xc0>
mov    %r14d,%edi
call   1040 <_EEPROMSectorMaskSet@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%eax
mov    %eax,0x400af014
nopw   0x0(%rax,%rax,1)
mov    0x400af018,%ebp
test   $0x1,%bpl
jne    11f0 <EEPROMProgram+0xd0>
test   $0x110,%ebp
jne    1226 <EEPROMProgram+0x106>
add    $0xffffffff,%ebx
je     1160 <EEPROMProgram+0x40>
add    $0x4,%r15
cmpl   $0x0,0x400af008
jne    11b0 <EEPROMProgram+0x90>
addl   $0x1,0x400af004
01
jmp    11b0 <EEPROMProgram+0x90>
mov    $0x70ff0000,%eax
and    0x400fe000,%eax
cmp    $0x10050000,%eax
jne    118d <EEPROMProgram+0x6d>
mov    0x400fe000,%eax
test   %ax,%ax
jne    118d <EEPROMProgram+0x6d>
xor    %eax,%eax
call   1030 <_EEPROMSectorMaskClear@plt>
jmp    118d <EEPROMProgram+0x6d>

LLVM IR (-O0):
define i32 @EEPROMProgram(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
br label %9
9: ; preds = %11, %3
%10 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
store i32 %10, i32* %8
br label %11
11: ; preds = %9
%12 = load i32, i32* %8
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %11
%16 = load i32, i32* %6
%17 = ashr i32 %16, 6
store volatile i32 %17, i32* inttoptr (i64 1074458628 to i32*)
%18 = load i32, i32* %6
%19 = ashr i32 %18, 2
%20 = and i32 %19, 15
store volatile i32 %20, i32* inttoptr (i64 1074458632 to i32*)
%21 = load i32, i32* %7
%22 = sdiv i32 %21, 4
store i32 %22, i32* %7
br label %23
23: ; preds = %75, %15
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %76
26: ; preds = %23
%27 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%28 = and i32 %27, 1895759872
%29 = icmp eq i32 %28, 268763136
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%32 = and i32 %31, 65535
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* %6
%36 = call i32 @_EEPROMSectorMaskSet(i32 %35)
br label %37
37: ; preds = %34, %30, %26
%38 = load i32*, i32** %5
%39 = load i32, i32* %38
store volatile i32 %39, i32* inttoptr (i64 1074458644 to i32*)
br label %40
40: ; preds = %42, %37
%41 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
store i32 %41, i32* %8
br label %42
42: ; preds = %40
%43 = load i32, i32* %8
%44 = and i32 %43, 1
%45 = icmp ne i32 %44, 0
br i1 %45, label %40, label %46
46: ; preds = %42
%47 = load i32, i32* %8
%48 = and i32 %47, 272
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %62
50: ; preds = %46
%51 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%52 = and i32 %51, 1895759872
%53 = icmp eq i32 %52, 268763136
br i1 %53, label %54, label %60
54: ; preds = %50
%55 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%56 = and i32 %55, 65535
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 (...) @_EEPROMSectorMaskClear()
br label %60
60: ; preds = %58, %54, %50
%61 = load i32, i32* %8
store i32 %61, i32* %4
br label %88
62: ; preds = %46
%63 = load i32*, i32** %5
%64 = getelementptr inbounds i32, i32* %63, i32 1
store i32* %64, i32** %5
%65 = load i32, i32* %7
%66 = add nsw i32 %65, -1
store i32 %66, i32* %7
%67 = load i32, i32* %7
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %75
69: ; preds = %62
%70 = load volatile i32, i32* inttoptr (i64 1074458632 to i32*)
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load volatile i32, i32* inttoptr (i64 1074458628 to i32*)
%74 = add nsw i32 %73, 1
store volatile i32 %74, i32* inttoptr (i64 1074458628 to i32*)
br label %75
75: ; preds = %72, %69, %62
br label %23
76: ; preds = %23
%77 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%78 = and i32 %77, 1895759872
%79 = icmp eq i32 %78, 268763136
br i1 %79, label %80, label %86
80: ; preds = %76
%81 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%82 = and i32 %81, 65535
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = call i32 (...) @_EEPROMSectorMaskClear()
br label %86
86: ; preds = %84, %80, %76
%87 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
store i32 %87, i32* %4
br label %88
88: ; preds = %86, %60
%89 = load i32, i32* %4
ret i32 %89
}

LLVM IR (-O2):
define i32 @EEPROMProgram(i32* nocapture %0, i32 %1, i32 %2) {
br label %4
4: ; preds = %4, %3
%5 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %4
8: ; preds = %4
%9 = ashr i32 %1, 6
store volatile i32 %9, i32* inttoptr (i64 1074458628 to i32*)
%10 = lshr i32 %1, 2
%11 = and i32 %10, 15
store volatile i32 %11, i32* inttoptr (i64 1074458632 to i32*)
%12 = add i32 %2, 3
%13 = icmp ult i32 %12, 7
br i1 %13, label %58, label %14
14: ; preds = %8
%15 = sdiv i32 %2, 4
br label %16
16: ; preds = %57, %14
%17 = phi i32 [ %15, %14 ], [ %49, %57 ]
%18 = phi i32* [ %0, %14 ], [ %48, %57 ]
%19 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%20 = and i32 %19, 1895759872
%21 = icmp eq i32 %20, 268763136
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%24 = and i32 %23, 65535
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = tail call i32 @_EEPROMSectorMaskSet(i32 %1)
br label %28
28: ; preds = %26, %22, %16
%29 = load i32, i32* %18
store volatile i32 %29, i32* inttoptr (i64 1074458644 to i32*)
br label %30
30: ; preds = %30, %28
%31 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
%32 = and i32 %31, 1
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %30
34: ; preds = %30
%35 = and i32 %31, 272
%36 = icmp eq i32 %35, 0
br i1 %36, label %47, label %37
37: ; preds = %34
%38 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%39 = and i32 %38, 1895759872
%40 = icmp eq i32 %39, 268763136
br i1 %40, label %41, label %70
41: ; preds = %37
%42 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%43 = and i32 %42, 65535
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %70
45: ; preds = %41
%46 = tail call i32 (...) @_EEPROMSectorMaskClear()
br label %70
47: ; preds = %34
%48 = getelementptr inbounds i32, i32* %18, i64 1
%49 = add nsw i32 %17, -1
%50 = icmp eq i32 %49, 0
br i1 %50, label %58, label %51
51: ; preds = %47
%52 = load volatile i32, i32* inttoptr (i64 1074458632 to i32*)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load volatile i32, i32* inttoptr (i64 1074458628 to i32*)
%56 = add nsw i32 %55, 1
store volatile i32 %56, i32* inttoptr (i64 1074458628 to i32*)
br label %57
57: ; preds = %54, %51
br label %16
58: ; preds = %47, %8
%59 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%60 = and i32 %59, 1895759872
%61 = icmp eq i32 %60, 268763136
br i1 %61, label %62, label %68
62: ; preds = %58
%63 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%64 = and i32 %63, 65535
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = tail call i32 (...) @_EEPROMSectorMaskClear()
br label %68
68: ; preds = %66, %62, %58
%69 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
br label %70
70: ; preds = %37, %41, %45, %68
%71 = phi i32 [ %69, %68 ], [ %31, %45 ], [ %31, %41 ], [ %31, %37 ]
ret i32 %71
}