#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_REQUEST_OUTPUT;
int gpiotools_release_linehandle(int);
int gpiotools_request_linehandle(char const *, unsigned int *, unsigned int,
                                 int /*<<< orphan*/, struct gpiohandle_data *,
                                 char *);
int gpiotools_sets(const char *device_name, unsigned int *lines,
                   unsigned int nlines, struct gpiohandle_data *data) {
  int ret;
  ret = gpiotools_request_linehandle(device_name, lines, nlines,
                                     GPIOHANDLE_REQUEST_OUTPUT, data,
                                     "gpio-utils");
  if (ret < 0)
    return ret;
  return gpiotools_release_linehandle(ret);
}


x86 assembly (clang, -O0):
<gpiotools_sets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    0x2e9f(%rip),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%r8
lea    0xeaa(%rip),%r9
call   1040 <gpiotools_request_linehandle@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1173 <gpiotools_sets+0x53>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117e <gpiotools_sets+0x5e>
mov    -0x2c(%rbp),%edi
call   1030 <gpiotools_release_linehandle@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpiotools_sets>:
push   %rax
mov    %rcx,%r8
mov    0x2ebd(%rip),%rax
mov    (%rax),%ecx
lea    0xecc(%rip),%r9
call   1040 <gpiotools_request_linehandle@plt>
test   %eax,%eax
js     1145 <gpiotools_sets+0x25>
mov    %eax,%edi
pop    %rax
jmp    1030 <gpiotools_release_linehandle@plt>
pop    %rcx
ret

LLVM IR (-O0):
%struct.gpiohandle_data = type { i32 }
@GPIOHANDLE_REQUEST_OUTPUT = global i32 0
@.str = [11 x i8] c"gpio-utils\00"
define i32 @gpiotools_sets(i8* %0, i32* %1, i32 %2, %struct.gpiohandle_data* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca %struct.gpiohandle_data*
%10 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store %struct.gpiohandle_data* %3, %struct.gpiohandle_data** %9
%11 = load i8*, i8** %6
%12 = load i32*, i32** %7
%13 = load i32, i32* %8
%14 = load i32, i32* @GPIOHANDLE_REQUEST_OUTPUT
%15 = load %struct.gpiohandle_data*, %struct.gpiohandle_data** %9
%16 = call i32 @gpiotools_request_linehandle(i8* %11, i32* %12, i32 %13, i32 %14, %struct.gpiohandle_data* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = load i32, i32* %10
store i32 %20, i32* %5
br label %24
21: ; preds = %4
%22 = load i32, i32* %10
%23 = call i32 @gpiotools_release_linehandle(i32 %22)
store i32 %23, i32* %5
br label %24
24: ; preds = %21, %19
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
%struct.gpiohandle_data = type { i32 }
@GPIOHANDLE_REQUEST_OUTPUT = global i32 0
@.str = [11 x i8] c"gpio-utils\00"
define i32 @gpiotools_sets(i8* %0, i32* %1, i32 %2, %struct.gpiohandle_data* %3) {
%5 = load i32, i32* @GPIOHANDLE_REQUEST_OUTPUT
%6 = tail call i32 @gpiotools_request_linehandle(i8* %0, i32* %1, i32 %2, i32 %5, %struct.gpiohandle_data* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = icmp slt i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @gpiotools_release_linehandle(i32 %6)
br label %10
10: ; preds = %4, %8
%11 = phi i32 [ %9, %8 ], [ %6, %4 ]
ret i32 %11
}