#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*/ DEBUG_ASSERT(int);
int /*<<< orphan*/ EEPROMSetSectorMask(unsigned long);
unsigned long EEPROMProgramNonBlocking(unsigned long ulData,
                                       unsigned long ulAddress) {
  DEBUG_ASSERT(
      ulAddress <
      (((((*((volatile unsigned long *)(0x400AF000)))) & 0x0000FFFF) >> 0) *
       4));
  DEBUG_ASSERT((ulAddress & 3) == 0);
  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);
  (*((volatile unsigned long *)(0x400AF014))) = ulData;
  return ((*((volatile unsigned long *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMProgramNonBlocking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x400af000,%ecx
mov    (%rcx),%rcx
and    $0xffff,%rcx
shr    $0x0,%rcx
shl    $0x2,%rcx
cmp    %rcx,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10050000,%rax
jne    11af <EEPROMProgramNonBlocking+0x8f>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0xffff,%rax
cmp    $0x0,%rax
jne    11af <EEPROMProgramNonBlocking+0x8f>
mov    -0x10(%rbp),%rdi
call   1040 <EEPROMSetSectorMask@plt>
mov    -0x10(%rbp),%rcx
shr    $0x6,%rcx
mov    $0x400af004,%eax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x2,%rcx
and    $0xf,%rcx
mov    $0x400af008,%eax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
mov    $0x400af014,%eax
mov    %rcx,(%rax)
mov    $0x400af018,%eax
mov    (%rax),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMProgramNonBlocking>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x400af000,%rax
40
movzwl %ax,%eax
shl    $0x2,%rax
xor    %edi,%edi
cmp    %rsi,%rax
seta   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
test   $0x3,%bl
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    117e <EEPROMProgramNonBlocking+0x5e>
mov    0x400fe000,%rax
40
test   %ax,%ax
jne    117e <EEPROMProgramNonBlocking+0x5e>
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
mov    %r14,0x400af014
40
mov    0x400af018,%rax
40
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @EEPROMProgramNonBlocking(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = load volatile i64, i64* inttoptr (i64 1074458624 to i64*)
%7 = and i64 %6, 65535
%8 = lshr i64 %7, 0
%9 = mul i64 %8, 4
%10 = icmp ult i64 %5, %9
%11 = zext i1 %10 to i32
%12 = call i32 @DEBUG_ASSERT(i32 %11)
%13 = load i64, i64* %4
%14 = and i64 %13, 3
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @DEBUG_ASSERT(i32 %16)
%18 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%19 = and i64 %18, 1895759872
%20 = icmp eq i64 %19, 268763136
br i1 %20, label %21, label %28
21: ; preds = %2
%22 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%23 = and i64 %22, 65535
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i64, i64* %4
%27 = call i32 @EEPROMSetSectorMask(i64 %26)
br label %28
28: ; preds = %25, %21, %2
%29 = load i64, i64* %4
%30 = lshr i64 %29, 6
store volatile i64 %30, i64* inttoptr (i64 1074458628 to i64*)
%31 = load i64, i64* %4
%32 = lshr i64 %31, 2
%33 = and i64 %32, 15
store volatile i64 %33, i64* inttoptr (i64 1074458632 to i64*)
%34 = load i64, i64* %3
store volatile i64 %34, i64* inttoptr (i64 1074458644 to i64*)
%35 = load volatile i64, i64* inttoptr (i64 1074458648 to i64*)
ret i64 %35
}

LLVM IR (-O2):
define i64 @EEPROMProgramNonBlocking(i64 %0, i64 %1) {
%3 = load volatile i64, i64* inttoptr (i64 1074458624 to i64*)
%4 = shl i64 %3, 2
%5 = and i64 %4, 262140
%6 = icmp ugt i64 %5, %1
%7 = zext i1 %6 to i32
%8 = tail call i32 @DEBUG_ASSERT(i32 %7)
%9 = and i64 %1, 3
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @DEBUG_ASSERT(i32 %11)
%13 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%14 = and i64 %13, 1895759872
%15 = icmp eq i64 %14, 268763136
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%18 = and i64 %17, 65535
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @EEPROMSetSectorMask(i64 %1)
br label %22
22: ; preds = %20, %16, %2
%23 = lshr i64 %1, 6
store volatile i64 %23, i64* inttoptr (i64 1074458628 to i64*)
%24 = lshr i64 %1, 2
%25 = and i64 %24, 15
store volatile i64 %25, i64* inttoptr (i64 1074458632 to i64*)
store volatile i64 %0, i64* inttoptr (i64 1074458644 to i64*)
%26 = load volatile i64, i64* inttoptr (i64 1074458648 to i64*)
ret i64 %26
}