#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;
int /*<<< orphan*/ I2C_SMBUS_READ;
int i2c_smbus_access(int, int /*<<< orphan*/, int /*<<< orphan*/,
                     int /*<<< orphan*/, union i2c_smbus_data *);
long i2c_smbus_read_byte(int file) {
  union i2c_smbus_data data;
  int err;
  err = i2c_smbus_access(file, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data);
  if (err < 0)
    return err;
  return 0x0FF & data.byte;
}


x86 assembly (clang, -O0):
<i2c_smbus_read_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2ebb(%rip),%rax
mov    (%rax),%esi
mov    0x2eba(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
lea    -0x10(%rbp),%r8
call   1030 <i2c_smbus_access@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1155 <i2c_smbus_read_byte+0x45>
movslq -0x14(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1163 <i2c_smbus_read_byte+0x53>
mov    -0x10(%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>:
push   %rax
mov    0x2ec8(%rip),%rax
mov    (%rax),%esi
mov    0x2ec7(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r8
xor    %edx,%edx
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 = global i32 0
define i64 @i2c_smbus_read_byte(i32 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca %union.i2c_smbus_data
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = load i32, i32* @I2C_SMBUS_READ
%8 = load i32, i32* @I2C_SMBUS_BYTE
%9 = call i32 @i2c_smbus_access(i32 %6, i32 %7, i32 0, i32 %8, %union.i2c_smbus_data* %4)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
store i64 %14, i64* %2
br label %20
15: ; preds = %1
%16 = bitcast %union.i2c_smbus_data* %4 to i32*
%17 = load i32, i32* %16
%18 = and i32 255, %17
%19 = sext i32 %18 to i64
store i64 %19, i64* %2
br label %20
20: ; preds = %15, %12
%21 = load i64, i64* %2
ret i64 %21
}

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