#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_chip_erase(unsigned long base_address) {
  base_address = chip_base_address(base_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(base_address | 0x5555, 0x10);
  flashrom_wait_toggle_bit(base_address);
}


x86 assembly (clang, -O0):
<flashrom_chip_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,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
or     $0x5555,%rdi
mov    $0xaa,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x8(%rbp),%rdi
or     $0x2aaa,%rdi
mov    $0x55,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x8(%rbp),%rdi
or     $0x5555,%rdi
mov    $0x80,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x8(%rbp),%rdi
or     $0x5555,%rdi
mov    $0xaa,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x8(%rbp),%rdi
or     $0x2aaa,%rdi
mov    $0x55,%esi
call   1040 <flashrom_chip_write@plt>
mov    -0x8(%rbp),%rdi
or     $0x5555,%rdi
mov    $0x10,%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_chip_erase>:
push   %r15
push   %r14
push   %rbx
call   1030 <chip_base_address@plt>
mov    %rax,%r14
mov    %rax,%rbx
or     $0x5555,%rbx
mov    %rbx,%rdi
mov    $0xaa,%esi
call   1040 <flashrom_chip_write@plt>
mov    %r14,%r15
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    %rbx,%rdi
mov    $0x10,%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_chip_erase(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = call i64 @chip_base_address(i64 %3)
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = or i64 %5, 21845
%7 = call i32 @flashrom_chip_write(i64 %6, i32 170)
%8 = load i64, i64* %2
%9 = or i64 %8, 10922
%10 = call i32 @flashrom_chip_write(i64 %9, i32 85)
%11 = load i64, i64* %2
%12 = or i64 %11, 21845
%13 = call i32 @flashrom_chip_write(i64 %12, i32 128)
%14 = load i64, i64* %2
%15 = or i64 %14, 21845
%16 = call i32 @flashrom_chip_write(i64 %15, i32 170)
%17 = load i64, i64* %2
%18 = or i64 %17, 10922
%19 = call i32 @flashrom_chip_write(i64 %18, i32 85)
%20 = load i64, i64* %2
%21 = or i64 %20, 21845
%22 = call i32 @flashrom_chip_write(i64 %21, i32 16)
%23 = load i64, i64* %2
%24 = call i32 @flashrom_wait_toggle_bit(i64 %23)
ret void
}

LLVM IR (-O2):
define void @flashrom_chip_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 %3, i32 16)
%11 = tail call i32 @flashrom_wait_toggle_bit(i64 %2)
ret void
}