#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*/ delete_chip();
int /*<<< orphan*/ select_chip();
int /*<<< orphan*/ send_addr(unsigned long);
int /*<<< orphan*/ send_cmd(int);
int /*<<< orphan*/ wait_RnB();
void NF_Page_Erase(unsigned long addr) {
  int i;
  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 *)0x70200010);
  delete_chip();
}


x86 assembly (clang, -O0):
<NF_Page_Erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <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   1030 <send_addr@plt>
mov    -0x8(%rbp),%rdi
shr    $0x8,%rdi
and    $0xff,%rdi
call   1030 <send_addr@plt>
mov    -0x8(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
call   1030 <send_addr@plt>
mov    $0xd0,%edi
call   1080 <send_cmd@plt>
mov    $0x0,%al
call   1050 <wait_RnB@plt>
mov    $0x70,%edi
call   1080 <send_cmd@plt>
mov    $0x70200010,%eax
mov    (%rax),%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <delete_chip@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @NF_Page_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 1881145360 to i8*)
%17 = tail call i32 (...) @delete_chip()
ret void
}