#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 */

/* Variables and functions */
int /*<<< orphan*/ EEPROMClearSectorMask();
int /*<<< orphan*/ EEPROMSetSectorMask(unsigned long);
unsigned long EEPROMProgram(unsigned long *pulData, unsigned long ulAddress,
                            unsigned long ulCount) {
  unsigned long ulStatus;
  ;
  ;
  ;
  ;
  ;
  if ((((*((volatile unsigned long *)(0x400FE000))) &
        (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) &&
      (((*((volatile unsigned long *)(0x400FE000))) &
        (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
    EEPROMSetSectorMask(ulAddress);
  }
  (*((volatile unsigned long *)(0x400AF004))) = ((ulAddress) >> 6);
  (*((volatile unsigned long *)(0x400AF008))) = (((ulAddress) >> 2) & 0x0F);
  ulCount /= 4;
  while (ulCount) {
    (*((volatile unsigned long *)(0x400AF014))) = *pulData;
    do {
      ulStatus = (*((volatile unsigned long *)(0x400AF018)));
    } while (ulStatus & 0x00000001);
    if (ulStatus & (0x00000010 | 0x00000100)) {
      if ((((*((volatile unsigned long *)(0x400FE000))) &
            (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) &&
          (((*((volatile unsigned long *)(0x400FE000))) &
            (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
        EEPROMClearSectorMask();
      }
      return (ulStatus);
    }
    pulData++;
    ulCount--;
    if ((*((volatile unsigned long *)(0x400AF008))) == 0) {
      (*((volatile unsigned long *)(0x400AF004))) += 1;
    }
  }
  if ((((*((volatile unsigned long *)(0x400FE000))) &
        (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) &&
      (((*((volatile unsigned long *)(0x400FE000))) &
        (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
    EEPROMClearSectorMask();
  }
  return ((*((volatile unsigned long *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10050000,%rax
jne    116f <EEPROMProgram+0x4f>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0xffff,%rax
cmp    $0x0,%rax
jne    116f <EEPROMProgram+0x4f>
mov    -0x18(%rbp),%rdi
call   1040 <EEPROMSetSectorMask@plt>
mov    -0x18(%rbp),%rcx
shr    $0x6,%rcx
mov    $0x400af004,%eax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
shr    $0x2,%rcx
and    $0xf,%rcx
mov    $0x400af008,%eax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
shr    $0x2,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1274 <EEPROMProgram+0x154>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x400af014,%eax
mov    %rcx,(%rax)
mov    $0x400af018,%eax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    11b9 <EEPROMProgram+0x99>
mov    -0x28(%rbp),%rax
and    $0x110,%rax
cmp    $0x0,%rax
je     1231 <EEPROMProgram+0x111>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10050000,%rax
jne    1224 <EEPROMProgram+0x104>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0xffff,%rax
cmp    $0x0,%rax
jne    1224 <EEPROMProgram+0x104>
mov    $0x0,%al
call   1030 <EEPROMClearSectorMask@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12b9 <EEPROMProgram+0x199>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    $0x400af008,%eax
mov    (%rax),%rax
cmp    $0x0,%rax
jne    126f <EEPROMProgram+0x14f>
mov    $0x400af004,%eax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    $0x400af004,%eax
mov    %rcx,(%rax)
jmp    119f <EEPROMProgram+0x7f>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10050000,%rax
jne    12ad <EEPROMProgram+0x18d>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0xffff,%rax
cmp    $0x0,%rax
jne    12ad <EEPROMProgram+0x18d>
mov    $0x0,%al
call   1030 <EEPROMClearSectorMask@plt>
mov    $0x400af018,%eax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMProgram>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    1157 <EEPROMProgram+0x37>
mov    0x400fe000,%rax
40
test   %ax,%ax
jne    1157 <EEPROMProgram+0x37>
mov    %rbx,%rdi
call   1040 <EEPROMSetSectorMask@plt>
mov    %rbx,%rax
shr    $0x6,%rax
mov    %rax,0x400af004
40
shr    $0x2,%ebx
and    $0xf,%ebx
mov    %rbx,0x400af008
40
cmp    $0x4,%r14
jae    11b3 <EEPROMProgram+0x93>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    11a2 <EEPROMProgram+0x82>
mov    0x400fe000,%rax
40
test   %ax,%ax
jne    11a2 <EEPROMProgram+0x82>
xor    %eax,%eax
call   1030 <EEPROMClearSectorMask@plt>
mov    0x400af018,%rbx
40
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
shr    $0x2,%r14
jmp    11c9 <EEPROMProgram+0xa9>
nopl   0x0(%rax)
add    $0x8,%r15
test   %r14,%r14
je     117a <EEPROMProgram+0x5a>
mov    (%r15),%rax
mov    %rax,0x400af014
40
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x400af018,%rbx
40
test   $0x1,%bl
jne    11e0 <EEPROMProgram+0xc0>
test   $0x110,%ebx
jne    120f <EEPROMProgram+0xef>
add    $0xffffffffffffffff,%r14
cmpq   $0x0,0x400af008
jne    11c0 <EEPROMProgram+0xa0>
addq   $0x1,0x400af004
40 01
jmp    11c0 <EEPROMProgram+0xa0>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    11aa <EEPROMProgram+0x8a>
mov    0x400fe000,%rax
40
test   %ax,%ax
jne    11aa <EEPROMProgram+0x8a>
xor    %eax,%eax
call   1030 <EEPROMClearSectorMask@plt>
jmp    11aa <EEPROMProgram+0x8a>

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

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