#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 */
typedef union i2c_smbus_data {
  int dummy;
} i2c_smbus_data;

/* Variables and functions */
int /*<<< orphan*/ I2C_SLAVE_FORCE;
int /*<<< orphan*/ I2C_SMBUS_BYTE;
int /*<<< orphan*/ I2C_SMBUS_READ;
scalar_t__ i2c_smbus_access(int, int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, union i2c_smbus_data *);
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
bool i2c_probe(int fd, int addr) {
  union i2c_smbus_data data;
  if (ioctl(fd, I2C_SLAVE_FORCE, addr) < 0)
    return false;
  if (i2c_smbus_access(fd, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data) < 0)
    return false;
  return true;
}


x86 assembly (clang, -O0):
<i2c_probe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    1158 <i2c_probe+0x38>
movl   $0x0,-0x4(%rbp)
jmp    1195 <i2c_probe+0x75>
mov    -0x8(%rbp),%edi
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
mov    0x2e7d(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
lea    -0x10(%rbp),%r8
call   1040 <i2c_smbus_access@plt>
cmp    $0x0,%rax
jge    118e <i2c_probe+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    1195 <i2c_probe+0x75>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_probe>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%edx
mov    %edi,%ebx
mov    0x2ea8(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
test   %rax,%rax
js     1165 <i2c_probe+0x45>
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
mov    0x2e9c(%rip),%rax
mov    (%rax),%ecx
lea    0x8(%rsp),%r8
mov    %ebx,%edi
xor    %edx,%edx
call   1040 <i2c_smbus_access@plt>
shr    $0x3f,%rax
xor    $0x1,%eax
jmp    1167 <i2c_probe+0x47>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%union.i2c_smbus_data = type { i32 }
@I2C_SLAVE_FORCE = global i32 0
@I2C_SMBUS_READ = global i32 0
@I2C_SMBUS_BYTE = global i32 0
define i32 @i2c_probe(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_SLAVE_FORCE
%9 = load i32, i32* %5
%10 = call i64 @ioctl(i32 %7, i32 %8, i32 %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %21
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load i32, i32* @I2C_SMBUS_READ
%16 = load i32, i32* @I2C_SMBUS_BYTE
%17 = call i64 @i2c_smbus_access(i32 %14, i32 %15, i32 0, i32 %16, %union.i2c_smbus_data* %6)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 0, i32* %3
br label %21
20: ; preds = %13
store i32 1, i32* %3
br label %21
21: ; preds = %20, %19, %12
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%union.i2c_smbus_data = type { i32 }
@I2C_SLAVE_FORCE = global i32 0
@I2C_SMBUS_READ = global i32 0
@I2C_SMBUS_BYTE = global i32 0
define i32 @i2c_probe(i32 %0, i32 %1) {
%3 = alloca %union.i2c_smbus_data
%4 = bitcast %union.i2c_smbus_data* %3 to i8*
%5 = load i32, i32* @I2C_SLAVE_FORCE
%6 = tail call i64 @ioctl(i32 %0, i32 %5, i32 %1)
%7 = icmp slt i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = load i32, i32* @I2C_SMBUS_READ
%10 = load i32, i32* @I2C_SMBUS_BYTE
%11 = call i64 @i2c_smbus_access(i32 %0, i32 %9, i32 0, i32 %10, %union.i2c_smbus_data* %3)
%12 = lshr i64 %11, 63
%13 = trunc i64 %12 to i32
%14 = xor i32 %13, 1
br label %15
15: ; preds = %8, %2
%16 = phi i32 [ 0, %2 ], [ %14, %8 ]
ret i32 %16
}