#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*/ assert(int);
int /*<<< orphan*/ store_erase_page(int);
void flash_erase(uint32_t addr, size_t len) {
  assert(addr < (64 * (128)));
  assert(len + addr <= (64 * (128)));
  assert(len % (128) == 0);
  assert(addr % (128) == 0);
  store_erase_page(addr / (128));
}


x86 assembly (clang, -O0):
<flash_erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2000,-0x4(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
add    %rcx,%rax
cmp    $0x2000,%rax
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
and    $0x7f,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <store_erase_page@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flash_erase>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x2000,%ebp
setl   %dil
call   1030 <assert@plt>
movslq %ebp,%rbp
lea    (%rbx,%rbp,1),%rax
xor    %edi,%edi
cmp    $0x2001,%rax
setb   %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   $0x7f,%bl
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   $0x7f,%bpl
sete   %dil
call   1030 <assert@plt>
lea    0x7f(%rbp),%edi
test   %ebp,%ebp
cmovns %ebp,%edi
sar    $0x7,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <store_erase_page@plt>

LLVM IR (-O0):
define void @flash_erase(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %3
store i64 %1, i64* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 8192
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i64, i64* %4
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = add i64 %9, %11
%13 = icmp ule i64 %12, 8192
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i64, i64* %4
%17 = urem i64 %16, 128
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %3
%22 = srem i32 %21, 128
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* %3
%27 = sdiv i32 %26, 128
%28 = call i32 @store_erase_page(i32 %27)
ret void
}

LLVM IR (-O2):
define void @flash_erase(i32 %0, i64 %1) {
%3 = icmp slt i32 %0, 8192
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = sext i32 %0 to i64
%7 = add i64 %6, %1
%8 = icmp ult i64 %7, 8193
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = and i64 %1, 127
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = and i32 %0, 127
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = sdiv i32 %0, 128
%20 = tail call i32 @store_erase_page(i32 %19)
ret void
}