_Bool AT24C02_Clear(unsigned char startAddr, unsigned char byte,
                    unsigned short len) {
  unsigned short count = 0;
  if (startAddr + len > 256)
    return 1;
  for (; count < len; count++) {
    I2C_WriteByte(0x50, startAddr, &byte);
    startAddr++;
    DelayXms(2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<AT24C02_Clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dx,%ax
mov    %sil,%cl
mov    %dil,%dl
mov    %dl,-0x2(%rbp)
mov    %cl,-0x3(%rbp)
mov    %ax,-0x6(%rbp)
movw   $0x0,-0x8(%rbp)
movzbl -0x2(%rbp),%eax
movzwl -0x6(%rbp),%ecx
add    %ecx,%eax
cmp    $0x100,%eax
jle    115f <AT24C02_Clear+0x3f>
movb   $0x1,-0x1(%rbp)
jmp    11b1 <AT24C02_Clear+0x91>
jmp    1164 <AT24C02_Clear+0x44>
movzwl -0x8(%rbp),%eax
movzwl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jge    11ad <AT24C02_Clear+0x8d>
movzbl -0x2(%rbp),%esi
mov    $0x50,%edi
lea    -0x3(%rbp),%rdx
mov    $0x0,%al
call   1040 <I2C_WriteByte@plt>
mov    -0x2(%rbp),%al
add    $0x1,%al
mov    %al,-0x2(%rbp)
mov    $0x2,%edi
mov    $0x0,%al
call   1030 <DelayXms@plt>
mov    -0x8(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x8(%rbp)
jmp    1164 <AT24C02_Clear+0x44>
movb   $0x0,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AT24C02_Clear>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %edi,%ebx
mov    %sil,0x7(%rsp)
lea    (%r14,%rbx,1),%ebp
cmp    $0x100,%ebp
ja     117a <AT24C02_Clear+0x5a>
test   %r14w,%r14w
je     117a <AT24C02_Clear+0x5a>
lea    0x7(%rsp),%r15
nopl   0x0(%rax,%rax,1)
movzbl %bl,%ebx
mov    $0x50,%edi
mov    %ebx,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <I2C_WriteByte@plt>
add    $0x1,%bl
mov    $0x2,%edi
xor    %eax,%eax
call   1030 <DelayXms@plt>
add    $0xffff,%r14w
jne    1150 <AT24C02_Clear+0x30>
cmp    $0x101,%ebp
setae  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i1 @AT24C02_Clear(i8 zeroext %0, i8 zeroext %1, i16 zeroext %2) {
%4 = alloca i1
%5 = alloca i8
%6 = alloca i8
%7 = alloca i16
%8 = alloca i16
store i8 %0, i8* %5
store i8 %1, i8* %6
store i16 %2, i16* %7
store i16 0, i16* %8
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
%11 = load i16, i16* %7
%12 = zext i16 %11 to i32
%13 = add nsw i32 %10, %12
%14 = icmp sgt i32 %13, 256
br i1 %14, label %15, label %16
15: ; preds = %3
store i1 true, i1* %4
br label %34
16: ; preds = %3
br label %17
17: ; preds = %30, %16
%18 = load i16, i16* %8
%19 = zext i16 %18 to i32
%20 = load i16, i16* %7
%21 = zext i16 %20 to i32
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %33
23: ; preds = %17
%24 = load i8, i8* %5
%25 = zext i8 %24 to i32
%26 = call i32 (i32, i32, i8*, ...) bitcast (i32 (...)* @I2C_WriteByte to i32 (i32, i32, i8*, ...)*)(i32 80, i32 %25, i8* %6)
%27 = load i8, i8* %5
%28 = add i8 %27, 1
store i8 %28, i8* %5
%29 = call i32 (i32, ...) bitcast (i32 (...)* @DelayXms to i32 (i32, ...)*)(i32 2)
br label %30
30: ; preds = %23
%31 = load i16, i16* %8
%32 = add i16 %31, 1
store i16 %32, i16* %8
br label %17
33: ; preds = %17
store i1 false, i1* %4
br label %34
34: ; preds = %33, %15
%35 = load i1, i1* %4
ret i1 %35
}

LLVM IR (-O2):
define zeroext i1 @AT24C02_Clear(i8 zeroext %0, i8 zeroext %1, i16 zeroext %2) {
%4 = alloca i8
store i8 %1, i8* %4
%5 = zext i8 %0 to i32
%6 = zext i16 %2 to i32
%7 = add nuw nsw i32 %6, %5
%8 = icmp ugt i32 %7, 256
%9 = icmp eq i16 %2, 0
%10 = or i1 %8, %9
br i1 %10, label %20, label %11
11: ; preds = %3, %11
%12 = phi i16 [ %18, %11 ], [ 0, %3 ]
%13 = phi i8 [ %16, %11 ], [ %0, %3 ]
%14 = zext i8 %13 to i32
%15 = call i32 (i32, i32, i8*, ...) bitcast (i32 (...)* @I2C_WriteByte to i32 (i32, i32, i8*, ...)*)(i32 80, i32 %14, i8* %4)
%16 = add i8 %13, 1
%17 = call i32 (i32, ...) bitcast (i32 (...)* @DelayXms to i32 (i32, ...)*)(i32 2)
%18 = add nuw i16 %12, 1
%19 = icmp eq i16 %18, %2
br i1 %19, label %20, label %11
20: ; preds = %11, %3
ret i1 %8
}