#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ intToChar(int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int PIN_VALUE(int n) {
  FILE *in;
  char command[100] = "/sys/class/gpio/gpio";
  char no_pin[2] = "";
  int valuePin = 0;
  char comman_end[11] = "/value";
  int j = n;
  intToChar(j, no_pin);
  strcat(command, no_pin);
  strcat(command, comman_end);
  char caracteres[3];
  in = fopen(command, "r");
  fgets(caracteres, 2, in);
  fclose(in);
  if (caracteres[0] == '1') {
    valuePin = 1;
  } else {
    valuePin = 0;
  }
  return valuePin;
}


x86 assembly (clang, -O0):
<PIN_VALUE>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe77(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x82(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <memset@plt>
movl   $0x0,-0x88(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x93(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x8b(%rbp)
mov    0xe9c(%rip),%al
mov    %al,-0x89(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%edi
lea    -0x82(%rbp),%rsi
call   1080 <intToChar@plt>
lea    -0x80(%rbp),%rdi
lea    -0x82(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x80(%rbp),%rdi
lea    -0x93(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x80(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x9b(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2,%esi
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movsbl -0x9b(%rbp),%eax
cmp    $0x31,%eax
jne    1264 <PIN_VALUE+0xf4>
movl   $0x1,-0x88(%rbp)
jmp    126e <PIN_VALUE+0xfe>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PIN_VALUE>:
push   %r14
push   %rbx
sub    $0x88,%rsp
movaps 0xeef(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeb7(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe63(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x80(%rsp)
movw   $0x0,0xa(%rsp)
movabs $0x65756c61762f,%rax
mov    %rax,0x10(%rsp)
movl   $0x0,0x17(%rsp)
lea    0xa(%rsp),%r14
mov    %r14,%rsi
call   1060 <intToChar@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xd(%rsp),%rdi
mov    $0x2,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
cmpb   $0x31,0xd(%rsp)
sete   %al
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.PIN_VALUE.command = [100 x i8] c"/sys/class/gpio/gpio\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.PIN_VALUE.comman_end = [11 x i8] c"/value\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
define i32 @PIN_VALUE(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [100 x i8]
%5 = alloca [2 x i8]
%6 = alloca i32
%7 = alloca [11 x i8]
%8 = alloca i32
%9 = alloca [3 x i8]
store i32 %0, i32* %2
%10 = bitcast [100 x i8]* %4 to i8*
%11 = bitcast [2 x i8]* %5 to i8*
store i32 0, i32* %6
%12 = bitcast [11 x i8]* %7 to i8*
%13 = load i32, i32* %2
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%16 = call i32 @intToChar(i32 %14, i8* %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%22 = call i32 @strcat(i8* %20, i8* %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %3
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%26 = load i32*, i32** %3
%27 = call i32 @fgets(i8* %25, i32 2, i32* %26)
%28 = load i32*, i32** %3
%29 = call i32 @fclose(i32* %28)
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 49
br i1 %33, label %34, label %35
34: ; preds = %1
store i32 1, i32* %6
br label %36
35: ; preds = %1
store i32 0, i32* %6
br label %36
36: ; preds = %35, %34
%37 = load i32, i32* %6
ret i32 %37
}

LLVM IR (-O2):
@__const.PIN_VALUE.command = [100 x i8] c"/sys/class/gpio/gpio\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.PIN_VALUE.comman_end = [11 x i8] c"/value\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
define i32 @PIN_VALUE(i32 %0) {
%2 = alloca [100 x i8]
%3 = alloca i16
%4 = alloca [11 x i8]
%5 = alloca [3 x i8]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = bitcast i16* %3 to i8*
store i16 0, i16* %3
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%9 = call i32 @intToChar(i32 %0, i8* %7)
%10 = call i32 @strcat(i8* %6, i8* %7)
%11 = call i32 @strcat(i8* %6, i8* %8)
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%13 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @fgets(i8* %12, i32 2, i32* %13)
%15 = call i32 @fclose(i32* %13)
%16 = load i8, i8* %12
%17 = icmp eq i8 %16, 49
%18 = zext i1 %17 to i32
ret i32 %18
}