#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 */
scalar_t__ FLASH_PrepareSectors(unsigned int, unsigned int);
int /*<<< orphan*/ iap_entry(unsigned int *, unsigned int *);
unsigned int FLASH_EraseSectors(unsigned int startSector,
                                unsigned int endSector) {
  unsigned int iap_command[5], iap_result[3];
  if (FLASH_PrepareSectors(startSector, endSector) == 0) {
    iap_command[0] = 52;
    iap_command[1] = startSector;
    iap_command[2] = endSector;
    iap_command[3] = 14745;
    iap_entry(iap_command, iap_result);
  }
  return iap_result[0];
}


x86 assembly (clang, -O0):
<FLASH_EraseSectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <FLASH_PrepareSectors@plt>
cmp    $0x0,%rax
jne    116a <FLASH_EraseSectors+0x4a>
movl   $0x34,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x3999,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <iap_entry@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FLASH_EraseSectors>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <FLASH_PrepareSectors@plt>
mov    %rax,%rcx
test   %rcx,%rcx
jne    115f <FLASH_EraseSectors+0x3f>
movl   $0x34,(%rsp)
mov    %ebp,0x4(%rsp)
mov    %ebx,0x8(%rsp)
movl   $0x3999,0xc(%rsp)
mov    %rsp,%rdi
lea    0x1c(%rsp),%rsi
call   1040 <iap_entry@plt>
mov    0x1c(%rsp),%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @FLASH_EraseSectors(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x i32]
%6 = alloca [3 x i32]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = call i64 @FLASH_PrepareSectors(i32 %7, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
store i32 52, i32* %12
%13 = load i32, i32* %3
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 1
store i32 %13, i32* %14
%15 = load i32, i32* %4
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
store i32 %15, i32* %16
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 3
store i32 14745, i32* %17
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%20 = call i32 @iap_entry(i32* %18, i32* %19)
br label %21
21: ; preds = %11, %2
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%23 = load i32, i32* %22
ret i32 %23
}

LLVM IR (-O2):
define i32 @FLASH_EraseSectors(i32 %0, i32 %1) {
%3 = alloca [5 x i32]
%4 = alloca [3 x i32]
%5 = bitcast [5 x i32]* %3 to i8*
%6 = bitcast [3 x i32]* %4 to i8*
%7 = tail call i64 @FLASH_PrepareSectors(i32 %0, i32 %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
store i32 52, i32* %10
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
store i32 %0, i32* %11
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 2
store i32 %1, i32* %12
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
store i32 14745, i32* %13
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%15 = call i32 @iap_entry(i32* %10, i32* %14)
%16 = load i32, i32* %14
br label %17
17: ; preds = %9, %2
%18 = phi i32 [ %16, %9 ], [ undef, %2 ]
ret i32 %18
}