#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 int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ I2C_SLAVE;
int _i2c_get_fd(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ log_message(char *, char *, int);
bool i2c_set_slave_address(int busno, uint8_t address) {
  int fd = _i2c_get_fd(busno);
  if (fd <= 0) {
    log_message("[ERROR][%d-%d-%d %d:%d:%d] ",
                "i2c_set_slave_address: the bus number (%d) is out of range or "
                "the bus is not yet open\r\n",
                busno);
    return false;
  }
  return ioctl(fd, I2C_SLAVE, address) >= 0;
}


x86 assembly (clang, -O0):
<i2c_set_slave_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <_i2c_get_fd@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jg     1175 <i2c_set_slave_address+0x45>
mov    -0x8(%rbp),%edx
lea    0xea3(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <log_message@plt>
movl   $0x0,-0x4(%rbp)
jmp    1198 <i2c_set_slave_address+0x68>
mov    -0x10(%rbp),%edi
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_set_slave_address>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
call   1040 <_i2c_get_fd@plt>
test   %eax,%eax
jle    115b <i2c_set_slave_address+0x2b>
mov    0x2ea1(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
mov    %ebx,%edx
call   1030 <ioctl@plt>
shr    $0x3f,%rax
xor    $0x1,%eax
jmp    1172 <i2c_set_slave_address+0x42>
lea    0xe9e(%rip),%rdi
lea    0xeb3(%rip),%rsi
mov    %ebp,%edx
call   1050 <log_message@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"[ERROR][%d-%d-%d %d:%d:%d] \00"
@.str.1 = [88 x i8] c"i2c_set_slave_address: the bus number (%d) is out of range or the bus is not yet open\0D\0A\00"
@I2C_SLAVE = global i32 0
define i32 @i2c_set_slave_address(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = call i32 @_i2c_get_fd(i32 %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp sle i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* %4
%13 = call i32 @log_message(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i32 0, i32* %3
br label %21
14: ; preds = %2
%15 = load i32, i32* %6
%16 = load i32, i32* @I2C_SLAVE
%17 = load i32, i32* %5
%18 = call i64 @ioctl(i32 %15, i32 %16, i32 %17)
%19 = icmp sge i64 %18, 0
%20 = zext i1 %19 to i32
store i32 %20, i32* %3
br label %21
21: ; preds = %14, %11
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [28 x i8] c"[ERROR][%d-%d-%d %d:%d:%d] \00"
@.str.1 = [88 x i8] c"i2c_set_slave_address: the bus number (%d) is out of range or the bus is not yet open\0D\0A\00"
@I2C_SLAVE = global i32 0
define i32 @i2c_set_slave_address(i32 %0, i32 %1) {
%3 = tail call i32 @_i2c_get_fd(i32 %0)
%4 = icmp slt i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @log_message(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %13
7: ; preds = %2
%8 = load i32, i32* @I2C_SLAVE
%9 = tail call i64 @ioctl(i32 %3, i32 %8, i32 %1)
%10 = lshr i64 %9, 63
%11 = trunc i64 %10 to i32
%12 = xor i32 %11, 1
br label %13
13: ; preds = %7, %5
%14 = phi i32 [ 0, %5 ], [ %12, %7 ]
ret i32 %14
}