#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__ block_write(int, int, int, unsigned char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void erase(int file, int addr, int eeprom_size) {
  unsigned char buf[64];
  int i, j, k, delka;
  delka = 0;
  k = 0;
  for (j = 0; j <= 64; j++)
    buf[j] = 0;
  for (i = 0; i < eeprom_size; i = i + 64) {
    if (block_write(file, addr, i, buf, 64) != 0) {
      fprintf(stderr, "Block write failed\n");
      return;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x40,-0x58(%rbp)
jg     1167 <erase+0x47>
movslq -0x58(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1146 <erase+0x26>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <erase+0xa9>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x54(%rbp),%edx
lea    -0x50(%rbp),%rcx
mov    $0x40,%r8d
call   1040 <block_write@plt>
cmp    $0x0,%rax
je     11b6 <erase+0x96>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11ce <erase+0xae>
jmp    11bb <erase+0x9b>
mov    -0x54(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x54(%rbp)
jmp    116e <erase+0x4e>
jmp    11ce <erase+0xae>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erase>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movb   $0x0,0x40(%rsp)
test   %edx,%edx
jle    1199 <erase+0x79>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
xor    %ebp,%ebp
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r12,%rcx
mov    $0x40,%r8d
call   1040 <block_write@plt>
test   %rax,%rax
jne    1184 <erase+0x64>
add    $0x40,%ebp
cmp    %ebx,%ebp
jl     1160 <erase+0x40>
jmp    1199 <erase+0x79>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Block write failed\0A\00"
define void @erase(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [64 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %11
store i32 0, i32* %10
store i32 0, i32* %9
br label %12
12: ; preds = %19, %3
%13 = load i32, i32* %9
%14 = icmp sle i32 %13, 64
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 %17
store i8 0, i8* %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %9
%21 = add nsw i32 %20, 1
store i32 %21, i32* %9
br label %12
22: ; preds = %12
store i32 0, i32* %8
br label %23
23: ; preds = %38, %22
%24 = load i32, i32* %8
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = load i32, i32* %8
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%32 = call i64 @block_write(i32 %28, i32 %29, i32 %30, i8* %31, i32 64)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %42
37: ; preds = %27
br label %38
38: ; preds = %37
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 64
store i32 %40, i32* %8
br label %23
41: ; preds = %23
br label %42
42: ; preds = %41, %34
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Block write failed\0A\00"
define void @erase(i32 %0, i32 %1, i32 %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %2, 0
br i1 %7, label %10, label %18
8: ; preds = %10
%9 = icmp slt i32 %14, %2
br i1 %9, label %10, label %18
10: ; preds = %3, %8
%11 = phi i32 [ %14, %8 ], [ 0, %3 ]
%12 = call i64 @block_write(i32 %0, i32 %1, i32 %11, i8* %6, i32 64)
%13 = icmp eq i64 %12, 0
%14 = add nuw nsw i32 %11, 64
br i1 %13, label %8, label %15
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %8, %3, %15
ret void
}