int main(void) {
  int fd = 0;
  char mybuf[16 + 1] = {0};
  printf("\n%s(+):", __FUNCTION__);
  fd = open_i2c("/dev/i2c/0");
  clear_24lc16b_eeprom(fd);
  write_eeprom(fd, 0x50, 0, "abcdefghijklmnop", sizeof("abcdefghijklmnop"));
  usleep(100 * 1);
  read_eeprom(fd, 0x50, 5, &mybuf[0], 16);
  mybuf[16] = 0;
  printf("\nRead back: %s.", mybuf);
  close_i2c(fd);
  printf("\n%s(-):", __FUNCTION__);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1060 <memset@plt>
lea    0xe5a(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1070 <open_i2c@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1030 <clear_24lc16b_eeprom@plt>
mov    -0x4(%rbp),%edi
mov    $0x50,%esi
xor    %edx,%edx
lea    0xe38(%rip),%rcx
mov    $0x11,%r8d
mov    $0x0,%al
call   1090 <write_eeprom@plt>
mov    $0x64,%edi
mov    $0x0,%al
call   10a0 <usleep@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rcx
mov    $0x50,%esi
mov    $0x5,%edx
mov    $0x10,%r8d
mov    $0x0,%al
call   1050 <read_eeprom@plt>
movb   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1080 <close_i2c@plt>
lea    0xdfb(%rip),%rdi
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xe75(%rip),%rdi
lea    0xe76(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1060 <open_i2c@plt>
mov    %eax,%ebp
mov    %eax,%edi
xor    %eax,%eax
call   1030 <clear_24lc16b_eeprom@plt>
lea    0xe5c(%rip),%rcx
mov    $0x11,%r8d
mov    %ebp,%edi
mov    $0x50,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1080 <write_eeprom@plt>
mov    $0x64,%edi
xor    %eax,%eax
call   1090 <usleep@plt>
mov    %rsp,%rbx
mov    %ebp,%edi
mov    $0x50,%esi
mov    $0x5,%edx
mov    %rbx,%rcx
mov    $0x10,%r8d
xor    %eax,%eax
call   1050 <read_eeprom@plt>
movb   $0x0,0x10(%rsp)
lea    0xe20(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
xor    %eax,%eax
call   1070 <close_i2c@plt>
lea    0xe16(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\0A%s(+):\00"
@__FUNCTION__.main = [5 x i8] c"main\00"
@.str.1 = [11 x i8] c"/dev/i2c/0\00"
@.str.2 = [17 x i8] c"abcdefghijklmnop\00"
@.str.3 = [16 x i8] c"\0ARead back: %s.\00"
@.str.4 = [8 x i8] c"\0A%s(-):\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [17 x i8]
store i32 0, i32* %1
%3 = bitcast [17 x i8]* %2 to i8*
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__FUNCTION__.main, i64 0, i64 0))
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @open_i2c to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 (i32, ...) bitcast (i32 (...)* @clear_24lc16b_eeprom to i32 (i32, ...)*)(i32 %6)
%8 = load i32, i32* %1
%9 = call i32 (i32, i32, i32, i8*, i64, ...) bitcast (i32 (...)* @write_eeprom to i32 (i32, i32, i32, i8*, i64, ...)*)(i32 %8, i32 80, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 17)
%10 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 100)
%11 = load i32, i32* %1
%12 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%13 = call i32 (i32, i32, i32, i8*, i32, ...) bitcast (i32 (...)* @read_eeprom to i32 (i32, i32, i32, i8*, i32, ...)*)(i32 %11, i32 80, i32 5, i8* %12, i32 16)
%14 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 16
store i8 0, i8* %14
%15 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %1
%18 = call i32 (i32, ...) bitcast (i32 (...)* @close_i2c to i32 (i32, ...)*)(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__FUNCTION__.main, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"\0A%s(+):\00"
@__FUNCTION__.main = [5 x i8] c"main\00"
@.str.1 = [11 x i8] c"/dev/i2c/0\00"
@.str.2 = [17 x i8] c"abcdefghijklmnop\00"
@.str.3 = [16 x i8] c"\0ARead back: %s.\00"
@.str.4 = [8 x i8] c"\0A%s(-):\00"
define i32 @main() {
%1 = alloca [17 x i8]
%2 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__FUNCTION__.main, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @open_i2c to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @clear_24lc16b_eeprom to i32 (i32, ...)*)(i32 %4)
%6 = tail call i32 (i32, i32, i32, i8*, i64, ...) bitcast (i32 (...)* @write_eeprom to i32 (i32, i32, i32, i8*, i64, ...)*)(i32 %4, i32 80, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 17)
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 100)
%8 = call i32 (i32, i32, i32, i8*, i32, ...) bitcast (i32 (...)* @read_eeprom to i32 (i32, i32, i32, i8*, i32, ...)*)(i32 %4, i32 80, i32 5, i8* %2, i32 16)
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 16
store i8 0, i8* %9
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%11 = call i32 (i32, ...) bitcast (i32 (...)* @close_i2c to i32 (i32, ...)*)(i32 %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__FUNCTION__.main, i64 0, i64 0))
ret i32 0
}