#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 _FLASH_nextPage(unsigned long);
short _FLASH_unlockBlocks(unsigned long start, unsigned long length) {
  unsigned long end = start + length - 1;
  unsigned long addr;
  volatile unsigned short *pblock;
  for (addr = start; addr <= end; addr = _FLASH_nextPage(addr)) {
    pblock = (volatile unsigned short *)addr;
    *pblock = 0x60;
    *pblock = 0xD0;
    *pblock = 0xFF;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_FLASH_unlockBlocks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     117b <_FLASH_unlockBlocks+0x6b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movw   $0x60,(%rax)
mov    -0x28(%rbp),%rax
movw   $0xd0,(%rax)
mov    -0x28(%rbp),%rax
movw   $0xff,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <_FLASH_nextPage@plt>
mov    %rax,-0x20(%rbp)
jmp    1138 <_FLASH_unlockBlocks+0x28>
xor    %eax,%eax
cwtl
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_FLASH_unlockBlocks>:
push   %rbx
lea    (%rdi,%rsi,1),%rbx
add    $0xffffffffffffffff,%rbx
cmp    %rdi,%rbx
jb     114c <_FLASH_unlockBlocks+0x3c>
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movw   $0x60,(%rax)
movw   $0xd0,(%rax)
movw   $0xff,(%rax)
mov    %rax,%rdi
call   1030 <_FLASH_nextPage@plt>
cmp    %rbx,%rax
jbe    1130 <_FLASH_unlockBlocks+0x20>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i16 @_FLASH_unlockBlocks(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i16*
store i64 %0, i64* %3
store i64 %1, i64* %4
%8 = load i64, i64* %3
%9 = load i64, i64* %4
%10 = add i64 %8, %9
%11 = sub i64 %10, 1
store i64 %11, i64* %5
%12 = load i64, i64* %3
store i64 %12, i64* %6
br label %13
13: ; preds = %23, %2
%14 = load i64, i64* %6
%15 = load i64, i64* %5
%16 = icmp ule i64 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i64, i64* %6
%19 = inttoptr i64 %18 to i16*
store i16* %19, i16** %7
%20 = load i16*, i16** %7
store volatile i16 96, i16* %20
%21 = load i16*, i16** %7
store volatile i16 208, i16* %21
%22 = load i16*, i16** %7
store volatile i16 255, i16* %22
br label %23
23: ; preds = %17
%24 = load i64, i64* %6
%25 = call i64 @_FLASH_nextPage(i64 %24)
store i64 %25, i64* %6
br label %13
26: ; preds = %13
ret i16 0
}

LLVM IR (-O2):
define signext i16 @_FLASH_unlockBlocks(i64 %0, i64 %1) {
%3 = add i64 %0, -1
%4 = add i64 %3, %1
%5 = icmp ult i64 %4, %0
br i1 %5, label %11, label %6
6: ; preds = %2, %6
%7 = phi i64 [ %9, %6 ], [ %0, %2 ]
%8 = inttoptr i64 %7 to i16*
store volatile i16 96, i16* %8
store volatile i16 208, i16* %8
store volatile i16 255, i16* %8
%9 = tail call i64 @_FLASH_nextPage(i64 %7)
%10 = icmp ugt i64 %9, %4
br i1 %10, label %11, label %6
11: ; preds = %6, %2
ret i16 0
}