#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;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
int32_t FlashErase(uint32_t ui32Address) {
  ASSERT(!(ui32Address & (0x00000400 - 1)));
  (*((volatile uint32_t *)(0x400FD014))) =
      (0x00000001 | 0x00000200 | 0x00000800);
  (*((volatile uint32_t *)(0x400FD000))) = ui32Address;
  (*((volatile uint32_t *)(0x400FD008))) = 0xA4420000 | 0x00000002;
  while ((*((volatile uint32_t *)(0x400FD008))) & 0x00000002) {
  }
  if ((*((volatile uint32_t *)(0x400FD00C))) &
      (0x00000001 | 0x00000200 | 0x00000800)) {
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashErase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x3ff,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    $0x400fd014,%eax
movl   $0xa01,(%rax)
mov    -0x8(%rbp),%ecx
mov    $0x400fd000,%eax
mov    %ecx,(%rax)
mov    $0x400fd008,%eax
movl   $0xa4420002,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     116d <FlashErase+0x5d>
jmp    1155 <FlashErase+0x45>
mov    $0x400fd00c,%eax
mov    (%rax),%eax
and    $0xa01,%eax
cmp    $0x0,%eax
je     118e <FlashErase+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <FlashErase+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlashErase>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
test   $0x3ff,%ebx
sete   %dil
call   1030 <ASSERT@plt>
movl   $0xa01,0x400fd014
mov    %ebx,0x400fd000
movl   $0xa4420002,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
testl  $0x2,0x400fd008
jne    1150 <FlashErase+0x40>
mov    $0xa01,%eax
and    0x400fd00c,%eax
neg    %eax
sbb    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @FlashErase(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 1023
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
%8 = zext i1 %7 to i32
%9 = call i32 @ASSERT(i32 %8)
store volatile i32 2561, i32* inttoptr (i64 1074778132 to i32*)
%10 = load i32, i32* %3
store volatile i32 %10, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178494, i32* inttoptr (i64 1074778120 to i32*)
br label %11
11: ; preds = %15, %1
%12 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%13 = and i32 %12, 2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
br label %11
16: ; preds = %11
%17 = load volatile i32, i32* inttoptr (i64 1074778124 to i32*)
%18 = and i32 %17, 2561
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %2
br label %22
21: ; preds = %16
store i32 0, i32* %2
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @FlashErase(i32 %0) {
%2 = and i32 %0, 1023
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @ASSERT(i32 %4)
store volatile i32 2561, i32* inttoptr (i64 1074778132 to i32*)
store volatile i32 %0, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178494, i32* inttoptr (i64 1074778120 to i32*)
br label %6
6: ; preds = %6, %1
%7 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%8 = and i32 %7, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %6
10: ; preds = %6
%11 = load volatile i32, i32* inttoptr (i64 1074778124 to i32*)
%12 = and i32 %11, 2561
%13 = icmp ne i32 %12, 0
%14 = sext i1 %13 to i32
ret i32 %14
}