#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 scalar_t__ time_t;

/* Variables and functions */
scalar_t__ difftime(scalar_t__, scalar_t__);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sflash_erase_area(unsigned int, unsigned int);
int /*<<< orphan*/ sflash_reset();
scalar_t__ time(scalar_t__ *);
void run_erase(char *filename, unsigned int start, unsigned int length) {
  time_t start_time = time(0);
  time_t end_time, elapsed_seconds;
  printf("*** You Selected to Erase the %s ***\n\n", filename);
  printf("=========================\n");
  printf("Erasing Routine Started\n");
  printf("=========================\n");
  sflash_erase_area(start, length);
  sflash_reset();
  printf("=========================\n");
  printf("Erasing Routine Complete\n");
  printf("=========================\n");
  time(&end_time);
  elapsed_seconds = difftime(end_time, start_time);
  printf("elapsed time: %d seconds\n", (int)elapsed_seconds);
}


x86 assembly (clang, -O0):
<run_erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <sflash_erase_area@plt>
mov    $0x0,%al
call   1060 <sflash_reset@plt>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <time@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <difftime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_erase>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%rbp
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%r14
lea    0xe80(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee1(%rip),%rbp
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    %r15d,%esi
call   1080 <sflash_erase_area@plt>
xor    %eax,%eax
call   1070 <sflash_reset@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1060 <time@plt>
mov    (%rsp),%rdi
mov    %r14,%rsi
call   1050 <difftime@plt>
lea    0xe32(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"*** You Selected to Erase the %s ***\0A\0A\00"
@.str.1 = [27 x i8] c"=========================\0A\00"
@.str.2 = [25 x i8] c"Erasing Routine Started\0A\00"
@.str.3 = [26 x i8] c"Erasing Routine Complete\0A\00"
@.str.4 = [26 x i8] c"elapsed time: %d seconds\0A\00"
define void @run_erase(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = call i64 @time(i64* null)
store i64 %10, i64* %7
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = call i32 @sflash_erase_area(i32 %16, i32 %17)
%19 = call i32 (...) @sflash_reset()
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%23 = call i64 @time(i64* %8)
%24 = load i64, i64* %8
%25 = load i64, i64* %7
%26 = call i64 @difftime(i64 %24, i64 %25)
store i64 %26, i64* %9
%27 = load i64, i64* %9
%28 = trunc i64 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"*** You Selected to Erase the %s ***\0A\0A\00"
@.str.4 = [26 x i8] c"elapsed time: %d seconds\0A\00"
@str.5 = [24 x i8] c"Erasing Routine Started\00"
@str.8 = [25 x i8] c"Erasing Routine Complete\00"
@str.9 = [26 x i8] c"=========================\00"
define void @run_erase(i8* %0, i32 %1, i32 %2) {
%4 = alloca i64
%5 = tail call i64 @time(i64* null)
%6 = bitcast i64* %4 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.5, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @sflash_erase_area(i32 %1, i32 %2)
%12 = tail call i32 (...) @sflash_reset()
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.8, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
%16 = call i64 @time(i64* %4)
%17 = load i64, i64* %4
%18 = call i64 @difftime(i64 %17, i64 %5)
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %19)
ret void
}