#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*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  int fd;
  int i = 0;
  fd = open("/sys/class/gpio/export", O_WRONLY);
  write(fd, "30", 2);
  close(fd);
  fd = open("/sys/class/gpio/gpio30/direction", O_WRONLY);
  write(fd, "out", 3);
  close(fd);
  fd = open("/sys/class/gpio/gpio30/value", O_WRONLY);
  write(fd, "0", 1);
  usleep(10);
  write(fd, "1", 1);
  close(fd);
  fd = open("/sys/class/gpio/unexport", O_WRONLY);
  write(fd, "30", 2);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xe9f(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xe8f(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
lea    0xe71(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xe38(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0xa,%edi
call   1060 <usleep@plt>
mov    -0x8(%rbp),%edi
lea    0xe5e(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xde5(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e8d(%rip),%rbx
mov    (%rbx),%esi
lea    0xeac(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
lea    0xeb5(%rip),%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    (%rbx),%esi
lea    0xe99(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
lea    0xeac(%rip),%rsi
mov    %eax,%edi
mov    $0x3,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    (%rbx),%esi
lea    0xe94(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
lea    0xe5f(%rip),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0xa,%edi
call   1060 <usleep@plt>
lea    0xe86(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    (%rbx),%esi
lea    0xe6c(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"/sys/class/gpio/export\00"
@O_WRONLY = global i32 0
@.str.1 = [3 x i8] c"30\00"
@.str.2 = [33 x i8] c"/sys/class/gpio/gpio30/direction\00"
@.str.3 = [4 x i8] c"out\00"
@.str.4 = [29 x i8] c"/sys/class/gpio/gpio30/value\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [25 x i8] c"/sys/class/gpio/unexport\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = load i32, i32* @O_WRONLY
%5 = call i32 @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @write(i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%8 = load i32, i32* %2
%9 = call i32 @close(i32 %8)
%10 = load i32, i32* @O_WRONLY
%11 = call i32 @open(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = call i32 @write(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%14 = load i32, i32* %2
%15 = call i32 @close(i32 %14)
%16 = load i32, i32* @O_WRONLY
%17 = call i32 @open(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = call i32 @write(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%20 = call i32 @usleep(i32 10)
%21 = load i32, i32* %2
%22 = call i32 @write(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
%23 = load i32, i32* %2
%24 = call i32 @close(i32 %23)
%25 = load i32, i32* @O_WRONLY
%26 = call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %25)
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = call i32 @write(i32 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%29 = load i32, i32* %2
%30 = call i32 @close(i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"/sys/class/gpio/export\00"
@O_WRONLY = global i32 0
@.str.1 = [3 x i8] c"30\00"
@.str.2 = [33 x i8] c"/sys/class/gpio/gpio30/direction\00"
@.str.3 = [4 x i8] c"out\00"
@.str.4 = [29 x i8] c"/sys/class/gpio/gpio30/value\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [25 x i8] c"/sys/class/gpio/unexport\00"
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%4 = tail call i32 @close(i32 %2)
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%8 = tail call i32 @close(i32 %6)
%9 = load i32, i32* @O_WRONLY
%10 = tail call i32 @open(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = tail call i32 @write(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%12 = tail call i32 @usleep(i32 10)
%13 = tail call i32 @write(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
%14 = tail call i32 @close(i32 %10)
%15 = load i32, i32* @O_WRONLY
%16 = tail call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %15)
%17 = tail call i32 @write(i32 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%18 = tail call i32 @close(i32 %16)
ret i32 0
}