#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 */
scalar_t__ getPin(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ system(char *);
void config_GPIO() {
  char pin[3];
  if (getPin(pin))
    return;
  char cmd[50];
  sprintf(cmd, "echo \"%s\" > /sys/class/gpio/export", pin);
  system(cmd);
  sprintf(cmd, " echo \"out\" > /sys/class/gpio/gpio%s/direction", pin);
  system(cmd);
}


x86 assembly (clang, -O0):
<config_GPIO>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x3(%rbp),%rdi
call   1040 <getPin@plt>
cmp    $0x0,%rax
je     1150 <config_GPIO+0x20>
jmp    118a <config_GPIO+0x5a>
lea    -0x40(%rbp),%rdi
lea    -0x3(%rbp),%rdx
lea    0xea1(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <system@plt>
lea    -0x40(%rbp),%rdi
lea    -0x3(%rbp),%rdx
lea    0xea7(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <system@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_GPIO>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xd(%rsp),%rdi
call   1040 <getPin@plt>
test   %rax,%rax
jne    1184 <config_GPIO+0x54>
lea    0xeb3(%rip),%rsi
lea    0x10(%rsp),%rbx
lea    0xd(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rdx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"echo \22%s\22 > /sys/class/gpio/export\00"
@.str.1 = [47 x i8] c" echo \22out\22 > /sys/class/gpio/gpio%s/direction\00"
define void @config_GPIO() {
%1 = alloca [3 x i8]
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%4 = call i64 @getPin(i8* %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
br label %18
7: ; preds = %0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @system(i8* %11)
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%17 = call i32 @system(i8* %16)
br label %18
18: ; preds = %7, %6
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"echo \22%s\22 > /sys/class/gpio/export\00"
@.str.1 = [47 x i8] c" echo \22out\22 > /sys/class/gpio/gpio%s/direction\00"
define void @config_GPIO() {
%1 = alloca [3 x i8]
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%4 = call i64 @getPin(i8* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %3)
%9 = call i32 @system(i8* %7)
%10 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%11 = call i32 @system(i8* %7)
br label %12
12: ; preds = %0, %6
ret void
}