#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ open_and_write(char *, char const *, int);
int /*<<< orphan*/ stderr;
int strnlen(char const *, int);
int gpio_clean(const char *gpio_no) {
  if (open_and_write("/sys/class/gpio/unexport", gpio_no,
                     sizeof(char) * strnlen(gpio_no, 8)) < 0) {
    fprintf(stderr, "Could not unexport gpio %s\n", gpio_no);
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<gpio_clean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1030 <strnlen@plt>
mov    -0x18(%rbp),%rsi
cltq
shl    $0x0,%rax
mov    %eax,%edx
lea    0xe9b(%rip),%rdi
call   1050 <open_and_write@plt>
cmp    $0x0,%rax
jge    119e <gpio_clean+0x6e>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe91(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <gpio_clean+0x7a>
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_clean>:
push   %rbx
mov    %rdi,%rbx
mov    $0x8,%esi
call   1030 <strnlen@plt>
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <open_and_write@plt>
test   %rax,%rax
js     115d <gpio_clean+0x2d>
mov    0x2e75(%rip),%rax
jmp    117c <gpio_clean+0x4c>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"/sys/class/gpio/unexport\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Could not unexport gpio %s\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @gpio_clean(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strnlen(i8* %5, i32 8)
%7 = sext i32 %6 to i64
%8 = mul i64 1, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @open_and_write(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %3
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %2
br label %19
17: ; preds = %1
%18 = load i32, i32* @EXIT_SUCCESS
store i32 %18, i32* %2
br label %19
19: ; preds = %17, %12
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [25 x i8] c"/sys/class/gpio/unexport\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Could not unexport gpio %s\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @gpio_clean(i8* %0) {
%2 = tail call i32 @strnlen(i8* %0, i32 8)
%3 = tail call i64 @open_and_write(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %8
8: ; preds = %1, %5
%9 = phi i32* [ @EXIT_FAILURE, %5 ], [ @EXIT_SUCCESS, %1 ]
%10 = load i32, i32* %9
ret i32 %10
}