#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];
  unsigned char pom;
  int dat, i, j, k, delka, addr_cnt;
  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    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x60(%rbp)
cmpl   $0x40,-0x60(%rbp)
jg     1167 <erase+0x47>
movslq -0x60(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1146 <erase+0x26>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <erase+0xa9>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x5c(%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    -0x5c(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x5c(%rbp)
jmp    116e <erase+0x4e>
jmp    11ce <erase+0xae>
add    $0x70,%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 i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %13
store i32 0, i32* %12
store i32 0, i32* %11
br label %15
15: ; preds = %22, %3
%16 = load i32, i32* %11
%17 = icmp sle i32 %16, 64
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %18
%23 = load i32, i32* %11
%24 = add nsw i32 %23, 1
store i32 %24, i32* %11
br label %15
25: ; preds = %15
store i32 0, i32* %10
br label %26
26: ; preds = %41, %25
%27 = load i32, i32* %10
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %44
30: ; preds = %26
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load i32, i32* %10
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%35 = call i64 @block_write(i32 %31, i32 %32, i32 %33, i8* %34, i32 64)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %45
40: ; preds = %30
br label %41
41: ; preds = %40
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 64
store i32 %43, i32* %10
br label %26
44: ; preds = %26
br label %45
45: ; preds = %44, %37
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
}