#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 TWIE_Read(int /*<<< orphan*/);
int /*<<< orphan*/ TWIE_Start();
int /*<<< orphan*/ TWIE_Stop();
int /*<<< orphan*/ TWIE_Write(char);
char Expander_Read_Byte(char ModuleAddress, char RegAddress) {
  unsigned char value;
  TWIE_Start();
  TWIE_Write(ModuleAddress << 1);
  TWIE_Write(RegAddress);
  TWIE_Start();
  TWIE_Write((ModuleAddress << 1) + 1);
  value = TWIE_Read(0);
  TWIE_Stop();
  return value;
}


x86 assembly (clang, -O0):
<Expander_Read_Byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
mov    $0x0,%al
call   1060 <TWIE_Start@plt>
movsbl -0x1(%rbp),%eax
shl    $0x1,%eax
movsbl %al,%edi
call   1030 <TWIE_Write@plt>
movsbl -0x2(%rbp),%edi
call   1030 <TWIE_Write@plt>
mov    $0x0,%al
call   1060 <TWIE_Start@plt>
movsbl -0x1(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
movsbl %al,%edi
call   1030 <TWIE_Write@plt>
xor    %edi,%edi
call   1040 <TWIE_Read@plt>
mov    %al,-0x3(%rbp)
mov    $0x0,%al
call   1050 <TWIE_Stop@plt>
movsbl -0x3(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Expander_Read_Byte>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <TWIE_Start@plt>
add    %bpl,%bpl
movsbl %bpl,%ebp
mov    %ebp,%edi
call   1030 <TWIE_Write@plt>
mov    %ebx,%edi
call   1030 <TWIE_Write@plt>
xor    %eax,%eax
call   1060 <TWIE_Start@plt>
or     $0x1,%bpl
movsbl %bpl,%edi
call   1030 <TWIE_Write@plt>
xor    %edi,%edi
call   1040 <TWIE_Read@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <TWIE_Stop@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @Expander_Read_Byte(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
%6 = call i32 (...) @TWIE_Start()
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
%9 = shl i32 %8, 1
%10 = trunc i32 %9 to i8
%11 = call i32 @TWIE_Write(i8 signext %10)
%12 = load i8, i8* %4
%13 = call i32 @TWIE_Write(i8 signext %12)
%14 = call i32 (...) @TWIE_Start()
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = shl i32 %16, 1
%18 = add nsw i32 %17, 1
%19 = trunc i32 %18 to i8
%20 = call i32 @TWIE_Write(i8 signext %19)
%21 = call zeroext i8 @TWIE_Read(i32 0)
store i8 %21, i8* %5
%22 = call i32 (...) @TWIE_Stop()
%23 = load i8, i8* %5
ret i8 %23
}

LLVM IR (-O2):
define signext i8 @Expander_Read_Byte(i8 signext %0, i8 signext %1) {
%3 = tail call i32 (...) @TWIE_Start()
%4 = shl i8 %0, 1
%5 = tail call i32 @TWIE_Write(i8 signext %4)
%6 = tail call i32 @TWIE_Write(i8 signext %1)
%7 = tail call i32 (...) @TWIE_Start()
%8 = or i8 %4, 1
%9 = tail call i32 @TWIE_Write(i8 signext %8)
%10 = tail call zeroext i8 @TWIE_Read(i32 0)
%11 = tail call i32 (...) @TWIE_Stop()
ret i8 %10
}