#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*/ EEPROMWaitForDone();
int /*<<< orphan*/ SysCtlDelay(int);
int /*<<< orphan*/ SysCtlPeripheralReset(int);
unsigned long EEPROMInit(void) {
  unsigned long ulStatus;
  SysCtlDelay(2);
  EEPROMWaitForDone();
  ulStatus = (*((volatile unsigned long *)(0x400AF01C)));
  if (ulStatus & (0x00000008 | 0x00000004)) {
    SysCtlPeripheralReset(0xf0005800);
    SysCtlDelay(2);
    EEPROMWaitForDone();
    ulStatus = (*((volatile unsigned long *)(0x400AF01C)));
    if (ulStatus & (0x00000008 | 0x00000004)) {
      return (2);
    } else {
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<EEPROMInit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2,%edi
call   1050 <SysCtlDelay@plt>
mov    $0x0,%al
call   1040 <EEPROMWaitForDone@plt>
mov    $0x400af01c,%eax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0xc,%rax
cmp    $0x0,%rax
je     11ba <EEPROMInit+0x8a>
mov    $0xf0005800,%edi
call   1030 <SysCtlPeripheralReset@plt>
mov    $0x2,%edi
call   1050 <SysCtlDelay@plt>
mov    $0x0,%al
call   1040 <EEPROMWaitForDone@plt>
mov    $0x400af01c,%eax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0xc,%rax
cmp    $0x0,%rax
je     11ad <EEPROMInit+0x7d>
movq   $0x2,-0x8(%rbp)
jmp    11c2 <EEPROMInit+0x92>
movq   $0x1,-0x8(%rbp)
jmp    11c2 <EEPROMInit+0x92>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMInit>:
push   %rbx
mov    $0x2,%edi
call   1050 <SysCtlDelay@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <EEPROMWaitForDone@plt>
testq  $0xc,0x400af01c
je     1185 <EEPROMInit+0x55>
mov    $0xf0005800,%edi
call   1030 <SysCtlPeripheralReset@plt>
mov    $0x2,%edi
call   1050 <SysCtlDelay@plt>
xor    %eax,%eax
call   1040 <EEPROMWaitForDone@plt>
mov    0x400af01c,%rax
40
and    $0xc,%eax
cmp    $0x1,%rax
mov    $0x2,%ebx
sbb    $0x0,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @EEPROMInit() {
%1 = alloca i64
%2 = alloca i64
%3 = call i32 @SysCtlDelay(i32 2)
%4 = call i32 (...) @EEPROMWaitForDone()
%5 = load volatile i64, i64* inttoptr (i64 1074458652 to i64*)
store i64 %5, i64* %2
%6 = load i64, i64* %2
%7 = and i64 %6, 12
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %0
%10 = call i32 @SysCtlPeripheralReset(i32 -268412928)
%11 = call i32 @SysCtlDelay(i32 2)
%12 = call i32 (...) @EEPROMWaitForDone()
%13 = load volatile i64, i64* inttoptr (i64 1074458652 to i64*)
store i64 %13, i64* %2
%14 = load i64, i64* %2
%15 = and i64 %14, 12
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %9
store i64 2, i64* %1
br label %20
18: ; preds = %9
store i64 1, i64* %1
br label %20
19: ; preds = %0
store i64 0, i64* %1
br label %20
20: ; preds = %19, %18, %17
%21 = load i64, i64* %1
ret i64 %21
}

LLVM IR (-O2):
define i64 @EEPROMInit() {
%1 = tail call i32 @SysCtlDelay(i32 2)
%2 = tail call i32 (...) @EEPROMWaitForDone()
%3 = load volatile i64, i64* inttoptr (i64 1074458652 to i64*)
%4 = and i64 %3, 12
%5 = icmp eq i64 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %0
%7 = tail call i32 @SysCtlPeripheralReset(i32 -268412928)
%8 = tail call i32 @SysCtlDelay(i32 2)
%9 = tail call i32 (...) @EEPROMWaitForDone()
%10 = load volatile i64, i64* inttoptr (i64 1074458652 to i64*)
%11 = and i64 %10, 12
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i64 1, i64 2
br label %14
14: ; preds = %0, %6
%15 = phi i64 [ %13, %6 ], [ 0, %0 ]
ret i64 %15
}