#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*/ EEPROMWaitForDone();
int /*<<< orphan*/ SysCtlDelay(int);
int /*<<< orphan*/ SysCtlPeripheralReset(int);
unsigned long EEPROMMassErase(void) {
  if ((((*((volatile unsigned long *)(0x400FE000))) &
        (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) &&
      (((*((volatile unsigned long *)(0x400FE000))) &
        (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
    EEPROMClearSectorMask();
  }
  (*((volatile unsigned long *)(0x400AF080))) =
      ((unsigned long)0xE37B << 16) | 0x00000001;
  EEPROMWaitForDone();
  SysCtlPeripheralReset(0xf0005800);
  SysCtlDelay(2);
  EEPROMWaitForDone();
  return ((*((volatile unsigned long *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMMassErase>:
push   %rbp
mov    %rsp,%rbp
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10050000,%rax
jne    117d <EEPROMMassErase+0x3d>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0xffff,%rax
cmp    $0x0,%rax
jne    117d <EEPROMMassErase+0x3d>
mov    $0x0,%al
call   1040 <EEPROMClearSectorMask@plt>
mov    $0x400af080,%eax
mov    $0xe37b0001,%ecx
mov    %rcx,(%rax)
mov    $0x0,%al
call   1050 <EEPROMWaitForDone@plt>
mov    $0xf0005800,%edi
call   1030 <SysCtlPeripheralReset@plt>
mov    $0x2,%edi
call   1060 <SysCtlDelay@plt>
mov    $0x0,%al
call   1050 <EEPROMWaitForDone@plt>
mov    $0x400af018,%eax
mov    (%rax),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMMassErase>:
push   %rax
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    1169 <EEPROMMassErase+0x29>
mov    0x400fe000,%rax
40
test   %ax,%ax
jne    1169 <EEPROMMassErase+0x29>
xor    %eax,%eax
call   1040 <EEPROMClearSectorMask@plt>
mov    $0xe37b0001,%eax
mov    %rax,0x400af080
40
xor    %eax,%eax
call   1050 <EEPROMWaitForDone@plt>
mov    $0xf0005800,%edi
call   1030 <SysCtlPeripheralReset@plt>
mov    $0x2,%edi
call   1060 <SysCtlDelay@plt>
xor    %eax,%eax
call   1050 <EEPROMWaitForDone@plt>
mov    0x400af018,%rax
40
pop    %rcx
ret

LLVM IR (-O0):
define i64 @EEPROMMassErase() {
%1 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%2 = and i64 %1, 1895759872
%3 = icmp eq i64 %2, 268763136
br i1 %3, label %4, label %10
4: ; preds = %0
%5 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%6 = and i64 %5, 65535
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = call i32 (...) @EEPROMClearSectorMask()
br label %10
10: ; preds = %8, %4, %0
store volatile i64 3816488961, i64* inttoptr (i64 1074458752 to i64*)
%11 = call i32 (...) @EEPROMWaitForDone()
%12 = call i32 @SysCtlPeripheralReset(i32 -268412928)
%13 = call i32 @SysCtlDelay(i32 2)
%14 = call i32 (...) @EEPROMWaitForDone()
%15 = load volatile i64, i64* inttoptr (i64 1074458648 to i64*)
ret i64 %15
}

LLVM IR (-O2):
define i64 @EEPROMMassErase() {
%1 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%2 = and i64 %1, 1895759872
%3 = icmp eq i64 %2, 268763136
br i1 %3, label %4, label %10
4: ; preds = %0
%5 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%6 = and i64 %5, 65535
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 (...) @EEPROMClearSectorMask()
br label %10
10: ; preds = %8, %4, %0
store volatile i64 3816488961, i64* inttoptr (i64 1074458752 to i64*)
%11 = tail call i32 (...) @EEPROMWaitForDone()
%12 = tail call i32 @SysCtlPeripheralReset(i32 -268412928)
%13 = tail call i32 @SysCtlDelay(i32 2)
%14 = tail call i32 (...) @EEPROMWaitForDone()
%15 = load volatile i64, i64* inttoptr (i64 1074458648 to i64*)
ret i64 %15
}