#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*/ nf_cmd(int);
int /*<<< orphan*/ nf_ncs0(int);
int /*<<< orphan*/ nf_reset();
int /*<<< orphan*/ nf_setaddr(unsigned long);
int /*<<< orphan*/ nf_wait_io();
int /*<<< orphan*/ nf_wait_rb();
int nf_erase(unsigned long addr) {
  ;
  addr >>= 17;
  nf_reset();
  nf_ncs0(0);
  nf_cmd(0x60);
  nf_setaddr(addr & 0xff);
  nf_setaddr((addr >> 8) & 0xff);
  nf_setaddr((addr >> 16) & 0xff);
  nf_cmd(0xD0);
  nf_wait_rb();
  nf_cmd(0x70);
  nf_wait_io();
  nf_ncs0(1);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<nf_erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x11,%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1080 <nf_reset@plt>
xor    %edi,%edi
call   1040 <nf_ncs0@plt>
mov    $0x60,%edi
call   1030 <nf_cmd@plt>
mov    -0x8(%rbp),%rdi
and    $0xff,%rdi
call   1070 <nf_setaddr@plt>
mov    -0x8(%rbp),%rdi
shr    $0x8,%rdi
and    $0xff,%rdi
call   1070 <nf_setaddr@plt>
mov    -0x8(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
call   1070 <nf_setaddr@plt>
mov    $0xd0,%edi
call   1030 <nf_cmd@plt>
mov    $0x0,%al
call   1060 <nf_wait_rb@plt>
mov    $0x70,%edi
call   1030 <nf_cmd@plt>
mov    $0x0,%al
call   1050 <nf_wait_io@plt>
mov    $0x1,%edi
call   1040 <nf_ncs0@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nf_erase>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %ebx,%eax
shr    $0x11,%eax
movzbl %al,%r14d
xor    %eax,%eax
call   1080 <nf_reset@plt>
xor    %edi,%edi
call   1040 <nf_ncs0@plt>
mov    $0x60,%edi
call   1030 <nf_cmd@plt>
mov    %r14,%rdi
call   1070 <nf_setaddr@plt>
mov    %rbx,%rax
shr    $0x19,%rax
movzbl %al,%edi
call   1070 <nf_setaddr@plt>
shr    $0x21,%rbx
movzbl %bl,%edi
call   1070 <nf_setaddr@plt>
mov    $0xd0,%edi
call   1030 <nf_cmd@plt>
xor    %eax,%eax
call   1060 <nf_wait_rb@plt>
mov    $0x70,%edi
call   1030 <nf_cmd@plt>
xor    %eax,%eax
call   1050 <nf_wait_io@plt>
mov    $0x1,%edi
call   1040 <nf_ncs0@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @nf_erase(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = lshr i64 %3, 17
store i64 %4, i64* %2
%5 = call i32 (...) @nf_reset()
%6 = call i32 @nf_ncs0(i32 0)
%7 = call i32 @nf_cmd(i32 96)
%8 = load i64, i64* %2
%9 = and i64 %8, 255
%10 = call i32 @nf_setaddr(i64 %9)
%11 = load i64, i64* %2
%12 = lshr i64 %11, 8
%13 = and i64 %12, 255
%14 = call i32 @nf_setaddr(i64 %13)
%15 = load i64, i64* %2
%16 = lshr i64 %15, 16
%17 = and i64 %16, 255
%18 = call i32 @nf_setaddr(i64 %17)
%19 = call i32 @nf_cmd(i32 208)
%20 = call i32 (...) @nf_wait_rb()
%21 = call i32 @nf_cmd(i32 112)
%22 = call i32 (...) @nf_wait_io()
%23 = call i32 @nf_ncs0(i32 1)
ret i32 0
}

LLVM IR (-O2):
define i32 @nf_erase(i64 %0) {
%2 = lshr i64 %0, 17
%3 = tail call i32 (...) @nf_reset()
%4 = tail call i32 @nf_ncs0(i32 0)
%5 = tail call i32 @nf_cmd(i32 96)
%6 = and i64 %2, 255
%7 = tail call i32 @nf_setaddr(i64 %6)
%8 = lshr i64 %0, 25
%9 = and i64 %8, 255
%10 = tail call i32 @nf_setaddr(i64 %9)
%11 = lshr i64 %0, 33
%12 = and i64 %11, 255
%13 = tail call i32 @nf_setaddr(i64 %12)
%14 = tail call i32 @nf_cmd(i32 208)
%15 = tail call i32 (...) @nf_wait_rb()
%16 = tail call i32 @nf_cmd(i32 112)
%17 = tail call i32 (...) @nf_wait_io()
%18 = tail call i32 @nf_ncs0(i32 1)
ret i32 0
}