#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 */
union i2c_smbus_data {
  int word;
};
typedef int /*<<< orphan*/ __u8;
typedef int __s32;

/* Variables and functions */
int /*<<< orphan*/ I2C_SMBUS_READ;
int /*<<< orphan*/ I2C_SMBUS_WORD_DATA;
int i2c_smbus_access(int, int /*<<< orphan*/, int /*<<< orphan*/,
                     int /*<<< orphan*/, union i2c_smbus_data *);
__s32 i2c_smbus_read_word_data(int file, __u8 command) {
  union i2c_smbus_data data;
  int err;
  err = i2c_smbus_access(file, I2C_SMBUS_READ, command, I2C_SMBUS_WORD_DATA,
                         &data);
  if (err < 0)
    return err;
  return 0x0FFFF & data.word;
}


x86 assembly (clang, -O0):
<i2c_smbus_read_word_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ec0(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
mov    0x2eac(%rip),%rax
mov    (%rax),%ecx
lea    -0x10(%rbp),%r8
call   1030 <i2c_smbus_access@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1157 <i2c_smbus_read_word_data+0x47>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1162 <i2c_smbus_read_word_data+0x52>
mov    -0x10(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_smbus_read_word_data>:
push   %rax
mov    %esi,%edx
mov    0x2ece(%rip),%rax
mov    (%rax),%esi
mov    0x2ebd(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r8
call   1030 <i2c_smbus_access@plt>
test   %eax,%eax
movzwl (%rsp),%ecx
cmovns %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%union.i2c_smbus_data = type { i32 }
@I2C_SMBUS_READ = global i32 0
@I2C_SMBUS_WORD_DATA = global i32 0
define i32 @i2c_smbus_read_word_data(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %union.i2c_smbus_data
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = load i32, i32* @I2C_SMBUS_READ
%10 = load i32, i32* %5
%11 = load i32, i32* @I2C_SMBUS_WORD_DATA
%12 = call i32 @i2c_smbus_access(i32 %8, i32 %9, i32 %10, i32 %11, %union.i2c_smbus_data* %6)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* %7
store i32 %16, i32* %3
br label %21
17: ; preds = %2
%18 = bitcast %union.i2c_smbus_data* %6 to i32*
%19 = load i32, i32* %18
%20 = and i32 65535, %19
store i32 %20, i32* %3
br label %21
21: ; preds = %17, %15
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%union.i2c_smbus_data = type { i32 }
@I2C_SMBUS_READ = global i32 0
@I2C_SMBUS_WORD_DATA = global i32 0
define i32 @i2c_smbus_read_word_data(i32 %0, i32 %1) {
%3 = alloca %union.i2c_smbus_data
%4 = bitcast %union.i2c_smbus_data* %3 to i8*
%5 = load i32, i32* @I2C_SMBUS_READ
%6 = load i32, i32* @I2C_SMBUS_WORD_DATA
%7 = call i32 @i2c_smbus_access(i32 %0, i32 %5, i32 %1, i32 %6, %union.i2c_smbus_data* %3)
%8 = icmp slt i32 %7, 0
%9 = getelementptr inbounds %union.i2c_smbus_data, %union.i2c_smbus_data* %3, i64 0, i32 0
%10 = load i32, i32* %9
%11 = and i32 %10, 65535
%12 = select i1 %8, i32 %7, i32 %11
ret i32 %12
}