#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*/ FCache_Invalidate();
int FCache_isEnabled();
void EFlash_Write(unsigned int waddr, unsigned int data) {
  *(volatile unsigned int *)(0x40009000 + 0x02C) = data;
  ;
  *(volatile unsigned int *)(0x40009000 + 0x028) = waddr;
  ;
  *(volatile unsigned int *)(0x40009000 + 0x014) = 1;
  ;
  while ((*(volatile unsigned int *)(0x40009000 + 0x018) & 1) == 1)
    ;
  if (FCache_isEnabled() == 1)
    FCache_Invalidate();
}


x86 assembly (clang, -O0):
<EFlash_Write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x4000902c,%eax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
mov    $0x40009028,%eax
mov    %ecx,(%rax)
mov    $0x40009014,%eax
movl   $0x1,(%rax)
mov    $0x40009018,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    1165 <EFlash_Write+0x45>
jmp    114d <EFlash_Write+0x2d>
mov    $0x0,%al
call   1040 <FCache_isEnabled@plt>
cmp    $0x1,%eax
jne    117c <EFlash_Write+0x5c>
mov    $0x0,%al
call   1030 <FCache_Invalidate@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EFlash_Write>:
push   %rax
mov    %esi,0x4000902c
mov    %edi,0x40009028
movl   $0x1,0x40009014
nopw   0x0(%rax,%rax,1)
mov    0x40009018,%eax
test   $0x1,%al
jne    1140 <EFlash_Write+0x20>
xor    %eax,%eax
call   1040 <FCache_isEnabled@plt>
cmp    $0x1,%eax
jne    115f <EFlash_Write+0x3f>
xor    %eax,%eax
pop    %rcx
jmp    1030 <FCache_Invalidate@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @EFlash_Write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
store volatile i32 %5, i32* inttoptr (i64 1073778732 to i32*)
%6 = load i32, i32* %3
store volatile i32 %6, i32* inttoptr (i64 1073778728 to i32*)
store volatile i32 1, i32* inttoptr (i64 1073778708 to i32*)
br label %7
7: ; preds = %11, %2
%8 = load volatile i32, i32* inttoptr (i64 1073778712 to i32*)
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = call i32 (...) @FCache_isEnabled()
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (...) @FCache_Invalidate()
br label %17
17: ; preds = %15, %12
ret void
}

LLVM IR (-O2):
define void @EFlash_Write(i32 %0, i32 %1) {
store volatile i32 %1, i32* inttoptr (i64 1073778732 to i32*)
store volatile i32 %0, i32* inttoptr (i64 1073778728 to i32*)
store volatile i32 1, i32* inttoptr (i64 1073778708 to i32*)
br label %3
3: ; preds = %3, %2
%4 = load volatile i32, i32* inttoptr (i64 1073778712 to i32*)
%5 = and i32 %4, 1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %3
7: ; preds = %3
%8 = tail call i32 (...) @FCache_isEnabled()
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 (...) @FCache_Invalidate()
br label %12
12: ; preds = %10, %7
ret void
}