#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 */
unsigned char I2C1_Rd(unsigned int);
int /*<<< orphan*/ I2C1_Repeated_Start();
int /*<<< orphan*/ I2C1_Start();
int /*<<< orphan*/ I2C1_Stop();
int /*<<< orphan*/ I2C1_Wr(int);
unsigned char eepromRead(int deviceAddress, unsigned int memAddress) {
  unsigned char value;
  I2C1_Start();
  I2C1_Wr(0xa0 + (deviceAddress << 1) + 0);
  I2C1_Wr(memAddress >> 8);
  I2C1_Wr(memAddress & 0xff);
  I2C1_Repeated_Start();
  I2C1_Wr(0xa0 + (deviceAddress << 1) + 1);
  value = I2C1_Rd(0u);
  I2C1_Stop();
  return value;
}


x86 assembly (clang, -O0):
<eepromRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <I2C1_Start@plt>
mov    -0x4(%rbp),%edi
shl    $0x1,%edi
add    $0xa0,%edi
add    $0x0,%edi
call   1050 <I2C1_Wr@plt>
mov    -0x8(%rbp),%edi
shr    $0x8,%edi
call   1050 <I2C1_Wr@plt>
mov    -0x8(%rbp),%edi
and    $0xff,%edi
call   1050 <I2C1_Wr@plt>
mov    $0x0,%al
call   1070 <I2C1_Repeated_Start@plt>
mov    -0x4(%rbp),%edi
shl    $0x1,%edi
add    $0xa0,%edi
add    $0x1,%edi
call   1050 <I2C1_Wr@plt>
xor    %edi,%edi
call   1030 <I2C1_Rd@plt>
mov    %al,-0x9(%rbp)
mov    $0x0,%al
call   1040 <I2C1_Stop@plt>
movzbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eepromRead>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r14d
xor    %eax,%eax
call   1060 <I2C1_Start@plt>
lea    (%r14,%r14,1),%edi
add    $0xa0,%edi
call   1050 <I2C1_Wr@plt>
mov    %ebx,%edi
shr    $0x8,%edi
call   1050 <I2C1_Wr@plt>
movzbl %bl,%edi
call   1050 <I2C1_Wr@plt>
xor    %eax,%eax
call   1070 <I2C1_Repeated_Start@plt>
lea    (%r14,%r14,1),%edi
add    $0xa1,%edi
call   1050 <I2C1_Wr@plt>
xor    %edi,%edi
call   1030 <I2C1_Rd@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <I2C1_Stop@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define zeroext i8 @eepromRead(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 (...) @I2C1_Start()
%7 = load i32, i32* %3
%8 = shl i32 %7, 1
%9 = add nsw i32 160, %8
%10 = add nsw i32 %9, 0
%11 = call i32 @I2C1_Wr(i32 %10)
%12 = load i32, i32* %4
%13 = lshr i32 %12, 8
%14 = call i32 @I2C1_Wr(i32 %13)
%15 = load i32, i32* %4
%16 = and i32 %15, 255
%17 = call i32 @I2C1_Wr(i32 %16)
%18 = call i32 (...) @I2C1_Repeated_Start()
%19 = load i32, i32* %3
%20 = shl i32 %19, 1
%21 = add nsw i32 160, %20
%22 = add nsw i32 %21, 1
%23 = call i32 @I2C1_Wr(i32 %22)
%24 = call zeroext i8 @I2C1_Rd(i32 0)
store i8 %24, i8* %5
%25 = call i32 (...) @I2C1_Stop()
%26 = load i8, i8* %5
ret i8 %26
}

LLVM IR (-O2):
define zeroext i8 @eepromRead(i32 %0, i32 %1) {
%3 = tail call i32 (...) @I2C1_Start()
%4 = shl i32 %0, 1
%5 = add nsw i32 %4, 160
%6 = tail call i32 @I2C1_Wr(i32 %5)
%7 = lshr i32 %1, 8
%8 = tail call i32 @I2C1_Wr(i32 %7)
%9 = and i32 %1, 255
%10 = tail call i32 @I2C1_Wr(i32 %9)
%11 = tail call i32 (...) @I2C1_Repeated_Start()
%12 = add nsw i32 %4, 161
%13 = tail call i32 @I2C1_Wr(i32 %12)
%14 = tail call zeroext i8 @I2C1_Rd(i32 0)
%15 = tail call i32 (...) @I2C1_Stop()
ret i8 %14
}