#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*/ bcm2835_i2c_setSlaveAddress(unsigned char);
int /*<<< orphan*/ bcm2835_i2c_write_read_rs(char *, int, char *, int);
unsigned int I2C_ReadWordRegisterRS(unsigned char address, char reg) {
  bcm2835_i2c_setSlaveAddress(address);
  char cmd[1] = {reg};
  char receive[2] = {0};
  bcm2835_i2c_write_read_rs(cmd, 1, receive, 2);
  return (receive[0] << 8) | receive[1];
}


x86 assembly (clang, -O0):
<I2C_ReadWordRegisterRS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%edi
call   1050 <bcm2835_i2c_setSlaveAddress@plt>
mov    -0x2(%rbp),%al
mov    %al,-0x3(%rbp)
lea    -0x5(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <memset@plt>
lea    -0x3(%rbp),%rdi
lea    -0x5(%rbp),%rdx
mov    $0x1,%esi
mov    $0x2,%ecx
call   1040 <bcm2835_i2c_write_read_rs@plt>
movsbl -0x5(%rbp),%eax
shl    $0x8,%eax
movsbl -0x4(%rbp),%ecx
or     %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2C_ReadWordRegisterRS>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
call   1040 <bcm2835_i2c_setSlaveAddress@plt>
mov    %bl,0xf(%rsp)
movw   $0x0,0xc(%rsp)
lea    0xf(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    $0x1,%esi
mov    $0x2,%ecx
call   1030 <bcm2835_i2c_write_read_rs@plt>
movsbl 0xc(%rsp),%ecx
shl    $0x8,%ecx
movsbl 0xd(%rsp),%eax
or     %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @I2C_ReadWordRegisterRS(i8 zeroext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca [1 x i8]
%6 = alloca [2 x i8]
store i8 %0, i8* %3
store i8 %1, i8* %4
%7 = load i8, i8* %3
%8 = call i32 @bcm2835_i2c_setSlaveAddress(i8 zeroext %7)
%9 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%10 = load i8, i8* %4
store i8 %10, i8* %9
%11 = bitcast [2 x i8]* %6 to i8*
%12 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%14 = call i32 @bcm2835_i2c_write_read_rs(i8* %12, i32 1, i8* %13, i32 2)
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = shl i32 %17, 8
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = or i32 %18, %21
ret i32 %22
}

LLVM IR (-O2):
define i32 @I2C_ReadWordRegisterRS(i8 zeroext %0, i8 signext %1) {
%3 = alloca [1 x i8]
%4 = alloca i16
%5 = bitcast i16* %4 to [2 x i8]*
%6 = tail call i32 @bcm2835_i2c_setSlaveAddress(i8 zeroext %0)
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 %1, i8* %7
%8 = bitcast i16* %4 to i8*
store i16 0, i16* %4
%9 = call i32 @bcm2835_i2c_write_read_rs(i8* %7, i32 1, i8* %8, i32 2)
%10 = load i8, i8* %8
%11 = sext i8 %10 to i32
%12 = shl nsw i32 %11, 8
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = or i32 %12, %15
ret i32 %16
}