#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 byte;
};

/* Variables and functions */
int /*<<< orphan*/ I2C_SMBUS_BYTE_DATA;
int /*<<< orphan*/ I2C_SMBUS_READ;
int i2c_smbus_access(int, int /*<<< orphan*/, unsigned char, int /*<<< orphan*/,
                     union i2c_smbus_data *);
long i2c_smbus_read_byte_data(int file, unsigned char command) {
  union i2c_smbus_data data;
  int err;
  err = i2c_smbus_access(file, I2C_SMBUS_READ, command, I2C_SMBUS_BYTE_DATA,
                         &data);
  if (err < 0)
    return err;
  return 0x0FF & data.byte;
}


x86 assembly (clang, -O0):
<i2c_smbus_read_byte_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2ebd(%rip),%rax
mov    (%rax),%esi
mov    -0xd(%rbp),%al
mov    0x2ea9(%rip),%rcx
mov    (%rcx),%ecx
lea    -0x18(%rbp),%r8
movzbl %al,%edx
call   1030 <i2c_smbus_access@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    115f <i2c_smbus_read_byte_data+0x4f>
movslq -0x1c(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    116d <i2c_smbus_read_byte_data+0x5d>
mov    -0x18(%rbp),%eax
and    $0xff,%eax
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_smbus_read_byte_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
movslq %eax,%rcx
movzbl (%rsp),%eax
cmovs  %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
%union.i2c_smbus_data = type { i32 }
@I2C_SMBUS_READ = global i32 0
@I2C_SMBUS_BYTE_DATA = global i32 0
define i64 @i2c_smbus_read_byte_data(i32 %0, i8 zeroext %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i8
%6 = alloca %union.i2c_smbus_data
%7 = alloca i32
store i32 %0, i32* %4
store i8 %1, i8* %5
%8 = load i32, i32* %4
%9 = load i32, i32* @I2C_SMBUS_READ
%10 = load i8, i8* %5
%11 = load i32, i32* @I2C_SMBUS_BYTE_DATA
%12 = call i32 @i2c_smbus_access(i32 %8, i32 %9, i8 zeroext %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 %18
15: ; preds = %2
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
store i64 %17, i64* %3
br label %23
18: ; preds = %2
%19 = bitcast %union.i2c_smbus_data* %6 to i32*
%20 = load i32, i32* %19
%21 = and i32 255, %20
%22 = sext i32 %21 to i64
store i64 %22, i64* %3
br label %23
23: ; preds = %18, %15
%24 = load i64, i64* %3
ret i64 %24
}

LLVM IR (-O2):
%union.i2c_smbus_data = type { i32 }
@I2C_SMBUS_READ = global i32 0
@I2C_SMBUS_BYTE_DATA = global i32 0
define i64 @i2c_smbus_read_byte_data(i32 %0, i8 zeroext %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_BYTE_DATA
%7 = call i32 @i2c_smbus_access(i32 %0, i32 %5, i8 zeroext %1, i32 %6, %union.i2c_smbus_data* %3)
%8 = icmp slt i32 %7, 0
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds %union.i2c_smbus_data, %union.i2c_smbus_data* %3, i64 0, i32 0
%11 = load i32, i32* %10
%12 = and i32 %11, 255
%13 = zext i32 %12 to i64
%14 = select i1 %8, i64 %9, i64 %13
ret i64 %14
}