#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*/ ASSERT(int);
uint32_t EEPROMBlockProtectSet(uint32_t ui32Block, uint32_t ui32Protect) {
  ASSERT(ui32Block <
         ((((*((volatile uint32_t *)(0x400AF000)))) & 0x07FF0000) >> 16));
  (*((volatile uint32_t *)(0x400AF004))) = ui32Block;
  (*((volatile uint32_t *)(0x400AF030))) = ui32Protect;
  while ((*((volatile uint32_t *)(0x400AF018))) & 0x00000001) {
  }
  return ((*((volatile uint32_t *)(0x400AF018))));
}


x86 assembly (clang, -O0):
<EEPROMBlockProtectSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x400af000,%ecx
mov    (%rcx),%ecx
and    $0x7ff0000,%ecx
sar    $0x10,%ecx
cmp    %ecx,%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x4(%rbp),%ecx
mov    $0x400af004,%eax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%ecx
mov    $0x400af030,%eax
mov    %ecx,(%rax)
mov    $0x400af018,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116c <EEPROMBlockProtectSet+0x5c>
jmp    1154 <EEPROMBlockProtectSet+0x44>
mov    $0x400af018,%eax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROMBlockProtectSet>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x400af000,%eax
shr    $0x10,%eax
and    $0x7ff,%eax
xor    %edi,%edi
cmp    %ebp,%eax
setg   %dil
call   1030 <ASSERT@plt>
mov    %ebp,0x400af004
mov    %ebx,0x400af030
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x400af018,%eax
test   $0x1,%al
jne    1150 <EEPROMBlockProtectSet+0x40>
mov    0x400af018,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @EEPROMBlockProtectSet(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load volatile i32, i32* inttoptr (i64 1074458624 to i32*)
%7 = and i32 %6, 134152192
%8 = ashr i32 %7, 16
%9 = icmp slt i32 %5, %8
%10 = zext i1 %9 to i32
%11 = call i32 @ASSERT(i32 %10)
%12 = load i32, i32* %3
store volatile i32 %12, i32* inttoptr (i64 1074458628 to i32*)
%13 = load i32, i32* %4
store volatile i32 %13, i32* inttoptr (i64 1074458672 to i32*)
br label %14
14: ; preds = %18, %2
%15 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
%16 = and i32 %15, 1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %14
19: ; preds = %14
%20 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
ret i32 %20
}

LLVM IR (-O2):
define i32 @EEPROMBlockProtectSet(i32 %0, i32 %1) {
%3 = load volatile i32, i32* inttoptr (i64 1074458624 to i32*)
%4 = lshr i32 %3, 16
%5 = and i32 %4, 2047
%6 = icmp sgt i32 %5, %0
%7 = zext i1 %6 to i32
%8 = tail call i32 @ASSERT(i32 %7)
store volatile i32 %0, i32* inttoptr (i64 1074458628 to i32*)
store volatile i32 %1, i32* inttoptr (i64 1074458672 to i32*)
br label %9
9: ; preds = %9, %2
%10 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %9
13: ; preds = %9
%14 = load volatile i32, i32* inttoptr (i64 1074458648 to i32*)
ret i32 %14
}