#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 */
struct gpiohandle_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ GPIOHANDLE_SET_LINE_VALUES_IOCTL;
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int ioctl(int const, int /*<<< orphan*/, struct gpiohandle_data *);
int /*<<< orphan*/ stderr;
int gpiotools_set_values(const int fd, struct gpiohandle_data *data) {
  int ret;
  ret = ioctl(fd, GPIOHANDLE_SET_LINE_VALUES_IOCTL, data);
  if (ret == -1) {
    ret = -errno;
    fprintf(stderr, "Failed to issue %s (%d)\n",
            "GPIOHANDLE_SET_LINE_VALUES_IOCTL", ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<gpiotools_set_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    117e <gpiotools_set_values+0x5e>
xor    %eax,%eax
mov    0x2e76(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
lea    0xe8e(%rip),%rsi
lea    0xea0(%rip),%rdx
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpiotools_set_values>:
push   %rbx
mov    %rsi,%rdx
mov    0x2eb5(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1162 <gpiotools_set_values+0x42>
mov    0x2e90(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
lea    0xebe(%rip),%rdx
mov    %ebx,%ecx
call   1040 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.gpiohandle_data = type { i32 }
@GPIOHANDLE_SET_LINE_VALUES_IOCTL = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"Failed to issue %s (%d)\0A\00"
@.str.1 = [33 x i8] c"GPIOHANDLE_SET_LINE_VALUES_IOCTL\00"
define i32 @gpiotools_set_values(i32 %0, %struct.gpiohandle_data* %1) {
%3 = alloca i32
%4 = alloca %struct.gpiohandle_data*
%5 = alloca i32
store i32 %0, i32* %3
store %struct.gpiohandle_data* %1, %struct.gpiohandle_data** %4
%6 = load i32, i32* %3
%7 = load i32, i32* @GPIOHANDLE_SET_LINE_VALUES_IOCTL
%8 = load %struct.gpiohandle_data*, %struct.gpiohandle_data** %4
%9 = call i32 @ioctl(i32 %6, i32 %7, %struct.gpiohandle_data* %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @errno
%14 = sub nsw i32 0, %13
store i32 %14, i32* %5
%15 = load i32, i32* @stderr
%16 = load i32, i32* %5
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %12, %2
%19 = load i32, i32* %5
ret i32 %19
}

LLVM IR (-O2):
%struct.gpiohandle_data = type { i32 }
@GPIOHANDLE_SET_LINE_VALUES_IOCTL = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"Failed to issue %s (%d)\0A\00"
@.str.1 = [33 x i8] c"GPIOHANDLE_SET_LINE_VALUES_IOCTL\00"
define i32 @gpiotools_set_values(i32 %0, %struct.gpiohandle_data* %1) {
%3 = load i32, i32* @GPIOHANDLE_SET_LINE_VALUES_IOCTL
%4 = tail call i32 @ioctl(i32 %0, i32 %3, %struct.gpiohandle_data* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @errno
%8 = sub nsw i32 0, %7
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %11
11: ; preds = %6, %2
%12 = phi i32 [ %8, %6 ], [ %4, %2 ]
ret i32 %12
}