#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*/ printf(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int system(char *);
int init_gpio(int gpio) {
  char command[120];
  sprintf(command,
          "if [ ! -d /sys/class/gpio/gpio%i ]; then echo %i > "
          "/sys/class/gpio/export; fi",
          gpio, gpio);
  printf("system command %s returned %i\n", command, system(command));
  sprintf(command, "echo out > /sys/class/gpio/gpio%i/direction", gpio);
  printf("system command %s returned %i\n", command, system(command));
  sprintf(command, "echo 0 > /sys/class/gpio/gpio%i/value", gpio);
  printf("system command %s returned %i\n", command, system(command));
  return 0;
}


x86 assembly (clang, -O0):
<init_gpio>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
lea    0xed4(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xee0(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_gpio>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %edi,%ebp
lea    0xebc(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
lea    0xeea(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xef5(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xef9(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [78 x i8] c"if [ ! -d /sys/class/gpio/gpio%i ]; then echo %i > /sys/class/gpio/export; fi\00"
@.str.1 = [31 x i8] c"system command %s returned %i\0A\00"
@.str.2 = [44 x i8] c"echo out > /sys/class/gpio/gpio%i/direction\00"
@.str.3 = [38 x i8] c"echo 0 > /sys/class/gpio/gpio%i/value\00"
define i32 @init_gpio(i32 %0) {
%2 = alloca i32
%3 = alloca [120 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %2
%6 = load i32, i32* %2
%7 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %4, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%10 = call i32 @system(i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32 %10)
%12 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%13 = load i32, i32* %2
%14 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%17 = call i32 @system(i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %17)
%19 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* %2
%21 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%24 = call i32 @system(i8* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %22, i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [78 x i8] c"if [ ! -d /sys/class/gpio/gpio%i ]; then echo %i > /sys/class/gpio/export; fi\00"
@.str.1 = [31 x i8] c"system command %s returned %i\0A\00"
@.str.2 = [44 x i8] c"echo out > /sys/class/gpio/gpio%i/direction\00"
@.str.3 = [38 x i8] c"echo 0 > /sys/class/gpio/gpio%i/value\00"
define i32 @init_gpio(i32 %0) {
%2 = alloca [120 x i8]
%3 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%4 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %0)
%5 = call i32 @system(i8* %3)
%6 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %5)
%7 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%8 = call i32 @system(i8* %3)
%9 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %8)
%10 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%11 = call i32 @system(i8* %3)
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %11)
ret i32 0
}