#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*/ clear_RnB();
int /*<<< orphan*/ deselect_chip();
int /*<<< orphan*/ select_chip();
int /*<<< orphan*/ send_addr(unsigned long);
int /*<<< orphan*/ send_cmd(int);
int /*<<< orphan*/ wait_RnB();
int NF_Erase(unsigned long addr) {
  int ret;
  select_chip();
  clear_RnB();
  send_cmd(0x60);
  send_addr(addr & 0xff);
  send_addr((addr >> 8) & 0xff);
  send_addr((addr >> 16) & 0xff);
  send_cmd(0xd0);
  wait_RnB();
  send_cmd(0x70);
  ret = (*(volatile unsigned char *)0x4E000010);
  deselect_chip();
  return ret;
}


x86 assembly (clang, -O0):
<NF_Erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <select_chip@plt>
mov    $0x0,%al
call   1070 <clear_RnB@plt>
mov    $0x60,%edi
call   1080 <send_cmd@plt>
mov    -0x8(%rbp),%rdi
and    $0xff,%rdi
call   1040 <send_addr@plt>
mov    -0x8(%rbp),%rdi
shr    $0x8,%rdi
and    $0xff,%rdi
call   1040 <send_addr@plt>
mov    -0x8(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
call   1040 <send_addr@plt>
mov    $0xd0,%edi
call   1080 <send_cmd@plt>
mov    $0x0,%al
call   1060 <wait_RnB@plt>
mov    $0x70,%edi
call   1080 <send_cmd@plt>
mov    $0x4e000010,%eax
mov    (%rax),%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <deselect_chip@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NF_Erase>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <select_chip@plt>
xor    %eax,%eax
call   1070 <clear_RnB@plt>
mov    $0x60,%edi
call   1080 <send_cmd@plt>
movzbl %bl,%edi
call   1040 <send_addr@plt>
movzbl %bh,%edi
call   1040 <send_addr@plt>
shr    $0x10,%ebx
movzbl %bl,%edi
call   1040 <send_addr@plt>
mov    $0xd0,%edi
call   1080 <send_cmd@plt>
xor    %eax,%eax
call   1060 <wait_RnB@plt>
mov    $0x70,%edi
call   1080 <send_cmd@plt>
movzbl 0x4e000010,%ebx
4e
xor    %eax,%eax
call   1030 <deselect_chip@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @NF_Erase(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
%4 = call i32 (...) @select_chip()
%5 = call i32 (...) @clear_RnB()
%6 = call i32 @send_cmd(i32 96)
%7 = load i64, i64* %2
%8 = and i64 %7, 255
%9 = call i32 @send_addr(i64 %8)
%10 = load i64, i64* %2
%11 = lshr i64 %10, 8
%12 = and i64 %11, 255
%13 = call i32 @send_addr(i64 %12)
%14 = load i64, i64* %2
%15 = lshr i64 %14, 16
%16 = and i64 %15, 255
%17 = call i32 @send_addr(i64 %16)
%18 = call i32 @send_cmd(i32 208)
%19 = call i32 (...) @wait_RnB()
%20 = call i32 @send_cmd(i32 112)
%21 = load volatile i8, i8* inttoptr (i64 1308622864 to i8*)
%22 = zext i8 %21 to i32
store i32 %22, i32* %3
%23 = call i32 (...) @deselect_chip()
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @NF_Erase(i64 %0) {
%2 = tail call i32 (...) @select_chip()
%3 = tail call i32 (...) @clear_RnB()
%4 = tail call i32 @send_cmd(i32 96)
%5 = and i64 %0, 255
%6 = tail call i32 @send_addr(i64 %5)
%7 = lshr i64 %0, 8
%8 = and i64 %7, 255
%9 = tail call i32 @send_addr(i64 %8)
%10 = lshr i64 %0, 16
%11 = and i64 %10, 255
%12 = tail call i32 @send_addr(i64 %11)
%13 = tail call i32 @send_cmd(i32 208)
%14 = tail call i32 (...) @wait_RnB()
%15 = tail call i32 @send_cmd(i32 112)
%16 = load volatile i8, i8* inttoptr (i64 1308622864 to i8*)
%17 = zext i8 %16 to i32
%18 = tail call i32 (...) @deselect_chip()
ret i32 %17
}