#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*/ FailMessage(char *);
int /*<<< orphan*/ I2C_SLAVE;
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int I2CWrapperSlaveAddress(int handle, int SlaveAddress) {
  if (SlaveAddress < 3)
    return -1;
  if (SlaveAddress > 0x77)
    return -1;
  if (ioctl(handle, I2C_SLAVE, SlaveAddress) < 0) {
    FailMessage("Failed to acquire bus access and/or talk to slave.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<I2CWrapperSlaveAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1144 <I2CWrapperSlaveAddress+0x24>
movl   $0xffffffff,-0x4(%rbp)
jmp    1197 <I2CWrapperSlaveAddress+0x77>
cmpl   $0x77,-0xc(%rbp)
jle    115a <I2CWrapperSlaveAddress+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1197 <I2CWrapperSlaveAddress+0x77>
mov    -0x8(%rbp),%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
jge    1190 <I2CWrapperSlaveAddress+0x70>
lea    0xe81(%rip),%rdi
call   1030 <FailMessage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1197 <I2CWrapperSlaveAddress+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2CWrapperSlaveAddress>:
push   %rax
mov    %esi,%edx
lea    -0x78(%rdx),%ecx
mov    $0xffffffff,%eax
cmp    $0xffffff8b,%ecx
jb     1148 <I2CWrapperSlaveAddress+0x28>
mov    0x2eb1(%rip),%rax
mov    (%rax),%esi
call   1040 <ioctl@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     114a <I2CWrapperSlaveAddress+0x2a>
pop    %rcx
ret
lea    0xeaf(%rip),%rdi
call   1030 <FailMessage@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@I2C_SLAVE = global i32 0
@.str = [52 x i8] c"Failed to acquire bus access and/or talk to slave.\0A\00"
define i32 @I2CWrapperSlaveAddress(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp slt i32 %6, 3
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %22
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 119
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 -1, i32* %3
br label %22
13: ; preds = %9
%14 = load i32, i32* %4
%15 = load i32, i32* @I2C_SLAVE
%16 = load i32, i32* %5
%17 = call i64 @ioctl(i32 %14, i32 %15, i32 %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 @FailMessage(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %22
21: ; preds = %13
store i32 0, i32* %3
br label %22
22: ; preds = %21, %19, %12, %8
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@I2C_SLAVE = global i32 0
@.str = [52 x i8] c"Failed to acquire bus access and/or talk to slave.\0A\00"
define i32 @I2CWrapperSlaveAddress(i32 %0, i32 %1) {
%3 = add i32 %1, -120
%4 = icmp ult i32 %3, -117
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = load i32, i32* @I2C_SLAVE
%7 = tail call i64 @ioctl(i32 %0, i32 %6, i32 %1)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @FailMessage(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %5, %2, %9
%12 = phi i32 [ -1, %9 ], [ -1, %2 ], [ 0, %5 ]
ret i32 %12
}