#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 */
int /*<<< orphan*/ i2c_read(int, unsigned char *, int);
int /*<<< orphan*/ i2c_write(int, unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
unsigned char at24cxx_read(unsigned char address) {
  unsigned char val;
  printf("at24cxx_read address = %d\r\n", address);
  i2c_write(0xA0, &address, 1);
  printf("at24cxx_read send address ok\r\n");
  i2c_read(0xA0, (unsigned char *)&val, 1);
  printf("at24cxx_read get data ok\r\n");
  return val;
}


x86 assembly (clang, -O0):
<at24cxx_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa0,%edi
lea    -0x1(%rbp),%rsi
mov    $0x1,%edx
call   1050 <i2c_write@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa0,%edi
lea    -0x2(%rbp),%rsi
mov    $0x1,%edx
call   1030 <i2c_read@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<at24cxx_read>:
push   %rax
mov    %edi,%esi
mov    %sil,0x7(%rsp)
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x7(%rsp),%rsi
mov    $0xa0,%edi
mov    $0x1,%edx
call   1060 <i2c_write@plt>
lea    0xeab(%rip),%rdi
call   1040 <puts@plt>
lea    0x6(%rsp),%rsi
mov    $0xa0,%edi
mov    $0x1,%edx
call   1030 <i2c_read@plt>
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
mov    0x6(%rsp),%al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"at24cxx_read address = %d\0D\0A\00"
@.str.1 = [31 x i8] c"at24cxx_read send address ok\0D\0A\00"
@.str.2 = [27 x i8] c"at24cxx_read get data ok\0D\0A\00"
define zeroext i8 @at24cxx_read(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @i2c_write(i32 160, i8* %2, i32 1)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @i2c_read(i32 160, i8* %3, i32 1)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%11 = load i8, i8* %3
ret i8 %11
}

LLVM IR (-O2):
@.str = [28 x i8] c"at24cxx_read address = %d\0D\0A\00"
@str = [30 x i8] c"at24cxx_read send address ok\0D\00"
@str.3 = [26 x i8] c"at24cxx_read get data ok\0D\00"
define zeroext i8 @at24cxx_read(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = zext i8 %0 to i32
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @i2c_write(i32 160, i8* %2, i32 1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%8 = call i32 @i2c_read(i32 160, i8* %3, i32 1)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.3, i64 0, i64 0))
%10 = load i8, i8* %3
ret i8 %10
}