#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 int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ bbspi_transfer(int, int);
void flash_serase(uint32_t addr) {
  bbspi_transfer(1, 0);
  bbspi_transfer(0, 0x06);
  bbspi_transfer(1, 0);
  bbspi_transfer(0, 0xD8);
  bbspi_transfer(0, (addr & 0xFF0000) >> 16);
  bbspi_transfer(0, (addr & 0xFF00) >> 8);
  bbspi_transfer(0, (addr & 0xFF));
  bbspi_transfer(1, 0);
}


x86 assembly (clang, -O0):
<flash_serase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <bbspi_transfer@plt>
xor    %edi,%edi
mov    $0x6,%esi
call   1030 <bbspi_transfer@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <bbspi_transfer@plt>
xor    %edi,%edi
mov    $0xd8,%esi
call   1030 <bbspi_transfer@plt>
mov    -0x4(%rbp),%esi
and    $0xff0000,%esi
sar    $0x10,%esi
xor    %edi,%edi
call   1030 <bbspi_transfer@plt>
mov    -0x4(%rbp),%esi
and    $0xff00,%esi
sar    $0x8,%esi
xor    %edi,%edi
call   1030 <bbspi_transfer@plt>
mov    -0x4(%rbp),%esi
and    $0xff,%esi
xor    %edi,%edi
call   1030 <bbspi_transfer@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <bbspi_transfer@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flash_serase>:
push   %rbx
mov    %edi,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <bbspi_transfer@plt>
xor    %edi,%edi
mov    $0x6,%esi
call   1030 <bbspi_transfer@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <bbspi_transfer@plt>
xor    %edi,%edi
mov    $0xd8,%esi
call   1030 <bbspi_transfer@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%esi
xor    %edi,%edi
call   1030 <bbspi_transfer@plt>
movzbl %bh,%esi
xor    %edi,%edi
call   1030 <bbspi_transfer@plt>
movzbl %bl,%esi
xor    %edi,%edi
call   1030 <bbspi_transfer@plt>
mov    $0x1,%edi
xor    %esi,%esi
pop    %rbx
jmp    1030 <bbspi_transfer@plt>

LLVM IR (-O0):
define void @flash_serase(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @bbspi_transfer(i32 1, i32 0)
%4 = call i32 @bbspi_transfer(i32 0, i32 6)
%5 = call i32 @bbspi_transfer(i32 1, i32 0)
%6 = call i32 @bbspi_transfer(i32 0, i32 216)
%7 = load i32, i32* %2
%8 = and i32 %7, 16711680
%9 = ashr i32 %8, 16
%10 = call i32 @bbspi_transfer(i32 0, i32 %9)
%11 = load i32, i32* %2
%12 = and i32 %11, 65280
%13 = ashr i32 %12, 8
%14 = call i32 @bbspi_transfer(i32 0, i32 %13)
%15 = load i32, i32* %2
%16 = and i32 %15, 255
%17 = call i32 @bbspi_transfer(i32 0, i32 %16)
%18 = call i32 @bbspi_transfer(i32 1, i32 0)
ret void
}

LLVM IR (-O2):
define void @flash_serase(i32 %0) {
%2 = tail call i32 @bbspi_transfer(i32 1, i32 0)
%3 = tail call i32 @bbspi_transfer(i32 0, i32 6)
%4 = tail call i32 @bbspi_transfer(i32 1, i32 0)
%5 = tail call i32 @bbspi_transfer(i32 0, i32 216)
%6 = lshr i32 %0, 16
%7 = and i32 %6, 255
%8 = tail call i32 @bbspi_transfer(i32 0, i32 %7)
%9 = lshr i32 %0, 8
%10 = and i32 %9, 255
%11 = tail call i32 @bbspi_transfer(i32 0, i32 %10)
%12 = and i32 %0, 255
%13 = tail call i32 @bbspi_transfer(i32 0, i32 %12)
%14 = tail call i32 @bbspi_transfer(i32 1, i32 0)
ret void
}