#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ errno;
scalar_t__ ioctl(int, int, int);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int wiringPiFailure(int, char *, int /*<<< orphan*/);
int wiringPiI2CSetupInterface(const char *device, int devId) {
  int fd;
  if ((fd = open(device, O_RDWR)) < 0)
    return wiringPiFailure((1 == 2), "Unable to open I2C device: %s\n",
                           strerror(errno));
  if (ioctl(fd, 0x0703, devId) < 0)
    return wiringPiFailure((1 == 2), "Unable to select I2C device: %s\n",
                           strerror(errno));
  return fd;
}


x86 assembly (clang, -O0):
<wiringPiI2CSetupInterface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e8e(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1193 <wiringPiI2CSetupInterface+0x53>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edx
xor    %edi,%edi
lea    0xe7a(%rip),%rsi
call   1040 <wiringPiFailure@plt>
mov    %eax,-0x4(%rbp)
jmp    11d9 <wiringPiI2CSetupInterface+0x99>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    $0x703,%esi
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    11d3 <wiringPiI2CSetupInterface+0x93>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edx
xor    %edi,%edi
lea    0xe59(%rip),%rsi
call   1040 <wiringPiFailure@plt>
mov    %eax,-0x4(%rbp)
jmp    11d9 <wiringPiI2CSetupInterface+0x99>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wiringPiI2CSetupInterface>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
test   %eax,%eax
js     1175 <wiringPiI2CSetupInterface+0x35>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x703,%esi
mov    %ebx,%edx
call   1030 <ioctl@plt>
test   %rax,%rax
js     117e <wiringPiI2CSetupInterface+0x3e>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe84(%rip),%rbx
jmp    1185 <wiringPiI2CSetupInterface+0x45>
lea    0xe9a(%rip),%rbx
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <wiringPiFailure@plt>

LLVM IR (-O0):
@O_RDWR = global i32 0
@.str = [31 x i8] c"Unable to open I2C device: %s\0A\00"
@errno = global i32 0
@.str.1 = [33 x i8] c"Unable to select I2C device: %s\0A\00"
define i32 @wiringPiI2CSetupInterface(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = load i32, i32* @O_RDWR
%9 = call i32 @open(i8* %7, i32 %8)
store i32 %9, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @wiringPiFailure(i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 %14, i32* %3
br label %26
15: ; preds = %2
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = call i64 @ioctl(i32 %16, i32 1795, i32 %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 @wiringPiFailure(i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i32 %23, i32* %3
br label %26
24: ; preds = %15
%25 = load i32, i32* %6
store i32 %25, i32* %3
br label %26
26: ; preds = %24, %20, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str = [31 x i8] c"Unable to open I2C device: %s\0A\00"
@errno = global i32 0
@.str.1 = [33 x i8] c"Unable to select I2C device: %s\0A\00"
define i32 @wiringPiI2CSetupInterface(i8* nocapture %0, i32 %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* %0, i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i64 @ioctl(i32 %4, i32 1795, i32 %1)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6, %2
%10 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), %6 ]
%11 = load i32, i32* @errno
%12 = tail call i32 @strerror(i32 %11)
%13 = tail call i32 @wiringPiFailure(i32 0, i8* %10, i32 %12)
br label %14
14: ; preds = %9, %6
%15 = phi i32 [ %4, %6 ], [ %13, %9 ]
ret i32 %15
}