#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;
scalar_t__ 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;
  if (i2c_smbus_access(file, I2C_SMBUS_READ, command, I2C_SMBUS_WORD_DATA,
                       &data))
    return -1;
  else
    return 0x0FFFF & data.word;
}


x86 assembly (clang, -O0):
<i2c_smbus_read_word_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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>
cmp    $0x0,%rax
je     1155 <i2c_smbus_read_word_data+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    1160 <i2c_smbus_read_word_data+0x50>
mov    -0x10(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%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>
movzwl (%rsp),%ecx
neg    %rax
sbb    %eax,%eax
or     %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
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = load i32, i32* @I2C_SMBUS_READ
%9 = load i32, i32* %5
%10 = load i32, i32* @I2C_SMBUS_WORD_DATA
%11 = call i64 @i2c_smbus_access(i32 %7, i32 %8, i32 %9, i32 %10, %union.i2c_smbus_data* %6)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %18
14: ; preds = %2
%15 = bitcast %union.i2c_smbus_data* %6 to i32*
%16 = load i32, i32* %15
%17 = and i32 65535, %16
store i32 %17, i32* %3
br label %18
18: ; preds = %14, %13
%19 = load i32, i32* %3
ret i32 %19
}

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 i64 @i2c_smbus_access(i32 %0, i32 %5, i32 %1, i32 %6, %union.i2c_smbus_data* %3)
%8 = icmp eq i64 %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 %11, i32 -1
ret i32 %12
}