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

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


x86 assembly (clang, -O0):
<FlashErase>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    $0x400fd014,%eax
movq   $0xa01,(%rax)
mov    -0x10(%rbp),%rcx
mov    $0x400fd000,%eax
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    $0xa4420002,%ecx
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     1148 <FlashErase+0x48>
jmp    112d <FlashErase+0x2d>
mov    $0x400fd00c,%eax
mov    (%rax),%rax
and    $0xa01,%rax
cmp    $0x0,%rax
je     116c <FlashErase+0x6c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1173 <FlashErase+0x73>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlashErase>:
movq   $0xa01,0x400fd014
mov    %rdi,0x400fd000
40
mov    $0xa4420002,%eax
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
testq  $0x2,0x400fd008
jne    1130 <FlashErase+0x30>
mov    0x400fd00c,%rax
40
and    $0xa01,%eax
neg    %rax
sbb    %eax,%eax
ret

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

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