#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_FORCE;
int /*<<< orphan*/ errno;
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, char *, int);
char *strerror(int /*<<< orphan*/);
int set_slave(int file, int address) {
  if (ioctl(file, I2C_SLAVE_FORCE, address) < 0) {
    printf("Error: Could not set address to %d: %s (fd=%d)", address,
           strerror(errno), file);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_slave>:
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   1040 <ioctl@plt>
cmp    $0x0,%rax
jge    1191 <set_slave+0x61>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x10(%rbp),%esi
mov    %rax,%rdx
mov    -0x8(%rbp),%ecx
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <set_slave+0x68>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_slave>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    0x2eaa(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edx
call   1040 <ioctl@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    1177 <set_slave+0x47>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe9a(%rip),%rdi
mov    %ebp,%esi
mov    %rax,%rdx
mov    %ebx,%ecx
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@I2C_SLAVE_FORCE = global i32 0
@.str = [47 x i8] c"Error: Could not set address to %d: %s (fd=%d)\00"
@errno = global i32 0
define i32 @set_slave(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* %4
%7 = load i32, i32* @I2C_SLAVE_FORCE
%8 = load i32, i32* %5
%9 = call i64 @ioctl(i32 %6, i32 %7, i32 %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* %5
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = load i32, i32* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %14, i32 %15)
store i32 -1, i32* %3
br label %18
17: ; preds = %2
store i32 0, i32* %3
br label %18
18: ; preds = %17, %11
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@I2C_SLAVE_FORCE = global i32 0
@.str = [47 x i8] c"Error: Could not set address to %d: %s (fd=%d)\00"
@errno = global i32 0
define i32 @set_slave(i32 %0, i32 %1) {
%3 = load i32, i32* @I2C_SLAVE_FORCE
%4 = tail call i64 @ioctl(i32 %0, i32 %3, i32 %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %8, i32 %0)
br label %10
10: ; preds = %2, %6
%11 = phi i32 [ -1, %6 ], [ 0, %2 ]
ret i32 %11
}