#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 /*<<< orphan*/ clearLastError();
int pintoGPIO(int);
int /*<<< orphan*/ sprintf(char *, char *, int, char *);
int writeIntValueToFile(char *, int);
int setGPIOValue(int pin, int value) {
  clearLastError();
  int gpio = pintoGPIO(pin);
  char fileName[255] = {0};
  sprintf(fileName, "/sys/class/gpio/gpio%d/%s", gpio, "value");
  return writeIntValueToFile(fileName, value);
}


x86 assembly (clang, -O0):
<setGPIOValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <clearLastError@plt>
mov    -0x4(%rbp),%edi
call   1030 <pintoGPIO@plt>
mov    %eax,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1040 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe69(%rip),%rsi
lea    0xe7c(%rip),%rcx
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <writeIntValueToFile@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setGPIOValue>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <clearLastError@plt>
mov    %ebp,%edi
call   1030 <pintoGPIO@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0xef(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe34(%rip),%rsi
lea    0xe47(%rip),%rcx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1050 <writeIntValueToFile@plt>
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"/sys/class/gpio/gpio%d/%s\00"
@.str.1 = [6 x i8] c"value\00"
define i32 @setGPIOValue(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [255 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 (...) @clearLastError()
%8 = load i32, i32* %3
%9 = call i32 @pintoGPIO(i32 %8)
store i32 %9, i32* %5
%10 = bitcast [255 x i8]* %6 to i8*
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* %5
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i32 @writeIntValueToFile(i8* %14, i32 %15)
ret i32 %16
}

LLVM IR (-O2):
@.str = [26 x i8] c"/sys/class/gpio/gpio%d/%s\00"
@.str.1 = [6 x i8] c"value\00"
define i32 @setGPIOValue(i32 %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = tail call i32 (...) @clearLastError()
%5 = tail call i32 @pintoGPIO(i32 %0)
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @writeIntValueToFile(i8* %6, i32 %1)
ret i32 %8
}