#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*/ exit(int);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int /*<<< orphan*/);
int initDataFolder() {
  char cmd[30];
  FILE *fp;
  sprintf(cmd, "%s%i", "mkdir -p ../commandexe/data/", getpid());
  fp = popen(cmd, "r");
  if (fp == NULL) {
    printf("[Error] - Error initialing process folder\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<initDataFolder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%ecx
lea    0xe8c(%rip),%rsi
lea    0xe8a(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b5 <initDataFolder+0x65>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initDataFolder>:
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe9d(%rip),%rsi
lea    0xe9b(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%ecx
call   1060 <sprintf@plt>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1050 <popen@plt>
test   %rax,%rax
je     1193 <initDataFolder+0x43>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s%i\00"
@.str.1 = [29 x i8] c"mkdir -p ../commandexe/data/\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [43 x i8] c"[Error] - Error initialing process folder\0A\00"
define i32 @initDataFolder() {
%1 = alloca [30 x i8]
%2 = alloca i32*
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = call i32 (...) @getpid()
%5 = call i32 @sprintf(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%7 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%i\00"
@.str.1 = [29 x i8] c"mkdir -p ../commandexe/data/\00"
@.str.2 = [2 x i8] c"r\00"
@str = [42 x i8] c"[Error] - Error initialing process folder\00"
define i32 @initDataFolder() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getpid()
%4 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = call i32* @popen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %0
ret i32 0
}