#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 */
unsigned long chip_base_address(unsigned long);
int /*<<< orphan*/ flashrom_chip_write(unsigned long, int);
int /*<<< orphan*/ flashrom_wait_toggle_bit(unsigned long);
void flashrom_sector_erase(unsigned long address) {
  unsigned long base_address;
  base_address = chip_base_address(address);
  flashrom_chip_write(base_address | 0x5555, 0xAA);
  flashrom_chip_write(base_address | 0x2AAA, 0x55);
  flashrom_chip_write(base_address | 0x5555, 0x80);
  flashrom_chip_write(base_address | 0x5555, 0xAA);
  flashrom_chip_write(base_address | 0x2AAA, 0x55);
  flashrom_chip_write(address, 0x30);
  flashrom_wait_toggle_bit(address);
}


x86 assembly (clang, -O0):
<flashrom_sector_erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <chip_base_address@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
or     $0x5555,%rdi
mov    $0xaa,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x10(%rbp),%rdi
or     $0x2aaa,%rdi
mov    $0x55,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x10(%rbp),%rdi
or     $0x5555,%rdi
mov    $0x80,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x10(%rbp),%rdi
or     $0x5555,%rdi
mov    $0xaa,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x10(%rbp),%rdi
or     $0x2aaa,%rdi
mov    $0x55,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x30,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x8(%rbp),%rdi
call   1050 <flashrom_wait_toggle_bit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flashrom_sector_erase>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <chip_base_address@plt>
mov    %rax,%r15
mov    %rax,%rbx
or     $0x5555,%rbx
mov    %rbx,%rdi
mov    $0xaa,%esi
call   1040 <flashrom_chip_write@plt>
or     $0x2aaa,%r15
mov    %r15,%rdi
mov    $0x55,%esi
call   1040 <flashrom_chip_write@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
call   1040 <flashrom_chip_write@plt>
mov    %rbx,%rdi
mov    $0xaa,%esi
call   1040 <flashrom_chip_write@plt>
mov    %r15,%rdi
mov    $0x55,%esi
call   1040 <flashrom_chip_write@plt>
mov    %r14,%rdi
mov    $0x30,%esi
call   1040 <flashrom_chip_write@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <flashrom_wait_toggle_bit@plt>

LLVM IR (-O0):
define void @flashrom_sector_erase(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i64 @chip_base_address(i64 %4)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = or i64 %6, 21845
%8 = call i32 @flashrom_chip_write(i64 %7, i32 170)
%9 = load i64, i64* %3
%10 = or i64 %9, 10922
%11 = call i32 @flashrom_chip_write(i64 %10, i32 85)
%12 = load i64, i64* %3
%13 = or i64 %12, 21845
%14 = call i32 @flashrom_chip_write(i64 %13, i32 128)
%15 = load i64, i64* %3
%16 = or i64 %15, 21845
%17 = call i32 @flashrom_chip_write(i64 %16, i32 170)
%18 = load i64, i64* %3
%19 = or i64 %18, 10922
%20 = call i32 @flashrom_chip_write(i64 %19, i32 85)
%21 = load i64, i64* %2
%22 = call i32 @flashrom_chip_write(i64 %21, i32 48)
%23 = load i64, i64* %2
%24 = call i32 @flashrom_wait_toggle_bit(i64 %23)
ret void
}

LLVM IR (-O2):
define void @flashrom_sector_erase(i64 %0) {
%2 = tail call i64 @chip_base_address(i64 %0)
%3 = or i64 %2, 21845
%4 = tail call i32 @flashrom_chip_write(i64 %3, i32 170)
%5 = or i64 %2, 10922
%6 = tail call i32 @flashrom_chip_write(i64 %5, i32 85)
%7 = tail call i32 @flashrom_chip_write(i64 %3, i32 128)
%8 = tail call i32 @flashrom_chip_write(i64 %3, i32 170)
%9 = tail call i32 @flashrom_chip_write(i64 %5, i32 85)
%10 = tail call i32 @flashrom_chip_write(i64 %0, i32 48)
%11 = tail call i32 @flashrom_wait_toggle_bit(i64 %0)
ret void
}