#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*/ I2C_SLAVE;
int /*<<< orphan*/ blackstrap_log_error(char *, int, unsigned char);
int ioctl(int, int /*<<< orphan*/, unsigned char);
int i2c_bus_set_slave_address(int fd, unsigned char address) {
  int err = ioctl(fd, I2C_SLAVE, address);
  if (err < 0) {
    blackstrap_log_error("I2C failed to set slave address: fd %d, "
                         "address 0x%02x",
                         fd, address);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<i2c_bus_set_slave_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
movzbl -0x9(%rbp),%edx
call   1030 <ioctl@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1172 <i2c_bus_set_slave_address+0x52>
mov    -0x8(%rbp),%esi
lea    0xea3(%rip),%rdi
movzbl -0x9(%rbp),%edx
call   1040 <blackstrap_log_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1179 <i2c_bus_set_slave_address+0x59>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_bus_set_slave_address>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    0x2eba(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edx
call   1030 <ioctl@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jns    1156 <i2c_bus_set_slave_address+0x36>
movzbl %bpl,%edx
lea    0xeb6(%rip),%rdi
mov    %ebx,%esi
call   1040 <blackstrap_log_error@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@I2C_SLAVE = global i32 0
@.str = [55 x i8] c"I2C failed to set slave address: fd %d, address 0x%02x\00"
define i32 @i2c_bus_set_slave_address(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i32 %0, i32* %4
store i8 %1, i8* %5
%7 = load i32, i32* %4
%8 = load i32, i32* @I2C_SLAVE
%9 = load i8, i8* %5
%10 = call i32 @ioctl(i32 %7, i32 %8, i8 zeroext %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load i8, i8* %5
%16 = call i32 @blackstrap_log_error(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %14, i8 zeroext %15)
store i32 -1, i32* %3
br label %18
17: ; preds = %2
store i32 0, i32* %3
br label %18
18: ; preds = %17, %13
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@I2C_SLAVE = global i32 0
@.str = [55 x i8] c"I2C failed to set slave address: fd %d, address 0x%02x\00"
define i32 @i2c_bus_set_slave_address(i32 %0, i8 zeroext %1) {
%3 = load i32, i32* @I2C_SLAVE
%4 = tail call i32 @ioctl(i32 %0, i32 %3, i8 zeroext %1)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @blackstrap_log_error(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %0, i8 zeroext %1)
br label %8
8: ; preds = %2, %6
%9 = phi i32 [ -1, %6 ], [ 0, %2 ]
ret i32 %9
}