#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, char *);
int ioctl(int const, int /*<<< orphan*/, struct gpiohandle_data *);
int /*<<< orphan*/ stderr;
char *strerror(int);
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), %s\n",
            "GPIOHANDLE_SET_LINE_VALUES_IOCTL", ret, strerror(errno));
  }
  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    0x2e97(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ab <gpiotools_set_values+0x7b>
xor    %eax,%eax
mov    0x2e66(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%ecx
mov    %rax,%r8
lea    0xe61(%rip),%rsi
lea    0xe77(%rip),%rdx
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpiotools_set_values>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rdx
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1180 <gpiotools_set_values+0x50>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    %edi,%ebx
neg    %ebx
mov    0x2e79(%rip),%rax
mov    (%rax),%ebp
call   1050 <strerror@plt>
lea    0xe93(%rip),%rsi
lea    0xea9(%rip),%rdx
mov    %ebp,%edi
mov    %ebx,%ecx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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 = [29 x i8] c"Failed to issue %s (%d), %s\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 %20
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 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %18)
br label %20
20: ; preds = %12, %2
%21 = load i32, i32* %5
ret i32 %21
}

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 = [29 x i8] c"Failed to issue %s (%d), %s\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 %12
6: ; preds = %2
%7 = load i32, i32* @errno
%8 = sub nsw i32 0, %7
%9 = load i32, i32* @stderr
%10 = tail call i8* @strerror(i32 %7)
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %8, i8* %10)
br label %12
12: ; preds = %6, %2
%13 = phi i32 [ %8, %6 ], [ %4, %2 ]
ret i32 %13
}