#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 SMBWriteBlock(int, int, unsigned char *, int);
int /*<<< orphan*/ readClearStatusRegister();
int /*<<< orphan*/ sleep(int);
int eraseFlashBlock(int address) {
  int status;
  unsigned char setAddr[2];
  setAddr[0] = (address >> 8) & 0xFF;
  setAddr[1] = address & 0xFF;
  status = SMBWriteBlock(0x16, 0x20, setAddr, 2);
  if (status >= 0) {
    sleep(1);
    readClearStatusRegister();
  }
  return status;
}


x86 assembly (clang, -O0):
<eraseFlashBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,-0xa(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x9(%rbp)
lea    -0xa(%rbp),%rdx
mov    $0x16,%edi
mov    $0x20,%esi
mov    $0x2,%ecx
call   1030 <SMBWriteBlock@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     118a <eraseFlashBlock+0x5a>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x0,%al
call   1040 <readClearStatusRegister@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eraseFlashBlock>:
push   %rbx
sub    $0x10,%rsp
rol    $0x8,%di
mov    %di,0xe(%rsp)
lea    0xe(%rsp),%rdx
mov    $0x16,%edi
mov    $0x20,%esi
mov    $0x2,%ecx
call   1030 <SMBWriteBlock@plt>
mov    %eax,%ebx
test   %eax,%eax
js     116e <eraseFlashBlock+0x3e>
mov    $0x1,%edi
call   1050 <sleep@plt>
xor    %eax,%eax
call   1040 <readClearStatusRegister@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @eraseFlashBlock(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8]
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = ashr i32 %5, 8
%7 = and i32 %6, 255
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
store i8 %8, i8* %9
%10 = load i32, i32* %2
%11 = and i32 %10, 255
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
store i8 %12, i8* %13
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%15 = call i32 @SMBWriteBlock(i32 22, i32 32, i8* %14, i32 2)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = call i32 @sleep(i32 1)
%20 = call i32 (...) @readClearStatusRegister()
br label %21
21: ; preds = %18, %1
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
define i32 @eraseFlashBlock(i32 %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = lshr i32 %0, 8
%5 = trunc i32 %4 to i8
store i8 %5, i8* %3
%6 = trunc i32 %0 to i8
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 %6, i8* %7
%8 = call i32 @SMBWriteBlock(i32 22, i32 32, i8* %3, i32 2)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 @sleep(i32 1)
%12 = call i32 (...) @readClearStatusRegister()
br label %13
13: ; preds = %10, %1
ret i32 %8
}